[PATCH] btrfs: set clear_cache for rescue=usebackuproot

"Dongjiang Zhu" <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
The change that moved setting CLEAR_CACHE from the backup root loading
path to mount option parsing updated the deprecated usebackuproot and
recovery options, but missed rescue=usebackuproot.

rescue=usebackuproot is the preferred spelling for the same mount
option, so it should also set CLEAR_CACHE. Otherwise the deprecated
usebackuproot option clears or rebuilds the free space cache/tree while
the recommended rescue=usebackuproot option does not.

Set CLEAR_CACHE when parsing rescue=usebackuproot as well.

Fixes: 9fb3b1a7fed7 ("btrfs: set clear_cache if we use usebackuproot")
Signed-off-by: Dongjiang Zhu <[email protected]>
---
 fs/btrfs/super.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c946bccf0748..b83391537c52 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -597,6 +597,9 @@ static int btrfs_parse_param(struct fs_context *fc, struct fs_parameter *param)
 		switch (result.uint_32) {
 		case Opt_rescue_usebackuproot:
 			btrfs_set_opt(ctx->mount_opt, USEBACKUPROOT);
+
+			/* If we're loading the backup roots we can't trust the space cache. */
+			btrfs_set_opt(ctx->mount_opt, CLEAR_CACHE);
 			break;
 		case Opt_rescue_nologreplay:
 			btrfs_set_opt(ctx->mount_opt, NOLOGREPLAY);
-- 
2.39.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.