[PATCH 08/23] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations

Yu Kuai posted 23 patches 6 months, 4 weeks ago
There is a newer version of this series
[PATCH 08/23] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations
Posted by Yu Kuai 6 months, 4 weeks ago
From: Yu Kuai <yukuai3@huawei.com>

This method is used to check if blocks can be skipped before calling
into pers->sync_request(), llbiltmap will use this method to skip
resync for unwritten/clean data blocks, and recovery/check/repair for
unwritten data blocks;

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md-bitmap.h | 1 +
 drivers/md/md.c        | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index 2b99ddef7a41..0de14d475ad3 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -98,6 +98,7 @@ struct bitmap_operations {
 	md_bitmap_fn *start_discard;
 	md_bitmap_fn *end_discard;
 
+	sector_t (*skip_sync_blocks)(struct mddev *mddev, sector_t offset);
 	bool (*start_sync)(struct mddev *mddev, sector_t offset,
 			   sector_t *blocks, bool degraded);
 	void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index dc4b85f30e13..890c8da43b3b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9362,6 +9362,12 @@ void md_do_sync(struct md_thread *thread)
 		if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
 			break;
 
+		if (mddev->bitmap_ops && mddev->bitmap_ops->skip_sync_blocks) {
+			sectors = mddev->bitmap_ops->skip_sync_blocks(mddev, j);
+			if (sectors)
+				goto update;
+		}
+
 		sectors = mddev->pers->sync_request(mddev, j, max_sectors,
 						    &skipped);
 		if (sectors == 0) {
@@ -9377,6 +9383,7 @@ void md_do_sync(struct md_thread *thread)
 		if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
 			break;
 
+update:
 		j += sectors;
 		if (j > max_sectors)
 			/* when skipping, extra large numbers can be returned. */
-- 
2.39.2
Re: [PATCH 08/23] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations
Posted by Hannes Reinecke 6 months, 3 weeks ago
On 5/24/25 08:13, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> This method is used to check if blocks can be skipped before calling
> into pers->sync_request(), llbiltmap will use this method to skip
> resync for unwritten/clean data blocks, and recovery/check/repair for
> unwritten data blocks;
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/md/md-bitmap.h | 1 +
>   drivers/md/md.c        | 7 +++++++
>   2 files changed, 8 insertions(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH 08/23] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations
Posted by Xiao Ni 6 months, 3 weeks ago
On Sat, May 24, 2025 at 2:18 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> This method is used to check if blocks can be skipped before calling
> into pers->sync_request(), llbiltmap will use this method to skip

type error: s/llbiltmap/llbitmap/g

> resync for unwritten/clean data blocks, and recovery/check/repair for
> unwritten data blocks;
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/md/md-bitmap.h | 1 +
>  drivers/md/md.c        | 7 +++++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
> index 2b99ddef7a41..0de14d475ad3 100644
> --- a/drivers/md/md-bitmap.h
> +++ b/drivers/md/md-bitmap.h
> @@ -98,6 +98,7 @@ struct bitmap_operations {
>         md_bitmap_fn *start_discard;
>         md_bitmap_fn *end_discard;
>
> +       sector_t (*skip_sync_blocks)(struct mddev *mddev, sector_t offset);
>         bool (*start_sync)(struct mddev *mddev, sector_t offset,
>                            sector_t *blocks, bool degraded);
>         void (*end_sync)(struct mddev *mddev, sector_t offset, sector_t *blocks);
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index dc4b85f30e13..890c8da43b3b 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -9362,6 +9362,12 @@ void md_do_sync(struct md_thread *thread)
>                 if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
>                         break;
>
> +               if (mddev->bitmap_ops && mddev->bitmap_ops->skip_sync_blocks) {
> +                       sectors = mddev->bitmap_ops->skip_sync_blocks(mddev, j);
> +                       if (sectors)
> +                               goto update;
> +               }
> +
>                 sectors = mddev->pers->sync_request(mddev, j, max_sectors,
>                                                     &skipped);
>                 if (sectors == 0) {
> @@ -9377,6 +9383,7 @@ void md_do_sync(struct md_thread *thread)
>                 if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
>                         break;
>
> +update:
>                 j += sectors;
>                 if (j > max_sectors)
>                         /* when skipping, extra large numbers can be returned. */
> --
> 2.39.2
>

Reviewed-by: Xiao Ni <xni@redhat.com>