pnode.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/fs/pnode.c
  4. *
  5. * (C) Copyright IBM Corporation 2005.
  6. * Author : Ram Pai ([email protected])
  7. */
  8. #include <linux/mnt_namespace.h>
  9. #include <linux/mount.h>
  10. #include <linux/fs.h>
  11. #include <linux/nsproxy.h>
  12. #include <uapi/linux/mount.h>
  13. #include "internal.h"
  14. #include "pnode.h"
  15. /* return the next shared peer mount of @p */
  16. static inline struct mount *next_peer(struct mount *p)
  17. {
  18. return list_entry(p->mnt_share.next, struct mount, mnt_share);
  19. }
  20. static inline struct mount *first_slave(struct mount *p)
  21. {
  22. return list_entry(p->mnt_slave_list.next, struct mount, mnt_slave);
  23. }
  24. static inline struct mount *last_slave(struct mount *p)
  25. {
  26. return list_entry(p->mnt_slave_list.prev, struct mount, mnt_slave);
  27. }
  28. static inline struct mount *next_slave(struct mount *p)
  29. {
  30. return list_entry(p->mnt_slave.next, struct mount, mnt_slave);
  31. }
  32. static struct mount *get_peer_under_root(struct mount *mnt,
  33. struct mnt_namespace *ns,
  34. const struct path *root)
  35. {
  36. struct mount *m = mnt;
  37. do {
  38. /* Check the namespace first for optimization */
  39. #ifdef CONFIG_KDP_NS
  40. if (m->mnt_ns == ns && is_path_reachable(m, ((struct kdp_mount *)m)->mnt->mnt_root, root))
  41. #else
  42. if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root))
  43. #endif
  44. return m;
  45. m = next_peer(m);
  46. } while (m != mnt);
  47. return NULL;
  48. }
  49. /*
  50. * Get ID of closest dominating peer group having a representative
  51. * under the given root.
  52. *
  53. * Caller must hold namespace_sem
  54. */
  55. int get_dominating_id(struct mount *mnt, const struct path *root)
  56. {
  57. struct mount *m;
  58. for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) {
  59. struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root);
  60. if (d)
  61. return d->mnt_group_id;
  62. }
  63. return 0;
  64. }
  65. static int do_make_slave(struct mount *mnt)
  66. {
  67. struct mount *master, *slave_mnt;
  68. if (list_empty(&mnt->mnt_share)) {
  69. if (IS_MNT_SHARED(mnt)) {
  70. mnt_release_group_id(mnt);
  71. CLEAR_MNT_SHARED(mnt);
  72. }
  73. master = mnt->mnt_master;
  74. if (!master) {
  75. struct list_head *p = &mnt->mnt_slave_list;
  76. while (!list_empty(p)) {
  77. slave_mnt = list_first_entry(p,
  78. struct mount, mnt_slave);
  79. list_del_init(&slave_mnt->mnt_slave);
  80. slave_mnt->mnt_master = NULL;
  81. }
  82. return 0;
  83. }
  84. } else {
  85. struct mount *m;
  86. /*
  87. * slave 'mnt' to a peer mount that has the
  88. * same root dentry. If none is available then
  89. * slave it to anything that is available.
  90. */
  91. for (m = master = next_peer(mnt); m != mnt; m = next_peer(m)) {
  92. #ifdef CONFIG_KDP_NS
  93. if (((struct kdp_mount *)m)->mnt->mnt_root == ((struct kdp_mount *)mnt)->mnt->mnt_root) {
  94. #else
  95. if (m->mnt.mnt_root == mnt->mnt.mnt_root) {
  96. #endif
  97. master = m;
  98. break;
  99. }
  100. }
  101. list_del_init(&mnt->mnt_share);
  102. mnt->mnt_group_id = 0;
  103. CLEAR_MNT_SHARED(mnt);
  104. }
  105. list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
  106. slave_mnt->mnt_master = master;
  107. list_move(&mnt->mnt_slave, &master->mnt_slave_list);
  108. list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
  109. INIT_LIST_HEAD(&mnt->mnt_slave_list);
  110. mnt->mnt_master = master;
  111. return 0;
  112. }
  113. /*
  114. * vfsmount lock must be held for write
  115. */
  116. void change_mnt_propagation(struct mount *mnt, int type)
  117. {
  118. if (type == MS_SHARED) {
  119. set_mnt_shared(mnt);
  120. return;
  121. }
  122. do_make_slave(mnt);
  123. if (type != MS_SLAVE) {
  124. list_del_init(&mnt->mnt_slave);
  125. mnt->mnt_master = NULL;
  126. if (type == MS_UNBINDABLE) {
  127. #ifdef CONFIG_KDP_NS
  128. kdp_set_mnt_flags(((struct kdp_mount *)mnt)->mnt, MNT_UNBINDABLE);
  129. #else
  130. mnt->mnt.mnt_flags |= MNT_UNBINDABLE;
  131. #endif
  132. } else {
  133. #ifdef CONFIG_KDP_NS
  134. kdp_clear_mnt_flags(((struct kdp_mount *)mnt)->mnt, MNT_UNBINDABLE);
  135. #else
  136. mnt->mnt.mnt_flags &= ~MNT_UNBINDABLE;
  137. #endif
  138. }
  139. }
  140. }
  141. /*
  142. * get the next mount in the propagation tree.
  143. * @m: the mount seen last
  144. * @origin: the original mount from where the tree walk initiated
  145. *
  146. * Note that peer groups form contiguous segments of slave lists.
  147. * We rely on that in get_source() to be able to find out if
  148. * vfsmount found while iterating with propagation_next() is
  149. * a peer of one we'd found earlier.
  150. */
  151. static struct mount *propagation_next(struct mount *m,
  152. struct mount *origin)
  153. {
  154. /* are there any slaves of this mount? */
  155. if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
  156. return first_slave(m);
  157. while (1) {
  158. struct mount *master = m->mnt_master;
  159. if (master == origin->mnt_master) {
  160. struct mount *next = next_peer(m);
  161. return (next == origin) ? NULL : next;
  162. } else if (m->mnt_slave.next != &master->mnt_slave_list)
  163. return next_slave(m);
  164. /* back at master */
  165. m = master;
  166. }
  167. }
  168. static struct mount *skip_propagation_subtree(struct mount *m,
  169. struct mount *origin)
  170. {
  171. /*
  172. * Advance m such that propagation_next will not return
  173. * the slaves of m.
  174. */
  175. if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
  176. m = last_slave(m);
  177. return m;
  178. }
  179. static struct mount *next_group(struct mount *m, struct mount *origin)
  180. {
  181. while (1) {
  182. while (1) {
  183. struct mount *next;
  184. if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list))
  185. return first_slave(m);
  186. next = next_peer(m);
  187. if (m->mnt_group_id == origin->mnt_group_id) {
  188. if (next == origin)
  189. return NULL;
  190. } else if (m->mnt_slave.next != &next->mnt_slave)
  191. break;
  192. m = next;
  193. }
  194. /* m is the last peer */
  195. while (1) {
  196. struct mount *master = m->mnt_master;
  197. if (m->mnt_slave.next != &master->mnt_slave_list)
  198. return next_slave(m);
  199. m = next_peer(master);
  200. if (master->mnt_group_id == origin->mnt_group_id)
  201. break;
  202. if (master->mnt_slave.next == &m->mnt_slave)
  203. break;
  204. m = master;
  205. }
  206. if (m == origin)
  207. return NULL;
  208. }
  209. }
  210. /* all accesses are serialized by namespace_sem */
  211. static struct mount *last_dest, *first_source, *last_source, *dest_master;
  212. static struct mountpoint *mp;
  213. static struct hlist_head *list;
  214. static inline bool peers(struct mount *m1, struct mount *m2)
  215. {
  216. return m1->mnt_group_id == m2->mnt_group_id && m1->mnt_group_id;
  217. }
  218. static int propagate_one(struct mount *m)
  219. {
  220. struct mount *child;
  221. int type;
  222. /* skip ones added by this propagate_mnt() */
  223. if (IS_MNT_NEW(m))
  224. return 0;
  225. /* skip if mountpoint isn't covered by it */
  226. #ifdef CONFIG_KDP_NS
  227. if (!is_subdir(mp->m_dentry, ((struct kdp_mount *)m)->mnt->mnt_root))
  228. #else
  229. if (!is_subdir(mp->m_dentry, m->mnt.mnt_root))
  230. #endif
  231. return 0;
  232. if (peers(m, last_dest)) {
  233. type = CL_MAKE_SHARED;
  234. } else {
  235. struct mount *n, *p;
  236. bool done;
  237. for (n = m; ; n = p) {
  238. p = n->mnt_master;
  239. if (p == dest_master || IS_MNT_MARKED(p))
  240. break;
  241. }
  242. do {
  243. struct mount *parent = last_source->mnt_parent;
  244. if (peers(last_source, first_source))
  245. break;
  246. done = parent->mnt_master == p;
  247. if (done && peers(n, parent))
  248. break;
  249. last_source = last_source->mnt_master;
  250. } while (!done);
  251. type = CL_SLAVE;
  252. /* beginning of peer group among the slaves? */
  253. if (IS_MNT_SHARED(m))
  254. type |= CL_MAKE_SHARED;
  255. }
  256. #ifdef CONFIG_KDP_NS
  257. child = copy_tree(last_source, ((struct kdp_mount *)last_source)->mnt->mnt_root, type);
  258. #else
  259. child = copy_tree(last_source, last_source->mnt.mnt_root, type);
  260. #endif
  261. if (IS_ERR(child))
  262. return PTR_ERR(child);
  263. read_seqlock_excl(&mount_lock);
  264. mnt_set_mountpoint(m, mp, child);
  265. if (m->mnt_master != dest_master)
  266. SET_MNT_MARK(m->mnt_master);
  267. read_sequnlock_excl(&mount_lock);
  268. last_dest = m;
  269. last_source = child;
  270. hlist_add_head(&child->mnt_hash, list);
  271. return count_mounts(m->mnt_ns, child);
  272. }
  273. /*
  274. * mount 'source_mnt' under the destination 'dest_mnt' at
  275. * dentry 'dest_dentry'. And propagate that mount to
  276. * all the peer and slave mounts of 'dest_mnt'.
  277. * Link all the new mounts into a propagation tree headed at
  278. * source_mnt. Also link all the new mounts using ->mnt_list
  279. * headed at source_mnt's ->mnt_list
  280. *
  281. * @dest_mnt: destination mount.
  282. * @dest_dentry: destination dentry.
  283. * @source_mnt: source mount.
  284. * @tree_list : list of heads of trees to be attached.
  285. */
  286. int propagate_mnt(struct mount *dest_mnt, struct mountpoint *dest_mp,
  287. struct mount *source_mnt, struct hlist_head *tree_list)
  288. {
  289. struct mount *m, *n;
  290. int ret = 0;
  291. /*
  292. * we don't want to bother passing tons of arguments to
  293. * propagate_one(); everything is serialized by namespace_sem,
  294. * so globals will do just fine.
  295. */
  296. last_dest = dest_mnt;
  297. first_source = source_mnt;
  298. last_source = source_mnt;
  299. mp = dest_mp;
  300. list = tree_list;
  301. dest_master = dest_mnt->mnt_master;
  302. /* all peers of dest_mnt, except dest_mnt itself */
  303. for (n = next_peer(dest_mnt); n != dest_mnt; n = next_peer(n)) {
  304. ret = propagate_one(n);
  305. if (ret)
  306. goto out;
  307. }
  308. /* all slave groups */
  309. for (m = next_group(dest_mnt, dest_mnt); m;
  310. m = next_group(m, dest_mnt)) {
  311. /* everything in that slave group */
  312. n = m;
  313. do {
  314. ret = propagate_one(n);
  315. if (ret)
  316. goto out;
  317. n = next_peer(n);
  318. } while (n != m);
  319. }
  320. out:
  321. read_seqlock_excl(&mount_lock);
  322. hlist_for_each_entry(n, tree_list, mnt_hash) {
  323. m = n->mnt_parent;
  324. if (m->mnt_master != dest_mnt->mnt_master)
  325. CLEAR_MNT_MARK(m->mnt_master);
  326. }
  327. read_sequnlock_excl(&mount_lock);
  328. return ret;
  329. }
  330. static struct mount *find_topper(struct mount *mnt)
  331. {
  332. /* If there is exactly one mount covering mnt completely return it. */
  333. struct mount *child;
  334. if (!list_is_singular(&mnt->mnt_mounts))
  335. return NULL;
  336. child = list_first_entry(&mnt->mnt_mounts, struct mount, mnt_child);
  337. #ifdef CONFIG_KDP_NS
  338. if (child->mnt_mountpoint != ((struct kdp_mount *)mnt)->mnt->mnt_root)
  339. #else
  340. if (child->mnt_mountpoint != mnt->mnt.mnt_root)
  341. #endif
  342. return NULL;
  343. return child;
  344. }
  345. /*
  346. * return true if the refcount is greater than count
  347. */
  348. static inline int do_refcount_check(struct mount *mnt, int count)
  349. {
  350. return mnt_get_count(mnt) > count;
  351. }
  352. /*
  353. * check if the mount 'mnt' can be unmounted successfully.
  354. * @mnt: the mount to be checked for unmount
  355. * NOTE: unmounting 'mnt' would naturally propagate to all
  356. * other mounts its parent propagates to.
  357. * Check if any of these mounts that **do not have submounts**
  358. * have more references than 'refcnt'. If so return busy.
  359. *
  360. * vfsmount lock must be held for write
  361. */
  362. int propagate_mount_busy(struct mount *mnt, int refcnt)
  363. {
  364. struct mount *m, *child, *topper;
  365. struct mount *parent = mnt->mnt_parent;
  366. if (mnt == parent)
  367. return do_refcount_check(mnt, refcnt);
  368. /*
  369. * quickly check if the current mount can be unmounted.
  370. * If not, we don't have to go checking for all other
  371. * mounts
  372. */
  373. if (!list_empty(&mnt->mnt_mounts) || do_refcount_check(mnt, refcnt))
  374. return 1;
  375. for (m = propagation_next(parent, parent); m;
  376. m = propagation_next(m, parent)) {
  377. int count = 1;
  378. #ifdef CONFIG_KDP_NS
  379. child = __lookup_mnt(((struct kdp_mount *)m)->mnt, mnt->mnt_mountpoint);
  380. #else
  381. child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint);
  382. #endif
  383. if (!child)
  384. continue;
  385. /* Is there exactly one mount on the child that covers
  386. * it completely whose reference should be ignored?
  387. */
  388. topper = find_topper(child);
  389. if (topper)
  390. count += 1;
  391. else if (!list_empty(&child->mnt_mounts))
  392. continue;
  393. if (do_refcount_check(child, count))
  394. return 1;
  395. }
  396. return 0;
  397. }
  398. /*
  399. * Clear MNT_LOCKED when it can be shown to be safe.
  400. *
  401. * mount_lock lock must be held for write
  402. */
  403. void propagate_mount_unlock(struct mount *mnt)
  404. {
  405. struct mount *parent = mnt->mnt_parent;
  406. struct mount *m, *child;
  407. BUG_ON(parent == mnt);
  408. for (m = propagation_next(parent, parent); m;
  409. m = propagation_next(m, parent)) {
  410. #ifdef CONFIG_KDP_NS
  411. child = __lookup_mnt(((struct kdp_mount *)m)->mnt, mnt->mnt_mountpoint);
  412. if (child)
  413. kdp_clear_mnt_flags(((struct kdp_mount *)child)->mnt,MNT_LOCKED);
  414. #else
  415. child = __lookup_mnt(&m->mnt, mnt->mnt_mountpoint);
  416. if (child)
  417. child->mnt.mnt_flags &= ~MNT_LOCKED;
  418. #endif
  419. }
  420. }
  421. static void umount_one(struct mount *mnt, struct list_head *to_umount)
  422. {
  423. CLEAR_MNT_MARK(mnt);
  424. #ifdef CONFIG_KDP_NS
  425. kdp_set_mnt_flags(((struct kdp_mount *)mnt)->mnt, MNT_UMOUNT);
  426. #else
  427. mnt->mnt.mnt_flags |= MNT_UMOUNT;
  428. #endif
  429. list_del_init(&mnt->mnt_child);
  430. list_del_init(&mnt->mnt_umounting);
  431. list_move_tail(&mnt->mnt_list, to_umount);
  432. }
  433. /*
  434. * NOTE: unmounting 'mnt' naturally propagates to all other mounts its
  435. * parent propagates to.
  436. */
  437. static bool __propagate_umount(struct mount *mnt,
  438. struct list_head *to_umount,
  439. struct list_head *to_restore)
  440. {
  441. bool progress = false;
  442. struct mount *child;
  443. /*
  444. * The state of the parent won't change if this mount is
  445. * already unmounted or marked as without children.
  446. */
  447. #ifdef CONFIG_KDP_NS
  448. if (((struct kdp_mount *)mnt)->mnt->mnt_flags & (MNT_UMOUNT | MNT_MARKED))
  449. goto out;
  450. #else
  451. if (mnt->mnt.mnt_flags & (MNT_UMOUNT | MNT_MARKED))
  452. goto out;
  453. #endif
  454. /* Verify topper is the only grandchild that has not been
  455. * speculatively unmounted.
  456. */
  457. list_for_each_entry(child, &mnt->mnt_mounts, mnt_child) {
  458. #ifdef CONFIG_KDP_NS
  459. if (child->mnt_mountpoint == ((struct kdp_mount *)mnt)->mnt->mnt_root)
  460. #else
  461. if (child->mnt_mountpoint == mnt->mnt.mnt_root)
  462. #endif
  463. continue;
  464. if (!list_empty(&child->mnt_umounting) && IS_MNT_MARKED(child))
  465. continue;
  466. /* Found a mounted child */
  467. goto children;
  468. }
  469. /* Mark mounts that can be unmounted if not locked */
  470. SET_MNT_MARK(mnt);
  471. progress = true;
  472. /* If a mount is without children and not locked umount it. */
  473. if (!IS_MNT_LOCKED(mnt)) {
  474. umount_one(mnt, to_umount);
  475. } else {
  476. children:
  477. list_move_tail(&mnt->mnt_umounting, to_restore);
  478. }
  479. out:
  480. return progress;
  481. }
  482. static void umount_list(struct list_head *to_umount,
  483. struct list_head *to_restore)
  484. {
  485. struct mount *mnt, *child, *tmp;
  486. list_for_each_entry(mnt, to_umount, mnt_list) {
  487. list_for_each_entry_safe(child, tmp, &mnt->mnt_mounts, mnt_child) {
  488. /* topper? */
  489. #ifdef CONFIG_KDP_NS
  490. if (child->mnt_mountpoint == ((struct kdp_mount *)mnt)->mnt->mnt_root)
  491. #else
  492. if (child->mnt_mountpoint == mnt->mnt.mnt_root)
  493. #endif
  494. list_move_tail(&child->mnt_umounting, to_restore);
  495. else
  496. umount_one(child, to_umount);
  497. }
  498. }
  499. }
  500. static void restore_mounts(struct list_head *to_restore)
  501. {
  502. /* Restore mounts to a clean working state */
  503. while (!list_empty(to_restore)) {
  504. struct mount *mnt, *parent;
  505. struct mountpoint *mp;
  506. mnt = list_first_entry(to_restore, struct mount, mnt_umounting);
  507. CLEAR_MNT_MARK(mnt);
  508. list_del_init(&mnt->mnt_umounting);
  509. /* Should this mount be reparented? */
  510. mp = mnt->mnt_mp;
  511. parent = mnt->mnt_parent;
  512. #ifdef CONFIG_KDP_NS
  513. while (((struct kdp_mount *)parent)->mnt->mnt_flags & MNT_UMOUNT) {
  514. #else
  515. while (parent->mnt.mnt_flags & MNT_UMOUNT) {
  516. #endif
  517. mp = parent->mnt_mp;
  518. parent = parent->mnt_parent;
  519. }
  520. if (parent != mnt->mnt_parent)
  521. mnt_change_mountpoint(parent, mp, mnt);
  522. }
  523. }
  524. static void cleanup_umount_visitations(struct list_head *visited)
  525. {
  526. while (!list_empty(visited)) {
  527. struct mount *mnt =
  528. list_first_entry(visited, struct mount, mnt_umounting);
  529. list_del_init(&mnt->mnt_umounting);
  530. }
  531. }
  532. /*
  533. * collect all mounts that receive propagation from the mount in @list,
  534. * and return these additional mounts in the same list.
  535. * @list: the list of mounts to be unmounted.
  536. *
  537. * vfsmount lock must be held for write
  538. */
  539. int propagate_umount(struct list_head *list)
  540. {
  541. struct mount *mnt;
  542. LIST_HEAD(to_restore);
  543. LIST_HEAD(to_umount);
  544. LIST_HEAD(visited);
  545. /* Find candidates for unmounting */
  546. list_for_each_entry_reverse(mnt, list, mnt_list) {
  547. struct mount *parent = mnt->mnt_parent;
  548. struct mount *m;
  549. /*
  550. * If this mount has already been visited it is known that it's
  551. * entire peer group and all of their slaves in the propagation
  552. * tree for the mountpoint has already been visited and there is
  553. * no need to visit them again.
  554. */
  555. if (!list_empty(&mnt->mnt_umounting))
  556. continue;
  557. list_add_tail(&mnt->mnt_umounting, &visited);
  558. for (m = propagation_next(parent, parent); m;
  559. m = propagation_next(m, parent)) {
  560. #ifdef CONFIG_KDP_NS
  561. struct mount *child = __lookup_mnt(((struct kdp_mount *)m)->mnt,
  562. #else
  563. struct mount *child = __lookup_mnt(&m->mnt,
  564. #endif
  565. mnt->mnt_mountpoint);
  566. if (!child)
  567. continue;
  568. if (!list_empty(&child->mnt_umounting)) {
  569. /*
  570. * If the child has already been visited it is
  571. * know that it's entire peer group and all of
  572. * their slaves in the propgation tree for the
  573. * mountpoint has already been visited and there
  574. * is no need to visit this subtree again.
  575. */
  576. m = skip_propagation_subtree(m, parent);
  577. continue;
  578. #ifdef CONFIG_KDP_NS
  579. } else if (((struct kdp_mount *)child)->mnt->mnt_flags & MNT_UMOUNT) {
  580. #else
  581. } else if (child->mnt.mnt_flags & MNT_UMOUNT) {
  582. #endif
  583. /*
  584. * We have come accross an partially unmounted
  585. * mount in list that has not been visited yet.
  586. * Remember it has been visited and continue
  587. * about our merry way.
  588. */
  589. list_add_tail(&child->mnt_umounting, &visited);
  590. continue;
  591. }
  592. /* Check the child and parents while progress is made */
  593. while (__propagate_umount(child,
  594. &to_umount, &to_restore)) {
  595. /* Is the parent a umount candidate? */
  596. child = child->mnt_parent;
  597. if (list_empty(&child->mnt_umounting))
  598. break;
  599. }
  600. }
  601. }
  602. umount_list(&to_umount, &to_restore);
  603. restore_mounts(&to_restore);
  604. cleanup_umount_visitations(&visited);
  605. list_splice_tail(&to_umount, list);
  606. return 0;
  607. }