From: Konstantin Khorenko <khore...@virtuozzo.com> We've got several cases when ploop could not be unmounted resulting in -EBUSY. Sometimes we could find what holds it sometimes not, so let's introduce the global list of mount namespaces: it will make it easier to debug such cases.
https://jira.sw.ru/browse/PSBM-80869 Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com> Reviewed-by: Andrey Ryabinin <aryabi...@virtuozzo.com> (cherry picked from vz7 commit abee9d40a8d1 ("mnt_ns: introduce global list of mount namespaces for debug")) VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127837 Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalit...@virtuozzo.com> Rebased to vz9: - there is 2 new functions that creates mntns. Instead of manually adding it to list, modify patch to add new mntns to list during alloc_mnt_ns - add all_mntns_list_lock spinlock to protect list instead of namespace_(un)lock() (cherry picked from vz8 commit b08585e9dc7bece4832a11312c9856860633a7a8) Signed-off-by: Andrey Zhadchenko <andrey.zhadche...@virtuozzo.com> --- fs/mount.h | 1 + fs/namespace.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/fs/mount.h b/fs/mount.h index 7c6b724..9043614 100644 --- a/fs/mount.h +++ b/fs/mount.h @@ -22,6 +22,7 @@ struct mnt_namespace { u64 event; unsigned int mounts; /* # of mounts in the namespace */ unsigned int pending_mounts; + struct list_head mntns_list; } __randomize_layout; struct mnt_pcp { diff --git a/fs/namespace.c b/fs/namespace.c index b2f925a..dc73e94 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3575,12 +3575,19 @@ static void dec_mnt_namespaces(struct ucounts *ucounts) dec_ucount(ucounts, UCOUNT_MNT_NAMESPACES); } +static LIST_HEAD(all_mntns_list); +static DEFINE_SPINLOCK(all_mntns_list_lock); + static void free_mnt_ns(struct mnt_namespace *ns) { if (!is_anon_ns(ns)) ns_free_inum(&ns->ns); dec_mnt_namespaces(ns->ucounts); put_user_ns(ns->user_ns); + + spin_lock(&all_mntns_list_lock); + list_del(&ns->mntns_list); + spin_unlock(&all_mntns_list_lock); kfree(ns); } @@ -3621,6 +3628,10 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a new_ns->seq = atomic64_add_return(1, &mnt_ns_seq); refcount_set(&new_ns->ns.count, 1); INIT_LIST_HEAD(&new_ns->list); + INIT_LIST_HEAD(&new_ns->mntns_list); + spin_lock(&all_mntns_list_lock); + list_add_tail(&new_ns->mntns_list, &all_mntns_list); + spin_unlock(&all_mntns_list_lock); init_waitqueue_head(&new_ns->poll); spin_lock_init(&new_ns->ns_lock); new_ns->user_ns = get_user_ns(user_ns); @@ -3653,6 +3664,7 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, return new_ns; namespace_lock(); + /* First pass: copy the tree topology */ copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE; if (user_ns != ns->user_ns) -- 1.8.3.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel