From: Yu Kuai <yuku...@huawei.com> This method is used to check if blocks can be skipped before calling into pers->sync_request(), llbitmap 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 <yuku...@huawei.com> Reviewed-by: Christoph Hellwig <h...@lst.de> Reviewed-by: Xiao Ni <x...@redhat.com> Reviewed-by: Hannes Reinecke <h...@suse.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 8616ced49077..95453696c68e 100644 --- a/drivers/md/md-bitmap.h +++ b/drivers/md/md-bitmap.h @@ -89,6 +89,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 639b0143cbb1..4a9e3f7cbfe3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9394,6 +9394,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) { @@ -9409,6 +9415,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