diff options
| author | Wale Zhang <wale.zhang.ftd@gmail.com> | 2026-07-31 03:47:29 -0400 |
|---|---|---|
| committer | Yu Kuai <yukuai@fygo.io> | 2026-08-07 16:36:32 +0800 |
| commit | efdffeb6d4915219a130607f5ae29613d2c5545a (patch) | |
| tree | 61949bdaa1f1f711935decd8b7bc1ad25f623abf | |
| parent | 162eb5ba791f6260fdaabae75fa2df20134f67d8 (diff) | |
md: skip discard on unsupported member devices
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>
Link: https://patch.msgid.link/20260731074729.1885314-1-wale.zhang.ftd@gmail.com
Signed-off-by: Yu Kuai <yukuai@fygo.io>
| -rw-r--r-- | drivers/md/md.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 42fca0cec8e4..680b34a63cb3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9377,6 +9377,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; |
