From: John Dorminy <jdorminy@redhat.com>
To: Mike Snitzer <snitzer@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>, NeilBrown <neilb@suse.com>,
linux-block@vger.kernel.org,
device-mapper development <dm-devel@redhat.com>,
Milan Broz <gmazyland@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: block: be more careful about status in __bio_chain_endio
Date: Fri, 22 Feb 2019 21:02:06 -0500 [thread overview]
Message-ID: <CAMeeMh-2ANOr_Sb66EyA_HULkVRudD7fyOZsDbpRpDrshwnR2w@mail.gmail.com> (raw)
In-Reply-To: <20190222235459.GA11726@redhat.com>
I am perhaps not understanding the intricacies here, or not seeing a
barrier protecting it, so forgive me if I'm off base. I think reading
parent->bi_status here is unsafe.
Consider the following sequence of events on two threads.
Thread 0 Thread 1
In __bio_chain_endio: In __bio_chain_endio:
[A] Child 0 reads parent->bi_status,
no error.
Child bio 1 reads parent, no error seen
It sets parent->bi_status to an error
It calls bio_put.
Child bio 0 calls bio_put
[end __bio_chain_endio] [end __bio_chain_endio]
In bio_chain_endio(), bio_endio(parent)
is called, calling bio_remaining_done()
which decrements __bi_remaining to 1
and returns false, so no further endio
stuff is done.
In bio_chain_endio(), bio_endio(parent)
is called, calling bio_remaining_done(),
decrementing parent->__bi_remaining to
0, and continuing to finish parent.
Either for block tracing or for parent's
bi_end_io(), this thread tries to read
parent->bi_status again.
The compiler or the CPU may cache the read from [A], and since there
are no intervening barriers, parent->bi_status is still believed on
thread 0 to be success. Thus the bio may still be falsely believed to
have completed successfully, even though child 1 set an error in it.
Am I missing a subtlety here?
next prev parent reply other threads:[~2019-02-23 2:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <70cda2a3-f246-d45b-f600-1f9d15ba22ff@gmail.com>
[not found] ` <87eflmpqkb.fsf@notabene.neil.brown.name>
2019-02-22 21:10 ` block: be more careful about status in __bio_chain_endio Mike Snitzer
2019-02-22 22:46 ` Jens Axboe
2019-02-22 23:55 ` Mike Snitzer
2019-02-23 2:02 ` John Dorminy [this message]
2019-02-23 2:44 ` Mike Snitzer
2019-02-23 3:10 ` John Dorminy
2019-06-12 2:56 ` John Dorminy
2019-06-12 7:01 ` Christoph Hellwig
2019-06-17 7:32 ` Hannes Reinecke
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=CAMeeMh-2ANOr_Sb66EyA_HULkVRudD7fyOZsDbpRpDrshwnR2w@mail.gmail.com \
--to=jdorminy@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=gmazyland@gmail.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.com \
--cc=snitzer@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).