From 3d5cc46e54de47d2acf3ce562c38958c0da47f9a Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 28 Aug 2004 13:21:43 +1000 Subject: [PATCH] [XFS] Fix O_SYNC flushing in XFS which regressed with concurrent O_SYNC write improvements recently. Signed-off-by: Nathan Scott --- fs/xfs/linux-2.6/xfs_lrw.c | 39 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c index 6286a4c00b2b6..585b004855ab6 100644 --- a/fs/xfs/linux-2.6/xfs_lrw.c +++ b/fs/xfs/linux-2.6/xfs_lrw.c @@ -74,6 +74,7 @@ #include "xfs_iomap.h" #include +#include #if defined(XFS_RW_TRACE) @@ -871,24 +872,22 @@ retry: xfs_iunlock(xip, XFS_ILOCK_EXCL); } - if (ret <= 0) { - xfs_rwunlock(bdp, locktype); - error = -ret; - goto out_unlock_isem; - } + error = -ret; + if (ret <= 0) + goto out_unlock_internal; XFS_STATS_ADD(xs_write_bytes, ret); /* Handle various SYNC-type writes */ - if ((file->f_flags & O_SYNC) || IS_SYNC(file->f_dentry->d_inode)) { - + if ((file->f_flags & O_SYNC) || IS_SYNC(inode)) { /* * If we're treating this as O_DSYNC and we have not updated the * size, force the log. */ + if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC) && + !(xip->i_update_size)) { + xfs_inode_log_item_t *iip = xip->i_itemp; - if (!(mp->m_flags & XFS_MOUNT_OSYNCISOSYNC) - && !(xip->i_update_size)) { /* * If an allocation transaction occurred * without extending the size, then we have to force @@ -908,14 +907,8 @@ retry: * all changes affecting the inode are permanent * when we return. */ - - xfs_inode_log_item_t *iip; - xfs_lsn_t lsn; - - iip = xip->i_itemp; if (iip && iip->ili_last_lsn) { - lsn = iip->ili_last_lsn; - xfs_log_force(mp, lsn, + xfs_log_force(mp, iip->ili_last_lsn, XFS_LOG_FORCE | XFS_LOG_SYNC); } else if (xfs_ipincount(xip) > 0) { xfs_log_force(mp, (xfs_lsn_t)0, @@ -956,13 +949,21 @@ retry: xfs_trans_set_sync(tp); error = xfs_trans_commit(tp, 0, NULL); xfs_iunlock(xip, XFS_ILOCK_EXCL); + if (error) + goto out_unlock_internal; } } - } /* (ioflags & O_SYNC) */ - xfs_rwunlock(bdp, locktype); - error = -ret; + xfs_rwunlock(bdp, locktype); + error = sync_page_range(inode, mapping, pos, ret); + if (!error) + error = -ret; + goto out_unlock_isem; + } + + out_unlock_internal: + xfs_rwunlock(bdp, locktype); out_unlock_isem: if (need_isem) up(&inode->i_sem); -- 2.53.0