aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-10-08 06:56:06 -0400
committerBen Myers <bpm@sgi.com>2012-10-17 13:28:47 -0400
commit34061f5c420561dd42addd252811a1fa4b0ac69b (patch)
treee0be8f994c6abd2407a1cb8c805291cea1d95712 /fs
parent5889608df35783590251cfd440fa5d48f1855179 (diff)
xfs: xfs_sync_fsdata is redundant
Why do we need to write the superblock to disk once we've written all the data? We don't actually - the reasons for doing this are lost in the mists of time, and go back to the way Irix used to drive VFS flushing. On linux, this code is only called from two contexts: remount and .sync_fs. In the remount case, the call is followed by a metadata sync, which unpins and writes the superblock. In the sync_fs case, we only need to force the log to disk to ensure that the superblock is correctly on disk, so we don't actually need to write it. Hence the functionality is either redundant or superfluous and thus can be removed. Seeing as xfs_quiesce_data is essentially now just a log force, remove it as well and fold the code back into the two callers. Neither of them need the log covering check, either, as that is redundant for the remount case, and unnecessary for the .sync_fs case. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_super.c19
-rw-r--r--fs/xfs/xfs_sync.c67
2 files changed, 14 insertions, 72 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 27d5a92e1210..b5e445a13f7b 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1057,7 +1057,6 @@ xfs_fs_sync_fs(
1057 int wait) 1057 int wait)
1058{ 1058{
1059 struct xfs_mount *mp = XFS_M(sb); 1059 struct xfs_mount *mp = XFS_M(sb);
1060 int error;
1061 1060
1062 /* 1061 /*
1063 * Doing anything during the async pass would be counterproductive. 1062 * Doing anything during the async pass would be counterproductive.
@@ -1065,10 +1064,7 @@ xfs_fs_sync_fs(
1065 if (!wait) 1064 if (!wait)
1066 return 0; 1065 return 0;
1067 1066
1068 error = xfs_quiesce_data(mp); 1067 xfs_log_force(mp, XFS_LOG_SYNC);
1069 if (error)
1070 return -error;
1071
1072 if (laptop_mode) { 1068 if (laptop_mode) {
1073 /* 1069 /*
1074 * The disk must be active because we're syncing. 1070 * The disk must be active because we're syncing.
@@ -1238,15 +1234,12 @@ xfs_fs_remount(
1238 /* rw -> ro */ 1234 /* rw -> ro */
1239 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) { 1235 if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & MS_RDONLY)) {
1240 /* 1236 /*
1241 * After we have synced the data but before we sync the 1237 * Before we sync the metadata, we need to free up the reserve
1242 * metadata, we need to free up the reserve block pool so that 1238 * block pool so that the used block count in the superblock on
1243 * the used block count in the superblock on disk is correct at 1239 * disk is correct at the end of the remount. Stash the current
1244 * the end of the remount. Stash the current reserve pool size 1240 * reserve pool size so that if we get remounted rw, we can
1245 * so that if we get remounted rw, we can return it to the same 1241 * return it to the same size.
1246 * size.
1247 */ 1242 */
1248
1249 xfs_quiesce_data(mp);
1250 xfs_save_resvblks(mp); 1243 xfs_save_resvblks(mp);
1251 xfs_quiesce_attr(mp); 1244 xfs_quiesce_attr(mp);
1252 mp->m_flags |= XFS_MOUNT_RDONLY; 1245 mp->m_flags |= XFS_MOUNT_RDONLY;
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index 15be21f074fd..581eb59a85b5 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -214,70 +214,16 @@ xfs_inode_ag_iterator(
214 return XFS_ERROR(last_error); 214 return XFS_ERROR(last_error);
215} 215}
216 216
217STATIC int
218xfs_sync_fsdata(
219 struct xfs_mount *mp)
220{
221 struct xfs_buf *bp;
222 int error;
223
224 /*
225 * If the buffer is pinned then push on the log so we won't get stuck
226 * waiting in the write for someone, maybe ourselves, to flush the log.
227 *
228 * Even though we just pushed the log above, we did not have the
229 * superblock buffer locked at that point so it can become pinned in
230 * between there and here.
231 */
232 bp = xfs_getsb(mp, 0);
233 if (xfs_buf_ispinned(bp))
234 xfs_log_force(mp, 0);
235 error = xfs_bwrite(bp);
236 xfs_buf_relse(bp);
237 return error;
238}
239
240/*
241 * When remounting a filesystem read-only or freezing the filesystem, we have
242 * two phases to execute. This first phase is syncing the data before we
243 * quiesce the filesystem, and the second is flushing all the inodes out after
244 * we've waited for all the transactions created by the first phase to
245 * complete. The second phase ensures that the inodes are written to their
246 * location on disk rather than just existing in transactions in the log. This
247 * means after a quiesce there is no log replay required to write the inodes to
248 * disk (this is the main difference between a sync and a quiesce).
249 */
250/*
251 * First stage of freeze - no writers will make progress now we are here,
252 * so we flush delwri and delalloc buffers here, then wait for all I/O to
253 * complete. Data is frozen at that point. Metadata is not frozen,
254 * transactions can still occur here so don't bother emptying the AIL
255 * because it'll just get dirty again.
256 */
257int
258xfs_quiesce_data(
259 struct xfs_mount *mp)
260{
261 int error, error2 = 0;
262
263 /* force out the log */
264 xfs_log_force(mp, XFS_LOG_SYNC);
265
266 /* write superblock and hoover up shutdown errors */
267 error = xfs_sync_fsdata(mp);
268
269 /* mark the log as covered if needed */
270 if (xfs_log_need_covered(mp))
271 error2 = xfs_fs_log_dummy(mp);
272
273 return error ? error : error2;
274}
275
276/* 217/*
277 * Second stage of a quiesce. The data is already synced, now we have to take 218 * Second stage of a quiesce. The data is already synced, now we have to take
278 * care of the metadata. New transactions are already blocked, so we need to 219 * care of the metadata. New transactions are already blocked, so we need to
279 * wait for any remaining transactions to drain out before proceeding. 220 * wait for any remaining transactions to drain out before proceeding.
280 * 221 *
222 * The second phase ensures that the inodes are written to their
223 * location on disk rather than just existing in transactions in the log. This
224 * means after a quiesce there is no log replay required to write the inodes to
225 * disk (this is the main difference between a sync and a quiesce).
226 *
281 * Note: this stops background sync work - the callers must ensure it is started 227 * Note: this stops background sync work - the callers must ensure it is started
282 * again when appropriate. 228 * again when appropriate.
283 */ 229 */
@@ -291,6 +237,9 @@ xfs_quiesce_attr(
291 while (atomic_read(&mp->m_active_trans) > 0) 237 while (atomic_read(&mp->m_active_trans) > 0)
292 delay(100); 238 delay(100);
293 239
240 /* force the log to unpin objects from the now complete transactions */
241 xfs_log_force(mp, XFS_LOG_SYNC);
242
294 /* reclaim inodes to do any IO before the freeze completes */ 243 /* reclaim inodes to do any IO before the freeze completes */
295 xfs_reclaim_inodes(mp, 0); 244 xfs_reclaim_inodes(mp, 0);
296 xfs_reclaim_inodes(mp, SYNC_WAIT); 245 xfs_reclaim_inodes(mp, SYNC_WAIT);