Linux RAID subsystem development
 help / color / mirror / Atom feed
From: Wale Zhang <wale.zhang.ftd@gmail.com>
To: song@kernel.org, yukuai@fygo.io, magiclinan@didiglobal.com,
	xiao@kernel.org
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wale Zhang <wale.zhang.ftd@gmail.com>
Subject: [PATCH 1/1] md: skip discard on unsupported member devices
Date: Fri, 31 Jul 2026 03:47:29 -0400	[thread overview]
Message-ID: <20260731074729.1885314-1-wale.zhang.ftd@gmail.com> (raw)

blk_stack_limits() uses min_not_zero() when stacking discard limits.
Thus an array containing devices with different discard capabilities can
expose discard support as long as at least one member has a non-zero
discard limit.

raid0 and raid10 use md_submit_discard_bio() to submit a discard bio to
each member covered by the request.  The helper currently also submits
bios to members whose max_discard_sectors is zero.  The block layer
completes these bios with BLK_STS_NOTSUPP, and bio chaining propagates
that status to the original discard request.

Discard is optional, so skip members which do not support it.  Members that
do support discard continue to receive their portion of the request.

Signed-off-by: Wale Zhang <wale.zhang.ftd@gmail.com>
---
 drivers/md/md.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index d1465bcd86c8..77e6e6bd5460 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -9350,6 +9350,10 @@ void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev,
 {
 	struct bio *discard_bio = NULL;
 
+	/* Discard is optional, so silently skip members that do not support it. */
+	if (unlikely(!bdev_max_discard_sectors(rdev->bdev)))
+		return;
+
 	__blkdev_issue_discard(rdev->bdev, start, size, GFP_NOIO, &discard_bio);
 	if (!discard_bio)
 		return;
-- 
2.47.3


             reply	other threads:[~2026-07-31  7:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  7:47 Wale Zhang [this message]
2026-08-07  8:35 ` [PATCH 1/1] md: skip discard on unsupported member devices yu kuai
2026-08-07  8:55   ` wale zhang
2026-08-07  8:43 ` wale zhang

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=20260731074729.1885314-1-wale.zhang.ftd@gmail.com \
    --to=wale.zhang.ftd@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=magiclinan@didiglobal.com \
    --cc=song@kernel.org \
    --cc=xiao@kernel.org \
    --cc=yukuai@fygo.io \
    /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