Skip to content

Commit 11159a0

Browse files
author
Ben Myers
committed
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>
1 parent bcf62ab commit 11159a0

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

fs/xfs/xfs_log.c

+1
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ xfs_log_unmount_write(xfs_mount_t *mp)
810810
void
811811
xfs_log_unmount(xfs_mount_t *mp)
812812
{
813+
cancel_delayed_work_sync(&mp->m_sync_work);
813814
xfs_trans_ail_destroy(mp);
814815
xlog_dealloc_log(mp->m_log);
815816
}

fs/xfs/xfs_sync.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -386,23 +386,23 @@ xfs_sync_worker(
386386
* We shouldn't write/force the log if we are in the mount/unmount
387387
* process or on a read only filesystem. The workqueue still needs to be
388388
* 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.
391393
*/
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);
400-
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);
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);
402+
403+
/* start pushing all the metadata that is currently
404+
* dirty */
405+
xfs_ail_push_all(mp->m_ail);
406406
}
407407

408408
/* queue us up again */

0 commit comments

Comments
 (0)