Skip to content

Commit 02ca9e6

Browse files
naotakdave
authored andcommitted
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: 9658b72 ("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>
1 parent f84353c commit 02ca9e6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/btrfs/zoned.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
122122
int i;
123123

124124
for (i = 0; i < BTRFS_NR_SB_LOG_ZONES; i++) {
125-
u64 bytenr;
126-
127-
bytenr = ((zones[i].start + zones[i].len)
128-
<< SECTOR_SHIFT) - BTRFS_SUPER_INFO_SIZE;
125+
u64 zone_end = (zones[i].start + zones[i].capacity) << SECTOR_SHIFT;
126+
u64 bytenr = ALIGN_DOWN(zone_end, BTRFS_SUPER_INFO_SIZE) -
127+
BTRFS_SUPER_INFO_SIZE;
129128

130129
page[i] = read_cache_page_gfp(mapping,
131130
bytenr >> PAGE_SHIFT, GFP_NOFS);

0 commit comments

Comments
 (0)