Re: [PATCH 08/11] md-bitmap: account for mddev->bitmap_info.offset in read_sb_page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Jun 14, 2023, at 11:48 PM, Christoph Hellwig <hch@xxxxxx> wrote:
> 
> Diretly apply mddev->bitmap_info.offset to the sector number to read
> instead of doing that in both callers.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
> drivers/md/md-bitmap.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index f4bff2dfe2fd8f..39ff75cc7a16ac 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -145,7 +145,8 @@ static int read_sb_page(struct mddev *mddev, loff_t offset,
> struct page *page, unsigned long index, int size)
> {
> 
> - sector_t sector = offset + index * (PAGE_SIZE / SECTOR_SIZE);
> + sector_t sector = mddev->bitmap_info.offset + offset +
> + index * (PAGE_SIZE / SECTOR_SIZE);
> struct md_rdev *rdev;
> 
> rdev_for_each(rdev, mddev) {
> @@ -593,7 +594,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
> unsigned long sectors_reserved = 0;
> int err = -EINVAL;
> struct page *sb_page;
> - loff_t offset = bitmap->mddev->bitmap_info.offset;
> + loff_t offset = 0;
> 
> if (!bitmap->storage.file && !bitmap->mddev->bitmap_info.offset) {
> chunksize = 128 * 1024 * 1024;
> @@ -620,7 +621,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
> bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
> /* to 4k blocks */
> bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, 4096);
> - offset = bitmap->mddev->bitmap_info.offset + (bitmap->cluster_slot * (bm_blocks << 3));
> + offset = bitmap->cluster_slot * (bm_blocks << 3);
> pr_debug("%s:%d bm slot: %d offset: %llu\n", __func__, __LINE__,
> bitmap->cluster_slot, offset);
> }
> @@ -632,10 +633,8 @@ static int md_bitmap_read_sb(struct bitmap *bitmap)
> err = read_file_page(bitmap->storage.file, 0,
> bitmap, bytes, sb_page);
> } else {
> - err = read_sb_page(bitmap->mddev,
> -   offset,
> -   sb_page,
> -   0, sizeof(bitmap_super_t));
> + err = read_sb_page(bitmap->mddev, offset, sb_page, 0,
> +   sizeof(bitmap_super_t));
> }
> if (err)
> return err;
> @@ -1127,8 +1126,8 @@ static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
> if (file)
> ret = read_file_page(file, i, bitmap, count, page);
> else
> - ret = read_sb_page(mddev, mddev->bitmap_info.offset,
> -   page, i + node_offset, count);
> + ret = read_sb_page(mddev, 0, page, i + node_offset,
> +   count);
> if (ret)
> goto err;
> }
> -- 
> 2.39.2
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx>

-- 
Himanshu Madhani Oracle Linux Engineering





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux