aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Chinner <david@fromorbit.com>2008-10-30 02:16:21 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 02:16:21 -0400
commit76bf105cb16da6c847a13a3c77dc962ba1081713 (patch)
tree83c75b54f897589a6f13efe1ca42d1352d5fe060
parenta4e4c4f4a8f9376158f8181a75285091f52a79e3 (diff)
[XFS] Move remaining quiesce code.
With all the other filesystem sync code it in xfs_sync.c including the data quiesce code, it makes sense to move the remaining quiesce code to the same place. SGI-PV: 988140 SGI-Modid: xfs-linux-melb:xfs-kern:32312a Signed-off-by: David Chinner <david@fromorbit.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Christoph Hellwig <hch@infradead.org>
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c55
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.h1
-rw-r--r--fs/xfs/xfs_vfsops.c55
-rw-r--r--fs/xfs/xfs_vfsops.h1
5 files changed, 59 insertions, 59 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 60ecf47b9f05..15fb262ef868 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1212,7 +1212,7 @@ xfs_fs_remount(
1212 /* rw -> ro */ 1212 /* rw -> ro */
1213 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { 1213 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
1214 xfs_quiesce_data(mp); 1214 xfs_quiesce_data(mp);
1215 xfs_attr_quiesce(mp); 1215 xfs_quiesce_attr(mp);
1216 mp->m_flags |= XFS_MOUNT_RDONLY; 1216 mp->m_flags |= XFS_MOUNT_RDONLY;
1217 } 1217 }
1218 1218
@@ -1221,7 +1221,7 @@ xfs_fs_remount(
1221 1221
1222/* 1222/*
1223 * Second stage of a freeze. The data is already frozen so we only 1223 * Second stage of a freeze. The data is already frozen so we only
1224 * need to take care of themetadata. Once that's done write a dummy 1224 * need to take care of the metadata. Once that's done write a dummy
1225 * record to dirty the log in case of a crash while frozen. 1225 * record to dirty the log in case of a crash while frozen.
1226 */ 1226 */
1227STATIC void 1227STATIC void
@@ -1230,7 +1230,7 @@ xfs_fs_lockfs(
1230{ 1230{
1231 struct xfs_mount *mp = XFS_M(sb); 1231 struct xfs_mount *mp = XFS_M(sb);
1232 1232
1233 xfs_attr_quiesce(mp); 1233 xfs_quiesce_attr(mp);
1234 xfs_fs_log_dummy(mp); 1234 xfs_fs_log_dummy(mp);
1235} 1235}
1236 1236
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index ed24435af651..b2b708254ae6 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -357,6 +357,61 @@ xfs_quiesce_data(
357 return error; 357 return error;
358} 358}
359 359
360STATIC void
361xfs_quiesce_fs(
362 struct xfs_mount *mp)
363{
364 int count = 0, pincount;
365
366 xfs_flush_buftarg(mp->m_ddev_targp, 0);
367 xfs_finish_reclaim_all(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC);
368
369 /*
370 * This loop must run at least twice. The first instance of the loop
371 * will flush most meta data but that will generate more meta data
372 * (typically directory updates). Which then must be flushed and
373 * logged before we can write the unmount record.
374 */
375 do {
376 xfs_sync_inodes(mp, SYNC_ATTR|SYNC_WAIT);
377 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
378 if (!pincount) {
379 delay(50);
380 count++;
381 }
382 } while (count < 2);
383}
384
385/*
386 * Second stage of a quiesce. The data is already synced, now we have to take
387 * care of the metadata. New transactions are already blocked, so we need to
388 * wait for any remaining transactions to drain out before proceding.
389 */
390void
391xfs_quiesce_attr(
392 struct xfs_mount *mp)
393{
394 int error = 0;
395
396 /* wait for all modifications to complete */
397 while (atomic_read(&mp->m_active_trans) > 0)
398 delay(100);
399
400 /* flush inodes and push all remaining buffers out to disk */
401 xfs_quiesce_fs(mp);
402
403 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0);
404
405 /* Push the superblock and write an unmount record */
406 error = xfs_log_sbcount(mp, 1);
407 if (error)
408 xfs_fs_cmn_err(CE_WARN, mp,
409 "xfs_attr_quiesce: failed to log sb changes. "
410 "Frozen image may not be consistent.");
411 xfs_log_unmount_write(mp);
412 xfs_unmountfs_writesb(mp);
413}
414
360/* 415/*
361 * Enqueue a work item to be picked up by the vfs xfssyncd thread. 416 * Enqueue a work item to be picked up by the vfs xfssyncd thread.
362 * Doing this has two advantages: 417 * Doing this has two advantages:
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/linux-2.6/xfs_sync.h
index 4591dc0c7880..3b49aa3bb5fc 100644
--- a/fs/xfs/linux-2.6/xfs_sync.h
+++ b/fs/xfs/linux-2.6/xfs_sync.h
@@ -40,6 +40,7 @@ int xfs_sync_inodes(struct xfs_mount *mp, int flags);
40int xfs_sync_fsdata(struct xfs_mount *mp, int flags); 40int xfs_sync_fsdata(struct xfs_mount *mp, int flags);
41 41
42int xfs_quiesce_data(struct xfs_mount *mp); 42int xfs_quiesce_data(struct xfs_mount *mp);
43void xfs_quiesce_attr(struct xfs_mount *mp);
43 44
44void xfs_flush_inode(struct xfs_inode *ip); 45void xfs_flush_inode(struct xfs_inode *ip);
45void xfs_flush_device(struct xfs_inode *ip); 46void xfs_flush_device(struct xfs_inode *ip);
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index b55a9bb3a6e3..883dd0f68e9a 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -59,61 +59,6 @@
59#include "xfs_sync.h" 59#include "xfs_sync.h"
60 60
61 61
62STATIC void
63xfs_quiesce_fs(
64 xfs_mount_t *mp)
65{
66 int count = 0, pincount;
67
68 xfs_flush_buftarg(mp->m_ddev_targp, 0);
69 xfs_finish_reclaim_all(mp, 0, XFS_IFLUSH_DELWRI_ELSE_ASYNC);
70
71 /*
72 * This loop must run at least twice. The first instance of the loop
73 * will flush most meta data but that will generate more meta data
74 * (typically directory updates). Which then must be flushed and
75 * logged before we can write the unmount record.
76 */
77 do {
78 xfs_sync_inodes(mp, SYNC_ATTR|SYNC_WAIT);
79 pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
80 if (!pincount) {
81 delay(50);
82 count++;
83 }
84 } while (count < 2);
85}
86
87/*
88 * Second stage of a quiesce. The data is already synced, now we have to take
89 * care of the metadata. New transactions are already blocked, so we need to
90 * wait for any remaining transactions to drain out before proceding.
91 */
92void
93xfs_attr_quiesce(
94 xfs_mount_t *mp)
95{
96 int error = 0;
97
98 /* wait for all modifications to complete */
99 while (atomic_read(&mp->m_active_trans) > 0)
100 delay(100);
101
102 /* flush inodes and push all remaining buffers out to disk */
103 xfs_quiesce_fs(mp);
104
105 ASSERT_ALWAYS(atomic_read(&mp->m_active_trans) == 0);
106
107 /* Push the superblock and write an unmount record */
108 error = xfs_log_sbcount(mp, 1);
109 if (error)
110 xfs_fs_cmn_err(CE_WARN, mp,
111 "xfs_attr_quiesce: failed to log sb changes. "
112 "Frozen image may not be consistent.");
113 xfs_log_unmount_write(mp);
114 xfs_unmountfs_writesb(mp);
115}
116
117/* 62/*
118 * xfs_unmount_flush implements a set of flush operation on special 63 * xfs_unmount_flush implements a set of flush operation on special
119 * inodes, which are needed as a separate set of operations so that 64 * inodes, which are needed as a separate set of operations so that
diff --git a/fs/xfs/xfs_vfsops.h b/fs/xfs/xfs_vfsops.h
index 6701d0ed8adc..6b8e0b52b95e 100644
--- a/fs/xfs/xfs_vfsops.h
+++ b/fs/xfs/xfs_vfsops.h
@@ -10,6 +10,5 @@ struct xfs_mount_args;
10 10
11void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname, 11void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname,
12 int lnnum); 12 int lnnum);
13void xfs_attr_quiesce(struct xfs_mount *mp);
14 13
15#endif /* _XFS_VFSOPS_H */ 14#endif /* _XFS_VFSOPS_H */