diff mbox

btrfs-progs: convert: Open the fs readonly for rollback

Message ID 20171026072837.27460-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Oct. 26, 2017, 7:28 a.m. UTC
For rollback, we only needs to open the fs to check if it meets the
condition to rollback.
And this RW read makes us failed to rollback btrfs with v2 space cache.

In fact, we don't even start a transaction during rollback.

So open the fs RO for rollback, to avoid v2 space cache problem.

Reported-by: Gu Jinxiang <gujx@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 convert/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

David Sterba Oct. 26, 2017, 5:16 p.m. UTC | #1
On Thu, Oct 26, 2017 at 08:35:29AM +0000, Gu, Jinxiang wrote:
> > Cc: dsterba@suse.cz
> > Subject: [PATCH] btrfs-progs: convert: Open the fs readonly for rollback
> > 
> > For rollback, we only needs to open the fs to check if it meets the condition to rollback.
> > And this RW read makes us failed to rollback btrfs with v2 space cache.
> > 
> > In fact, we don't even start a transaction during rollback.
> > 
> > So open the fs RO for rollback, to avoid v2 space cache problem.
> > 
> > Reported-by: Gu Jinxiang <gujx@cn.fujitsu.com>
> > Signed-off-by: Qu Wenruo <wqu@suse.com>

> Reviewed-by: Gu JinXiang <gujx@cn.fujitsu.com>
> Tested-by: Gu JinXiang <gujx@cn.fujitsu.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/convert/main.c b/convert/main.c
index 882daf7ced53..3ec10f233915 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -1529,7 +1529,13 @@  static int do_rollback(const char *devname)
 		goto free_mem;
 	}
 	fsize = lseek(fd, 0, SEEK_END);
-	root = open_ctree_fd(fd, devname, 0, OPEN_CTREE_WRITES);
+
+	/*
+	 * For rollback, we don't really need write anything into btrfs,
+	 * so open it RO.
+	 * The write part will happen after we close the btrfs.
+	 */
+	root = open_ctree_fd(fd, devname, 0, 0);
 	if (!root) {
 		error("unable to open ctree");
 		ret = -EIO;