Lines Matching +full:parent +full:- +full:child

1 // SPDX-License-Identifier: GPL-2.0-only
19 return list_entry(p->mnt_share.next, struct mount, mnt_share); in next_peer()
24 return list_entry(p->mnt_slave_list.next, struct mount, mnt_slave); in first_slave()
29 return list_entry(p->mnt_slave_list.prev, struct mount, mnt_slave); in last_slave()
34 return list_entry(p->mnt_slave.next, struct mount, mnt_slave); in next_slave()
45 if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) in get_peer_under_root()
64 for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { in get_dominating_id()
65 struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root); in get_dominating_id()
67 return d->mnt_group_id; in get_dominating_id()
77 if (list_empty(&mnt->mnt_share)) { in do_make_slave()
82 master = mnt->mnt_master; in do_make_slave()
84 struct list_head *p = &mnt->mnt_slave_list; in do_make_slave()
88 list_del_init(&slave_mnt->mnt_slave); in do_make_slave()
89 slave_mnt->mnt_master = NULL; in do_make_slave()
101 if (m->mnt.mnt_root == mnt->mnt.mnt_root) { in do_make_slave()
106 list_del_init(&mnt->mnt_share); in do_make_slave()
107 mnt->mnt_group_id = 0; in do_make_slave()
110 list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave) in do_make_slave()
111 slave_mnt->mnt_master = master; in do_make_slave()
112 list_move(&mnt->mnt_slave, &master->mnt_slave_list); in do_make_slave()
113 list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev); in do_make_slave()
114 INIT_LIST_HEAD(&mnt->mnt_slave_list); in do_make_slave()
115 mnt->mnt_master = master; in do_make_slave()
130 list_del_init(&mnt->mnt_slave); in change_mnt_propagation()
131 mnt->mnt_master = NULL; in change_mnt_propagation()
133 mnt->mnt.mnt_flags |= MNT_UNBINDABLE; in change_mnt_propagation()
135 mnt->mnt.mnt_flags &= ~MNT_UNBINDABLE; in change_mnt_propagation()
153 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) in propagation_next()
157 struct mount *master = m->mnt_master; in propagation_next()
159 if (master == origin->mnt_master) { in propagation_next()
162 } else if (m->mnt_slave.next != &master->mnt_slave_list) in propagation_next()
177 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) in skip_propagation_subtree()
188 if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) in next_group()
191 if (m->mnt_group_id == origin->mnt_group_id) { in next_group()
194 } else if (m->mnt_slave.next != &next->mnt_slave) in next_group()
200 struct mount *master = m->mnt_master; in next_group()
201 if (m->mnt_slave.next != &master->mnt_slave_list) in next_group()
204 if (master->mnt_group_id == origin->mnt_group_id) in next_group()
206 if (master->mnt_slave.next == &m->mnt_slave) in next_group()
222 return m1->mnt_group_id == m2->mnt_group_id && m1->mnt_group_id; in peers()
227 struct mount *child; in propagate_one() local
233 if (!is_subdir(mp->m_dentry, m->mnt.mnt_root)) in propagate_one()
241 p = n->mnt_master; in propagate_one()
246 struct mount *parent = last_source->mnt_parent; in propagate_one() local
249 done = parent->mnt_master == p; in propagate_one()
250 if (done && peers(n, parent)) in propagate_one()
252 last_source = last_source->mnt_master; in propagate_one()
261 child = copy_tree(last_source, last_source->mnt.mnt_root, type); in propagate_one()
262 if (IS_ERR(child)) in propagate_one()
263 return PTR_ERR(child); in propagate_one()
265 mnt_set_mountpoint(m, mp, child); in propagate_one()
266 if (m->mnt_master != dest_master) in propagate_one()
267 SET_MNT_MARK(m->mnt_master); in propagate_one()
270 last_source = child; in propagate_one()
271 hlist_add_head(&child->mnt_hash, list); in propagate_one()
272 return count_mounts(m->mnt_ns, child); in propagate_one()
280 * source_mnt. Also link all the new mounts using ->mnt_list
281 * headed at source_mnt's ->mnt_list
304 dest_master = dest_mnt->mnt_master; in propagate_mnt()
328 m = n->mnt_parent; in propagate_mnt()
329 if (m->mnt_master != dest_mnt->mnt_master) in propagate_mnt()
330 CLEAR_MNT_MARK(m->mnt_master); in propagate_mnt()
339 struct mount *child; in find_topper() local
341 if (!list_is_singular(&mnt->mnt_mounts)) in find_topper()
344 child = list_first_entry(&mnt->mnt_mounts, struct mount, mnt_child); in find_topper()
345 if (child->mnt_mountpoint != mnt->mnt.mnt_root) in find_topper()
348 return child; in find_topper()
363 * other mounts its parent propagates to.
371 struct mount *m, *child, *topper; in propagate_mount_busy() local
372 struct mount *parent = mnt->mnt_parent; in propagate_mount_busy() local
374 if (mnt == parent) in propagate_mount_busy()
382 if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt)) in propagate_mount_busy()
385 for (m = propagation_next(parent, parent); m; in propagate_mount_busy()
386 m = propagation_next(m, parent)) { in propagate_mount_busy()
388 child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint); in propagate_mount_busy()
389 if (!child) in propagate_mount_busy()
392 /* Is there exactly one mount on the child that covers in propagate_mount_busy()
395 topper = find_topper(child); in propagate_mount_busy()
398 else if (!list_empty(&child->mnt_mounts)) in propagate_mount_busy()
401 if (do_refcount_check(child, count)) in propagate_mount_busy()
414 struct mount *parent = mnt->mnt_parent; in propagate_mount_unlock() local
415 struct mount *m, *child; in propagate_mount_unlock() local
417 BUG_ON(parent == mnt); in propagate_mount_unlock()
419 for (m = propagation_next(parent, parent); m; in propagate_mount_unlock()
420 m = propagation_next(m, parent)) { in propagate_mount_unlock()
421 child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint); in propagate_mount_unlock()
422 if (child) in propagate_mount_unlock()
423 child->mnt.mnt_flags &= ~MNT_LOCKED; in propagate_mount_unlock()
430 mnt->mnt.mnt_flags |= MNT_UMOUNT; in umount_one()
431 list_del_init(&mnt->mnt_child); in umount_one()
432 list_del_init(&mnt->mnt_umounting); in umount_one()
433 list_move_tail(&mnt->mnt_list, to_umount); in umount_one()
438 * parent propagates to.
445 struct mount *child; in __propagate_umount() local
448 * The state of the parent won't change if this mount is in __propagate_umount()
451 if (mnt->mnt.mnt_flags & (MNT_UMOUNT | MNT_MARKED)) in __propagate_umount()
457 list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) { in __propagate_umount()
458 if (child->mnt_mountpoint == mnt->mnt.mnt_root) in __propagate_umount()
460 if (!list_empty(&child->mnt_umounting) && IS_MNT_MARKED(child)) in __propagate_umount()
462 /* Found a mounted child */ in __propagate_umount()
475 list_move_tail(&mnt->mnt_umounting, to_restore); in __propagate_umount()
484 struct mount *mnt, *child, *tmp; in umount_list() local
486 list_for_each_entry_safe(child, tmp, &mnt->mnt_mounts, mnt_child) { in umount_list()
488 if (child->mnt_mountpoint == mnt->mnt.mnt_root) in umount_list()
489 list_move_tail(&child->mnt_umounting, to_restore); in umount_list()
491 umount_one(child, to_umount); in umount_list()
500 struct mount *mnt, *parent; in restore_mounts() local
505 list_del_init(&mnt->mnt_umounting); in restore_mounts()
508 mp = mnt->mnt_mp; in restore_mounts()
509 parent = mnt->mnt_parent; in restore_mounts()
510 while (parent->mnt.mnt_flags & MNT_UMOUNT) { in restore_mounts()
511 mp = parent->mnt_mp; in restore_mounts()
512 parent = parent->mnt_parent; in restore_mounts()
514 if (parent != mnt->mnt_parent) in restore_mounts()
515 mnt_change_mountpoint(parent, mp, mnt); in restore_mounts()
524 list_del_init(&mnt->mnt_umounting); in cleanup_umount_visitations()
544 struct mount *parent = mnt->mnt_parent; in propagate_umount() local
553 if (!list_empty(&mnt->mnt_umounting)) in propagate_umount()
556 list_add_tail(&mnt->mnt_umounting, &visited); in propagate_umount()
557 for (m = propagation_next(parent, parent); m; in propagate_umount()
558 m = propagation_next(m, parent)) { in propagate_umount()
559 struct mount *child = __lookup_mnt(&m->mnt, in propagate_umount() local
560 mnt->mnt_mountpoint); in propagate_umount()
561 if (!child) in propagate_umount()
564 if (!list_empty(&child->mnt_umounting)) { in propagate_umount()
566 * If the child has already been visited it is in propagate_umount()
572 m = skip_propagation_subtree(m, parent); in propagate_umount()
574 } else if (child->mnt.mnt_flags & MNT_UMOUNT) { in propagate_umount()
581 list_add_tail(&child->mnt_umounting, &visited); in propagate_umount()
585 /* Check the child and parents while progress is made */ in propagate_umount()
586 while (__propagate_umount(child, in propagate_umount()
588 /* Is the parent a umount candidate? */ in propagate_umount()
589 child = child->mnt_parent; in propagate_umount()
590 if (list_empty(&child->mnt_umounting)) in propagate_umount()