md: Fix types in sb writer
authorJon Derrick <jonathan.derrick@linux.dev>
Fri, 24 Feb 2023 18:33:22 +0000 (11:33 -0700)
committerSong Liu <song@kernel.org>
Fri, 14 Apr 2023 05:20:24 +0000 (22:20 -0700)
commit10172f200b67aafcb9b8ce7d0575d713c1aafbb7
tree06f77774f5aa2ef9d4b970343d61873123c6ce09
parent328e17d8d9428b390ab48bdedcaf5106e4b511fe
md: Fix types in sb writer

Page->index is a pgoff_t and multiplying could cause overflows on a
32-bit architecture. In the sb writer, this is used to calculate and
verify the sector being used, and is multiplied by a sector value. Using
sector_t will cast it to a u64 type and is the more appropriate type for
the unit. Additionally, the integer size unit is converted to a sector
unit in later calculations, and is now corrected to be an unsigned type.

Finally, clean up the calculations using variable aliases to improve
readabiliy.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jon Derrick <jonathan.derrick@linux.dev>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230224183323.638-3-jonathan.derrick@linux.dev
drivers/md/md-bitmap.c