lkml.org 
[lkml]   [2014]   [Jul]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [dm-devel] [PATCH] blk-lib: fix error reporting
From
Date
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




\
 
 \ /
  Last update: 2014-07-08 16:41    [W:0.115 / U:0.652 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site