From: Christoph Hellwig <hch@lst.de>
To: Song Liu <song@kernel.org>
Cc: linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH 08/11] md-bitmap: account for mddev->bitmap_info.offset in read_sb_page
Date: Thu, 15 Jun 2023 08:48:37 +0200 [thread overview]
Message-ID: <20230615064840.629492-9-hch@lst.de> (raw)
In-Reply-To: <20230615064840.629492-1-hch@lst.de>
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@lst.de>
---
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
next prev parent reply other threads:[~2023-06-15 6:50 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 6:48 deprecate md bitmap file support Christoph Hellwig
2023-06-15 6:48 ` [PATCH 01/11] md-bitmap: set BITMAP_WRITE_ERROR in write_sb_page Christoph Hellwig
2023-06-15 6:56 ` Hannes Reinecke
2023-06-15 14:22 ` Johannes Thumshirn
2023-06-15 17:05 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 02/11] md-bitmap: initialize variables at declaration time in md_bitmap_file_unmap Christoph Hellwig
2023-06-15 6:56 ` Hannes Reinecke
2023-06-15 14:23 ` Johannes Thumshirn
2023-06-15 17:05 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 03/11] md-bitmap: use %pD to print the file name in md_bitmap_file_kick Christoph Hellwig
2023-06-15 6:58 ` Hannes Reinecke
2023-06-15 14:24 ` Johannes Thumshirn
2023-06-15 18:12 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 04/11] md-bitmap: split file writes into a separate helper Christoph Hellwig
2023-06-15 6:59 ` Hannes Reinecke
2023-06-15 14:26 ` Johannes Thumshirn
2023-06-15 18:13 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 05/11] md-bitmap: rename read_page to read_file_page Christoph Hellwig
2023-06-15 6:59 ` Hannes Reinecke
2023-06-15 14:38 ` Johannes Thumshirn
2023-06-15 18:14 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 06/11] md-bitmap: refactor md_bitmap_init_from_disk Christoph Hellwig
2023-06-15 21:59 ` kernel test robot
2023-06-16 6:53 ` Song Liu
2023-06-16 7:01 ` Christoph Hellwig
2023-06-15 6:48 ` [PATCH 07/11] md-bitmap: cleanup read_sb_page Christoph Hellwig
2023-06-15 8:24 ` Hannes Reinecke
2023-06-15 14:42 ` Johannes Thumshirn
2023-06-15 18:30 ` Himanshu Madhani
2023-06-15 6:48 ` Christoph Hellwig [this message]
2023-06-15 8:25 ` [PATCH 08/11] md-bitmap: account for mddev->bitmap_info.offset in read_sb_page Hannes Reinecke
2023-06-15 18:38 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 09/11] md-bitmap: don't use ->index for pages backing the bitmap file Christoph Hellwig
2023-06-15 8:37 ` Hannes Reinecke
2023-06-15 6:48 ` [PATCH 10/11] md: make bitmap file support optional Christoph Hellwig
2023-06-15 8:37 ` Hannes Reinecke
2023-06-15 19:37 ` Himanshu Madhani
2023-06-15 6:48 ` [PATCH 11/11] md: deprecate bitmap file support Christoph Hellwig
2023-06-15 8:38 ` Hannes Reinecke
2023-06-15 19:37 ` Himanshu Madhani
2023-06-15 19:37 ` Himanshu Madhani
2023-06-15 8:05 ` deprecate md " Mariusz Tkaczyk
2023-06-16 7:01 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230615064840.629492-9-hch@lst.de \
--to=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).