linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: christian.brauner@ubuntu.com, akpm@linux-foundation.org,
	ebiederm@xmission.com, viro@zeniv.linux.org.uk,
	adobriyan@gmail.com, davem@davemloft.net,
	linux-kernel@vger.kernel.org, ktkhai@virtuozzo.com
Subject: [PATCH 6/8] mnt: Use generic ns_common::count
Date: Mon, 03 Aug 2020 13:16:42 +0300	[thread overview]
Message-ID: <159644980287.604812.761686947449081169.stgit@localhost.localdomain> (raw)
In-Reply-To: <159644958332.604812.13004003379291842292.stgit@localhost.localdomain>

Convert mount namespace to use generic counter.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
---
 fs/mount.h     |    3 +--
 fs/namespace.c |    4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/mount.h b/fs/mount.h
index c3e0bb6e5782..f296862032ec 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -7,7 +7,6 @@
 #include <linux/watch_queue.h>
 
 struct mnt_namespace {
-	atomic_t		count;
 	struct ns_common	ns;
 	struct mount *	root;
 	/*
@@ -130,7 +129,7 @@ static inline void detach_mounts(struct dentry *dentry)
 
 static inline void get_mnt_ns(struct mnt_namespace *ns)
 {
-	atomic_inc(&ns->count);
+	refcount_inc(&ns->ns.count);
 }
 
 extern seqlock_t mount_lock;
diff --git a/fs/namespace.c b/fs/namespace.c
index 31c387794fbd..8c39810e6ec3 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3296,7 +3296,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns, bool a
 	new_ns->ns.ops = &mntns_operations;
 	if (!anon)
 		new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
-	atomic_set(&new_ns->count, 1);
+	refcount_set(&new_ns->ns.count, 1);
 	INIT_LIST_HEAD(&new_ns->list);
 	init_waitqueue_head(&new_ns->poll);
 	spin_lock_init(&new_ns->ns_lock);
@@ -3870,7 +3870,7 @@ void __init mnt_init(void)
 
 void put_mnt_ns(struct mnt_namespace *ns)
 {
-	if (!atomic_dec_and_test(&ns->count))
+	if (!refcount_dec_and_test(&ns->ns.count))
 		return;
 	drop_collected_mounts(&ns->root->mnt);
 	free_mnt_ns(ns);



  parent reply	other threads:[~2020-08-03 10:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 10:16 [PATCH 0/8] namespaces: Introduce generic refcount Kirill Tkhai
2020-08-03 10:16 ` [PATCH 1/8] ns: Add common refcount into ns_common add use it as counter for net_ns Kirill Tkhai
2020-08-04 12:21   ` Eric W. Biederman
2020-08-04 12:48     ` Kirill Tkhai
2020-08-04 13:52       ` Eric W. Biederman
2020-08-04 14:36         ` Kirill Tkhai
2020-08-03 10:16 ` [PATCH 2/8] uts: Use generic ns_common::count Kirill Tkhai
2020-08-03 10:16 ` [PATCH 3/8] ipc: " Kirill Tkhai
2020-08-03 10:16 ` [PATCH 4/8] pid: " Kirill Tkhai
2020-08-03 10:16 ` [PATCH 5/8] user: " Kirill Tkhai
2020-08-03 10:16 ` Kirill Tkhai [this message]
2020-08-03 10:16 ` [PATCH 7/8] cgroup: " Kirill Tkhai
2020-08-03 10:17 ` [PATCH 8/8] time: " Kirill Tkhai
2020-08-04 11:56 ` [PATCH 0/8] namespaces: Introduce generic refcount Christian Brauner
2020-08-04 12:11   ` Eric W. Biederman
2020-08-04 12:30     ` Christian Brauner
2020-08-04 13:21       ` Eric W. Biederman
2020-08-04 14:57         ` Christian Brauner
2020-08-04 21:38           ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159644980287.604812.761686947449081169.stgit@localhost.localdomain \
    --to=ktkhai@virtuozzo.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).