aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
authorKangNing Liao <lkangn.kernel@gmail.com>2026-05-21 20:29:45 +0800
committerDavid Sterba <dsterba@suse.com>2026-05-25 15:18:28 +0200
commit6cfd0b77103ae33184187b29c02d7ea3847d5dbc (patch)
tree7284c206c5abee6c04203d879a77f622cb6d93fd /fs
parentf13342e15deafb7538a7a8577ed5f4c33c56f64e (diff)
downloadlinux-next-history-6cfd0b77103ae33184187b29c02d7ea3847d5dbc.tar.gz
btrfs: protect sb_write_pointer() with invalidate lock
sb_write_pointer() reads the super block from the block device page cache using read_cache_page_gfp(). This has the same race with BLKBSZSET as the one fixed by commit 3f29d661e568 ("btrfs: sync read disk super and set block size"). Take the mapping invalidate lock around read_cache_page_gfp() to serialize the read against block size changes. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: KangNing Liao <lkangn.kernel@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/zoned.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 16dd87aa06f20..5f75cf0e14b95 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -131,8 +131,10 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
BTRFS_SUPER_INFO_SIZE;
+ filemap_invalidate_lock(mapping);
page[i] = read_cache_page_gfp(mapping,
bytenr >> PAGE_SHIFT, GFP_NOFS);
+ filemap_invalidate_unlock(mapping);
if (IS_ERR(page[i])) {
if (i == 1)
btrfs_release_disk_super(super[0]);