• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/fs/

Lines Matching refs:mnt

68 static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
70 unsigned long tmp = ((unsigned long)mnt / L1_CACHE_BYTES);
82 static int mnt_alloc_id(struct vfsmount *mnt)
89 res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id);
91 mnt_id_start = mnt->mnt_id + 1;
99 static void mnt_free_id(struct vfsmount *mnt)
101 int id = mnt->mnt_id;
114 static int mnt_alloc_group_id(struct vfsmount *mnt)
123 &mnt->mnt_group_id);
125 mnt_group_start = mnt->mnt_group_id + 1;
133 void mnt_release_group_id(struct vfsmount *mnt)
135 int id = mnt->mnt_group_id;
139 mnt->mnt_group_id = 0;
144 struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
145 if (mnt) {
148 err = mnt_alloc_id(mnt);
153 mnt->mnt_devname = kstrdup(name, GFP_KERNEL);
154 if (!mnt->mnt_devname)
158 atomic_set(&mnt->mnt_count, 1);
159 INIT_LIST_HEAD(&mnt->mnt_hash);
160 INIT_LIST_HEAD(&mnt->mnt_child);
161 INIT_LIST_HEAD(&mnt->mnt_mounts);
162 INIT_LIST_HEAD(&mnt->mnt_list);
163 INIT_LIST_HEAD(&mnt->mnt_expire);
164 INIT_LIST_HEAD(&mnt->mnt_share);
165 INIT_LIST_HEAD(&mnt->mnt_slave_list);
166 INIT_LIST_HEAD(&mnt->mnt_slave);
168 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
171 mnt->mnt_writers = alloc_percpu(int);
172 if (!mnt->mnt_writers)
175 mnt->mnt_writers = 0;
178 return mnt;
182 kfree(mnt->mnt_devname);
185 mnt_free_id(mnt);
187 kmem_cache_free(mnt_cache, mnt);
201 * @mnt: the mount to check for its write status
210 int __mnt_is_readonly(struct vfsmount *mnt)
212 if (mnt->mnt_flags & MNT_READONLY)
214 if (mnt->mnt_sb->s_flags & MS_RDONLY)
220 static inline void inc_mnt_writers(struct vfsmount *mnt)
223 (*per_cpu_ptr(mnt->mnt_writers, smp_processor_id()))++;
225 mnt->mnt_writers++;
229 static inline void dec_mnt_writers(struct vfsmount *mnt)
232 (*per_cpu_ptr(mnt->mnt_writers, smp_processor_id()))--;
234 mnt->mnt_writers--;
238 static unsigned int count_mnt_writers(struct vfsmount *mnt)
245 count += *per_cpu_ptr(mnt->mnt_writers, cpu);
250 return mnt->mnt_writers;
264 * @mnt: the mount on which to take a write
272 int mnt_want_write(struct vfsmount *mnt)
277 inc_mnt_writers(mnt);
284 while (mnt->mnt_flags & MNT_WRITE_HOLD)
292 if (__mnt_is_readonly(mnt)) {
293 dec_mnt_writers(mnt);
305 * @mnt: the mount on which to take a write
315 int mnt_clone_write(struct vfsmount *mnt)
318 if (__mnt_is_readonly(mnt))
321 inc_mnt_writers(mnt);
338 return mnt_want_write(file->f_path.mnt);
340 return mnt_clone_write(file->f_path.mnt);
346 * @mnt: the mount on which to give up write access
352 void mnt_drop_write(struct vfsmount *mnt)
355 dec_mnt_writers(mnt);
360 static int mnt_make_readonly(struct vfsmount *mnt)
365 mnt->mnt_flags |= MNT_WRITE_HOLD;
388 if (count_mnt_writers(mnt) > 0)
391 mnt->mnt_flags |= MNT_READONLY;
397 mnt->mnt_flags &= ~MNT_WRITE_HOLD;
402 static void __mnt_unmake_readonly(struct vfsmount *mnt)
405 mnt->mnt_flags &= ~MNT_READONLY;
409 void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb)
411 mnt->mnt_sb = sb;
412 mnt->mnt_root = dget(sb->s_root);
417 void free_vfsmnt(struct vfsmount *mnt)
419 kfree(mnt->mnt_devname);
420 mnt_free_id(mnt);
422 free_percpu(mnt->mnt_writers);
424 kmem_cache_free(mnt_cache, mnt);
428 * find the first or last mount at @dentry on vfsmount @mnt depending on
432 struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
435 struct list_head *head = mount_hashtable + hash(mnt, dentry);
445 if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) {
462 if ((child_mnt = __lookup_mnt(path->mnt, path->dentry, 1)))
468 static inline int check_mnt(struct vfsmount *mnt)
470 return mnt->mnt_ns == current->nsproxy->mnt_ns;
498 static void detach_mnt(struct vfsmount *mnt, struct path *old_path)
500 old_path->dentry = mnt->mnt_mountpoint;
501 old_path->mnt = mnt->mnt_parent;
502 mnt->mnt_parent = mnt;
503 mnt->mnt_mountpoint = mnt->mnt_root;
504 list_del_init(&mnt->mnt_child);
505 list_del_init(&mnt->mnt_hash);
512 void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
515 child_mnt->mnt_parent = mntget(mnt);
523 static void attach_mnt(struct vfsmount *mnt, struct path *path)
525 mnt_set_mountpoint(path->mnt, path->dentry, mnt);
526 list_add_tail(&mnt->mnt_hash, mount_hashtable +
527 hash(path->mnt, path->dentry));
528 list_add_tail(&mnt->mnt_child, &path->mnt->mnt_mounts);
534 static void commit_tree(struct vfsmount *mnt)
536 struct vfsmount *parent = mnt->mnt_parent;
541 BUG_ON(parent == mnt);
543 list_add_tail(&head, &mnt->mnt_list);
548 list_add_tail(&mnt->mnt_hash, mount_hashtable +
549 hash(parent, mnt->mnt_mountpoint));
550 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
584 struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname);
586 if (mnt) {
588 mnt->mnt_group_id = 0; /* not a peer of original */
590 mnt->mnt_group_id = old->mnt_group_id;
592 if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) {
593 int err = mnt_alloc_group_id(mnt);
598 mnt->mnt_flags = old->mnt_flags;
600 mnt->mnt_sb = sb;
601 mnt->mnt_root = dget(root);
602 mnt->mnt_mountpoint = mnt->mnt_root;
603 mnt->mnt_parent = mnt;
606 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
607 mnt->mnt_master = old;
608 CLEAR_MNT_SHARED(mnt);
611 list_add(&mnt->mnt_share, &old->mnt_share);
613 list_add(&mnt->mnt_slave, &old->mnt_slave);
614 mnt->mnt_master = old->mnt_master;
617 set_mnt_shared(mnt);
623 list_add(&mnt->mnt_expire, &old->mnt_expire);
626 return mnt;
629 free_vfsmnt(mnt);
633 static inline void __mntput(struct vfsmount *mnt)
635 struct super_block *sb = mnt->mnt_sb;
646 WARN_ON(count_mnt_writers(mnt));
647 fsnotify_vfsmount_delete(mnt);
648 dput(mnt->mnt_root);
649 free_vfsmnt(mnt);
653 void mntput_no_expire(struct vfsmount *mnt)
656 if (atomic_add_unless(&mnt->mnt_count, -1, 1))
659 if (!atomic_dec_and_test(&mnt->mnt_count)) {
663 if (likely(!mnt->mnt_pinned)) {
665 __mntput(mnt);
668 atomic_add(mnt->mnt_pinned + 1, &mnt->mnt_count);
669 mnt->mnt_pinned = 0;
671 acct_auto_close_mnt(mnt);
676 void mnt_pin(struct vfsmount *mnt)
679 mnt->mnt_pinned++;
685 void mnt_unpin(struct vfsmount *mnt)
688 if (mnt->mnt_pinned) {
689 atomic_inc(&mnt->mnt_count);
690 mnt->mnt_pinned--;
708 int generic_show_options(struct seq_file *m, struct vfsmount *mnt)
713 options = rcu_dereference(mnt->mnt_sb->s_options);
816 static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt)
830 if (mnt->mnt_flags & fs_infop->flag)
846 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
848 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
850 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
854 show_type(m, mnt->mnt_sb);
855 seq_puts(m, __mnt_is_readonly(mnt) ? " ro" : " rw");
856 err = show_sb_opts(m, mnt->mnt_sb);
859 show_mnt_opts(m, mnt);
860 if (mnt->mnt_sb->s_op->show_options)
861 err = mnt->mnt_sb->s_op->show_options(m, mnt);
877 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
878 struct super_block *sb = mnt->mnt_sb;
879 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
883 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id,
885 seq_dentry(m, mnt->mnt_root, " \t\n\\");
888 if (root.mnt != p->root.mnt || root.dentry != p->root.dentry) {
896 seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
897 show_mnt_opts(m, mnt);
900 if (IS_MNT_SHARED(mnt))
901 seq_printf(m, " shared:%i", mnt->mnt_group_id);
902 if (IS_MNT_SLAVE(mnt)) {
903 int master = mnt->mnt_master->mnt_group_id;
904 int dom = get_dominating_id(mnt, &p->root);
909 if (IS_MNT_UNBINDABLE(mnt))
916 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
922 err = sb->s_op->show_options(m, mnt);
937 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
938 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
942 if (mnt->mnt_devname) {
944 mangle(m, mnt->mnt_devname);
955 show_type(m, mnt->mnt_sb);
958 if (mnt->mnt_sb->s_op->show_stats) {
960 err = mnt->mnt_sb->s_op->show_stats(m, mnt);
977 * @mnt: root of mount tree
983 int may_umount_tree(struct vfsmount *mnt)
990 for (p = mnt; p; p = next_mnt(p, mnt)) {
1006 * @mnt: root of mount
1017 int may_umount(struct vfsmount *mnt)
1022 if (propagate_mount_busy(mnt, 2))
1033 struct vfsmount *mnt;
1035 mnt = list_first_entry(head, struct vfsmount, mnt_hash);
1036 list_del_init(&mnt->mnt_hash);
1037 if (mnt->mnt_parent != mnt) {
1042 dentry = mnt->mnt_mountpoint;
1043 m = mnt->mnt_parent;
1044 mnt->mnt_mountpoint = mnt->mnt_root;
1045 mnt->mnt_parent = mnt;
1051 mntput(mnt);
1059 void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
1063 for (p = mnt; p; p = next_mnt(p, mnt))
1083 static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts);
1085 static int do_umount(struct vfsmount *mnt, int flags)
1087 struct super_block *sb = mnt->mnt_sb;
1091 retval = security_sb_umount(mnt, flags);
1102 if (mnt == current->fs->root.mnt ||
1106 if (atomic_read(&mnt->mnt_count) != 2)
1109 if (!xchg(&mnt->mnt_expiry_mark, 1))
1136 if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) {
1153 shrink_submounts(mnt, &umount_list);
1156 if (flags & MNT_DETACH || !propagate_mount_busy(mnt, 2)) {
1157 if (!list_empty(&mnt->mnt_list))
1158 umount_tree(mnt, 1, &umount_list);
1191 if (path.dentry != path.mnt->mnt_root)
1193 if (!check_mnt(path.mnt))
1200 retval = do_umount(path.mnt, flags);
1204 mntput_no_expire(path.mnt);
1239 struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1245 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt))
1248 res = q = clone_mnt(mnt, dentry, flag);
1251 q->mnt_mountpoint = mnt->mnt_mountpoint;
1253 p = mnt;
1254 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {
1268 path.mnt = q;
1295 tree = copy_tree(path->mnt, path->dentry, CL_COPY_ALL | CL_PRIVATE);
1300 void drop_collected_mounts(struct vfsmount *mnt)
1305 umount_tree(mnt, 0, &umount_list);
1314 struct vfsmount *mnt;
1318 list_for_each_entry(mnt, &root->mnt_list, mnt_list) {
1319 res = f(mnt, arg);
1326 static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end)
1330 for (p = mnt; p != end; p = next_mnt(p, mnt)) {
1336 static int invent_group_ids(struct vfsmount *mnt, bool recurse)
1340 for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) {
1344 cleanup_group_ids(mnt, p);
1420 struct vfsmount *dest_mnt = path->mnt;
1443 touch_mnt_namespace(parent_path->mnt->mnt_ns);
1464 static int graft_tree(struct vfsmount *mnt, struct path *path)
1467 if (mnt->mnt_sb->s_flags & MS_NOUSER)
1471 S_ISDIR(mnt->mnt_root->d_inode->i_mode))
1480 err = attach_recursive_mnt(mnt, path, NULL);
1508 struct vfsmount *m, *mnt = path->mnt;
1516 if (path->dentry != path->mnt->mnt_root)
1525 err = invent_group_ids(mnt, recurse);
1531 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
1547 struct vfsmount *mnt = NULL;
1559 if (IS_MNT_UNBINDABLE(old_path.mnt))
1562 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt))
1567 mnt = copy_tree(old_path.mnt, old_path.dentry, 0);
1569 mnt = clone_mnt(old_path.mnt, old_path.dentry, 0);
1571 if (!mnt)
1574 err = graft_tree(mnt, path);
1579 umount_tree(mnt, 0, &umount_list);
1590 static int change_mount_flags(struct vfsmount *mnt, int ms_flags)
1597 if (readonly_request == __mnt_is_readonly(mnt))
1601 error = mnt_make_readonly(mnt);
1603 __mnt_unmake_readonly(mnt);
1616 struct super_block *sb = path->mnt->mnt_sb;
1621 if (!check_mnt(path->mnt))
1624 if (path->dentry != path->mnt->mnt_root)
1629 err = change_mount_flags(path->mnt, flags);
1634 mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK;
1635 path->mnt->mnt_flags = mnt_flags;
1641 touch_mnt_namespace(path->mnt->mnt_ns);
1647 static inline int tree_contains_unbindable(struct vfsmount *mnt)
1650 for (p = mnt; p; p = next_mnt(p, mnt)) {
1675 if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt))
1687 if (old_path.dentry != old_path.mnt->mnt_root)
1690 if (old_path.mnt == old_path.mnt->mnt_parent)
1699 if (old_path.mnt->mnt_parent &&
1700 IS_MNT_SHARED(old_path.mnt->mnt_parent))
1706 if (IS_MNT_SHARED(path->mnt) &&
1707 tree_contains_unbindable(old_path.mnt))
1710 for (p = path->mnt; p->mnt_parent != p; p = p->mnt_parent)
1711 if (p == old_path.mnt)
1714 err = attach_recursive_mnt(old_path.mnt, path, &parent_path);
1720 list_del_init(&old_path.mnt->mnt_expire);
1738 struct vfsmount *mnt;
1748 mnt = do_kern_mount(type, flags, name, data);
1750 if (IS_ERR(mnt))
1751 return PTR_ERR(mnt);
1753 return do_add_mount(mnt, path, mnt_flags, NULL);
1773 if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt))
1778 if (path->mnt->mnt_sb == newmnt->mnt_sb &&
1779 path->mnt->mnt_root == path->dentry)
1811 struct vfsmount *mnt, *next;
1827 list_for_each_entry_safe(mnt, next, mounts, mnt_expire) {
1828 if (!xchg(&mnt->mnt_expiry_mark, 1) ||
1829 propagate_mount_busy(mnt, 1))
1831 list_move(&mnt->mnt_expire, &graveyard);
1834 mnt = list_first_entry(&graveyard, struct vfsmount, mnt_expire);
1835 touch_mnt_namespace(mnt->mnt_ns);
1836 umount_tree(mnt, 1, &umounts);
1863 struct vfsmount *mnt = list_entry(tmp, struct vfsmount, mnt_child);
1866 if (!(mnt->mnt_flags & MNT_SHRINKABLE))
1871 if (!list_empty(&mnt->mnt_mounts)) {
1872 this_parent = mnt;
1876 if (!propagate_mount_busy(mnt, 1)) {
1877 list_move_tail(&mnt->mnt_expire, graveyard);
1898 static void shrink_submounts(struct vfsmount *mnt, struct list_head *umounts)
1904 while (select_submounts(mnt, &graveyard)) {
2129 if (p == fs->root.mnt) {
2131 fs->root.mnt = mntget(q);
2133 if (p == fs->pwd.mnt) {
2135 fs->pwd.mnt = mntget(q);
2170 * @mnt: pointer to the new root filesystem mountpoint
2172 struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt)
2178 mnt->mnt_ns = new_ns;
2179 new_ns->root = mnt;
2266 if (!check_mnt(new.mnt))
2283 if (IS_MNT_SHARED(old.mnt) ||
2284 IS_MNT_SHARED(new.mnt->mnt_parent) ||
2285 IS_MNT_SHARED(root.mnt->mnt_parent))
2287 if (!check_mnt(root.mnt))
2297 if (new.mnt == root.mnt ||
2298 old.mnt == root.mnt)
2301 if (root.mnt->mnt_root != root.dentry)
2303 if (root.mnt->mnt_parent == root.mnt)
2305 if (new.mnt->mnt_root != new.dentry)
2307 if (new.mnt->mnt_parent == new.mnt)
2310 tmp = old.mnt;
2312 if (tmp != new.mnt) {
2316 if (tmp->mnt_parent == new.mnt)
2324 detach_mnt(new.mnt, &parent_path);
2325 detach_mnt(root.mnt, &root_parent);
2327 attach_mnt(root.mnt, &old);
2329 attach_mnt(new.mnt, &root_parent);
2352 struct vfsmount *mnt;
2356 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
2357 if (IS_ERR(mnt))
2359 ns = create_mnt_ns(mnt);
2366 root.mnt = ns->root;