]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: zoned: fix zone number to sector/physical calculation
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 27 May 2021 06:27:32 +0000 (15:27 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 4 Jun 2021 11:11:50 +0000 (13:11 +0200)
commit823cd803119f2fa584d9e302330bce3a40f24e68
tree7624ad69ad0208990c115a9794e72341f5347758
parent60dc57642ef28d6d9d1442175fe23155c674661f
btrfs: zoned: fix zone number to sector/physical calculation

In btrfs_get_dev_zone_info(), we have "u32 sb_zone" and calculate "sector_t
sector" by shifting it. But, this "sector" is calculated in 32bit, leading
it to be 0 for the 2nd superblock copy.

Since zone number is u32, shifting it to sector (sector_t) or physical
address (u64) can easily trigger a missing cast bug like this.

This commit introduces helpers to convert zone number to sector/LBA, so we
won't fall into the same pitfall again.

Reported-by: Dmitry Fomichev <Dmitry.Fomichev@wdc.com>
Fixes: 0942f67d4364 ("btrfs: implement log-structured superblock for ZONED mode")
CC: stable@vger.kernel.org # 5.11+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/zoned.c