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>
Reviewed-by: Gu JinXiang <gujx@cn.fujitsu.com>
Tested-by: Gu JinXiang <gujx@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2017-10-26 15:28:37 +08:00 committed by David Sterba
parent fec462240d
commit da2659b090
1 changed files with 7 additions and 1 deletions

View File

@ -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;