xfs: unregister inode shrinker before freeing filesystem structures
authorDave Chinner <dchinner@redhat.com>
Fri, 25 Jun 2010 01:08:40 +0000 (11:08 +1000)
committerAlex Elder <aelder@sgi.com>
Mon, 26 Jul 2010 18:16:45 +0000 (13:16 -0500)
Currently we don't remove the XFS mount from the shrinker list until
late in the unmount path. By this time, we have already torn down
the internals of the filesystem (e.g. the per-ag structures), and
hence if the shrinker is executed between the teardown and the
unregistering, the shrinker will get NULL per-ag structure pointers
and panic trying to dereference them.

Fix this by removing the xfs mount from the shrinker list before
tearing down it's internal structures.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Alex Elder <aelder@sgi.com>
fs/xfs/linux-2.6/xfs_super.c

index 22faaea5f3e1195dcdc6fa8bd3683cc8d5c3737d..c734bc6cf32ea2f847877b4c2558da129de063e0 100644 (file)
@@ -1156,9 +1156,13 @@ xfs_fs_put_super(
 
        XFS_bflush(mp->m_ddev_targp);
 
+       /*
+        * Unregister the memory shrinker before we tear down the mount
+        * structure so we don't have memory reclaim racing with us here.
+        */
+       xfs_inode_shrinker_unregister(mp);
        xfs_unmountfs(mp);
        xfs_freesb(mp);
-       xfs_inode_shrinker_unregister(mp);
        xfs_icsb_destroy_counters(mp);
        xfs_close_devices(mp);
        xfs_free_fsname(mp);