From: Qu Wenruo Date: Thu, 26 Oct 2017 07:28:37 +0000 (+0800) Subject: btrfs-progs: convert: Open the fs readonly for rollback X-Git-Tag: upstream/4.16.1~302 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da2659b090af383dea6dec71d2d4e128c643d455;p=platform%2Fupstream%2Fbtrfs-progs.git 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 Reviewed-by: Gu JinXiang Tested-by: Gu JinXiang Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- diff --git a/convert/main.c b/convert/main.c index 67616c4..af28553 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 to write anything so open it + * read-only. The write part will happen after we close the + * filesystem. + */ + root = open_ctree_fd(fd, devname, 0, 0); if (!root) { error("unable to open ctree"); ret = -EIO;