Commit e9f1c6ee authored by David Chinner's avatar David Chinner Committed by Lachlan McIlroy

[XFS] make SYNC_DELWRI no longer use xfs_sync

Continue to de-multiplex xfs_sync be replacing all SYNC_DELWRI callers
with direct calls functions that do the work. Isolate the data quiesce
case to a function in xfs_sync.c. Isolate the FSDATA case with explicit
calls to xfs_sync_fsdata().

Version 2: o Push delwri related log forces into xfs_sync_inodes().

SGI-PV: 988140

SGI-Modid: xfs-linux-melb:xfs-kern:32309a
Signed-off-by: default avatarDavid Chinner <david@fromorbit.com>
Signed-off-by: default avatarLachlan McIlroy <lachlan@sgi.com>
Signed-off-by: default avatarChristoph Hellwig <hch@infradead.org>
parent be97d9d5
...@@ -998,7 +998,6 @@ xfs_fs_put_super( ...@@ -998,7 +998,6 @@ xfs_fs_put_super(
int error; int error;
xfs_syncd_stop(mp); xfs_syncd_stop(mp);
xfs_log_force(mp, 0, XFS_LOG_FORCE|XFS_LOG_SYNC);
xfs_sync_inodes(mp, SYNC_ATTR|SYNC_DELWRI); xfs_sync_inodes(mp, SYNC_ATTR|SYNC_DELWRI);
#ifdef HAVE_DMAPI #ifdef HAVE_DMAPI
...@@ -1057,7 +1056,7 @@ xfs_fs_write_super( ...@@ -1057,7 +1056,7 @@ xfs_fs_write_super(
struct super_block *sb) struct super_block *sb)
{ {
if (!(sb->s_flags & MS_RDONLY)) if (!(sb->s_flags & MS_RDONLY))
xfs_sync(XFS_M(sb), SYNC_FSDATA); xfs_sync_fsdata(XFS_M(sb), 0);
sb->s_dirt = 0; sb->s_dirt = 0;
} }
...@@ -1068,7 +1067,6 @@ xfs_fs_sync_super( ...@@ -1068,7 +1067,6 @@ xfs_fs_sync_super(
{ {
struct xfs_mount *mp = XFS_M(sb); struct xfs_mount *mp = XFS_M(sb);
int error; int error;
int flags;
/* /*
* Treat a sync operation like a freeze. This is to work * Treat a sync operation like a freeze. This is to work
...@@ -1082,20 +1080,10 @@ xfs_fs_sync_super( ...@@ -1082,20 +1080,10 @@ xfs_fs_sync_super(
* dirty the Linux inode until after the transaction I/O * dirty the Linux inode until after the transaction I/O
* completes. * completes.
*/ */
if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE)) { if (wait || unlikely(sb->s_frozen == SB_FREEZE_WRITE))
/* error = xfs_quiesce_data(mp);
* First stage of freeze - no more writers will make progress else
* now we are here, so we flush delwri and delalloc buffers error = xfs_sync_fsdata(mp, 0);
* here, then wait for all I/O to complete. Data is frozen at
* that point. Metadata is not frozen, transactions can still
* occur here so don't bother flushing the buftarg (i.e
* SYNC_QUIESCE) because it'll just get dirty again.
*/
flags = SYNC_DATA_QUIESCE;
} else
flags = SYNC_FSDATA;
error = xfs_sync(mp, flags);
sb->s_dirt = 0; sb->s_dirt = 0;
if (unlikely(laptop_mode)) { if (unlikely(laptop_mode)) {
...@@ -1233,8 +1221,7 @@ xfs_fs_remount( ...@@ -1233,8 +1221,7 @@ xfs_fs_remount(
/* rw -> ro */ /* rw -> ro */
if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
xfs_filestream_flush(mp); xfs_quiesce_data(mp);
xfs_sync(mp, SYNC_DATA_QUIESCE);
xfs_attr_quiesce(mp); xfs_attr_quiesce(mp);
mp->m_flags |= XFS_MOUNT_RDONLY; mp->m_flags |= XFS_MOUNT_RDONLY;
} }
......
...@@ -217,12 +217,16 @@ xfs_sync_inodes( ...@@ -217,12 +217,16 @@ xfs_sync_inodes(
int error; int error;
int last_error; int last_error;
int i; int i;
int lflags = XFS_LOG_FORCE;
if (mp->m_flags & XFS_MOUNT_RDONLY) if (mp->m_flags & XFS_MOUNT_RDONLY)
return 0; return 0;
error = 0; error = 0;
last_error = 0; last_error = 0;
if (flags & SYNC_WAIT)
lflags |= XFS_LOG_SYNC;
for (i = 0; i < mp->m_sb.sb_agcount; i++) { for (i = 0; i < mp->m_sb.sb_agcount; i++) {
if (!mp->m_perag[i].pag_ici_init) if (!mp->m_perag[i].pag_ici_init)
continue; continue;
...@@ -232,6 +236,9 @@ xfs_sync_inodes( ...@@ -232,6 +236,9 @@ xfs_sync_inodes(
if (error == EFSCORRUPTED) if (error == EFSCORRUPTED)
break; break;
} }
if (flags & SYNC_DELWRI)
xfs_log_force(mp, 0, lflags);
return XFS_ERROR(last_error); return XFS_ERROR(last_error);
} }
...@@ -269,7 +276,7 @@ xfs_commit_dummy_trans( ...@@ -269,7 +276,7 @@ xfs_commit_dummy_trans(
return 0; return 0;
} }
STATIC int int
xfs_sync_fsdata( xfs_sync_fsdata(
struct xfs_mount *mp, struct xfs_mount *mp,
int flags) int flags)
...@@ -322,6 +329,39 @@ xfs_sync_fsdata( ...@@ -322,6 +329,39 @@ xfs_sync_fsdata(
return error; return error;
} }
/*
* First stage of freeze - no more writers will make progress now we are here,
* so we flush delwri and delalloc buffers here, then wait for all I/O to
* complete. Data is frozen at that point. Metadata is not frozen,
* transactions can still occur here so don't bother flushing the buftarg (i.e
* SYNC_QUIESCE) because it'll just get dirty again.
*/
int
xfs_quiesce_data(
struct xfs_mount *mp)
{
int error;
/* push non-blocking */
xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_BDFLUSH);
XFS_QM_DQSYNC(mp, SYNC_BDFLUSH);
xfs_filestream_flush(mp);
/* push and block */
xfs_sync_inodes(mp, SYNC_DELWRI|SYNC_WAIT|SYNC_IOWAIT);
XFS_QM_DQSYNC(mp, SYNC_WAIT);
/* write superblock and hoover shutdown errors */
error = xfs_sync_fsdata(mp, 0);
/* flush devices */
XFS_bflush(mp->m_ddev_targp);
if (mp->m_rtdev_targp)
XFS_bflush(mp->m_rtdev_targp);
return error;
}
/* /*
* xfs_sync flushes any pending I/O to file system vfsp. * xfs_sync flushes any pending I/O to file system vfsp.
* *
......
...@@ -55,6 +55,9 @@ void xfs_syncd_stop(struct xfs_mount *mp); ...@@ -55,6 +55,9 @@ void xfs_syncd_stop(struct xfs_mount *mp);
int xfs_sync(struct xfs_mount *mp, int flags); int xfs_sync(struct xfs_mount *mp, int flags);
int xfs_sync_inodes(struct xfs_mount *mp, int flags); int xfs_sync_inodes(struct xfs_mount *mp, int flags);
int xfs_sync_fsdata(struct xfs_mount *mp, int flags);
int xfs_quiesce_data(struct xfs_mount *mp);
void xfs_flush_inode(struct xfs_inode *ip); void xfs_flush_inode(struct xfs_inode *ip);
void xfs_flush_device(struct xfs_inode *ip); void xfs_flush_device(struct xfs_inode *ip);
......
...@@ -75,7 +75,6 @@ xfs_quiesce_fs( ...@@ -75,7 +75,6 @@ xfs_quiesce_fs(
* logged before we can write the unmount record. * logged before we can write the unmount record.
*/ */
do { do {
xfs_log_force(mp, 0, XFS_LOG_FORCE|XFS_LOG_SYNC);
xfs_sync_inodes(mp, SYNC_ATTR|SYNC_WAIT); xfs_sync_inodes(mp, SYNC_ATTR|SYNC_WAIT);
pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1); pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
if (!pincount) { if (!pincount) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment