From: Christoph Hellwig <hch@infradead.org>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: zhangshida <starzhangzsd@gmail.com>,
Johannes.Thumshirn@wdc.com, hch@infradead.org,
ming.lei@redhat.com, hsiangkao@linux.alibaba.com,
csander@purestorage.com, colyli@fnnas.com,
linux-block@vger.kernel.org, linux-bcache@vger.kernel.org,
linux-kernel@vger.kernel.org, zhangshida@kylinos.cn,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v4 3/3] block: prevent race condition on bi_status in __bio_chain_endio
Date: Mon, 1 Dec 2025 03:25:32 -0800 [thread overview]
Message-ID: <aS17LOwklgbzNhJY@infradead.org> (raw)
In-Reply-To: <CAHc6FU4o8Wv+6TQti4NZJRUQpGF9RWqiN9fO6j55p4xgysM_3g@mail.gmail.com>
On Mon, Dec 01, 2025 at 11:22:32AM +0100, Andreas Gruenbacher wrote:
> > - if (bio->bi_status && !parent->bi_status)
> > - parent->bi_status = bio->bi_status;
> > + if (bio->bi_status)
> > + cmpxchg(&parent->bi_status, 0, bio->bi_status);
>
> Hmm. I don't think cmpxchg() actually is of any value here: for all
> the chained bios, bi_status is initialized to 0, and it is only set
> again (to a non-0 value) when a failure occurs. When there are
> multiple failures, we only need to make sure that one of those
> failures is eventually reported, but for that, a simple assignment is
> enough here.
A simple assignment doesn't guarantee atomicy. It also overrides
earlier with later status codes, which might not be desirable.
next prev parent reply other threads:[~2025-12-01 11:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 9:04 [PATCH v4 0/3] Fix bio chain related issues zhangshida
2025-12-01 9:04 ` [PATCH v4 1/3] bcache: fix improper use of bi_end_io zhangshida
2025-12-01 9:04 ` [PATCH v4 2/3] block: prohibit calls to bio_chain_endio zhangshida
2025-12-01 9:34 ` Andreas Gruenbacher
2025-12-04 1:17 ` Stephen Zhang
2025-12-01 9:04 ` [PATCH v4 3/3] block: prevent race condition on bi_status in __bio_chain_endio zhangshida
2025-12-01 10:22 ` Andreas Gruenbacher
2025-12-01 11:25 ` Christoph Hellwig [this message]
2025-12-01 13:07 ` Andreas Gruenbacher
2025-12-02 5:48 ` Christoph Hellwig
2025-12-02 21:15 ` Andreas Gruenbacher
2025-12-03 1:51 ` Stephen Zhang
2025-12-03 3:09 ` Stephen Zhang
2025-12-03 4:34 ` Caleb Sander Mateos
2025-12-03 6:14 ` Christoph Hellwig
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=aS17LOwklgbzNhJY@infradead.org \
--to=hch@infradead.org \
--cc=Johannes.Thumshirn@wdc.com \
--cc=agruenba@redhat.com \
--cc=colyli@fnnas.com \
--cc=csander@purestorage.com \
--cc=hch@lst.de \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=starzhangzsd@gmail.com \
--cc=zhangshida@kylinos.cn \
/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