aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-24 18:57:30 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-03 22:56:58 -0500
commit315fc83e56c6998f67af24b49c619f40a6ff2803 (patch)
tree5fc9270118d0c4a6a89a619715c5acb0bd881956 /fs
parent61ef47b1e4ba9f2b939e6772e2f96082df0ae7eb (diff)
vfs: spread struct mount - namespace.c internal iterators
next_mnt() return value, first argument skip_mnt_tree() return value and argument Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namespace.c145
1 files changed, 74 insertions, 71 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 398eb2421494..7226dc514b3b 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -632,28 +632,28 @@ static void commit_tree(struct vfsmount *mnt)
632 touch_mnt_namespace(n); 632 touch_mnt_namespace(n);
633} 633}
634 634
635static struct vfsmount *next_mnt(struct vfsmount *p, struct vfsmount *root) 635static struct mount *next_mnt(struct mount *p, struct vfsmount *root)
636{ 636{
637 struct list_head *next = p->mnt_mounts.next; 637 struct list_head *next = p->mnt.mnt_mounts.next;
638 if (next == &p->mnt_mounts) { 638 if (next == &p->mnt.mnt_mounts) {
639 while (1) { 639 while (1) {
640 if (p == root) 640 if (&p->mnt == root)
641 return NULL; 641 return NULL;
642 next = p->mnt_child.next; 642 next = p->mnt.mnt_child.next;
643 if (next != &p->mnt_parent->mnt_mounts) 643 if (next != &p->mnt.mnt_parent->mnt_mounts)
644 break; 644 break;
645 p = p->mnt_parent; 645 p = real_mount(p->mnt.mnt_parent);
646 } 646 }
647 } 647 }
648 return list_entry(next, struct vfsmount, mnt_child); 648 return list_entry(next, struct mount, mnt.mnt_child);
649} 649}
650 650
651static struct vfsmount *skip_mnt_tree(struct vfsmount *p) 651static struct mount *skip_mnt_tree(struct mount *p)
652{ 652{
653 struct list_head *prev = p->mnt_mounts.prev; 653 struct list_head *prev = p->mnt.mnt_mounts.prev;
654 while (prev != &p->mnt_mounts) { 654 while (prev != &p->mnt.mnt_mounts) {
655 p = list_entry(prev, struct vfsmount, mnt_child); 655 p = list_entry(prev, struct mount, mnt.mnt_child);
656 prev = p->mnt_mounts.prev; 656 prev = p->mnt.mnt_mounts.prev;
657 } 657 }
658 return p; 658 return p;
659} 659}
@@ -1144,12 +1144,13 @@ int may_umount_tree(struct vfsmount *mnt)
1144{ 1144{
1145 int actual_refs = 0; 1145 int actual_refs = 0;
1146 int minimum_refs = 0; 1146 int minimum_refs = 0;
1147 struct vfsmount *p; 1147 struct mount *p;
1148 BUG_ON(!mnt);
1148 1149
1149 /* write lock needed for mnt_get_count */ 1150 /* write lock needed for mnt_get_count */
1150 br_write_lock(vfsmount_lock); 1151 br_write_lock(vfsmount_lock);
1151 for (p = mnt; p; p = next_mnt(p, mnt)) { 1152 for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) {
1152 actual_refs += mnt_get_count(p); 1153 actual_refs += mnt_get_count(&p->mnt);
1153 minimum_refs += 2; 1154 minimum_refs += 2;
1154 } 1155 }
1155 br_write_unlock(vfsmount_lock); 1156 br_write_unlock(vfsmount_lock);
@@ -1220,26 +1221,26 @@ void release_mounts(struct list_head *head)
1220void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill) 1221void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
1221{ 1222{
1222 LIST_HEAD(tmp_list); 1223 LIST_HEAD(tmp_list);
1223 struct vfsmount *p; 1224 struct mount *p;
1224 1225
1225 for (p = mnt; p; p = next_mnt(p, mnt)) 1226 for (p = real_mount(mnt); p; p = next_mnt(p, mnt))
1226 list_move(&p->mnt_hash, &tmp_list); 1227 list_move(&p->mnt.mnt_hash, &tmp_list);
1227 1228
1228 if (propagate) 1229 if (propagate)
1229 propagate_umount(&tmp_list); 1230 propagate_umount(&tmp_list);
1230 1231
1231 list_for_each_entry(p, &tmp_list, mnt_hash) { 1232 list_for_each_entry(p, &tmp_list, mnt.mnt_hash) {
1232 list_del_init(&p->mnt_expire); 1233 list_del_init(&p->mnt.mnt_expire);
1233 list_del_init(&p->mnt_list); 1234 list_del_init(&p->mnt.mnt_list);
1234 __touch_mnt_namespace(p->mnt_ns); 1235 __touch_mnt_namespace(p->mnt.mnt_ns);
1235 p->mnt_ns = NULL; 1236 p->mnt.mnt_ns = NULL;
1236 __mnt_make_shortterm(p); 1237 __mnt_make_shortterm(&p->mnt);
1237 list_del_init(&p->mnt_child); 1238 list_del_init(&p->mnt.mnt_child);
1238 if (mnt_has_parent(p)) { 1239 if (mnt_has_parent(&p->mnt)) {
1239 p->mnt_parent->mnt_ghosts++; 1240 p->mnt.mnt_parent->mnt_ghosts++;
1240 dentry_reset_mounted(p->mnt_mountpoint); 1241 dentry_reset_mounted(p->mnt.mnt_mountpoint);
1241 } 1242 }
1242 change_mnt_propagation(p, MS_PRIVATE); 1243 change_mnt_propagation(&p->mnt, MS_PRIVATE);
1243 } 1244 }
1244 list_splice(&tmp_list, kill); 1245 list_splice(&tmp_list, kill);
1245} 1246}
@@ -1411,7 +1412,7 @@ static int mount_is_safe(struct path *path)
1411struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry, 1412struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1412 int flag) 1413 int flag)
1413{ 1414{
1414 struct vfsmount *res, *p, *q, *r, *s; 1415 struct vfsmount *res, *p, *q, *r;
1415 struct path path; 1416 struct path path;
1416 1417
1417 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt)) 1418 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(mnt))
@@ -1424,19 +1425,20 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
1424 1425
1425 p = mnt; 1426 p = mnt;
1426 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) { 1427 list_for_each_entry(r, &mnt->mnt_mounts, mnt_child) {
1428 struct mount *s;
1427 if (!is_subdir(r->mnt_mountpoint, dentry)) 1429 if (!is_subdir(r->mnt_mountpoint, dentry))
1428 continue; 1430 continue;
1429 1431
1430 for (s = r; s; s = next_mnt(s, r)) { 1432 for (s = real_mount(r); s; s = next_mnt(s, r)) {
1431 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(s)) { 1433 if (!(flag & CL_COPY_ALL) && IS_MNT_UNBINDABLE(&s->mnt)) {
1432 s = skip_mnt_tree(s); 1434 s = skip_mnt_tree(s);
1433 continue; 1435 continue;
1434 } 1436 }
1435 while (p != s->mnt_parent) { 1437 while (p != s->mnt.mnt_parent) {
1436 p = p->mnt_parent; 1438 p = p->mnt_parent;
1437 q = q->mnt_parent; 1439 q = q->mnt_parent;
1438 } 1440 }
1439 p = s; 1441 p = &s->mnt;
1440 path.mnt = q; 1442 path.mnt = q;
1441 path.dentry = p->mnt_mountpoint; 1443 path.dentry = p->mnt_mountpoint;
1442 q = clone_mnt(p, p->mnt_root, flag); 1444 q = clone_mnt(p, p->mnt_root, flag);
@@ -1497,23 +1499,23 @@ int iterate_mounts(int (*f)(struct vfsmount *, void *), void *arg,
1497 1499
1498static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end) 1500static void cleanup_group_ids(struct vfsmount *mnt, struct vfsmount *end)
1499{ 1501{
1500 struct vfsmount *p; 1502 struct mount *p;
1501 1503
1502 for (p = mnt; p != end; p = next_mnt(p, mnt)) { 1504 for (p = real_mount(mnt); &p->mnt != end; p = next_mnt(p, mnt)) {
1503 if (p->mnt_group_id && !IS_MNT_SHARED(p)) 1505 if (p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt))
1504 mnt_release_group_id(p); 1506 mnt_release_group_id(&p->mnt);
1505 } 1507 }
1506} 1508}
1507 1509
1508static int invent_group_ids(struct vfsmount *mnt, bool recurse) 1510static int invent_group_ids(struct vfsmount *mnt, bool recurse)
1509{ 1511{
1510 struct vfsmount *p; 1512 struct mount *p;
1511 1513
1512 for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) { 1514 for (p = real_mount(mnt); p; p = recurse ? next_mnt(p, mnt) : NULL) {
1513 if (!p->mnt_group_id && !IS_MNT_SHARED(p)) { 1515 if (!p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) {
1514 int err = mnt_alloc_group_id(p); 1516 int err = mnt_alloc_group_id(&p->mnt);
1515 if (err) { 1517 if (err) {
1516 cleanup_group_ids(mnt, p); 1518 cleanup_group_ids(mnt, &p->mnt);
1517 return err; 1519 return err;
1518 } 1520 }
1519 } 1521 }
@@ -1591,7 +1593,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1591 LIST_HEAD(tree_list); 1593 LIST_HEAD(tree_list);
1592 struct vfsmount *dest_mnt = path->mnt; 1594 struct vfsmount *dest_mnt = path->mnt;
1593 struct dentry *dest_dentry = path->dentry; 1595 struct dentry *dest_dentry = path->dentry;
1594 struct vfsmount *child, *p; 1596 struct mount *child, *p;
1595 int err; 1597 int err;
1596 1598
1597 if (IS_MNT_SHARED(dest_mnt)) { 1599 if (IS_MNT_SHARED(dest_mnt)) {
@@ -1606,8 +1608,8 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1606 br_write_lock(vfsmount_lock); 1608 br_write_lock(vfsmount_lock);
1607 1609
1608 if (IS_MNT_SHARED(dest_mnt)) { 1610 if (IS_MNT_SHARED(dest_mnt)) {
1609 for (p = source_mnt; p; p = next_mnt(p, source_mnt)) 1611 for (p = real_mount(source_mnt); p; p = next_mnt(p, source_mnt))
1610 set_mnt_shared(p); 1612 set_mnt_shared(&p->mnt);
1611 } 1613 }
1612 if (parent_path) { 1614 if (parent_path) {
1613 detach_mnt(source_mnt, parent_path); 1615 detach_mnt(source_mnt, parent_path);
@@ -1618,9 +1620,9 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
1618 commit_tree(source_mnt); 1620 commit_tree(source_mnt);
1619 } 1621 }
1620 1622
1621 list_for_each_entry_safe(child, p, &tree_list, mnt_hash) { 1623 list_for_each_entry_safe(child, p, &tree_list, mnt.mnt_hash) {
1622 list_del_init(&child->mnt_hash); 1624 list_del_init(&child->mnt.mnt_hash);
1623 commit_tree(child); 1625 commit_tree(&child->mnt);
1624 } 1626 }
1625 br_write_unlock(vfsmount_lock); 1627 br_write_unlock(vfsmount_lock);
1626 1628
@@ -1697,7 +1699,8 @@ static int flags_to_propagation_type(int flags)
1697 */ 1699 */
1698static int do_change_type(struct path *path, int flag) 1700static int do_change_type(struct path *path, int flag)
1699{ 1701{
1700 struct vfsmount *m, *mnt = path->mnt; 1702 struct mount *m;
1703 struct vfsmount *mnt = path->mnt;
1701 int recurse = flag & MS_REC; 1704 int recurse = flag & MS_REC;
1702 int type; 1705 int type;
1703 int err = 0; 1706 int err = 0;
@@ -1720,8 +1723,8 @@ static int do_change_type(struct path *path, int flag)
1720 } 1723 }
1721 1724
1722 br_write_lock(vfsmount_lock); 1725 br_write_lock(vfsmount_lock);
1723 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) 1726 for (m = real_mount(mnt); m; m = (recurse ? next_mnt(m, mnt) : NULL))
1724 change_mnt_propagation(m, type); 1727 change_mnt_propagation(&m->mnt, type);
1725 br_write_unlock(vfsmount_lock); 1728 br_write_unlock(vfsmount_lock);
1726 1729
1727 out_unlock: 1730 out_unlock:
@@ -1844,9 +1847,9 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1844 1847
1845static inline int tree_contains_unbindable(struct vfsmount *mnt) 1848static inline int tree_contains_unbindable(struct vfsmount *mnt)
1846{ 1849{
1847 struct vfsmount *p; 1850 struct mount *p;
1848 for (p = mnt; p; p = next_mnt(p, mnt)) { 1851 for (p = real_mount(mnt); p; p = next_mnt(p, mnt)) {
1849 if (IS_MNT_UNBINDABLE(p)) 1852 if (IS_MNT_UNBINDABLE(&p->mnt))
1850 return 1; 1853 return 1;
1851 } 1854 }
1852 return 0; 1855 return 0;
@@ -2379,7 +2382,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2379{ 2382{
2380 struct mnt_namespace *new_ns; 2383 struct mnt_namespace *new_ns;
2381 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL; 2384 struct vfsmount *rootmnt = NULL, *pwdmnt = NULL;
2382 struct vfsmount *p, *q; 2385 struct mount *p, *q;
2383 2386
2384 new_ns = alloc_mnt_ns(); 2387 new_ns = alloc_mnt_ns();
2385 if (IS_ERR(new_ns)) 2388 if (IS_ERR(new_ns))
@@ -2403,23 +2406,23 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2403 * as belonging to new namespace. We have already acquired a private 2406 * as belonging to new namespace. We have already acquired a private
2404 * fs_struct, so tsk->fs->lock is not needed. 2407 * fs_struct, so tsk->fs->lock is not needed.
2405 */ 2408 */
2406 p = mnt_ns->root; 2409 p = real_mount(mnt_ns->root);
2407 q = new_ns->root; 2410 q = real_mount(new_ns->root);
2408 while (p) { 2411 while (p) {
2409 q->mnt_ns = new_ns; 2412 q->mnt.mnt_ns = new_ns;
2410 __mnt_make_longterm(q); 2413 __mnt_make_longterm(&q->mnt);
2411 if (fs) { 2414 if (fs) {
2412 if (p == fs->root.mnt) { 2415 if (&p->mnt == fs->root.mnt) {
2413 fs->root.mnt = mntget(q); 2416 fs->root.mnt = mntget(&q->mnt);
2414 __mnt_make_longterm(q); 2417 __mnt_make_longterm(&q->mnt);
2415 mnt_make_shortterm(p); 2418 mnt_make_shortterm(&p->mnt);
2416 rootmnt = p; 2419 rootmnt = &p->mnt;
2417 } 2420 }
2418 if (p == fs->pwd.mnt) { 2421 if (&p->mnt == fs->pwd.mnt) {
2419 fs->pwd.mnt = mntget(q); 2422 fs->pwd.mnt = mntget(&q->mnt);
2420 __mnt_make_longterm(q); 2423 __mnt_make_longterm(&q->mnt);
2421 mnt_make_shortterm(p); 2424 mnt_make_shortterm(&p->mnt);
2422 pwdmnt = p; 2425 pwdmnt = &p->mnt;
2423 } 2426 }
2424 } 2427 }
2425 p = next_mnt(p, mnt_ns->root); 2428 p = next_mnt(p, mnt_ns->root);