aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-10-08 06:56:01 -0400
committerBen Myers <bpm@sgi.com>2012-10-17 12:48:29 -0400
commit7f7bebefba152c5bdfe961cd2e97e8695a32998c (patch)
tree07aed46523a0bfa02e6d25f025861b8260e89f66
parent7e18530bef6a18a5479690ae7e8256319ecf1300 (diff)
xfs: don't run the sync work if the filesystem is read-only
If the filesystem is mounted or remounted read-only, stop the sync worker that tries to flush or cover the log if the filesystem is dirty. It's read-only, so it isn't dirty. Restart it on a remount,rw as necessary. This avoids the need for RO checks in the work. Similarly, stop the sync work when the filesystem is frozen, and start it again when the filesysetm is thawed. This avoids the need for special freeze checks in the work. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r--fs/xfs/xfs_super.c2
-rw-r--r--fs/xfs/xfs_sync.c29
2 files changed, 18 insertions, 13 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 9805cac81fc9..20fa955d80d1 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1200,6 +1200,7 @@ xfs_fs_remount(
1200 * value if it is non-zero, otherwise go with the default. 1200 * value if it is non-zero, otherwise go with the default.
1201 */ 1201 */
1202 xfs_restore_resvblks(mp); 1202 xfs_restore_resvblks(mp);
1203 xfs_syncd_queue_sync(mp);
1203 } 1204 }
1204 1205
1205 /* rw -> ro */ 1206 /* rw -> ro */
@@ -1245,6 +1246,7 @@ xfs_fs_unfreeze(
1245 struct xfs_mount *mp = XFS_M(sb); 1246 struct xfs_mount *mp = XFS_M(sb);
1246 1247
1247 xfs_restore_resvblks(mp); 1248 xfs_restore_resvblks(mp);
1249 xfs_syncd_queue_sync(mp);
1248 return 0; 1250 return 0;
1249} 1251}
1250 1252
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index a68761696ab5..e898d1807044 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -323,6 +323,9 @@ xfs_quiesce_data(
323 * Second stage of a quiesce. The data is already synced, now we have to take 323 * Second stage of a quiesce. The data is already synced, now we have to take
324 * care of the metadata. New transactions are already blocked, so we need to 324 * care of the metadata. New transactions are already blocked, so we need to
325 * wait for any remaining transactions to drain out before proceeding. 325 * wait for any remaining transactions to drain out before proceeding.
326 *
327 * Note: this stops background sync work - the callers must ensure it is started
328 * again when appropriate.
326 */ 329 */
327void 330void
328xfs_quiesce_attr( 331xfs_quiesce_attr(
@@ -341,6 +344,9 @@ xfs_quiesce_attr(
341 /* flush all pending changes from the AIL */ 344 /* flush all pending changes from the AIL */
342 xfs_ail_push_all_sync(mp->m_ail); 345 xfs_ail_push_all_sync(mp->m_ail);
343 346
347 /* stop background sync work */
348 cancel_delayed_work_sync(&mp->m_sync_work);
349
344 /* 350 /*
345 * Just warn here till VFS can correctly support 351 * Just warn here till VFS can correctly support
346 * read-only remount without racing. 352 * read-only remount without racing.
@@ -379,9 +385,8 @@ xfs_syncd_queue_sync(
379} 385}
380 386
381/* 387/*
382 * Every sync period we need to unpin all items in the AIL and push them to 388 * Every sync period we need to push dirty metadata and try to cover the log
383 * disk. If there is nothing dirty, then we might need to cover the log to 389 * to indicate the filesystem is idle and not frozen.
384 * indicate that the filesystem is idle and not frozen.
385 */ 390 */
386void 391void
387xfs_sync_worker( 392xfs_sync_worker(
@@ -391,17 +396,15 @@ xfs_sync_worker(
391 struct xfs_mount, m_sync_work); 396 struct xfs_mount, m_sync_work);
392 int error; 397 int error;
393 398
394 if (!(mp->m_flags & XFS_MOUNT_RDONLY)) { 399 /* dgc: errors ignored here */
395 /* dgc: errors ignored here */ 400 if (mp->m_super->s_writers.frozen == SB_UNFROZEN &&
396 if (mp->m_super->s_writers.frozen == SB_UNFROZEN && 401 xfs_log_need_covered(mp))
397 xfs_log_need_covered(mp)) 402 error = xfs_fs_log_dummy(mp);
398 error = xfs_fs_log_dummy(mp); 403 else
399 else 404 xfs_log_force(mp, 0);
400 xfs_log_force(mp, 0);
401 405
402 /* start pushing all the metadata that is currently dirty */ 406 /* start pushing all the metadata that is currently dirty */
403 xfs_ail_push_all(mp->m_ail); 407 xfs_ail_push_all(mp->m_ail);
404 }
405 408
406 /* queue us up again */ 409 /* queue us up again */
407 xfs_syncd_queue_sync(mp); 410 xfs_syncd_queue_sync(mp);