diff mbox series

[07/11] md-bitmap: cleanup read_sb_page

Message ID 20230615064840.629492-8-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/11] md-bitmap: set BITMAP_WRITE_ERROR in write_sb_page | expand

Commit Message

Christoph Hellwig June 15, 2023, 6:48 a.m. UTC
Convert read_sb_page to the normal kernel coding style, calculate the
target sector only once, and add a local iosize variable to make the call
to sync_page_io more readable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md-bitmap.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Comments

Hannes Reinecke June 15, 2023, 8:24 a.m. UTC | #1
On 6/15/23 08:48, Christoph Hellwig wrote:
> Convert read_sb_page to the normal kernel coding style, calculate the
> target sector only once, and add a local iosize variable to make the call
> to sync_page_io more readable.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/md/md-bitmap.c | 23 +++++++++++------------
>   1 file changed, 11 insertions(+), 12 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Johannes Thumshirn June 15, 2023, 2:42 p.m. UTC | #2
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Himanshu Madhani June 15, 2023, 6:30 p.m. UTC | #3
> On Jun 14, 2023, at 11:48 PM, Christoph Hellwig <hch@lst.de> wrote:
> 
> Convert read_sb_page to the normal kernel coding style, calculate the
> target sector only once, and add a local iosize variable to make the call
> to sync_page_io more readable.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/md/md-bitmap.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index 1f71683b417981..f4bff2dfe2fd8f 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -139,26 +139,25 @@ static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page
>  */
> 
> /* IO operations when bitmap is stored near all superblocks */
> +
> +/* choose a good rdev and read the page from there */
> static int read_sb_page(struct mddev *mddev, loff_t offset,
> - struct page *page,
> - unsigned long index, int size)
> + struct page *page, unsigned long index, int size)
> {
> - /* choose a good rdev and read the page from there */
> 
> + sector_t sector = offset + index * (PAGE_SIZE / SECTOR_SIZE);
> struct md_rdev *rdev;
> - sector_t target;
> 
> rdev_for_each(rdev, mddev) {
> - if (! test_bit(In_sync, &rdev->flags)
> -    || test_bit(Faulty, &rdev->flags)
> -    || test_bit(Bitmap_sync, &rdev->flags))
> - continue;
> + u32 iosize = roundup(size, bdev_logical_block_size(rdev->bdev));
> 
> - target = offset + index * (PAGE_SIZE/512);
> + if (!test_bit(In_sync, &rdev->flags) ||
> +    test_bit(Faulty, &rdev->flags) ||
> +    test_bit(Bitmap_sync, &rdev->flags))
> + continue;
> 
> - if (sync_page_io(rdev, target,
> - roundup(size, bdev_logical_block_size(rdev->bdev)),
> - page, REQ_OP_READ, true)) {
> + if (sync_page_io(rdev, sector, iosize, page, REQ_OP_READ,
> + true)) {
> page->index = index;
> return 0;
> }
> -- 
> 2.39.2
> 

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
diff mbox series

Patch

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 1f71683b417981..f4bff2dfe2fd8f 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -139,26 +139,25 @@  static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page
  */
 
 /* IO operations when bitmap is stored near all superblocks */
+
+/* choose a good rdev and read the page from there */
 static int read_sb_page(struct mddev *mddev, loff_t offset,
-			struct page *page,
-			unsigned long index, int size)
+		struct page *page, unsigned long index, int size)
 {
-	/* choose a good rdev and read the page from there */
 
+	sector_t sector = offset + index * (PAGE_SIZE / SECTOR_SIZE);
 	struct md_rdev *rdev;
-	sector_t target;
 
 	rdev_for_each(rdev, mddev) {
-		if (! test_bit(In_sync, &rdev->flags)
-		    || test_bit(Faulty, &rdev->flags)
-		    || test_bit(Bitmap_sync, &rdev->flags))
-			continue;
+		u32 iosize = roundup(size, bdev_logical_block_size(rdev->bdev));
 
-		target = offset + index * (PAGE_SIZE/512);
+		if (!test_bit(In_sync, &rdev->flags) ||
+		    test_bit(Faulty, &rdev->flags) ||
+		    test_bit(Bitmap_sync, &rdev->flags))
+			continue;
 
-		if (sync_page_io(rdev, target,
-				 roundup(size, bdev_logical_block_size(rdev->bdev)),
-				 page, REQ_OP_READ, true)) {
+		if (sync_page_io(rdev, sector, iosize, page, REQ_OP_READ,
+				true)) {
 			page->index = index;
 			return 0;
 		}