linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: corbet@lwn.net, agk@redhat.com, snitzer@kernel.org,
	mpatocka@redhat.com, song@kernel.org, yukuai3@huawei.com,
	hare@suse.de
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	dm-devel@lists.linux.dev, linux-raid@vger.kernel.org,
	yukuai1@huaweicloud.com, yi.zhang@huawei.com,
	yangerkun@huawei.com, johnny.chenyi@huawei.com
Subject: [PATCH v3 07/11] md/md-bitmap: add a new method skip_sync_blocks() in bitmap_operations
Date: Fri, 18 Jul 2025 17:23:32 +0800	[thread overview]
Message-ID: <20250718092336.3346644-8-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20250718092336.3346644-1-yukuai1@huaweicloud.com>

From: Yu Kuai <yukuai3@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 <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Xiao Ni <xni@redhat.com>
Reviewed-by: Hannes Reinecke <hare@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


  parent reply	other threads:[~2025-07-18  9:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18  9:23 [PATCH v3 00/11] md/llbitmap: md/md-llbitmap: introduce a new lockless bitmap Yu Kuai
2025-07-18  9:23 ` [PATCH v3 01/11] md: add a new parameter 'offset' to md_super_write() Yu Kuai
2025-07-18  9:23 ` [PATCH v3 02/11] md: factor out a helper raid_is_456() Yu Kuai
2025-07-18  9:23 ` [PATCH v3 03/11] md/md-bitmap: support discard for bitmap ops Yu Kuai
2025-07-18  9:23 ` [PATCH v3 04/11] md: add a new mddev field 'bitmap_id' Yu Kuai
2025-07-18  9:23 ` [PATCH v3 05/11] md/md-bitmap: add a new sysfs api bitmap_type Yu Kuai
2025-07-18  9:23 ` [PATCH v3 06/11] md/md-bitmap: delay registration of bitmap_ops until creating bitmap Yu Kuai
2025-07-19  6:49   ` Li Nan
2025-07-19  9:45     ` Yu Kuai
2025-07-21  6:01   ` Hannes Reinecke
2025-07-21  6:10     ` Yu Kuai
2025-07-18  9:23 ` Yu Kuai [this message]
2025-07-18  9:23 ` [PATCH v3 08/11] md/md-bitmap: add a new method blocks_synced() in bitmap_operations Yu Kuai
2025-07-18  9:23 ` [PATCH v3 09/11] md: add a new recovery_flag MD_RECOVERY_LAZY_RECOVER Yu Kuai
2025-07-18  9:23 ` [PATCH v3 10/11] md/md-bitmap: make method bitmap_ops->daemon_work optional Yu Kuai
2025-07-18  9:23 ` [PATCH v3 11/11] md/md-llbitmap: introduce new lockless bitmap Yu Kuai
2025-07-21  6:20   ` Hannes Reinecke
2025-07-21  7:12     ` Yu Kuai
2025-07-21  7:20       ` Hannes Reinecke

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=20250718092336.3346644-8-yukuai1@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=agk@redhat.com \
    --cc=corbet@lwn.net \
    --cc=dm-devel@lists.linux.dev \
    --cc=hare@suse.de \
    --cc=johnny.chenyi@huawei.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /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).