lkml.org 
[lkml]   [2017]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4.4 13/16] ocfs2: should wait dio before inode lock in ocfs2_setattr()
From
Date
On Wed, 2017-12-06 at 09:02 +0800, alex chen wrote:
> Hi Ben,
>
> Thanks for your reply.
>
> On 2017/12/5 23:49, Ben Hutchings wrote:
> > On Wed, 2017-11-22 at 11:12 +0100, Greg Kroah-Hartman wrote:
> > > 4.4-stable review patch.  If anyone has any objections, please let me know.
> > >
> > > ------------------
> > >
> > > From: alex chen <alex.chen@huawei.com>
> > >
> > > commit 28f5a8a7c033cbf3e32277f4cc9c6afd74f05300 upstream.
> > >
> > > we should wait dio requests to finish before inode lock in
> > > ocfs2_setattr(), otherwise the following deadlock will happen:
> >
> > [...]
> >
> > I looked at the kernel-doc for inode_dio_wait():
> >
> > /**
> >  * inode_dio_wait - wait for outstanding DIO requests to finish
> >  * @inode: inode to wait for
> >  *
> >  * Waits for all pending direct I/O requests to finish so that we can
> >  * proceed with a truncate or equivalent operation.
> >  *
> >  * Must be called under a lock that serializes taking new references
> >  * to i_dio_count, usually by inode->i_mutex.
> >  */
> >
> > Now that ocfs2_setattr() calls this outside of the inode locked region,
> > what prevents another task adding a new dio request immediately
> > afterward?
> >
>
> In the kernel 4.6, firstly, we use the inode_lock() in do_truncate() to
> prevent another bio to be issued from this node.
[...]

Yes but there seems to be a race condition - after the call to
inode_dio_wait() and before the call to inode_lock(), another dio
request can be added.

Ben.

--
Ben Hutchings
Software Developer, Codethink Ltd.

\
 
 \ /
  Last update: 2017-12-07 19:27    [W:0.069 / U:4.500 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site