Lines Matching refs:m
37 struct mount *m = mnt;
41 if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root))
42 return m;
44 m = next_peer(m);
45 } while (m != mnt);
58 struct mount *m;
60 for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) {
61 struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root);
69 static inline bool will_be_unmounted(struct mount *m)
71 return m->mnt.mnt_flags & MNT_UMOUNT;
77 struct mount *m;
79 hlist_for_each_entry_safe(m, n, &mnt->mnt_slave_list, mnt_slave) {
80 m->mnt_master = to;
82 hlist_del_init(&m->mnt_slave);
84 p = &m->mnt_slave;
95 struct mount *m = mnt->mnt_master;
105 m = next_peer(mnt);
110 transfer_propagation(mnt, m);
114 mnt->mnt_master = m;
115 if (m)
116 hlist_add_head(&mnt->mnt_slave, &m->mnt_slave_list);
126 static struct mount *trace_transfers(struct mount *m)
129 struct mount *next = next_peer(m);
131 if (next != m) {
132 list_del_init(&m->mnt_share);
133 m->mnt_group_id = 0;
134 m->mnt_master = next;
136 if (IS_MNT_SHARED(m))
137 mnt_release_group_id(m);
138 next = m->mnt_master;
140 hlist_del_init(&m->mnt_slave);
141 CLEAR_MNT_SHARED(m);
142 SET_MNT_MARK(m);
148 m = next;
152 static void set_destinations(struct mount *m, struct mount *master)
156 while ((next = m->mnt_master) != master) {
157 m->mnt_master = master;
158 m = next;
164 struct mount *m;
166 list_for_each_entry(m, set, mnt_list)
167 if (!IS_MNT_MARKED(m))
168 set_destinations(m, trace_transfers(m));
170 list_for_each_entry(m, set, mnt_list) {
171 transfer_propagation(m, m->mnt_master);
172 m->mnt_master = NULL;
173 CLEAR_MNT_MARK(m);
177 static struct mount *__propagation_next(struct mount *m,
181 struct mount *master = m->mnt_master;
184 struct mount *next = next_peer(m);
186 } else if (m->mnt_slave.next)
187 return next_slave(m);
190 m = master;
196 * @m: the mount seen last
204 static struct mount *propagation_next(struct mount *m,
208 if (!IS_MNT_NEW(m) && !hlist_empty(&m->mnt_slave_list))
209 return first_slave(m);
211 return __propagation_next(m, origin);
214 static struct mount *skip_propagation_subtree(struct mount *m,
218 * Advance m past everything that gets propagation from it.
220 struct mount *p = __propagation_next(m, origin);
222 while (p && peers(m, p))
228 static struct mount *next_group(struct mount *m, struct mount *origin)
233 if (!IS_MNT_NEW(m) && !hlist_empty(&m->mnt_slave_list))
234 return first_slave(m);
235 next = next_peer(m);
236 if (m->mnt_group_id == origin->mnt_group_id) {
239 } else if (m->mnt_slave.next != &next->mnt_slave)
241 m = next;
243 /* m is the last peer */
245 struct mount *master = m->mnt_master;
246 if (m->mnt_slave.next)
247 return next_slave(m);
248 m = next_peer(master);
251 if (master->mnt_slave.next == &m->mnt_slave)
253 m = master;
255 if (m == origin)
260 static bool need_secondary(struct mount *m, struct mountpoint *dest_mp)
263 if (IS_MNT_NEW(m))
265 /* skip if mountpoint isn't visible in m */
266 if (!is_subdir(dest_mp->m_dentry, m->mnt.mnt_root))
268 /* skip if m is in the anon_ns */
269 if (is_anon_ns(m->mnt_ns))
274 static struct mount *find_master(struct mount *m,
282 p = m->mnt_master;
285 m = p;
290 if (!peers(parent, m))
314 struct mount *m, *n, *copy, *this;
321 for (m = dest_mnt; m && !err; m = next_group(m, dest_mnt)) {
322 if (m == dest_mnt) { // have one for dest_mnt itself
325 n = next_peer(m);
326 if (n == m)
331 if (IS_MNT_SHARED(m))
333 n = m;
355 } while ((n = next_peer(n)) != m);
359 m = n->mnt_parent;
360 if (m->mnt_master)
361 CLEAR_MNT_MARK(m->mnt_master);
405 for (const struct mount *m = to; m; m = m->mnt_master) {
406 if (peers(from, m))
413 /* Does @m receive propagation from @parent? */
414 static bool receives_from(struct mount *m, struct mount *parent)
416 if (m == parent)
418 for (; m; m = m->mnt_master)
419 if (m == parent || peers(m, parent))
425 * Does @m receive propagation from the victim's parent as well? If so, then
426 * the mount at the victim's mountpoint inside of @m is a umount candidate as
428 * @m.
430 static struct mount *next_candidate(struct mount *m, struct mount *victim)
432 if (!receives_from(m, victim->mnt_parent))
434 return __lookup_mnt(&m->mnt, victim->mnt_mountpoint);
456 struct mount *m, *n, *next, *deepest = NULL;
460 for (m = c; m; m = next) {
461 next = next_candidate(m, victim);
462 list_for_each_entry(n, &m->mnt_mounts, mnt_child) {
464 deepest = m;
470 above = deepest != NULL; /* @deepest is at or below @m */
471 for (m = c; m; m = next) {
474 next = next_candidate(m, victim);
475 list_for_each_entry(n, &m->mnt_mounts, mnt_child) {
476 if (n != next && n != m->overmount && n != victim) {
481 if (goes && next && next != m->overmount && above && m != deepest)
483 if (m == deepest)
485 if (goes && do_refcount_check(m, 1))
505 struct mount *m;
519 for (m = propagation_next(parent, parent); m;
520 m = propagation_next(m, parent)) {
521 struct mount *c = __lookup_mnt(&m->mnt, mp);
524 if (!c || (mnt_has_parent(m) && m->mnt_mountpoint == mp &&
525 receives_from(m->mnt_parent, parent)))
541 struct mount *m, *child;
545 for (m = propagation_next(parent, parent); m;
546 m = propagation_next(m, parent)) {
547 child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint);
553 static inline bool is_candidate(struct mount *m)
555 return m->mnt_t_flags & T_UMOUNT_CANDIDATE;
558 static void umount_one(struct mount *m, struct list_head *to_umount)
560 m->mnt.mnt_flags |= MNT_UMOUNT;
561 list_del_init(&m->mnt_child);
562 move_from_ns(m);
563 list_add_tail(&m->mnt_list, to_umount);
566 static void remove_from_candidate_list(struct mount *m)
568 m->mnt_t_flags &= ~(T_MARKED | T_UMOUNT_CANDIDATE);
569 list_del_init(&m->mnt_list);
575 struct mount *m, *p, *q;
577 list_for_each_entry(m, set, mnt_list) {
578 if (is_candidate(m))
580 m->mnt_t_flags |= T_UMOUNT_CANDIDATE;
581 p = m->mnt_parent;
585 m->mnt_mountpoint);
605 list_for_each_entry(m, set, mnt_list)
606 m->mnt_t_flags &= ~T_UMOUNT_CANDIDATE;
610 * We know that some child of @m can't be unmounted. In all places where the
611 * chain of descent of @m has child not overmounting the root of parent,
614 static void trim_ancestors(struct mount *m)
618 for (p = m->mnt_parent; is_candidate(p); m = p, p = p->mnt_parent) {
619 if (IS_MNT_MARKED(m)) // all candidates beneath are overmounts
621 SET_MNT_MARK(m);
622 if (m != p->overmount)
628 * Find and exclude all umount candidates forbidden by @m
630 * If we can immediately tell that @m is OK to unmount (unlocked
633 * Only @m itself might be taken from the candidates list;
637 static void trim_one(struct mount *m, struct list_head *to_umount)
642 if (!is_candidate(m)) { // trim_ancestors() left it on list
643 remove_from_candidate_list(m);
647 list_for_each_entry(n, &m->mnt_mounts, mnt_child) {
650 if (n != m->overmount) {
657 trim_ancestors(m);
658 } else if (!IS_MNT_LOCKED(m) && list_empty(&m->mnt_mounts)) {
663 remove_from_candidate_list(m);
665 umount_one(m, to_umount);
669 static void handle_locked(struct mount *m, struct list_head *to_umount)
671 struct mount *cutoff = m, *p;
673 if (!is_candidate(m)) { // trim_ancestors() left it on list
674 remove_from_candidate_list(m);
677 for (p = m; is_candidate(p); p = p->mnt_parent) {
684 while (m != cutoff) {
685 umount_one(m, to_umount);
686 m = m->mnt_parent;
691 * @m is not to going away, and it overmounts the top of a stack of mounts
693 * by the one above (@m being the topmost of the chain), so @m can be slid
699 * the stack from the parent it (and now @m) is attached to. umount_tree()
703 static void reparent(struct mount *m)
705 struct mount *p = m;
713 mnt_change_mountpoint(p, mp, m);
714 mnt_notify_add(m);
732 struct mount *m, *p;
740 list_for_each_entry_safe(m, p, &candidates, mnt_list)
741 trim_one(m, &to_umount);
745 m = list_first_entry(&candidates,struct mount, mnt_list);
746 handle_locked(m, &to_umount);
751 list_for_each_entry(m, &to_umount, mnt_list) {
752 struct mount *over = m->overmount;