]> git.hungrycats.org Git - linux/commitdiff
[PATCH] (3/3) fs/super.c cleanups
authorAlexander Viro <viro@math.psu.edu>
Mon, 25 Feb 2002 04:07:53 +0000 (20:07 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Mon, 25 Feb 2002 04:07:53 +0000 (20:07 -0800)
Preparation to adding new method:
 new helper - shutdown_super().  It is cut from kill_super() and
 it had absorbed all actions done with superblock contents -
 now kill_super(s) is simply

struct file_system_type *fs = s->s_type;
if (!deactivate_super(s))
return;
shutdown_super(s);
put_filesystem(fs);

 and shutdown_super() is going to become a method.

fs/super.c

index fad35d0daf26f43072a753304d32bea95b231733..b722653292d45cc8413644e62ada814d1282a286 100644 (file)
@@ -400,6 +400,68 @@ static void remove_super(struct super_block *s)
        put_super(s);
 }
 
+static void generic_shutdown_super(struct super_block *sb)
+{
+       struct dentry *root = sb->s_root;
+       struct super_operations *sop = sb->s_op;
+
+       if (root) {
+               sb->s_root = NULL;
+               shrink_dcache_parent(root);
+               dput(root);
+               fsync_super(sb);
+               lock_super(sb);
+               lock_kernel();
+               sb->s_flags &= ~MS_ACTIVE;
+               /* bad name - it should be evict_inodes() */
+               invalidate_inodes(sb);
+               if (sop) {
+                       if (sop->write_super && sb->s_dirt)
+                               sop->write_super(sb);
+                       if (sop->put_super)
+                               sop->put_super(sb);
+               }
+
+               /* Forget any remaining inodes */
+               if (invalidate_inodes(sb)) {
+                       printk("VFS: Busy inodes after unmount. "
+                          "Self-destruct in 5 seconds.  Have a nice day...\n");
+               }
+
+               unlock_kernel();
+               unlock_super(sb);
+       }
+       remove_super(sb);
+}
+
+static void shutdown_super(struct super_block *sb)
+{
+       struct file_system_type *fs = sb->s_type;
+       kdev_t dev = sb->s_dev;
+       struct block_device *bdev = sb->s_bdev;
+
+       /* Need to clean after the sucker */
+       if (fs->fs_flags & FS_LITTER && sb->s_root)
+               d_genocide(sb->s_root);
+       generic_shutdown_super(sb);
+       if (bdev)
+               blkdev_put(bdev, BDEV_FS);
+       else
+               put_anon_dev(dev);
+}
+
+void kill_super(struct super_block *sb)
+{
+       struct file_system_type *fs = sb->s_type;
+
+       if (!deactivate_super(sb))
+               return;
+
+       down_write(&sb->s_umount);
+       shutdown_super(sb);
+       put_filesystem(fs);
+}
+
 struct vfsmount *alloc_vfsmnt(char *name);
 void free_vfsmnt(struct vfsmount *mnt);
 
@@ -808,55 +870,6 @@ out:
        return (struct vfsmount *)sb;
 }
 
-void kill_super(struct super_block *sb)
-{
-       struct dentry *root = sb->s_root;
-       struct file_system_type *fs = sb->s_type;
-       struct super_operations *sop = sb->s_op;
-       kdev_t dev = sb->s_dev;
-       struct block_device *bdev = sb->s_bdev;
-
-       if (!deactivate_super(sb))
-               return;
-
-       down_write(&sb->s_umount);
-       if (sb->s_root) {
-               sb->s_root = NULL;
-               /* Need to clean after the sucker */
-               if (fs->fs_flags & FS_LITTER)
-                       d_genocide(root);
-               shrink_dcache_parent(root);
-               dput(root);
-               fsync_super(sb);
-               lock_super(sb);
-               lock_kernel();
-               sb->s_flags &= ~MS_ACTIVE;
-               /* bad name - it should be evict_inodes() */
-               invalidate_inodes(sb);
-               if (sop) {
-                       if (sop->write_super && sb->s_dirt)
-                               sop->write_super(sb);
-                       if (sop->put_super)
-                               sop->put_super(sb);
-               }
-
-               /* Forget any remaining inodes */
-               if (invalidate_inodes(sb)) {
-                       printk("VFS: Busy inodes after unmount. "
-                          "Self-destruct in 5 seconds.  Have a nice day...\n");
-               }
-
-               unlock_kernel();
-               unlock_super(sb);
-       }
-       remove_super(sb);
-       if (bdev)
-               blkdev_put(bdev, BDEV_FS);
-       else
-               put_anon_dev(dev);
-       put_filesystem(fs);
-}
-
 struct vfsmount *kern_mount(struct file_system_type *type)
 {
        return do_kern_mount(type->name, 0, (char *)type->name, NULL);