diff options
| -rw-r--r-- | Documentation/filesystems/Locking | 6 | ||||
| -rw-r--r-- | Documentation/filesystems/porting | 7 | ||||
| -rw-r--r-- | Documentation/filesystems/vfs.txt | 56 | ||||
| -rw-r--r-- | fs/super.c | 67 | ||||
| -rw-r--r-- | include/linux/fs.h | 14 |
5 files changed, 47 insertions, 103 deletions
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 4471a416c274..2e994efe12cb 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking | |||
| @@ -166,13 +166,11 @@ prototypes: | |||
| 166 | void (*kill_sb) (struct super_block *); | 166 | void (*kill_sb) (struct super_block *); |
| 167 | locking rules: | 167 | locking rules: |
| 168 | may block | 168 | may block |
| 169 | get_sb yes | ||
| 170 | mount yes | 169 | mount yes |
| 171 | kill_sb yes | 170 | kill_sb yes |
| 172 | 171 | ||
| 173 | ->get_sb() returns error or 0 with locked superblock attached to the vfsmount | 172 | ->mount() returns ERR_PTR or the root dentry; its superblock should be locked |
| 174 | (exclusive on ->s_umount). | 173 | on return. |
| 175 | ->mount() returns ERR_PTR or the root dentry. | ||
| 176 | ->kill_sb() takes a write-locked superblock, does all shutdown work on it, | 174 | ->kill_sb() takes a write-locked superblock, does all shutdown work on it, |
| 177 | unlocks and drops the reference. | 175 | unlocks and drops the reference. |
| 178 | 176 | ||
diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index dfbcd1b00b0a..0c986c9e8519 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting | |||
| @@ -394,3 +394,10 @@ file) you must return -EOPNOTSUPP if FALLOC_FL_PUNCH_HOLE is set in mode. | |||
| 394 | Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set, | 394 | Currently you can only have FALLOC_FL_PUNCH_HOLE with FALLOC_FL_KEEP_SIZE set, |
| 395 | so the i_size should not change when hole punching, even when puching the end of | 395 | so the i_size should not change when hole punching, even when puching the end of |
| 396 | a file off. | 396 | a file off. |
| 397 | |||
| 398 | -- | ||
| 399 | [mandatory] | ||
| 400 | ->get_sb() is gone. Switch to use of ->mount(). Typically it's just | ||
| 401 | a matter of switching from calling get_sb_... to mount_... and changing the | ||
| 402 | function type. If you were doing it manually, just switch from setting ->mnt_root | ||
| 403 | to some pointer to returning that pointer. On errors return ERR_PTR(...). | ||
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 94cf97b901d7..ef0714aa8e40 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt | |||
| @@ -95,10 +95,11 @@ functions: | |||
| 95 | extern int unregister_filesystem(struct file_system_type *); | 95 | extern int unregister_filesystem(struct file_system_type *); |
| 96 | 96 | ||
| 97 | The passed struct file_system_type describes your filesystem. When a | 97 | The passed struct file_system_type describes your filesystem. When a |
| 98 | request is made to mount a device onto a directory in your filespace, | 98 | request is made to mount a filesystem onto a directory in your namespace, |
| 99 | the VFS will call the appropriate get_sb() method for the specific | 99 | the VFS will call the appropriate mount() method for the specific |
| 100 | filesystem. The dentry for the mount point will then be updated to | 100 | filesystem. New vfsmount refering to the tree returned by ->mount() |
| 101 | point to the root inode for the new filesystem. | 101 | will be attached to the mountpoint, so that when pathname resolution |
| 102 | reaches the mountpoint it will jump into the root of that vfsmount. | ||
| 102 | 103 | ||
| 103 | You can see all filesystems that are registered to the kernel in the | 104 | You can see all filesystems that are registered to the kernel in the |
| 104 | file /proc/filesystems. | 105 | file /proc/filesystems. |
| @@ -107,14 +108,14 @@ file /proc/filesystems. | |||
| 107 | struct file_system_type | 108 | struct file_system_type |
| 108 | ----------------------- | 109 | ----------------------- |
| 109 | 110 | ||
| 110 | This describes the filesystem. As of kernel 2.6.22, the following | 111 | This describes the filesystem. As of kernel 2.6.39, the following |
| 111 | members are defined: | 112 | members are defined: |
| 112 | 113 | ||
| 113 | struct file_system_type { | 114 | struct file_system_type { |
| 114 | const char *name; | 115 | const char *name; |
| 115 | int fs_flags; | 116 | int fs_flags; |
| 116 | int (*get_sb) (struct file_system_type *, int, | 117 | struct dentry (*mount) (struct file_system_type *, int, |
| 117 | const char *, void *, struct vfsmount *); | 118 | const char *, void *); |
| 118 | void (*kill_sb) (struct super_block *); | 119 | void (*kill_sb) (struct super_block *); |
| 119 | struct module *owner; | 120 | struct module *owner; |
| 120 | struct file_system_type * next; | 121 | struct file_system_type * next; |
| @@ -128,11 +129,11 @@ struct file_system_type { | |||
| 128 | 129 | ||
| 129 | fs_flags: various flags (i.e. FS_REQUIRES_DEV, FS_NO_DCACHE, etc.) | 130 | fs_flags: various flags (i.e. FS_REQUIRES_DEV, FS_NO_DCACHE, etc.) |
| 130 | 131 | ||
| 131 | get_sb: the method to call when a new instance of this | 132 | mount: the method to call when a new instance of this |
| 132 | filesystem should be mounted | 133 | filesystem should be mounted |
| 133 | 134 | ||
| 134 | kill_sb: the method to call when an instance of this filesystem | 135 | kill_sb: the method to call when an instance of this filesystem |
| 135 | should be unmounted | 136 | should be shut down |
| 136 | 137 | ||
| 137 | owner: for internal VFS use: you should initialize this to THIS_MODULE in | 138 | owner: for internal VFS use: you should initialize this to THIS_MODULE in |
| 138 | most cases. | 139 | most cases. |
| @@ -141,7 +142,7 @@ struct file_system_type { | |||
| 141 | 142 | ||
| 142 | s_lock_key, s_umount_key: lockdep-specific | 143 | s_lock_key, s_umount_key: lockdep-specific |
| 143 | 144 | ||
| 144 | The get_sb() method has the following arguments: | 145 | The mount() method has the following arguments: |
| 145 | 146 | ||
| 146 | struct file_system_type *fs_type: describes the filesystem, partly initialized | 147 | struct file_system_type *fs_type: describes the filesystem, partly initialized |
| 147 | by the specific filesystem code | 148 | by the specific filesystem code |
| @@ -153,32 +154,39 @@ The get_sb() method has the following arguments: | |||
| 153 | void *data: arbitrary mount options, usually comes as an ASCII | 154 | void *data: arbitrary mount options, usually comes as an ASCII |
| 154 | string (see "Mount Options" section) | 155 | string (see "Mount Options" section) |
| 155 | 156 | ||
| 156 | struct vfsmount *mnt: a vfs-internal representation of a mount point | 157 | The mount() method must return the root dentry of the tree requested by |
| 158 | caller. An active reference to its superblock must be grabbed and the | ||
| 159 | superblock must be locked. On failure it should return ERR_PTR(error). | ||
| 157 | 160 | ||
| 158 | The get_sb() method must determine if the block device specified | 161 | The arguments match those of mount(2) and their interpretation |
| 159 | in the dev_name and fs_type contains a filesystem of the type the method | 162 | depends on filesystem type. E.g. for block filesystems, dev_name is |
| 160 | supports. If it succeeds in opening the named block device, it initializes a | 163 | interpreted as block device name, that device is opened and if it |
| 161 | struct super_block descriptor for the filesystem contained by the block device. | 164 | contains a suitable filesystem image the method creates and initializes |
| 162 | On failure it returns an error. | 165 | struct super_block accordingly, returning its root dentry to caller. |
| 166 | |||
| 167 | ->mount() may choose to return a subtree of existing filesystem - it | ||
| 168 | doesn't have to create a new one. The main result from the caller's | ||
| 169 | point of view is a reference to dentry at the root of (sub)tree to | ||
| 170 | be attached; creation of new superblock is a common side effect. | ||
| 163 | 171 | ||
| 164 | The most interesting member of the superblock structure that the | 172 | The most interesting member of the superblock structure that the |
| 165 | get_sb() method fills in is the "s_op" field. This is a pointer to | 173 | mount() method fills in is the "s_op" field. This is a pointer to |
| 166 | a "struct super_operations" which describes the next level of the | 174 | a "struct super_operations" which describes the next level of the |
| 167 | filesystem implementation. | 175 | filesystem implementation. |
| 168 | 176 | ||
| 169 | Usually, a filesystem uses one of the generic get_sb() implementations | 177 | Usually, a filesystem uses one of the generic mount() implementations |
| 170 | and provides a fill_super() method instead. The generic methods are: | 178 | and provides a fill_super() callback instead. The generic variants are: |
| 171 | 179 | ||
| 172 | get_sb_bdev: mount a filesystem residing on a block device | 180 | mount_bdev: mount a filesystem residing on a block device |
| 173 | 181 | ||
| 174 | get_sb_nodev: mount a filesystem that is not backed by a device | 182 | mount_nodev: mount a filesystem that is not backed by a device |
| 175 | 183 | ||
| 176 | get_sb_single: mount a filesystem which shares the instance between | 184 | mount_single: mount a filesystem which shares the instance between |
| 177 | all mounts | 185 | all mounts |
| 178 | 186 | ||
| 179 | A fill_super() method implementation has the following arguments: | 187 | A fill_super() callback implementation has the following arguments: |
| 180 | 188 | ||
| 181 | struct super_block *sb: the superblock structure. The method fill_super() | 189 | struct super_block *sb: the superblock structure. The callback |
| 182 | must initialize this properly. | 190 | must initialize this properly. |
| 183 | 191 | ||
| 184 | void *data: arbitrary mount options, usually comes as an ASCII | 192 | void *data: arbitrary mount options, usually comes as an ASCII |
diff --git a/fs/super.c b/fs/super.c index 7e9dd4cc2c01..4bae0ef6110e 100644 --- a/fs/super.c +++ b/fs/super.c | |||
| @@ -843,23 +843,6 @@ error: | |||
| 843 | } | 843 | } |
| 844 | EXPORT_SYMBOL(mount_bdev); | 844 | EXPORT_SYMBOL(mount_bdev); |
| 845 | 845 | ||
| 846 | int get_sb_bdev(struct file_system_type *fs_type, | ||
| 847 | int flags, const char *dev_name, void *data, | ||
| 848 | int (*fill_super)(struct super_block *, void *, int), | ||
| 849 | struct vfsmount *mnt) | ||
| 850 | { | ||
| 851 | struct dentry *root; | ||
| 852 | |||
| 853 | root = mount_bdev(fs_type, flags, dev_name, data, fill_super); | ||
| 854 | if (IS_ERR(root)) | ||
| 855 | return PTR_ERR(root); | ||
| 856 | mnt->mnt_root = root; | ||
| 857 | mnt->mnt_sb = root->d_sb; | ||
| 858 | return 0; | ||
| 859 | } | ||
| 860 | |||
| 861 | EXPORT_SYMBOL(get_sb_bdev); | ||
| 862 | |||
| 863 | void kill_block_super(struct super_block *sb) | 846 | void kill_block_super(struct super_block *sb) |
| 864 | { | 847 | { |
| 865 | struct block_device *bdev = sb->s_bdev; | 848 | struct block_device *bdev = sb->s_bdev; |
| @@ -897,22 +880,6 @@ struct dentry *mount_nodev(struct file_system_type *fs_type, | |||
| 897 | } | 880 | } |
| 898 | EXPORT_SYMBOL(mount_nodev); | 881 | EXPORT_SYMBOL(mount_nodev); |
| 899 | 882 | ||
| 900 | int get_sb_nodev(struct file_system_type *fs_type, | ||
| 901 | int flags, void *data, | ||
| 902 | int (*fill_super)(struct super_block *, void *, int), | ||
| 903 | struct vfsmount *mnt) | ||
| 904 | { | ||
| 905 | struct dentry *root; | ||
| 906 | |||
| 907 | root = mount_nodev(fs_type, flags, data, fill_super); | ||
| 908 | if (IS_ERR(root)) | ||
| 909 | return PTR_ERR(root); | ||
| 910 | mnt->mnt_root = root; | ||
| 911 | mnt->mnt_sb = root->d_sb; | ||
| 912 | return 0; | ||
| 913 | } | ||
| 914 | EXPORT_SYMBOL(get_sb_nodev); | ||
| 915 | |||
| 916 | static int compare_single(struct super_block *s, void *p) | 883 | static int compare_single(struct super_block *s, void *p) |
| 917 | { | 884 | { |
| 918 | return 1; | 885 | return 1; |
| @@ -943,22 +910,6 @@ struct dentry *mount_single(struct file_system_type *fs_type, | |||
| 943 | } | 910 | } |
| 944 | EXPORT_SYMBOL(mount_single); | 911 | EXPORT_SYMBOL(mount_single); |
| 945 | 912 | ||
| 946 | int get_sb_single(struct file_system_type *fs_type, | ||
| 947 | int flags, void *data, | ||
| 948 | int (*fill_super)(struct super_block *, void *, int), | ||
| 949 | struct vfsmount *mnt) | ||
| 950 | { | ||
| 951 | struct dentry *root; | ||
| 952 | root = mount_single(fs_type, flags, data, fill_super); | ||
| 953 | if (IS_ERR(root)) | ||
| 954 | return PTR_ERR(root); | ||
| 955 | mnt->mnt_root = root; | ||
| 956 | mnt->mnt_sb = root->d_sb; | ||
| 957 | return 0; | ||
| 958 | } | ||
| 959 | |||
| 960 | EXPORT_SYMBOL(get_sb_single); | ||
| 961 | |||
| 962 | struct vfsmount * | 913 | struct vfsmount * |
| 963 | vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) | 914 | vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) |
| 964 | { | 915 | { |
| @@ -988,19 +939,13 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void | |||
| 988 | goto out_free_secdata; | 939 | goto out_free_secdata; |
| 989 | } | 940 | } |
| 990 | 941 | ||
| 991 | if (type->mount) { | 942 | root = type->mount(type, flags, name, data); |
| 992 | root = type->mount(type, flags, name, data); | 943 | if (IS_ERR(root)) { |
| 993 | if (IS_ERR(root)) { | 944 | error = PTR_ERR(root); |
| 994 | error = PTR_ERR(root); | 945 | goto out_free_secdata; |
| 995 | goto out_free_secdata; | ||
| 996 | } | ||
| 997 | mnt->mnt_root = root; | ||
| 998 | mnt->mnt_sb = root->d_sb; | ||
| 999 | } else { | ||
| 1000 | error = type->get_sb(type, flags, name, data, mnt); | ||
| 1001 | if (error < 0) | ||
| 1002 | goto out_free_secdata; | ||
| 1003 | } | 946 | } |
| 947 | mnt->mnt_root = root; | ||
| 948 | mnt->mnt_sb = root->d_sb; | ||
| 1004 | BUG_ON(!mnt->mnt_sb); | 949 | BUG_ON(!mnt->mnt_sb); |
| 1005 | WARN_ON(!mnt->mnt_sb->s_bdi); | 950 | WARN_ON(!mnt->mnt_sb->s_bdi); |
| 1006 | mnt->mnt_sb->s_flags |= MS_BORN; | 951 | mnt->mnt_sb->s_flags |= MS_BORN; |
diff --git a/include/linux/fs.h b/include/linux/fs.h index e6d3fe45981b..ffaa0e4926ed 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -1797,8 +1797,6 @@ int sync_inode_metadata(struct inode *inode, int wait); | |||
| 1797 | struct file_system_type { | 1797 | struct file_system_type { |
| 1798 | const char *name; | 1798 | const char *name; |
| 1799 | int fs_flags; | 1799 | int fs_flags; |
| 1800 | int (*get_sb) (struct file_system_type *, int, | ||
| 1801 | const char *, void *, struct vfsmount *); | ||
| 1802 | struct dentry *(*mount) (struct file_system_type *, int, | 1800 | struct dentry *(*mount) (struct file_system_type *, int, |
| 1803 | const char *, void *); | 1801 | const char *, void *); |
| 1804 | void (*kill_sb) (struct super_block *); | 1802 | void (*kill_sb) (struct super_block *); |
| @@ -1821,24 +1819,12 @@ extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, | |||
| 1821 | extern struct dentry *mount_bdev(struct file_system_type *fs_type, | 1819 | extern struct dentry *mount_bdev(struct file_system_type *fs_type, |
| 1822 | int flags, const char *dev_name, void *data, | 1820 | int flags, const char *dev_name, void *data, |
| 1823 | int (*fill_super)(struct super_block *, void *, int)); | 1821 | int (*fill_super)(struct super_block *, void *, int)); |
| 1824 | extern int get_sb_bdev(struct file_system_type *fs_type, | ||
| 1825 | int flags, const char *dev_name, void *data, | ||
| 1826 | int (*fill_super)(struct super_block *, void *, int), | ||
| 1827 | struct vfsmount *mnt); | ||
| 1828 | extern struct dentry *mount_single(struct file_system_type *fs_type, | 1822 | extern struct dentry *mount_single(struct file_system_type *fs_type, |
| 1829 | int flags, void *data, | 1823 | int flags, void *data, |
| 1830 | int (*fill_super)(struct super_block *, void *, int)); | 1824 | int (*fill_super)(struct super_block *, void *, int)); |
| 1831 | extern int get_sb_single(struct file_system_type *fs_type, | ||
| 1832 | int flags, void *data, | ||
| 1833 | int (*fill_super)(struct super_block *, void *, int), | ||
| 1834 | struct vfsmount *mnt); | ||
| 1835 | extern struct dentry *mount_nodev(struct file_system_type *fs_type, | 1825 | extern struct dentry *mount_nodev(struct file_system_type *fs_type, |
| 1836 | int flags, void *data, | 1826 | int flags, void *data, |
| 1837 | int (*fill_super)(struct super_block *, void *, int)); | 1827 | int (*fill_super)(struct super_block *, void *, int)); |
| 1838 | extern int get_sb_nodev(struct file_system_type *fs_type, | ||
| 1839 | int flags, void *data, | ||
| 1840 | int (*fill_super)(struct super_block *, void *, int), | ||
| 1841 | struct vfsmount *mnt); | ||
| 1842 | void generic_shutdown_super(struct super_block *sb); | 1828 | void generic_shutdown_super(struct super_block *sb); |
| 1843 | void kill_block_super(struct super_block *sb); | 1829 | void kill_block_super(struct super_block *sb); |
| 1844 | void kill_anon_super(struct super_block *sb); | 1830 | void kill_anon_super(struct super_block *sb); |
