new helper: mount_bdev()
[pandora-kernel.git] / fs / super.c
index 8819e3a..40989e9 100644 (file)
@@ -273,14 +273,14 @@ void generic_shutdown_super(struct super_block *sb)
                get_fs_excl();
                sb->s_flags &= ~MS_ACTIVE;
 
-               /* bad name - it should be evict_inodes() */
-               invalidate_inodes(sb);
+               fsnotify_unmount_inodes(&sb->s_inodes);
+
+               evict_inodes(sb);
 
                if (sop->put_super)
                        sop->put_super(sb);
 
-               /* Forget any remaining inodes */
-               if (invalidate_inodes(sb)) {
+               if (!list_empty(&sb->s_inodes)) {
                        printk("VFS: Busy inodes after unmount of %s. "
                           "Self-destruct in 5 seconds.  Have a nice day...\n",
                           sb->s_id);
@@ -762,10 +762,9 @@ static int test_bdev_super(struct super_block *s, void *data)
        return (void *)s->s_bdev == data;
 }
 
-int get_sb_bdev(struct file_system_type *fs_type,
+struct dentry *mount_bdev(struct file_system_type *fs_type,
        int flags, const char *dev_name, void *data,
-       int (*fill_super)(struct super_block *, void *, int),
-       struct vfsmount *mnt)
+       int (*fill_super)(struct super_block *, void *, int))
 {
        struct block_device *bdev;
        struct super_block *s;
@@ -777,7 +776,7 @@ int get_sb_bdev(struct file_system_type *fs_type,
 
        bdev = open_bdev_exclusive(dev_name, mode, fs_type);
        if (IS_ERR(bdev))
-               return PTR_ERR(bdev);
+               return ERR_CAST(bdev);
 
        /*
         * once the super is inserted into the list by sget, s_umount
@@ -829,15 +828,30 @@ int get_sb_bdev(struct file_system_type *fs_type,
                bdev->bd_super = s;
        }
 
-       simple_set_mnt(mnt, s);
-       return 0;
+       return dget(s->s_root);
 
 error_s:
        error = PTR_ERR(s);
 error_bdev:
        close_bdev_exclusive(bdev, mode);
 error:
-       return error;
+       return ERR_PTR(error);
+}
+EXPORT_SYMBOL(mount_bdev);
+
+int get_sb_bdev(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data,
+       int (*fill_super)(struct super_block *, void *, int),
+       struct vfsmount *mnt)
+{
+       struct dentry *root;
+
+       root = mount_bdev(fs_type, flags, dev_name, data, fill_super);
+       if (IS_ERR(root))
+               return PTR_ERR(root);
+       mnt->mnt_root = root;
+       mnt->mnt_sb = root->d_sb;
+       return 0;
 }
 
 EXPORT_SYMBOL(get_sb_bdev);
@@ -918,6 +932,7 @@ struct vfsmount *
 vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
 {
        struct vfsmount *mnt;
+       struct dentry *root;
        char *secdata = NULL;
        int error;
 
@@ -942,9 +957,19 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
                        goto out_free_secdata;
        }
 
-       error = type->get_sb(type, flags, name, data, mnt);
-       if (error < 0)
-               goto out_free_secdata;
+       if (type->mount) {
+               root = type->mount(type, flags, name, data);
+               if (IS_ERR(root)) {
+                       error = PTR_ERR(root);
+                       goto out_free_secdata;
+               }
+               mnt->mnt_root = root;
+               mnt->mnt_sb = root->d_sb;
+       } else {
+               error = type->get_sb(type, flags, name, data, mnt);
+               if (error < 0)
+                       goto out_free_secdata;
+       }
        BUG_ON(!mnt->mnt_sb);
        WARN_ON(!mnt->mnt_sb->s_bdi);
        mnt->mnt_sb->s_flags |= MS_BORN;