xfs: protect xfs_sync_worker with s_umount semaphore
[deliverable/linux.git] / fs / xfs / xfs_sync.c
index d2422683ed766361f6a6691ab71a418b7bf692df..c9d3409c5ca3f991b7bde133994c4920316a216c 100644 (file)
@@ -386,20 +386,23 @@ xfs_sync_worker(
         * We shouldn't write/force the log if we are in the mount/unmount
         * process or on a read only filesystem. The workqueue still needs to be
         * active in both cases, however, because it is used for inode reclaim
-        * during these times. hence use the MS_ACTIVE flag to avoid doing
-        * anything in these periods.
+        * during these times.  Use the s_umount semaphore to provide exclusion
+        * with unmount.
         */
-       if (!(mp->m_super->s_flags & MS_ACTIVE) &&
-           !(mp->m_flags & XFS_MOUNT_RDONLY)) {
-               /* dgc: errors ignored here */
-               if (mp->m_super->s_frozen == SB_UNFROZEN &&
-                   xfs_log_need_covered(mp))
-                       error = xfs_fs_log_dummy(mp);
-               else
-                       xfs_log_force(mp, 0);
-
-               /* start pushing all the metadata that is currently dirty */
-               xfs_ail_push_all(mp->m_ail);
+       if (down_read_trylock(&mp->m_super->s_umount)) {
+               if (!(mp->m_flags & XFS_MOUNT_RDONLY)) {
+                       /* dgc: errors ignored here */
+                       if (mp->m_super->s_frozen == SB_UNFROZEN &&
+                           xfs_log_need_covered(mp))
+                               error = xfs_fs_log_dummy(mp);
+                       else
+                               xfs_log_force(mp, 0);
+
+                       /* start pushing all the metadata that is currently
+                        * dirty */
+                       xfs_ail_push_all(mp->m_ail);
+               }
+               up_read(&mp->m_super->s_umount);
        }
 
        /* queue us up again */
This page took 0.037724 seconds and 5 git commands to generate.