Skip to content

Commit 0591f04

Browse files
adam900710kdave
authored andcommitted
btrfs: prevent remounting to v1 space cache for subpage mount
Upstream commit 9f73f1a ("btrfs: force v2 space cache usage for subpage mount") forces subpage mount to use v2 cache, to avoid deprecated v1 cache which doesn't support subpage properly. But there is a loophole that user can still remount to v1 cache. The existing check will only give users a warning, but does not really prevent to do the remount. Although remounting to v1 will not cause any problems since the v1 cache will always be marked invalid when mounted with a different page size, it's still better to prevent v1 cache at all for subpage mounts. Fixes: 9f73f1a ("btrfs: force v2 space cache usage for subpage mount") CC: [email protected] # 5.15+ Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 31e70e5 commit 0591f04

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/btrfs/super.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,14 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
19851985
if (ret)
19861986
goto restore;
19871987

1988+
/* V1 cache is not supported for subpage mount. */
1989+
if (fs_info->sectorsize < PAGE_SIZE && btrfs_test_opt(fs_info, SPACE_CACHE)) {
1990+
btrfs_warn(fs_info,
1991+
"v1 space cache is not supported for page size %lu with sectorsize %u",
1992+
PAGE_SIZE, fs_info->sectorsize);
1993+
ret = -EINVAL;
1994+
goto restore;
1995+
}
19881996
btrfs_remount_begin(fs_info, old_opts, *flags);
19891997
btrfs_resize_thread_pool(fs_info,
19901998
fs_info->thread_pool_size, old_thread_pool_size);

0 commit comments

Comments
 (0)