Skip to content

Commit

Permalink
btrfs: zoned: fix missing endianness conversion in sb_write_pointer
Browse files Browse the repository at this point in the history
commit c51f0e6 upstream.

generation is an on-disk __le64 value, so use btrfs_super_generation to
convert it to host endian before comparing it.

Fixes: 1265925 ("btrfs: implement log-structured superblock for ZONED mode")
CC: [email protected] # 5.15+
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Sasha Levin committed Dec 2, 2022
1 parent ccb8bf5 commit da8fdbb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/btrfs/zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ static int sb_write_pointer(struct block_device *bdev, struct blk_zone *zones,
super[i] = page_address(page[i]);
}

if (super[0]->generation > super[1]->generation)
if (btrfs_super_generation(super[0]) >
btrfs_super_generation(super[1]))
sector = zones[1].start;
else
sector = zones[0].start;
Expand Down

0 comments on commit da8fdbb

Please sign in to comment.