From: "yu kuai" <yukuai@fygo.io>
To: "Konstantin Nikiforov" <helllamer@gmail.com>,
<linux-raid@vger.kernel.org>, "yu kuai" <yukuai@fygo.io>
Cc: <linux-bcache@vger.kernel.org>, <regressions@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <stable@vger.kernel.org>,
<song@kernel.org>, <magiclinan@didiglobal.com>,
<xiao@kernel.org>, <colyli@fygo.io>, <kent.overstreet@linux.dev>
Subject: Re: [PATCH] md/raid5: complete unsupported discards successfully
Date: Fri, 6 Nov 2026 11:26:23 +0800 [thread overview]
Message-ID: <770fdf93-4330-4094-9807-a0cb449ecb73@fygo.io> (raw)
In-Reply-To: <179299857972.12222.2729359466842183358@gmail.com>
在 2026/10/26 14:21, Konstantin Nikiforov 写道:
> Since commit 90573092673c ("md/raid5: validate discard support at
> request time") raid5 advertises max_hw_discard_sectors = UINT_MAX no
> matter whether the member devices support discard or
> devices_handle_discard_safely is set, and make_discard_request() fails
> the discards it cannot handle with BLK_STS_NOTSUPP.
>
> Before that commit such arrays did not advertise discard at all, so
> upper layers never sent one. Now they do, and the failure is not
> harmless:
>
> - bcache forwards discards to its backing device whenever
> bdev_max_discard_sectors() is non-zero, and backing_request_endio()
> treats every non-zero bi_status as a media error. After io_error_limit
> (64) of them bch_cached_dev_error() stops the cached device. On a
> machine with root on LVM over bcache over a raid5 of three HDDs the
> root filesystem disappeared a few minutes after every boot.
>
> - btrfs enables discard=async by default on any device that advertises
> discard, which is what generated the discards in the first place.
>
> Discard is advisory: blkdev_issue_discard() already turns -EOPNOTSUPP
> into success for its callers, and md_submit_discard_bio() silently skips
> raid0/raid10 members without discard support. Do the same here and
> complete the bio successfully when the array cannot pass it down safely,
> so that callers submitting their own discard bios, like bcache, see the
> same behaviour.
>
> Fixes: 90573092673c ("md/raid5: validate discard support at request time")
> Cc:stable@vger.kernel.org # 7.2
> Closes:https://lore.kernel.org/all/CAO96y0V6oncv54ihXnHfJMYiG_QAQ-NM8BOdqPDXKL8r8-kR9Q@mail.gmail.com/
> Signed-off-by: Konstantin Nikiforov<helllamer@gmail.com>
> ---
> Kuai, this is the raid5-side change you were fine with in the report
> thread. Reproducer: raid5 over three loop devices with a bcache backing
> device on top, four blkdiscard calls on the bcache device. On 7.2.11
> without the patch bcache's io_errors goes to 4 (bch_count_backing_io_errors
> in dmesg); with the patch applied to 7.2.11 it stays at 0, and the
> affected machine (root on LVM over bcache over raid5 of HDDs) boots and
> runs with the patched module without any backing-device errors.
> blkdiscard on the md device itself reports success either way because
> blkdev_issue_discard() masks EOPNOTSUPP.
>
> One correction to my report: the "discard_granularity is 0" observation
> was a side effect of my own workaround (writing 0 to discard_max_bytes
> makes the block layer report granularity 0); on a fresh array the
> granularity is the stripe size as expected.
>
> drivers/md/raid5.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
Applied
--
Thanks,
Kuai
prev parent reply other threads:[~2026-11-06 3:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAO96y0V6oncv54ihXnHfJMYiG_QAQ-NM8BOdqPDXKL8r8-kR9Q@mail.gmail.com>
2026-10-26 6:21 ` Konstantin Nikiforov
2026-11-06 3:26 ` yu kuai [this message]
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=770fdf93-4330-4094-9807-a0cb449ecb73@fygo.io \
--to=yukuai@fygo.io \
--cc=colyli@fygo.io \
--cc=helllamer@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=regressions@lists.linux.dev \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=xiao@kernel.org \
/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
all inboxes | Powered by JetHome®