]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations
authorYu Kuai <yukuai3@huawei.com>
Fri, 29 Aug 2025 08:04:22 +0000 (16:04 +0800)
committerYu Kuai <yukuai3@huawei.com>
Sat, 6 Sep 2025 09:19:45 +0000 (17:19 +0800)
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;

Link: https://lore.kernel.org/linux-raid/20250829080426.1441678-8-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Xiao Ni <xni@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Li Nan <linan122@huawei.com>
drivers/md/md-bitmap.h
drivers/md/md.c

index 8616ced49077d30a0eaa26d495b2ed8cf914a103..95453696c68e4cba42c285f860b1ad63f9000712 100644 (file)
@@ -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);
index 51dee0a98af1c926be4479b99df1a5eec6e20c8d..ec80c8d6cbcb71e1fbc001847832752c6ba248a7 100644 (file)
@@ -9460,6 +9460,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) {
@@ -9475,6 +9481,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. */