Commit c71053659e3bb27d44b79da0bb4abf5838c2060a

Authored by Al Viro
1 parent 7d6fec45a5

vfs: spread struct mount - __lookup_mnt() result

switch __lookup_mnt() to returning struct mount *; callers adjusted.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 5 changed files with 31 additions and 22 deletions Side-by-side Diff

... ... @@ -15,6 +15,7 @@
15 15 struct file_system_type;
16 16 struct linux_binprm;
17 17 struct path;
  18 +struct mount;
18 19  
19 20 /*
20 21 * block_dev.c
... ... @@ -46,7 +47,6 @@
46 47 extern int copy_mount_options(const void __user *, unsigned long *);
47 48 extern int copy_mount_string(const void __user *, char **);
48 49  
49   -extern struct vfsmount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
50 50 extern struct vfsmount *lookup_mnt(struct path *);
51 51 extern int finish_automount(struct vfsmount *, struct path *);
52 52  
... ... @@ -13,4 +13,6 @@
13 13 {
14 14 return mnt != mnt->mnt_parent;
15 15 }
  16 +
  17 +extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
... ... @@ -36,6 +36,7 @@
36 36 #include <asm/uaccess.h>
37 37  
38 38 #include "internal.h"
  39 +#include "mount.h"
39 40  
40 41 /* [Feb-1997 T. Schoebel-Theuer]
41 42 * Fundamental changes in the pathname lookup mechanisms (namei)
... ... @@ -884,7 +885,7 @@
884 885 struct inode **inode)
885 886 {
886 887 for (;;) {
887   - struct vfsmount *mounted;
  888 + struct mount *mounted;
888 889 /*
889 890 * Don't forget we might have a non-mountpoint managed dentry
890 891 * that wants to block transit.
... ... @@ -898,8 +899,8 @@
898 899 mounted = __lookup_mnt(path->mnt, path->dentry, 1);
899 900 if (!mounted)
900 901 break;
901   - path->mnt = mounted;
902   - path->dentry = mounted->mnt_root;
  902 + path->mnt = &mounted->mnt;
  903 + path->dentry = mounted->mnt.mnt_root;
903 904 nd->flags |= LOOKUP_JUMPED;
904 905 nd->seq = read_seqcount_begin(&path->dentry->d_seq);
905 906 /*
906 907  
... ... @@ -915,12 +916,12 @@
915 916 static void follow_mount_rcu(struct nameidata *nd)
916 917 {
917 918 while (d_mountpoint(nd->path.dentry)) {
918   - struct vfsmount *mounted;
  919 + struct mount *mounted;
919 920 mounted = __lookup_mnt(nd->path.mnt, nd->path.dentry, 1);
920 921 if (!mounted)
921 922 break;
922   - nd->path.mnt = mounted;
923   - nd->path.dentry = mounted->mnt_root;
  923 + nd->path.mnt = &mounted->mnt;
  924 + nd->path.dentry = mounted->mnt.mnt_root;
924 925 nd->seq = read_seqcount_begin(&nd->path.dentry->d_seq);
925 926 }
926 927 }
... ... @@ -464,20 +464,20 @@
464 464 * @dir. If @dir is set return the first mount else return the last mount.
465 465 * vfsmount_lock must be held for read or write.
466 466 */
467   -struct vfsmount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
  467 +struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
468 468 int dir)
469 469 {
470 470 struct list_head *head = mount_hashtable + hash(mnt, dentry);
471 471 struct list_head *tmp = head;
472   - struct vfsmount *p, *found = NULL;
  472 + struct mount *p, *found = NULL;
473 473  
474 474 for (;;) {
475 475 tmp = dir ? tmp->next : tmp->prev;
476 476 p = NULL;
477 477 if (tmp == head)
478 478 break;
479   - p = list_entry(tmp, struct vfsmount, mnt_hash);
480   - if (p->mnt_parent == mnt && p->mnt_mountpoint == dentry) {
  479 + p = list_entry(tmp, struct mount, mnt.mnt_hash);
  480 + if (p->mnt.mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) {
481 481 found = p;
482 482 break;
483 483 }
484 484  
... ... @@ -491,13 +491,18 @@
491 491 */
492 492 struct vfsmount *lookup_mnt(struct path *path)
493 493 {
494   - struct vfsmount *child_mnt;
  494 + struct mount *child_mnt;
495 495  
496 496 br_read_lock(vfsmount_lock);
497   - if ((child_mnt = __lookup_mnt(path->mnt, path->dentry, 1)))
498   - mntget(child_mnt);
499   - br_read_unlock(vfsmount_lock);
500   - return child_mnt;
  497 + child_mnt = __lookup_mnt(path->mnt, path->dentry, 1);
  498 + if (child_mnt) {
  499 + mnt_add_count(child_mnt, 1);
  500 + br_read_unlock(vfsmount_lock);
  501 + return &child_mnt->mnt;
  502 + } else {
  503 + br_read_unlock(vfsmount_lock);
  504 + return NULL;
  505 + }
501 506 }
502 507  
503 508 static inline int check_mnt(struct vfsmount *mnt)
... ... @@ -289,7 +289,8 @@
289 289 */
290 290 int propagate_mount_busy(struct vfsmount *mnt, int refcnt)
291 291 {
292   - struct vfsmount *m, *child;
  292 + struct vfsmount *m;
  293 + struct mount *child;
293 294 struct vfsmount *parent = mnt->mnt_parent;
294 295 int ret = 0;
295 296  
... ... @@ -307,8 +308,8 @@
307 308 for (m = propagation_next(parent, parent); m;
308 309 m = propagation_next(m, parent)) {
309 310 child = __lookup_mnt(m, mnt->mnt_mountpoint, 0);
310   - if (child && list_empty(&child->mnt_mounts) &&
311   - (ret = do_refcount_check(child, 1)))
  311 + if (child && list_empty(&child->mnt.mnt_mounts) &&
  312 + (ret = do_refcount_check(&child->mnt, 1)))
312 313 break;
313 314 }
314 315 return ret;
315 316  
... ... @@ -328,14 +329,14 @@
328 329 for (m = propagation_next(parent, parent); m;
329 330 m = propagation_next(m, parent)) {
330 331  
331   - struct vfsmount *child = __lookup_mnt(m,
  332 + struct mount *child = __lookup_mnt(m,
332 333 mnt->mnt_mountpoint, 0);
333 334 /*
334 335 * umount the child only if the child has no
335 336 * other children
336 337 */
337   - if (child && list_empty(&child->mnt_mounts))
338   - list_move_tail(&child->mnt_hash, &mnt->mnt_hash);
  338 + if (child && list_empty(&child->mnt.mnt_mounts))
  339 + list_move_tail(&child->mnt.mnt_hash, &mnt->mnt_hash);
339 340 }
340 341 }
341 342