On Thu, May 27, 2021 at 03:27:32PM +0900, Naohiro Aota wrote:
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.
Fixes: 12659251ca5d ("btrfs: implement log-structured superblock for ZONED mode") Cc: stable@vger.kernel.org # 5.11+ Reported-by: Dmitry Fomichev Dmitry.Fomichev@wdc.com Signed-off-by: Naohiro Aota naohiro.aota@wdc.com
Added to misc-next, thanks.