Commit 8866fc6fa55e31b2bce931b7963ff16641b39dc7

Authored by Ben Myers
1 parent 59c84ed0dd

xfs: shutdown xfs_sync_worker before the log

Revert commit 1307bbd, which uses the s_umount semaphore to provide
exclusion between xfs_sync_worker and unmount, in favor of shutting down
the sync worker before freeing the log in xfs_log_unmount.  This is a
cleaner way of resolving the race between xfs_sync_worker and unmount
than using s_umount.

Signed-off-by: Ben Myers <bpm@sgi.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>

Showing 2 changed files with 17 additions and 16 deletions Side-by-side Diff

... ... @@ -810,6 +810,7 @@
810 810 void
811 811 xfs_log_unmount(xfs_mount_t *mp)
812 812 {
  813 + cancel_delayed_work_sync(&mp->m_sync_work);
813 814 xfs_trans_ail_destroy(mp);
814 815 xlog_dealloc_log(mp->m_log);
815 816 }
... ... @@ -386,23 +386,23 @@
386 386 * We shouldn't write/force the log if we are in the mount/unmount
387 387 * process or on a read only filesystem. The workqueue still needs to be
388 388 * active in both cases, however, because it is used for inode reclaim
389   - * during these times. Use the s_umount semaphore to provide exclusion
390   - * with unmount.
  389 + * during these times. Use the MS_ACTIVE flag to avoid doing anything
  390 + * during mount. Doing work during unmount is avoided by calling
  391 + * cancel_delayed_work_sync on this work queue before tearing down
  392 + * the ail and the log in xfs_log_unmount.
391 393 */
392   - if (down_read_trylock(&mp->m_super->s_umount)) {
393   - if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
394   - /* dgc: errors ignored here */
395   - if (mp->m_super->s_frozen == SB_UNFROZEN &&
396   - xfs_log_need_covered(mp))
397   - error = xfs_fs_log_dummy(mp);
398   - else
399   - xfs_log_force(mp, 0);
  394 + if (!(mp->m_super->s_flags & MS_ACTIVE) &&
  395 + !(mp->m_flags & XFS_MOUNT_RDONLY)) {
  396 + /* dgc: errors ignored here */
  397 + if (mp->m_super->s_frozen == SB_UNFROZEN &&
  398 + xfs_log_need_covered(mp))
  399 + error = xfs_fs_log_dummy(mp);
  400 + else
  401 + xfs_log_force(mp, 0);
400 402  
401   - /* start pushing all the metadata that is currently
402   - * dirty */
403   - xfs_ail_push_all(mp->m_ail);
404   - }
405   - up_read(&mp->m_super->s_umount);
  403 + /* start pushing all the metadata that is currently
  404 + * dirty */
  405 + xfs_ail_push_all(mp->m_ail);
406 406 }
407 407  
408 408 /* queue us up again */