lkml.org 
[lkml]   [2020]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] xfs: fix data races in inode->i_*time
On Tue, Feb 25, 2020 at 12:28:29PM -0800, Darrick J. Wong wrote:
> > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> > index 81f2f93caec0..2d5ca13ee9da 100644
> > --- a/fs/xfs/xfs_iops.c
> > +++ b/fs/xfs/xfs_iops.c
> > @@ -547,9 +547,9 @@
> > stat->uid = inode->i_uid;
> > stat->gid = inode->i_gid;
> > stat->ino = ip->i_ino;
> > - stat->atime = inode->i_atime;
> > - stat->mtime = inode->i_mtime;
> > - stat->ctime = inode->i_ctime;
> > + stat->atime = READ_ONCE(inode->i_atime);
> > + stat->mtime = READ_ONCE(inode->i_mtime);
> > + stat->ctime = READ_ONCE(inode->i_ctime);
>
> Seeing as one is supposed to take ILOCK_SHARED before reading inode core
> information, why don't we do that here? Is there some huge performance
> benefit to be realized from READ_ONCE vs. waiting for the lock that
> protects all the writes from each other?

Yes, I don't see how READ_ONCE works on a structure.

I think you should look into fixing this race in generic_fillattr
first, and we then piggy back on that fix in XFS once it has all been
sorted out.

\
 
 \ /
  Last update: 2020-02-25 21:47    [W:0.043 / U:0.560 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site