Commit 5b434df
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: 1265925 ("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>1 parent 165ea85 commit 5b434df
1 file changed
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
| |||
405 | 417 | | |
406 | 418 | | |
407 | 419 | | |
408 | | - | |
409 | | - | |
| 420 | + | |
| 421 | + | |
410 | 422 | | |
411 | 423 | | |
412 | 424 | | |
| |||
721 | 733 | | |
722 | 734 | | |
723 | 735 | | |
724 | | - | |
| 736 | + | |
725 | 737 | | |
726 | 738 | | |
727 | 739 | | |
| |||
826 | 838 | | |
827 | 839 | | |
828 | 840 | | |
829 | | - | |
| 841 | + | |
830 | 842 | | |
831 | 843 | | |
832 | 844 | | |
| |||
878 | 890 | | |
879 | 891 | | |
880 | 892 | | |
881 | | - | |
| 893 | + | |
| 894 | + | |
882 | 895 | | |
883 | 896 | | |
884 | 897 | | |
| |||
0 commit comments