Skip to contentSkip to conversation

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

PATCH Applied Qu Wenruo 3 participants 3 messages Oct 26, 2017 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 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.

---
 convert/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
convert/main.c +7 -1
index 882daf7ced53..3ec10f233915 100644
@@ -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;
Signature · 1 line
2.14.3
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 30 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Qu Wenruo
Sent: Thursday, October 26, 2017 3:29 PM
To: [email protected]
Cc: [email protected]
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.

---
 convert/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
convert/main.c +0 -1
@@ -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);

convert/main.c static int do_rollback(const char *devname) · line 1541

Quoted 10 lines
convert/main.c +7 -0
+
+	/*
+	 * 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;
Quoted 7 lines

--
2.14.3

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

�翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{饼籯~镶炟^n噐■�侂h櫒璀�&{鄗夸z罐楘+€�+zf"穐殘啳嗃i��飦�戧鐉_璁鎗:+v墾�)撸鴐

Applied
#2 lore raw
Quoted 8 lines · Jinxiang
Quoted 8 lines

Cc: [email protected]
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.

Quoted 7 lines
Quoted 4 lines

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

Applied, thanks.