summaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorNaohiro Aota <Naohiro.Aota@wdc.com>2023-05-09 21:29:15 +0300
committerDavid Sterba <dsterba@suse.com>2023-05-10 15:50:22 +0300
commit02ca9e6fb5f66a031df4fac508b8e477ca69e918 (patch)
treeb96908056b7856e13a1040a9cb39a9ee7487ee49 /fs/btrfs
parentf84353c7c20536ea7e01eca79430eccdf3cc7348 (diff)
downloadlinux-02ca9e6fb5f66a031df4fac508b8e477ca69e918.tar.xz
btrfs: zoned: fix full zone super block reading on ZNS
When both of the superblock zones are full, we need to check which superblock is newer. The calculation of last superblock position is wrong as it does not consider zone_capacity and uses the length. Fixes: 9658b72ef300 ("btrfs: zoned: locate superblock position using zone capacity") CC: stable@vger.kernel.org # 6.1+ Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/zoned.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index d51057608fc3..4243b0427a30 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -122,10 +122,9 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
int i;
for (i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
- u64 bytenr;
-
- bytenr = ((zones[i].start + zones[i].len)
- << SECTOR_SHIFT) - BTRFS_SUPER_INFO_SIZE;
+ u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
+ u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
+ BTRFS_SUPER_INFO_SIZE;
page[i] = read_cache_page_gfp(mapping,
bytenr >> PAGE_SHIFT, GFP_NOFS);