diff options
author | Dave Chinner <david@fromorbit.com> | 2015-11-03 13:27:58 +1100 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-11-03 13:27:58 +1100 |
commit | 2da5c4b05ab55225f5d1fcc8c1c37d1918232bf4 (patch) | |
tree | f19bd87d6e66c251566be226fdf40c24c168e04a /fs/xfs/xfs_file.c | |
parent | fcd8a399a9d44a637b5ded0eeea14c7933132121 (diff) | |
parent | fc0561cefc04e7803c0f6501ca4f310a502f65b8 (diff) | |
download | blackbird-obmc-linux-2da5c4b05ab55225f5d1fcc8c1c37d1918232bf4.tar.gz blackbird-obmc-linux-2da5c4b05ab55225f5d1fcc8c1c37d1918232bf4.zip |
Merge branch 'xfs-misc-fixes-for-4.4-2' into for-next
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r-- | fs/xfs/xfs_file.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 2f7b6bd39f61..a3bf4c099dd2 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -242,19 +242,30 @@ xfs_file_fsync( } /* - * All metadata updates are logged, which means that we just have - * to flush the log up to the latest LSN that touched the inode. + * All metadata updates are logged, which means that we just have to + * flush the log up to the latest LSN that touched the inode. If we have + * concurrent fsync/fdatasync() calls, we need them to all block on the + * log force before we clear the ili_fsync_fields field. This ensures + * that we don't get a racing sync operation that does not wait for the + * metadata to hit the journal before returning. If we race with + * clearing the ili_fsync_fields, then all that will happen is the log + * force will do nothing as the lsn will already be on disk. We can't + * race with setting ili_fsync_fields because that is done under + * XFS_ILOCK_EXCL, and that can't happen because we hold the lock shared + * until after the ili_fsync_fields is cleared. */ xfs_ilock(ip, XFS_ILOCK_SHARED); if (xfs_ipincount(ip)) { if (!datasync || - (ip->i_itemp->ili_fields & ~XFS_ILOG_TIMESTAMP)) + (ip->i_itemp->ili_fsync_fields & ~XFS_ILOG_TIMESTAMP)) lsn = ip->i_itemp->ili_last_lsn; } - xfs_iunlock(ip, XFS_ILOCK_SHARED); - if (lsn) + if (lsn) { error = _xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, &log_flushed); + ip->i_itemp->ili_fsync_fields = 0; + } + xfs_iunlock(ip, XFS_ILOCK_SHARED); /* * If we only have a single device, and the log force about was |