From: Al Viro <viro@zeniv.linux.org.uk>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [bug?] blk_queue_may_bounce() has the comparison max_low_pfn and max_pfn wrong way
Date: Sun, 30 Oct 2022 18:47:33 +0000 [thread overview]
Message-ID: <Y17GxQf8TV2/zNo1@ZenIV> (raw)
In-Reply-To: <20221030075032.GC4214@lst.de>
On Sun, Oct 30, 2022 at 08:50:32AM +0100, Christoph Hellwig wrote:
> On Sat, Oct 29, 2022 at 05:45:45PM +0100, Al Viro wrote:
> > completion (in NULL_Q_BIO case, at least). What happens if request
> > gets split and split-off part finishes first with an error? AFAICS,
> > its ->bi_status will be copied to parent (original bio, the one that
> > covers the tail). Now the IO on the original bio is over as well
> > and we hit drivers/block/null_blk/main.c:end_cmd(). Suppose this
> > part succeeds; won't we end up overwriting ->bi_status with zero
> > and assuming that the entire thing had succeeded, despite the
> > (now lost) error on the split-off part?
>
> As a rule of thumb drives should never set bi_status to 0, so null_blk
> here has a bug. What is missing everywhere is proper memory barriers,
> though.
Something like
static inline void set_bio_status(struct bio *bio, blk_status_t status)
{
if (unlikely(status))
cmpxchg(&bio->bi_status, 0, status);
}
with e.g.
if (bio->bi_status && !dio->bio.bi_status)
dio->bio.bi_status = bio->bi_status;
in blkdev_bio_end_io() replaced with
set_bio_status(&dio->bio, bio->bi_status);
perhaps? That would probably do for almost all users, but... what about
e.g. drivers/md/raid1.c:fix_sync_read_error()? Looks like it really
intends non-zero -> zero change; I'm not familiar enough with the guts
of that sucker to tell if it is guaranteed to get no propagation from
another bio...
next prev parent reply other threads:[~2022-10-30 18:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 18:02 [bug?] blk_queue_may_bounce() has the comparison max_low_pfn and max_pfn wrong way Al Viro
2022-10-28 18:51 ` Jens Axboe
2022-10-28 19:21 ` Al Viro
2022-10-29 16:45 ` Al Viro
2022-10-30 7:50 ` Christoph Hellwig
2022-10-30 18:47 ` Al Viro [this message]
2022-11-01 11:11 ` Christoph Hellwig
2022-10-30 7:48 ` Christoph Hellwig
2022-10-28 19:14 ` Al Viro
2022-10-30 7:45 ` 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=Y17GxQf8TV2/zNo1@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.