Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/fs/super.c |
| 3 | * |
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 5 | * |
| 6 | * super.c contains code to handle: - mount structures |
| 7 | * - super-block tables |
| 8 | * - filesystem drivers list |
| 9 | * - mount system call |
| 10 | * - umount system call |
| 11 | * - ustat system call |
| 12 | * |
| 13 | * GK 2/5/95 - Changed to support mounting the root fs via NFS |
| 14 | * |
| 15 | * Added kerneld support: Jacques Gelinas and Bjorn Ekwall |
| 16 | * Added change_root: Werner Almesberger & Hans Lermen, Feb '96 |
| 17 | * Added options to /proc/mounts: |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 18 | * Torbjörn Lindh (torbjorn.lindh@gopta.se), April 14, 1996. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * Added devfs support: Richard Gooch <rgooch@atnf.csiro.au>, 13-JAN-1998 |
| 20 | * Heavily rewritten for 'one fs - one tree' dcache architecture. AV, Mar 2000 |
| 21 | */ |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/module.h> |
| 24 | #include <linux/slab.h> |
| 25 | #include <linux/init.h> |
| 26 | #include <linux/smp_lock.h> |
| 27 | #include <linux/acct.h> |
| 28 | #include <linux/blkdev.h> |
| 29 | #include <linux/quotaops.h> |
| 30 | #include <linux/namei.h> |
| 31 | #include <linux/buffer_head.h> /* for fsync_super() */ |
| 32 | #include <linux/mount.h> |
| 33 | #include <linux/security.h> |
| 34 | #include <linux/syscalls.h> |
| 35 | #include <linux/vfs.h> |
| 36 | #include <linux/writeback.h> /* for the emergency remount stuff */ |
| 37 | #include <linux/idr.h> |
| 38 | #include <linux/kobject.h> |
Ingo Molnar | 353ab6e | 2006-03-26 01:37:12 -0800 | [diff] [blame] | 39 | #include <linux/mutex.h> |
Dave Hansen | 49e0d02 | 2008-02-15 14:37:32 -0800 | [diff] [blame] | 40 | #include <linux/file.h> |
Arjan van de Ven | efaee19 | 2009-01-06 07:20:54 -0800 | [diff] [blame] | 41 | #include <linux/async.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/uaccess.h> |
Al Viro | 6d59e7f | 2008-03-22 15:48:17 -0400 | [diff] [blame] | 43 | #include "internal.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | LIST_HEAD(super_blocks); |
| 47 | DEFINE_SPINLOCK(sb_lock); |
| 48 | |
| 49 | /** |
| 50 | * alloc_super - create new superblock |
Henrik Kretzschmar | fe2bbc4 | 2006-09-06 00:03:41 -0700 | [diff] [blame] | 51 | * @type: filesystem type superblock should belong to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | * |
| 53 | * Allocates and initializes a new &struct super_block. alloc_super() |
| 54 | * returns a pointer new superblock or %NULL if allocation had failed. |
| 55 | */ |
Ingo Molnar | cf51624 | 2006-07-03 00:25:27 -0700 | [diff] [blame] | 56 | static struct super_block *alloc_super(struct file_system_type *type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | { |
Oliver Neukum | 11b0b5a | 2006-03-25 03:08:13 -0800 | [diff] [blame] | 58 | struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | static struct super_operations default_op; |
| 60 | |
| 61 | if (s) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | if (security_sb_alloc(s)) { |
| 63 | kfree(s); |
| 64 | s = NULL; |
| 65 | goto out; |
| 66 | } |
| 67 | INIT_LIST_HEAD(&s->s_dirty); |
| 68 | INIT_LIST_HEAD(&s->s_io); |
Ken Chen | 0e0f4fc | 2007-10-16 23:30:38 -0700 | [diff] [blame] | 69 | INIT_LIST_HEAD(&s->s_more_io); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | INIT_LIST_HEAD(&s->s_files); |
| 71 | INIT_LIST_HEAD(&s->s_instances); |
| 72 | INIT_HLIST_HEAD(&s->s_anon); |
| 73 | INIT_LIST_HEAD(&s->s_inodes); |
Kentaro Makita | da3bbdd | 2008-07-23 21:27:13 -0700 | [diff] [blame] | 74 | INIT_LIST_HEAD(&s->s_dentry_lru); |
Arjan van de Ven | efaee19 | 2009-01-06 07:20:54 -0800 | [diff] [blame] | 75 | INIT_LIST_HEAD(&s->s_async_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | init_rwsem(&s->s_umount); |
Ingo Molnar | 7892f2f4 | 2006-01-09 15:59:25 -0800 | [diff] [blame] | 77 | mutex_init(&s->s_lock); |
Arjan van de Ven | 897c6ff | 2006-07-03 00:25:28 -0700 | [diff] [blame] | 78 | lockdep_set_class(&s->s_umount, &type->s_umount_key); |
Ingo Molnar | cf51624 | 2006-07-03 00:25:27 -0700 | [diff] [blame] | 79 | /* |
| 80 | * The locking rules for s_lock are up to the |
| 81 | * filesystem. For example ext3fs has different |
| 82 | * lock ordering than usbfs: |
| 83 | */ |
| 84 | lockdep_set_class(&s->s_lock, &type->s_lock_key); |
Peter Zijlstra | ada723d | 2009-02-18 14:48:30 -0800 | [diff] [blame] | 85 | /* |
| 86 | * sget() can have s_umount recursion. |
| 87 | * |
| 88 | * When it cannot find a suitable sb, it allocates a new |
| 89 | * one (this one), and tries again to find a suitable old |
| 90 | * one. |
| 91 | * |
| 92 | * In case that succeeds, it will acquire the s_umount |
| 93 | * lock of the old one. Since these are clearly distrinct |
| 94 | * locks, and this object isn't exposed yet, there's no |
| 95 | * risk of deadlocks. |
| 96 | * |
| 97 | * Annotate this by putting this lock in a different |
| 98 | * subclass. |
| 99 | */ |
| 100 | down_write_nested(&s->s_umount, SINGLE_DEPTH_NESTING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | s->s_count = S_BIAS; |
| 102 | atomic_set(&s->s_active, 1); |
Arjan van de Ven | a11f3a0 | 2006-03-23 03:00:33 -0800 | [diff] [blame] | 103 | mutex_init(&s->s_vfs_rename_mutex); |
Ingo Molnar | d3be915 | 2006-03-23 03:00:29 -0800 | [diff] [blame] | 104 | mutex_init(&s->s_dquot.dqio_mutex); |
| 105 | mutex_init(&s->s_dquot.dqonoff_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | init_rwsem(&s->s_dquot.dqptr_sem); |
| 107 | init_waitqueue_head(&s->s_wait_unfrozen); |
| 108 | s->s_maxbytes = MAX_NON_LFS; |
| 109 | s->dq_op = sb_dquot_ops; |
| 110 | s->s_qcop = sb_quotactl_ops; |
| 111 | s->s_op = &default_op; |
| 112 | s->s_time_gran = 1000000000; |
| 113 | } |
| 114 | out: |
| 115 | return s; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * destroy_super - frees a superblock |
| 120 | * @s: superblock to free |
| 121 | * |
| 122 | * Frees a superblock. |
| 123 | */ |
| 124 | static inline void destroy_super(struct super_block *s) |
| 125 | { |
| 126 | security_sb_free(s); |
Miklos Szeredi | 79c0b2d | 2007-05-08 00:25:43 -0700 | [diff] [blame] | 127 | kfree(s->s_subtype); |
Miklos Szeredi | b3b304a | 2008-02-08 04:21:35 -0800 | [diff] [blame] | 128 | kfree(s->s_options); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | kfree(s); |
| 130 | } |
| 131 | |
| 132 | /* Superblock refcounting */ |
| 133 | |
| 134 | /* |
| 135 | * Drop a superblock's refcount. Returns non-zero if the superblock was |
| 136 | * destroyed. The caller must hold sb_lock. |
| 137 | */ |
Adrian Bunk | 6b09ae6 | 2008-04-29 00:58:54 -0700 | [diff] [blame] | 138 | static int __put_super(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
| 140 | int ret = 0; |
| 141 | |
| 142 | if (!--sb->s_count) { |
| 143 | destroy_super(sb); |
| 144 | ret = 1; |
| 145 | } |
| 146 | return ret; |
| 147 | } |
| 148 | |
| 149 | /* |
| 150 | * Drop a superblock's refcount. |
| 151 | * Returns non-zero if the superblock is about to be destroyed and |
| 152 | * at least is already removed from super_blocks list, so if we are |
| 153 | * making a loop through super blocks then we need to restart. |
| 154 | * The caller must hold sb_lock. |
| 155 | */ |
| 156 | int __put_super_and_need_restart(struct super_block *sb) |
| 157 | { |
| 158 | /* check for race with generic_shutdown_super() */ |
| 159 | if (list_empty(&sb->s_list)) { |
| 160 | /* super block is removed, need to restart... */ |
| 161 | __put_super(sb); |
| 162 | return 1; |
| 163 | } |
| 164 | /* can't be the last, since s_list is still in use */ |
| 165 | sb->s_count--; |
| 166 | BUG_ON(sb->s_count == 0); |
| 167 | return 0; |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * put_super - drop a temporary reference to superblock |
| 172 | * @sb: superblock in question |
| 173 | * |
| 174 | * Drops a temporary reference, frees superblock if there's no |
| 175 | * references left. |
| 176 | */ |
| 177 | static void put_super(struct super_block *sb) |
| 178 | { |
| 179 | spin_lock(&sb_lock); |
| 180 | __put_super(sb); |
| 181 | spin_unlock(&sb_lock); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /** |
| 186 | * deactivate_super - drop an active reference to superblock |
| 187 | * @s: superblock to deactivate |
| 188 | * |
| 189 | * Drops an active reference to superblock, acquiring a temprory one if |
| 190 | * there is no active references left. In that case we lock superblock, |
| 191 | * tell fs driver to shut it down and drop the temporary reference we |
| 192 | * had just acquired. |
| 193 | */ |
| 194 | void deactivate_super(struct super_block *s) |
| 195 | { |
| 196 | struct file_system_type *fs = s->s_type; |
| 197 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { |
| 198 | s->s_count -= S_BIAS-1; |
| 199 | spin_unlock(&sb_lock); |
Jan Kara | 9e3509e | 2009-01-26 16:45:12 +0100 | [diff] [blame] | 200 | vfs_dq_off(s, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | down_write(&s->s_umount); |
| 202 | fs->kill_sb(s); |
| 203 | put_filesystem(fs); |
| 204 | put_super(s); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | EXPORT_SYMBOL(deactivate_super); |
| 209 | |
| 210 | /** |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 211 | * deactivate_locked_super - drop an active reference to superblock |
| 212 | * @s: superblock to deactivate |
| 213 | * |
| 214 | * Equivalent of up_write(&s->s_umount); deactivate_super(s);, except that |
| 215 | * it does not unlock it until it's all over. As the result, it's safe to |
| 216 | * use to dispose of new superblock on ->get_sb() failure exits - nobody |
| 217 | * will see the sucker until it's all over. Equivalent using up_write + |
| 218 | * deactivate_super is safe for that purpose only if superblock is either |
| 219 | * safe to use or has NULL ->s_root when we unlock. |
| 220 | */ |
| 221 | void deactivate_locked_super(struct super_block *s) |
| 222 | { |
| 223 | struct file_system_type *fs = s->s_type; |
| 224 | if (atomic_dec_and_lock(&s->s_active, &sb_lock)) { |
| 225 | s->s_count -= S_BIAS-1; |
| 226 | spin_unlock(&sb_lock); |
| 227 | vfs_dq_off(s, 0); |
| 228 | fs->kill_sb(s); |
| 229 | put_filesystem(fs); |
| 230 | put_super(s); |
| 231 | } else { |
| 232 | up_write(&s->s_umount); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | EXPORT_SYMBOL(deactivate_locked_super); |
| 237 | |
| 238 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | * grab_super - acquire an active reference |
| 240 | * @s: reference we are trying to make active |
| 241 | * |
| 242 | * Tries to acquire an active reference. grab_super() is used when we |
| 243 | * had just found a superblock in super_blocks or fs_type->fs_supers |
| 244 | * and want to turn it into a full-blown active reference. grab_super() |
| 245 | * is called with sb_lock held and drops it. Returns 1 in case of |
| 246 | * success, 0 if we had failed (superblock contents was already dead or |
| 247 | * dying when grab_super() had been called). |
| 248 | */ |
Josh Triplett | 9c4dbee | 2006-09-29 01:59:29 -0700 | [diff] [blame] | 249 | static int grab_super(struct super_block *s) __releases(sb_lock) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | { |
| 251 | s->s_count++; |
| 252 | spin_unlock(&sb_lock); |
| 253 | down_write(&s->s_umount); |
| 254 | if (s->s_root) { |
| 255 | spin_lock(&sb_lock); |
| 256 | if (s->s_count > S_BIAS) { |
| 257 | atomic_inc(&s->s_active); |
| 258 | s->s_count--; |
| 259 | spin_unlock(&sb_lock); |
| 260 | return 1; |
| 261 | } |
| 262 | spin_unlock(&sb_lock); |
| 263 | } |
| 264 | up_write(&s->s_umount); |
| 265 | put_super(s); |
| 266 | yield(); |
| 267 | return 0; |
| 268 | } |
| 269 | |
David Howells | cf9a2ae | 2006-08-29 19:05:54 +0100 | [diff] [blame] | 270 | /* |
Al Viro | 914e263 | 2006-10-18 13:55:46 -0400 | [diff] [blame] | 271 | * Superblock locking. We really ought to get rid of these two. |
| 272 | */ |
| 273 | void lock_super(struct super_block * sb) |
| 274 | { |
| 275 | get_fs_excl(); |
| 276 | mutex_lock(&sb->s_lock); |
| 277 | } |
| 278 | |
| 279 | void unlock_super(struct super_block * sb) |
| 280 | { |
| 281 | put_fs_excl(); |
| 282 | mutex_unlock(&sb->s_lock); |
| 283 | } |
| 284 | |
| 285 | EXPORT_SYMBOL(lock_super); |
| 286 | EXPORT_SYMBOL(unlock_super); |
| 287 | |
| 288 | /* |
David Howells | cf9a2ae | 2006-08-29 19:05:54 +0100 | [diff] [blame] | 289 | * Write out and wait upon all dirty data associated with this |
| 290 | * superblock. Filesystem data as well as the underlying block |
| 291 | * device. Takes the superblock lock. Requires a second blkdev |
| 292 | * flush by the caller to complete the operation. |
| 293 | */ |
| 294 | void __fsync_super(struct super_block *sb) |
| 295 | { |
| 296 | sync_inodes_sb(sb, 0); |
Jan Kara | 9e3509e | 2009-01-26 16:45:12 +0100 | [diff] [blame] | 297 | vfs_dq_sync(sb); |
David Howells | cf9a2ae | 2006-08-29 19:05:54 +0100 | [diff] [blame] | 298 | lock_super(sb); |
| 299 | if (sb->s_dirt && sb->s_op->write_super) |
| 300 | sb->s_op->write_super(sb); |
| 301 | unlock_super(sb); |
| 302 | if (sb->s_op->sync_fs) |
| 303 | sb->s_op->sync_fs(sb, 1); |
| 304 | sync_blockdev(sb->s_bdev); |
| 305 | sync_inodes_sb(sb, 1); |
| 306 | } |
| 307 | |
| 308 | /* |
| 309 | * Write out and wait upon all dirty data associated with this |
| 310 | * superblock. Filesystem data as well as the underlying block |
| 311 | * device. Takes the superblock lock. |
| 312 | */ |
| 313 | int fsync_super(struct super_block *sb) |
| 314 | { |
| 315 | __fsync_super(sb); |
| 316 | return sync_blockdev(sb->s_bdev); |
| 317 | } |
David Howells | 800a964 | 2009-04-03 16:42:40 +0100 | [diff] [blame] | 318 | EXPORT_SYMBOL_GPL(fsync_super); |
David Howells | cf9a2ae | 2006-08-29 19:05:54 +0100 | [diff] [blame] | 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | /** |
| 321 | * generic_shutdown_super - common helper for ->kill_sb() |
| 322 | * @sb: superblock to kill |
| 323 | * |
| 324 | * generic_shutdown_super() does all fs-independent work on superblock |
| 325 | * shutdown. Typical ->kill_sb() should pick all fs-specific objects |
| 326 | * that need destruction out of superblock, call generic_shutdown_super() |
| 327 | * and release aforementioned objects. Note: dentries and inodes _are_ |
| 328 | * taken care of and do not need specific handling. |
David Howells | c636ebd | 2006-10-11 01:22:19 -0700 | [diff] [blame] | 329 | * |
| 330 | * Upon calling this function, the filesystem may no longer alter or |
| 331 | * rearrange the set of dentries belonging to this super_block, nor may it |
| 332 | * change the attachments of dentries to inodes. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | */ |
| 334 | void generic_shutdown_super(struct super_block *sb) |
| 335 | { |
Josef 'Jeff' Sipek | ee9b6d6 | 2007-02-12 00:55:41 -0800 | [diff] [blame] | 336 | const struct super_operations *sop = sb->s_op; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | |
Arjan van de Ven | efaee19 | 2009-01-06 07:20:54 -0800 | [diff] [blame] | 338 | |
David Howells | c636ebd | 2006-10-11 01:22:19 -0700 | [diff] [blame] | 339 | if (sb->s_root) { |
| 340 | shrink_dcache_for_umount(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | fsync_super(sb); |
| 342 | lock_super(sb); |
| 343 | sb->s_flags &= ~MS_ACTIVE; |
Arjan van de Ven | efaee19 | 2009-01-06 07:20:54 -0800 | [diff] [blame] | 344 | |
| 345 | /* |
| 346 | * wait for asynchronous fs operations to finish before going further |
| 347 | */ |
Cornelia Huck | 766ccb9 | 2009-01-20 15:31:31 +0100 | [diff] [blame] | 348 | async_synchronize_full_domain(&sb->s_async_list); |
Arjan van de Ven | efaee19 | 2009-01-06 07:20:54 -0800 | [diff] [blame] | 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* bad name - it should be evict_inodes() */ |
| 351 | invalidate_inodes(sb); |
| 352 | lock_kernel(); |
| 353 | |
| 354 | if (sop->write_super && sb->s_dirt) |
| 355 | sop->write_super(sb); |
| 356 | if (sop->put_super) |
| 357 | sop->put_super(sb); |
| 358 | |
| 359 | /* Forget any remaining inodes */ |
| 360 | if (invalidate_inodes(sb)) { |
Dave Jones | 7b4fe29 | 2006-02-07 12:58:48 -0800 | [diff] [blame] | 361 | printk("VFS: Busy inodes after unmount of %s. " |
| 362 | "Self-destruct in 5 seconds. Have a nice day...\n", |
| 363 | sb->s_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | unlock_kernel(); |
| 367 | unlock_super(sb); |
| 368 | } |
| 369 | spin_lock(&sb_lock); |
| 370 | /* should be initialized for __put_super_and_need_restart() */ |
| 371 | list_del_init(&sb->s_list); |
| 372 | list_del(&sb->s_instances); |
| 373 | spin_unlock(&sb_lock); |
| 374 | up_write(&sb->s_umount); |
| 375 | } |
| 376 | |
| 377 | EXPORT_SYMBOL(generic_shutdown_super); |
| 378 | |
| 379 | /** |
| 380 | * sget - find or create a superblock |
| 381 | * @type: filesystem type superblock should belong to |
| 382 | * @test: comparison callback |
| 383 | * @set: setup callback |
| 384 | * @data: argument to each of them |
| 385 | */ |
| 386 | struct super_block *sget(struct file_system_type *type, |
| 387 | int (*test)(struct super_block *,void *), |
| 388 | int (*set)(struct super_block *,void *), |
| 389 | void *data) |
| 390 | { |
| 391 | struct super_block *s = NULL; |
Matthias Kaehlcke | d473012 | 2007-10-18 23:39:57 -0700 | [diff] [blame] | 392 | struct super_block *old; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | int err; |
| 394 | |
| 395 | retry: |
| 396 | spin_lock(&sb_lock); |
Matthias Kaehlcke | d473012 | 2007-10-18 23:39:57 -0700 | [diff] [blame] | 397 | if (test) { |
| 398 | list_for_each_entry(old, &type->fs_supers, s_instances) { |
| 399 | if (!test(old, data)) |
| 400 | continue; |
| 401 | if (!grab_super(old)) |
| 402 | goto retry; |
Li Zefan | a3cfbb5 | 2009-03-12 14:31:29 -0700 | [diff] [blame] | 403 | if (s) { |
| 404 | up_write(&s->s_umount); |
Matthias Kaehlcke | d473012 | 2007-10-18 23:39:57 -0700 | [diff] [blame] | 405 | destroy_super(s); |
Li Zefan | a3cfbb5 | 2009-03-12 14:31:29 -0700 | [diff] [blame] | 406 | } |
Matthias Kaehlcke | d473012 | 2007-10-18 23:39:57 -0700 | [diff] [blame] | 407 | return old; |
| 408 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | } |
| 410 | if (!s) { |
| 411 | spin_unlock(&sb_lock); |
Ingo Molnar | cf51624 | 2006-07-03 00:25:27 -0700 | [diff] [blame] | 412 | s = alloc_super(type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | if (!s) |
| 414 | return ERR_PTR(-ENOMEM); |
| 415 | goto retry; |
| 416 | } |
| 417 | |
| 418 | err = set(s, data); |
| 419 | if (err) { |
| 420 | spin_unlock(&sb_lock); |
Li Zefan | a3cfbb5 | 2009-03-12 14:31:29 -0700 | [diff] [blame] | 421 | up_write(&s->s_umount); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | destroy_super(s); |
| 423 | return ERR_PTR(err); |
| 424 | } |
| 425 | s->s_type = type; |
| 426 | strlcpy(s->s_id, type->name, sizeof(s->s_id)); |
| 427 | list_add_tail(&s->s_list, &super_blocks); |
| 428 | list_add(&s->s_instances, &type->fs_supers); |
| 429 | spin_unlock(&sb_lock); |
| 430 | get_filesystem(type); |
| 431 | return s; |
| 432 | } |
| 433 | |
| 434 | EXPORT_SYMBOL(sget); |
| 435 | |
| 436 | void drop_super(struct super_block *sb) |
| 437 | { |
| 438 | up_read(&sb->s_umount); |
| 439 | put_super(sb); |
| 440 | } |
| 441 | |
| 442 | EXPORT_SYMBOL(drop_super); |
| 443 | |
| 444 | static inline void write_super(struct super_block *sb) |
| 445 | { |
| 446 | lock_super(sb); |
| 447 | if (sb->s_root && sb->s_dirt) |
| 448 | if (sb->s_op->write_super) |
| 449 | sb->s_op->write_super(sb); |
| 450 | unlock_super(sb); |
| 451 | } |
| 452 | |
| 453 | /* |
| 454 | * Note: check the dirty flag before waiting, so we don't |
| 455 | * hold up the sync while mounting a device. (The newly |
| 456 | * mounted device won't need syncing.) |
| 457 | */ |
| 458 | void sync_supers(void) |
| 459 | { |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 460 | struct super_block *sb; |
| 461 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 462 | spin_lock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 463 | restart: |
| 464 | list_for_each_entry(sb, &super_blocks, s_list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | if (sb->s_dirt) { |
| 466 | sb->s_count++; |
| 467 | spin_unlock(&sb_lock); |
| 468 | down_read(&sb->s_umount); |
| 469 | write_super(sb); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 470 | up_read(&sb->s_umount); |
| 471 | spin_lock(&sb_lock); |
| 472 | if (__put_super_and_need_restart(sb)) |
| 473 | goto restart; |
| 474 | } |
| 475 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | spin_unlock(&sb_lock); |
| 477 | } |
| 478 | |
| 479 | /* |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 480 | * Call the ->sync_fs super_op against all filesystems which are r/w and |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 | * which implement it. |
| 482 | * |
| 483 | * This operation is careful to avoid the livelock which could easily happen |
| 484 | * if two or more filesystems are being continuously dirtied. s_need_sync_fs |
| 485 | * is used only here. We set it against all filesystems and then clear it as |
| 486 | * we sync them. So redirtied filesystems are skipped. |
| 487 | * |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 488 | * But if process A is currently running sync_filesystems and then process B |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | * calls sync_filesystems as well, process B will set all the s_need_sync_fs |
| 490 | * flags again, which will cause process A to resync everything. Fix that with |
| 491 | * a local mutex. |
| 492 | * |
| 493 | * (Fabian) Avoid sync_fs with clean fs & wait mode 0 |
| 494 | */ |
| 495 | void sync_filesystems(int wait) |
| 496 | { |
| 497 | struct super_block *sb; |
Ingo Molnar | 353ab6e | 2006-03-26 01:37:12 -0800 | [diff] [blame] | 498 | static DEFINE_MUTEX(mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | |
Ingo Molnar | 353ab6e | 2006-03-26 01:37:12 -0800 | [diff] [blame] | 500 | mutex_lock(&mutex); /* Could be down_interruptible */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | spin_lock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 502 | list_for_each_entry(sb, &super_blocks, s_list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | if (!sb->s_op->sync_fs) |
| 504 | continue; |
| 505 | if (sb->s_flags & MS_RDONLY) |
| 506 | continue; |
| 507 | sb->s_need_sync_fs = 1; |
| 508 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | |
| 510 | restart: |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 511 | list_for_each_entry(sb, &super_blocks, s_list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | if (!sb->s_need_sync_fs) |
| 513 | continue; |
| 514 | sb->s_need_sync_fs = 0; |
| 515 | if (sb->s_flags & MS_RDONLY) |
| 516 | continue; /* hm. Was remounted r/o meanwhile */ |
| 517 | sb->s_count++; |
| 518 | spin_unlock(&sb_lock); |
| 519 | down_read(&sb->s_umount); |
Cornelia Huck | 766ccb9 | 2009-01-20 15:31:31 +0100 | [diff] [blame] | 520 | async_synchronize_full_domain(&sb->s_async_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | if (sb->s_root && (wait || sb->s_dirt)) |
| 522 | sb->s_op->sync_fs(sb, wait); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 523 | up_read(&sb->s_umount); |
| 524 | /* restart only when sb is no longer on the list */ |
| 525 | spin_lock(&sb_lock); |
| 526 | if (__put_super_and_need_restart(sb)) |
| 527 | goto restart; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 528 | } |
| 529 | spin_unlock(&sb_lock); |
Ingo Molnar | 353ab6e | 2006-03-26 01:37:12 -0800 | [diff] [blame] | 530 | mutex_unlock(&mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | /** |
| 534 | * get_super - get the superblock of a device |
| 535 | * @bdev: device to get the superblock for |
| 536 | * |
| 537 | * Scans the superblock list and finds the superblock of the file system |
| 538 | * mounted on the device given. %NULL is returned if no match is found. |
| 539 | */ |
| 540 | |
| 541 | struct super_block * get_super(struct block_device *bdev) |
| 542 | { |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 543 | struct super_block *sb; |
| 544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | if (!bdev) |
| 546 | return NULL; |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 547 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | spin_lock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 549 | rescan: |
| 550 | list_for_each_entry(sb, &super_blocks, s_list) { |
| 551 | if (sb->s_bdev == bdev) { |
| 552 | sb->s_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | spin_unlock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 554 | down_read(&sb->s_umount); |
| 555 | if (sb->s_root) |
| 556 | return sb; |
| 557 | up_read(&sb->s_umount); |
| 558 | /* restart only when sb is no longer on the list */ |
| 559 | spin_lock(&sb_lock); |
| 560 | if (__put_super_and_need_restart(sb)) |
| 561 | goto rescan; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | } |
| 563 | } |
| 564 | spin_unlock(&sb_lock); |
| 565 | return NULL; |
| 566 | } |
| 567 | |
| 568 | EXPORT_SYMBOL(get_super); |
| 569 | |
| 570 | struct super_block * user_get_super(dev_t dev) |
| 571 | { |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 572 | struct super_block *sb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | spin_lock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 575 | rescan: |
| 576 | list_for_each_entry(sb, &super_blocks, s_list) { |
| 577 | if (sb->s_dev == dev) { |
| 578 | sb->s_count++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | spin_unlock(&sb_lock); |
Kirill Korotaev | 618f063 | 2005-06-23 00:09:54 -0700 | [diff] [blame] | 580 | down_read(&sb->s_umount); |
| 581 | if (sb->s_root) |
| 582 | return sb; |
| 583 | up_read(&sb->s_umount); |
| 584 | /* restart only when sb is no longer on the list */ |
| 585 | spin_lock(&sb_lock); |
| 586 | if (__put_super_and_need_restart(sb)) |
| 587 | goto rescan; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | } |
| 589 | } |
| 590 | spin_unlock(&sb_lock); |
| 591 | return NULL; |
| 592 | } |
| 593 | |
Heiko Carstens | 257ac26 | 2009-01-14 14:14:13 +0100 | [diff] [blame] | 594 | SYSCALL_DEFINE2(ustat, unsigned, dev, struct ustat __user *, ubuf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | { |
| 596 | struct super_block *s; |
| 597 | struct ustat tmp; |
| 598 | struct kstatfs sbuf; |
| 599 | int err = -EINVAL; |
| 600 | |
| 601 | s = user_get_super(new_decode_dev(dev)); |
| 602 | if (s == NULL) |
| 603 | goto out; |
David Howells | 726c334 | 2006-06-23 02:02:58 -0700 | [diff] [blame] | 604 | err = vfs_statfs(s->s_root, &sbuf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 605 | drop_super(s); |
| 606 | if (err) |
| 607 | goto out; |
| 608 | |
| 609 | memset(&tmp,0,sizeof(struct ustat)); |
| 610 | tmp.f_tfree = sbuf.f_bfree; |
| 611 | tmp.f_tinode = sbuf.f_ffree; |
| 612 | |
| 613 | err = copy_to_user(ubuf,&tmp,sizeof(struct ustat)) ? -EFAULT : 0; |
| 614 | out: |
| 615 | return err; |
| 616 | } |
| 617 | |
| 618 | /** |
Randy Dunlap | a6b9191 | 2008-03-19 17:01:00 -0700 | [diff] [blame] | 619 | * mark_files_ro - mark all files read-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 620 | * @sb: superblock in question |
| 621 | * |
Randy Dunlap | a6b9191 | 2008-03-19 17:01:00 -0700 | [diff] [blame] | 622 | * All files are marked read-only. We don't care about pending |
| 623 | * delete files so this should be used in 'force' mode only. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | */ |
| 625 | |
| 626 | static void mark_files_ro(struct super_block *sb) |
| 627 | { |
| 628 | struct file *f; |
| 629 | |
Dave Hansen | 49e0d02 | 2008-02-15 14:37:32 -0800 | [diff] [blame] | 630 | retry: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | file_list_lock(); |
Eric Dumazet | 2f51201 | 2005-10-30 15:02:16 -0800 | [diff] [blame] | 632 | list_for_each_entry(f, &sb->s_files, f_u.fu_list) { |
Dave Hansen | 49e0d02 | 2008-02-15 14:37:32 -0800 | [diff] [blame] | 633 | struct vfsmount *mnt; |
| 634 | if (!S_ISREG(f->f_path.dentry->d_inode->i_mode)) |
| 635 | continue; |
| 636 | if (!file_count(f)) |
| 637 | continue; |
| 638 | if (!(f->f_mode & FMODE_WRITE)) |
| 639 | continue; |
| 640 | f->f_mode &= ~FMODE_WRITE; |
Dave Hansen | ad775f5 | 2008-02-15 14:38:01 -0800 | [diff] [blame] | 641 | if (file_check_writeable(f) != 0) |
| 642 | continue; |
| 643 | file_release_write(f); |
Dave Hansen | 49e0d02 | 2008-02-15 14:37:32 -0800 | [diff] [blame] | 644 | mnt = mntget(f->f_path.mnt); |
| 645 | file_list_unlock(); |
| 646 | /* |
| 647 | * This can sleep, so we can't hold |
| 648 | * the file_list_lock() spinlock. |
| 649 | */ |
| 650 | mnt_drop_write(mnt); |
| 651 | mntput(mnt); |
| 652 | goto retry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | } |
| 654 | file_list_unlock(); |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * do_remount_sb - asks filesystem to change mount options. |
| 659 | * @sb: superblock in question |
| 660 | * @flags: numeric part of options |
| 661 | * @data: the rest of options |
| 662 | * @force: whether or not to force the change |
| 663 | * |
| 664 | * Alters the mount options of a mounted file system. |
| 665 | */ |
| 666 | int do_remount_sb(struct super_block *sb, int flags, void *data, int force) |
| 667 | { |
| 668 | int retval; |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 669 | int remount_rw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 670 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 671 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | if (!(flags & MS_RDONLY) && bdev_read_only(sb->s_bdev)) |
| 673 | return -EACCES; |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 674 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | if (flags & MS_RDONLY) |
| 676 | acct_auto_close(sb); |
| 677 | shrink_dcache_sb(sb); |
| 678 | fsync_super(sb); |
| 679 | |
| 680 | /* If we are remounting RDONLY and current sb is read/write, |
| 681 | make sure there are no rw files opened */ |
| 682 | if ((flags & MS_RDONLY) && !(sb->s_flags & MS_RDONLY)) { |
| 683 | if (force) |
| 684 | mark_files_ro(sb); |
| 685 | else if (!fs_may_remount_ro(sb)) |
| 686 | return -EBUSY; |
Jan Kara | 9e3509e | 2009-01-26 16:45:12 +0100 | [diff] [blame] | 687 | retval = vfs_dq_off(sb, 1); |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 688 | if (retval < 0 && retval != -ENOSYS) |
| 689 | return -EBUSY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | } |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 691 | remount_rw = !(flags & MS_RDONLY) && (sb->s_flags & MS_RDONLY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | |
| 693 | if (sb->s_op->remount_fs) { |
| 694 | lock_super(sb); |
| 695 | retval = sb->s_op->remount_fs(sb, &flags, data); |
| 696 | unlock_super(sb); |
| 697 | if (retval) |
| 698 | return retval; |
| 699 | } |
| 700 | sb->s_flags = (sb->s_flags & ~MS_RMT_MASK) | (flags & MS_RMT_MASK); |
Jan Kara | 0ff5af8 | 2008-04-28 02:14:33 -0700 | [diff] [blame] | 701 | if (remount_rw) |
Jan Kara | 9e3509e | 2009-01-26 16:45:12 +0100 | [diff] [blame] | 702 | vfs_dq_quota_on_remount(sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | return 0; |
| 704 | } |
| 705 | |
Jens Axboe | a2a9537 | 2009-03-17 09:38:40 +0100 | [diff] [blame] | 706 | static void do_emergency_remount(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | { |
| 708 | struct super_block *sb; |
| 709 | |
| 710 | spin_lock(&sb_lock); |
| 711 | list_for_each_entry(sb, &super_blocks, s_list) { |
| 712 | sb->s_count++; |
| 713 | spin_unlock(&sb_lock); |
| 714 | down_read(&sb->s_umount); |
| 715 | if (sb->s_root && sb->s_bdev && !(sb->s_flags & MS_RDONLY)) { |
| 716 | /* |
| 717 | * ->remount_fs needs lock_kernel(). |
| 718 | * |
| 719 | * What lock protects sb->s_flags?? |
| 720 | */ |
| 721 | lock_kernel(); |
| 722 | do_remount_sb(sb, MS_RDONLY, NULL, 1); |
| 723 | unlock_kernel(); |
| 724 | } |
| 725 | drop_super(sb); |
| 726 | spin_lock(&sb_lock); |
| 727 | } |
| 728 | spin_unlock(&sb_lock); |
Jens Axboe | a2a9537 | 2009-03-17 09:38:40 +0100 | [diff] [blame] | 729 | kfree(work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 730 | printk("Emergency Remount complete\n"); |
| 731 | } |
| 732 | |
| 733 | void emergency_remount(void) |
| 734 | { |
Jens Axboe | a2a9537 | 2009-03-17 09:38:40 +0100 | [diff] [blame] | 735 | struct work_struct *work; |
| 736 | |
| 737 | work = kmalloc(sizeof(*work), GFP_ATOMIC); |
| 738 | if (work) { |
| 739 | INIT_WORK(work, do_emergency_remount); |
| 740 | schedule_work(work); |
| 741 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /* |
| 745 | * Unnamed block devices are dummy devices used by virtual |
| 746 | * filesystems which don't use real block-devices. -- jrs |
| 747 | */ |
| 748 | |
Alexey Dobriyan | ad76cbc | 2008-08-28 06:26:23 +0400 | [diff] [blame] | 749 | static DEFINE_IDA(unnamed_dev_ida); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | static DEFINE_SPINLOCK(unnamed_dev_lock);/* protects the above */ |
| 751 | |
| 752 | int set_anon_super(struct super_block *s, void *data) |
| 753 | { |
| 754 | int dev; |
| 755 | int error; |
| 756 | |
| 757 | retry: |
Alexey Dobriyan | ad76cbc | 2008-08-28 06:26:23 +0400 | [diff] [blame] | 758 | if (ida_pre_get(&unnamed_dev_ida, GFP_ATOMIC) == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 759 | return -ENOMEM; |
| 760 | spin_lock(&unnamed_dev_lock); |
Alexey Dobriyan | ad76cbc | 2008-08-28 06:26:23 +0400 | [diff] [blame] | 761 | error = ida_get_new(&unnamed_dev_ida, &dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 762 | spin_unlock(&unnamed_dev_lock); |
| 763 | if (error == -EAGAIN) |
| 764 | /* We raced and lost with another CPU. */ |
| 765 | goto retry; |
| 766 | else if (error) |
| 767 | return -EAGAIN; |
| 768 | |
| 769 | if ((dev & MAX_ID_MASK) == (1 << MINORBITS)) { |
| 770 | spin_lock(&unnamed_dev_lock); |
Alexey Dobriyan | ad76cbc | 2008-08-28 06:26:23 +0400 | [diff] [blame] | 771 | ida_remove(&unnamed_dev_ida, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 772 | spin_unlock(&unnamed_dev_lock); |
| 773 | return -EMFILE; |
| 774 | } |
| 775 | s->s_dev = MKDEV(0, dev & MINORMASK); |
| 776 | return 0; |
| 777 | } |
| 778 | |
| 779 | EXPORT_SYMBOL(set_anon_super); |
| 780 | |
| 781 | void kill_anon_super(struct super_block *sb) |
| 782 | { |
| 783 | int slot = MINOR(sb->s_dev); |
| 784 | |
| 785 | generic_shutdown_super(sb); |
| 786 | spin_lock(&unnamed_dev_lock); |
Alexey Dobriyan | ad76cbc | 2008-08-28 06:26:23 +0400 | [diff] [blame] | 787 | ida_remove(&unnamed_dev_ida, slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | spin_unlock(&unnamed_dev_lock); |
| 789 | } |
| 790 | |
| 791 | EXPORT_SYMBOL(kill_anon_super); |
| 792 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | void kill_litter_super(struct super_block *sb) |
| 794 | { |
| 795 | if (sb->s_root) |
| 796 | d_genocide(sb->s_root); |
| 797 | kill_anon_super(sb); |
| 798 | } |
| 799 | |
| 800 | EXPORT_SYMBOL(kill_litter_super); |
| 801 | |
Serge E. Hallyn | 909e6d9 | 2009-04-06 19:01:07 -0700 | [diff] [blame] | 802 | static int ns_test_super(struct super_block *sb, void *data) |
| 803 | { |
| 804 | return sb->s_fs_info == data; |
| 805 | } |
| 806 | |
| 807 | static int ns_set_super(struct super_block *sb, void *data) |
| 808 | { |
| 809 | sb->s_fs_info = data; |
| 810 | return set_anon_super(sb, NULL); |
| 811 | } |
| 812 | |
| 813 | int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, |
| 814 | int (*fill_super)(struct super_block *, void *, int), |
| 815 | struct vfsmount *mnt) |
| 816 | { |
| 817 | struct super_block *sb; |
| 818 | |
| 819 | sb = sget(fs_type, ns_test_super, ns_set_super, data); |
| 820 | if (IS_ERR(sb)) |
| 821 | return PTR_ERR(sb); |
| 822 | |
| 823 | if (!sb->s_root) { |
| 824 | int err; |
| 825 | sb->s_flags = flags; |
| 826 | err = fill_super(sb, data, flags & MS_SILENT ? 1 : 0); |
| 827 | if (err) { |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 828 | deactivate_locked_super(sb); |
Serge E. Hallyn | 909e6d9 | 2009-04-06 19:01:07 -0700 | [diff] [blame] | 829 | return err; |
| 830 | } |
| 831 | |
| 832 | sb->s_flags |= MS_ACTIVE; |
| 833 | } |
| 834 | |
| 835 | simple_set_mnt(mnt, sb); |
| 836 | return 0; |
| 837 | } |
| 838 | |
| 839 | EXPORT_SYMBOL(get_sb_ns); |
| 840 | |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 841 | #ifdef CONFIG_BLOCK |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 842 | static int set_bdev_super(struct super_block *s, void *data) |
| 843 | { |
| 844 | s->s_bdev = data; |
| 845 | s->s_dev = s->s_bdev->bd_dev; |
| 846 | return 0; |
| 847 | } |
| 848 | |
| 849 | static int test_bdev_super(struct super_block *s, void *data) |
| 850 | { |
| 851 | return (void *)s->s_bdev == data; |
| 852 | } |
| 853 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 854 | int get_sb_bdev(struct file_system_type *fs_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 855 | int flags, const char *dev_name, void *data, |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 856 | int (*fill_super)(struct super_block *, void *, int), |
| 857 | struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 858 | { |
| 859 | struct block_device *bdev; |
| 860 | struct super_block *s; |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 861 | fmode_t mode = FMODE_READ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | int error = 0; |
| 863 | |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 864 | if (!(flags & MS_RDONLY)) |
| 865 | mode |= FMODE_WRITE; |
| 866 | |
| 867 | bdev = open_bdev_exclusive(dev_name, mode, fs_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | if (IS_ERR(bdev)) |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 869 | return PTR_ERR(bdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | |
| 871 | /* |
| 872 | * once the super is inserted into the list by sget, s_umount |
| 873 | * will protect the lockfs code from trying to start a snapshot |
| 874 | * while we are mounting |
| 875 | */ |
David Chinner | f73ca1b | 2007-01-10 23:15:41 -0800 | [diff] [blame] | 876 | down(&bdev->bd_mount_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | s = sget(fs_type, test_bdev_super, set_bdev_super, bdev); |
David Chinner | f73ca1b | 2007-01-10 23:15:41 -0800 | [diff] [blame] | 878 | up(&bdev->bd_mount_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | if (IS_ERR(s)) |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 880 | goto error_s; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | |
| 882 | if (s->s_root) { |
| 883 | if ((flags ^ s->s_flags) & MS_RDONLY) { |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 884 | deactivate_locked_super(s); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 885 | error = -EBUSY; |
| 886 | goto error_bdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 887 | } |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 888 | |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 889 | close_bdev_exclusive(bdev, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 890 | } else { |
| 891 | char b[BDEVNAME_SIZE]; |
| 892 | |
| 893 | s->s_flags = flags; |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 894 | s->s_mode = mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id)); |
Pekka Enberg | e78c9a0 | 2006-01-08 01:03:39 -0800 | [diff] [blame] | 896 | sb_set_blocksize(s, block_size(bdev)); |
Theodore Ts'o | 9b04c99 | 2006-03-24 03:15:10 -0800 | [diff] [blame] | 897 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | if (error) { |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 899 | deactivate_locked_super(s); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 900 | goto error; |
Greg Kroah-Hartman | fa67576 | 2006-02-22 09:39:02 -0800 | [diff] [blame] | 901 | } |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 902 | |
| 903 | s->s_flags |= MS_ACTIVE; |
Theodore Ts'o | 87d8fe1 | 2009-01-03 09:47:09 -0500 | [diff] [blame] | 904 | bdev->bd_super = s; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | } |
| 906 | |
Sukadev Bhattiprolu | a3ec947 | 2009-03-04 12:06:34 -0800 | [diff] [blame] | 907 | simple_set_mnt(mnt, s); |
| 908 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 909 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 910 | error_s: |
| 911 | error = PTR_ERR(s); |
| 912 | error_bdev: |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 913 | close_bdev_exclusive(bdev, mode); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 914 | error: |
| 915 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 916 | } |
| 917 | |
| 918 | EXPORT_SYMBOL(get_sb_bdev); |
| 919 | |
| 920 | void kill_block_super(struct super_block *sb) |
| 921 | { |
| 922 | struct block_device *bdev = sb->s_bdev; |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 923 | fmode_t mode = sb->s_mode; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 924 | |
H Hartley Sweeten | ddbaaf3 | 2009-04-29 20:14:57 -0400 | [diff] [blame] | 925 | bdev->bd_super = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | generic_shutdown_super(sb); |
| 927 | sync_blockdev(bdev); |
Al Viro | 30c40d2 | 2008-02-22 19:50:45 -0500 | [diff] [blame] | 928 | close_bdev_exclusive(bdev, mode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | EXPORT_SYMBOL(kill_block_super); |
David Howells | 9361401 | 2006-09-30 20:45:40 +0200 | [diff] [blame] | 932 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 933 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 934 | int get_sb_nodev(struct file_system_type *fs_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 935 | int flags, void *data, |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 936 | int (*fill_super)(struct super_block *, void *, int), |
| 937 | struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 938 | { |
| 939 | int error; |
| 940 | struct super_block *s = sget(fs_type, NULL, set_anon_super, NULL); |
| 941 | |
| 942 | if (IS_ERR(s)) |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 943 | return PTR_ERR(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | |
| 945 | s->s_flags = flags; |
| 946 | |
Theodore Ts'o | 9b04c99 | 2006-03-24 03:15:10 -0800 | [diff] [blame] | 947 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | if (error) { |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 949 | deactivate_locked_super(s); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 950 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | } |
| 952 | s->s_flags |= MS_ACTIVE; |
Sukadev Bhattiprolu | a3ec947 | 2009-03-04 12:06:34 -0800 | [diff] [blame] | 953 | simple_set_mnt(mnt, s); |
| 954 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | EXPORT_SYMBOL(get_sb_nodev); |
| 958 | |
| 959 | static int compare_single(struct super_block *s, void *p) |
| 960 | { |
| 961 | return 1; |
| 962 | } |
| 963 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 964 | int get_sb_single(struct file_system_type *fs_type, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | int flags, void *data, |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 966 | int (*fill_super)(struct super_block *, void *, int), |
| 967 | struct vfsmount *mnt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | { |
| 969 | struct super_block *s; |
| 970 | int error; |
| 971 | |
| 972 | s = sget(fs_type, compare_single, set_anon_super, NULL); |
| 973 | if (IS_ERR(s)) |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 974 | return PTR_ERR(s); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | if (!s->s_root) { |
| 976 | s->s_flags = flags; |
Theodore Ts'o | 9b04c99 | 2006-03-24 03:15:10 -0800 | [diff] [blame] | 977 | error = fill_super(s, data, flags & MS_SILENT ? 1 : 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | if (error) { |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 979 | deactivate_locked_super(s); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 980 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 981 | } |
| 982 | s->s_flags |= MS_ACTIVE; |
| 983 | } |
| 984 | do_remount_sb(s, flags, data, 0); |
Sukadev Bhattiprolu | a3ec947 | 2009-03-04 12:06:34 -0800 | [diff] [blame] | 985 | simple_set_mnt(mnt, s); |
| 986 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | } |
| 988 | |
| 989 | EXPORT_SYMBOL(get_sb_single); |
| 990 | |
| 991 | struct vfsmount * |
Trond Myklebust | bb4a58b | 2006-06-09 09:34:15 -0400 | [diff] [blame] | 992 | vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | struct vfsmount *mnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | char *secdata = NULL; |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 996 | int error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | |
| 998 | if (!type) |
| 999 | return ERR_PTR(-ENODEV); |
| 1000 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1001 | error = -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | mnt = alloc_vfsmnt(name); |
| 1003 | if (!mnt) |
| 1004 | goto out; |
| 1005 | |
Eric Paris | e000752 | 2008-03-05 10:31:54 -0500 | [diff] [blame] | 1006 | if (data && !(type->fs_flags & FS_BINARY_MOUNTDATA)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | secdata = alloc_secdata(); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1008 | if (!secdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | goto out_mnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1010 | |
Eric Paris | e000752 | 2008-03-05 10:31:54 -0500 | [diff] [blame] | 1011 | error = security_sb_copy_data(data, secdata); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1012 | if (error) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | goto out_free_secdata; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1016 | error = type->get_sb(type, flags, name, data, mnt); |
| 1017 | if (error < 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | goto out_free_secdata; |
Lee Schermerhorn | b4c07bc | 2007-07-15 23:40:54 -0700 | [diff] [blame] | 1019 | BUG_ON(!mnt->mnt_sb); |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1020 | |
James Morris | 12204e2 | 2008-12-19 10:44:42 +1100 | [diff] [blame] | 1021 | error = security_sb_kern_mount(mnt->mnt_sb, flags, secdata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | if (error) |
| 1023 | goto out_sb; |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1024 | |
| 1025 | mnt->mnt_mountpoint = mnt->mnt_root; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | mnt->mnt_parent = mnt; |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1027 | up_write(&mnt->mnt_sb->s_umount); |
Gerald Schaefer | 8680e22 | 2005-06-21 17:15:16 -0700 | [diff] [blame] | 1028 | free_secdata(secdata); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1029 | return mnt; |
| 1030 | out_sb: |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1031 | dput(mnt->mnt_root); |
Al Viro | 74dbbdd | 2009-05-06 01:07:50 -0400 | [diff] [blame] | 1032 | deactivate_locked_super(mnt->mnt_sb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | out_free_secdata: |
| 1034 | free_secdata(secdata); |
| 1035 | out_mnt: |
| 1036 | free_vfsmnt(mnt); |
| 1037 | out: |
David Howells | 454e239 | 2006-06-23 02:02:57 -0700 | [diff] [blame] | 1038 | return ERR_PTR(error); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | } |
| 1040 | |
Trond Myklebust | bb4a58b | 2006-06-09 09:34:15 -0400 | [diff] [blame] | 1041 | EXPORT_SYMBOL_GPL(vfs_kern_mount); |
| 1042 | |
Miklos Szeredi | 79c0b2d | 2007-05-08 00:25:43 -0700 | [diff] [blame] | 1043 | static struct vfsmount *fs_set_subtype(struct vfsmount *mnt, const char *fstype) |
| 1044 | { |
| 1045 | int err; |
| 1046 | const char *subtype = strchr(fstype, '.'); |
| 1047 | if (subtype) { |
| 1048 | subtype++; |
| 1049 | err = -EINVAL; |
| 1050 | if (!subtype[0]) |
| 1051 | goto err; |
| 1052 | } else |
| 1053 | subtype = ""; |
| 1054 | |
| 1055 | mnt->mnt_sb->s_subtype = kstrdup(subtype, GFP_KERNEL); |
| 1056 | err = -ENOMEM; |
| 1057 | if (!mnt->mnt_sb->s_subtype) |
| 1058 | goto err; |
| 1059 | return mnt; |
| 1060 | |
| 1061 | err: |
| 1062 | mntput(mnt); |
| 1063 | return ERR_PTR(err); |
| 1064 | } |
| 1065 | |
Trond Myklebust | bb4a58b | 2006-06-09 09:34:15 -0400 | [diff] [blame] | 1066 | struct vfsmount * |
| 1067 | do_kern_mount(const char *fstype, int flags, const char *name, void *data) |
| 1068 | { |
| 1069 | struct file_system_type *type = get_fs_type(fstype); |
| 1070 | struct vfsmount *mnt; |
| 1071 | if (!type) |
| 1072 | return ERR_PTR(-ENODEV); |
| 1073 | mnt = vfs_kern_mount(type, flags, name, data); |
Miklos Szeredi | 79c0b2d | 2007-05-08 00:25:43 -0700 | [diff] [blame] | 1074 | if (!IS_ERR(mnt) && (type->fs_flags & FS_HAS_SUBTYPE) && |
| 1075 | !mnt->mnt_sb->s_subtype) |
| 1076 | mnt = fs_set_subtype(mnt, fstype); |
Trond Myklebust | bb4a58b | 2006-06-09 09:34:15 -0400 | [diff] [blame] | 1077 | put_filesystem(type); |
| 1078 | return mnt; |
| 1079 | } |
Al Viro | 8a4e98d | 2008-02-24 01:43:03 -0500 | [diff] [blame] | 1080 | EXPORT_SYMBOL_GPL(do_kern_mount); |
Trond Myklebust | bb4a58b | 2006-06-09 09:34:15 -0400 | [diff] [blame] | 1081 | |
Pavel Emelyanov | 8bf9725 | 2007-10-18 23:40:02 -0700 | [diff] [blame] | 1082 | struct vfsmount *kern_mount_data(struct file_system_type *type, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | { |
Pavel Emelyanov | 8bf9725 | 2007-10-18 23:40:02 -0700 | [diff] [blame] | 1084 | return vfs_kern_mount(type, MS_KERNMOUNT, type->name, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | } |
| 1086 | |
Pavel Emelyanov | 8bf9725 | 2007-10-18 23:40:02 -0700 | [diff] [blame] | 1087 | EXPORT_SYMBOL_GPL(kern_mount_data); |