Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp563685pxb; Thu, 19 Nov 2020 08:12:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJze/w+7grQfeNRLBCmXIZDJuUZRSydzG/49YdofCdUii1H9G6BOGgS4Ab1rIpWzwx8qPCPv X-Received: by 2002:a17:906:3a8d:: with SMTP id y13mr12002014ejd.542.1605802363702; Thu, 19 Nov 2020 08:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605802363; cv=none; d=google.com; s=arc-20160816; b=oJFIUQmBxC7TiawjVI6TrQMSGYeropQezxa5c90fOqzjxjCkuH1Fh2z1Pv2TkAyKH1 afGrKorqrsgf0PrGYPWvUwX+KmDrLcljy7ZCQkg3TwfVCvhXswL7BuOPRFQzuEJgSrg9 pSu1Idwl/bEjhh4V9DOY/p7DrCRqca3OLPcINeL2ib12ukDl8KsVZbJsDKiWBBXwu0Bc 4nnLR78zxA4T4F8jvOk+Y9KJBw5byF+lKI3ZHVNlbdkeRY8cZbds6Hmiauoxn7WRclmU /Oz8M3eC2OoENuiGDxKUzLH0GXyJTjUjHMPIqAidjWM+tzlJGzKI5rEmEEaEHKzT6EZv h7WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature; bh=FgwVOGrQRgSaXC/c3SASSffjnbPG4AmXzCDcQORhByg=; b=oXzWiTQYo7bib8lRMuYvzM/Kt6QarEaQ+1LkkeCUjzTq81DGZ3J8rxsdE3i2d4LPv3 omdEXopu61iaRJ+f2NeHj4U3OpLeb2yPoDTPwLA7b2JTRaJ84caI2+KxX5h6dIra2+Rp oPHxnjE9d4LXHHmxjjTDXFIXd53/M3NzAnZ7Ww+wbJrxti6+ywOZTCtC8OeX2e7431Qt ZY3b1JATAIbdCve23vKu4hsvUdRnWH+E+F7RtnTZzNQeTuknC5mPPfXg8k8Q6LBve051 RJwS3diOcLlgpBd8aVHkKRr6dj00Hux0t7/PrM8VKyioeKZ5vliStWvlXuFkZz0yyyvQ LbEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@codewreck.org header.s=2 header.b=0lf2G7K2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oj19si86816ejb.384.2020.11.19.08.12.18; Thu, 19 Nov 2020 08:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@codewreck.org header.s=2 header.b=0lf2G7K2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728485AbgKSQHU (ORCPT + 99 others); Thu, 19 Nov 2020 11:07:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727678AbgKSQHT (ORCPT ); Thu, 19 Nov 2020 11:07:19 -0500 Received: from nautica.notk.org (ipv6.notk.org [IPv6:2001:41d0:1:7a93::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54D78C0613CF for ; Thu, 19 Nov 2020 08:07:19 -0800 (PST) Received: by nautica.notk.org (Postfix, from userid 1001) id 1EAA0C01A; Thu, 19 Nov 2020 17:07:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1605802038; bh=FgwVOGrQRgSaXC/c3SASSffjnbPG4AmXzCDcQORhByg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0lf2G7K2lKoVaavnFtQbb1FO4UFaw1BEp0YxrN2XOn3AZ5fyAEVIgdytk1JxZEVGm GUtMrTyYebQdVaU6k50motBOb38Fs7eQCE4opHi+UoekJsvpPZLSzTbdkzw0Z/2TeI y2+YDcuWBsibkVM+nTTIuIxFHF0mpSmJYvvdQlATVf3Uva0t2hOp3wYXAPh+L62we5 2DxbyUH6b3S6eWfS3C/053zpmfxTO+6glIBsUZv4X0xc+GxS0oognuVvMynVh6EOlu eZSxiTJzysr9mNkiGKhAP8iz6kFnsYl7N6Q5+jcQr5gVUx0VIEm1Sk5i4PsWOeT9HB bsz4V0Jvp0hmQ== From: Dominique Martinet Cc: Jianyong Wu , lucho@ionkov.net, justin.he@arm.com, ericvh@gmail.com, qemu_oss@crudebyte.com, groug@kaod.org, linux-kernel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, Dominique Martinet Subject: [PATCH 1/2] 9p: apply review requests for fid refcounting Date: Thu, 19 Nov 2020 17:06:51 +0100 Message-Id: <1605802012-31133-2-git-send-email-asmadeus@codewreck.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1605802012-31133-1-git-send-email-asmadeus@codewreck.org> References: <20201103104116.GA19587@nautica> <1605802012-31133-1-git-send-email-asmadeus@codewreck.org> To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix style issues in parent commit ("apply review requests for fid refcounting"), no functional change. Signed-off-by: Dominique Martinet --- fs/9p/fid.c | 10 ++++------ fs/9p/fid.h | 2 +- include/net/9p/client.h | 2 +- net/9p/client.c | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 89643dabcdae..50118ec72a92 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -28,7 +28,6 @@ static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid) { - atomic_set(&fid->count, 1); hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); } @@ -62,7 +61,7 @@ static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid) } } if (ret && !IS_ERR(ret)) - atomic_inc(&ret->count); + refcount_inc(&ret->count); spin_unlock(&inode->i_lock); return ret; } @@ -77,7 +76,6 @@ static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid) void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid) { spin_lock(&inode->i_lock); - atomic_set(&fid->count, 1); hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private); spin_unlock(&inode->i_lock); } @@ -110,7 +108,7 @@ static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) hlist_for_each_entry(fid, h, dlist) { if (any || uid_eq(fid->uid, uid)) { ret = fid; - atomic_inc(&ret->count); + refcount_inc(&ret->count); break; } } @@ -201,7 +199,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, } /* If we are root ourself just return that */ if (dentry->d_sb->s_root == dentry) { - atomic_inc(&fid->count); + refcount_inc(&fid->count); return fid; } /* @@ -250,7 +248,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, fid = ERR_PTR(-ENOENT); } else { __add_fid(dentry, fid); - atomic_inc(&fid->count); + refcount_inc(&fid->count); spin_unlock(&dentry->d_lock); } } diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 1fed96546728..f7f33509e169 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h @@ -28,7 +28,7 @@ static inline struct p9_fid *v9fs_fid_clone(struct dentry *dentry) if (!fid || IS_ERR(fid)) return fid; - nfid = p9_client_walk(fid, 0, NULL, 1); + nfid = clone_fid(fid); p9_client_clunk(fid); return nfid; } diff --git a/include/net/9p/client.h b/include/net/9p/client.h index 58ed9bd306bd..e1c308d8d288 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -149,7 +149,7 @@ enum fid_source { struct p9_fid { struct p9_client *clnt; u32 fid; - atomic_t count; + refcount_t count; int mode; struct p9_qid qid; u32 iounit; diff --git a/net/9p/client.c b/net/9p/client.c index a6c8a915e0d8..ba4910138c5b 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -901,7 +901,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) fid->clnt = clnt; fid->rdir = NULL; fid->fid = 0; - atomic_set(&fid->count, 1); + refcount_set(&fid->count, 1); idr_preload(GFP_KERNEL); spin_lock_irq(&clnt->lock); @@ -1466,7 +1466,7 @@ int p9_client_clunk(struct p9_fid *fid) dump_stack(); return 0; } - if (!atomic_dec_and_test(&fid->count)) + if (!refcount_dec_and_test(&fid->count)) return 0; again: -- 2.28.0