md: Fix bitmap offset type in sb writer
authorJonathan Derrick <jonathan.derrick@linux.dev>
Tue, 25 Apr 2023 01:14:38 +0000 (19:14 -0600)
committerSong Liu <song@kernel.org>
Fri, 28 Apr 2023 16:21:06 +0000 (09:21 -0700)
Bitmap offset is allowed to be negative, indicating that bitmap precedes
metadata. Change the type back from sector_t to loff_t to satisfy
conditionals and calculations.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/linux-raid/CAPhsuW6HuaUJ5WcyPajVgUfkQFYp2D_cy1g6qxN4CU_gP2=z7g@mail.gmail.com/
Fixes: 10172f200b67 ("md: Fix types in sb writer")
Signed-off-by: Jonathan Derrick <jonathan.derrick@linux.dev>
Suggested-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230425011438.71046-1-jonathan.derrick@linux.dev
drivers/md/md-bitmap.c

index 920bb68156d276789f5739a403490e63c83f1e76..bc8d7565171d44f3027186fbf5a7b05714e49bda 100644 (file)
@@ -219,7 +219,7 @@ static unsigned int optimal_io_size(struct block_device *bdev,
 }
 
 static unsigned int bitmap_io_size(unsigned int io_size, unsigned int opt_size,
-                                  sector_t start, sector_t boundary)
+                                  loff_t start, loff_t boundary)
 {
        if (io_size != opt_size &&
            start + opt_size / SECTOR_SIZE <= boundary)
@@ -237,8 +237,8 @@ static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
        struct block_device *bdev;
        struct mddev *mddev = bitmap->mddev;
        struct bitmap_storage *store = &bitmap->storage;
-       sector_t offset = mddev->bitmap_info.offset;
-       sector_t ps, sboff, doff;
+       loff_t sboff, offset = mddev->bitmap_info.offset;
+       sector_t ps, doff;
        unsigned int size = PAGE_SIZE;
        unsigned int opt_size = PAGE_SIZE;