From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org
Subject: Re: [dm-devel] [PATCH] blk-lib: fix error reporting
Date: Tue, 08 Jul 2014 07:04:06 -0700 [thread overview]
Message-ID: <1404828246.1967.8.camel@jarvis.lan> (raw)
In-Reply-To: <alpine.LRH.2.02.1407080859370.27276@file01.intranet.prod.int.rdu2.redhat.com>
On Tue, 2014-07-08 at 09:05 -0400, Mikulas Patocka wrote:
>
> On Tue, 8 Jul 2014, Christoph Hellwig wrote:
>
> > > + if (unlikely(err))
> > > + ACCESS_ONCE(bb->error) = err;
> >
> > I can't see a reason for the ACCESS_ONCE here.
>
> Multiple bios can be completed concurrently, so they write bb->error at
> the same time. The compiler may do store tearing (see "store tearing" in
> Documentation/memory-barriers.txt) - it may split one 4-byte write into
> several smaller writes - and it could result in setting bb->error to
> invalid value. We need ACCESS_ONCE to make sure that store tearing doesn't
> happen.
That's not correct, because it's not applicable in this case. Tearing
may occur on misalignment (which ACCESS_ONCE() cannot rectify because
it's architectural), short constant loads (again, usually architectural)
and structure copies, none of which applies here.
We can rely on a properly aligned 32 bit write being atomic.
James
next prev parent reply other threads:[~2014-07-08 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 19:16 [PATCH] blk-lib: fix error reporting Mikulas Patocka
2014-07-08 9:50 ` [dm-devel] " Christoph Hellwig
2014-07-08 13:05 ` Mikulas Patocka
2014-07-08 14:04 ` James Bottomley [this message]
2014-07-16 10:22 ` Mikulas Patocka
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=1404828246.1967.8.camel@jarvis.lan \
--to=james.bottomley@hansenpartnership.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox