On Thu, Jul 30, 2020 at 02:59:52PM +0300, Kirill Tkhai wrote:
> Convert mount namespace to use generic counter.
> 
> Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com>
> ---

Looks good!
Acked-by: Christian Brauner <christian.brau...@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);
> 
> 

Reply via email to