From nobody Mon Sep 29 21:17:39 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6212CC25B08 for ; Tue, 16 Aug 2022 00:48:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239742AbiHPAsV (ORCPT ); Mon, 15 Aug 2022 20:48:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243828AbiHPApj (ORCPT ); Mon, 15 Aug 2022 20:45:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17033D4772; Mon, 15 Aug 2022 13:40:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 66481B8119A; Mon, 15 Aug 2022 20:40:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68FC6C433C1; Mon, 15 Aug 2022 20:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596053; bh=cxXucUSZz/3hhprAB3D1nyqJ+G2drWUuZmqO81cbMuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOStMD9zTDsu9J34tA48cE83YpzADPtnO+tWMgKlcyvNpFZYzRhyrIX93TTnDKqTL PE9+R2LhahDGeK/6++pRjCLK642ra3/uUjYCCVMY0FESR10frE1ynZDYUe/oQgvhbu 0SRwNo08Moa7A1zBeW+UOGCrygLtW2151I+3+jAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kent Overstreet , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Sasha Levin Subject: [PATCH 5.19 0958/1157] 9p: Drop kref usage Date: Mon, 15 Aug 2022 20:05:14 +0200 Message-Id: <20220815180517.953367760@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Kent Overstreet [ Upstream commit 6cda12864cb0f99810a5809e11e3ee5b102c9a47 ] An upcoming patch is going to require passing the client through p9_req_put() -> p9_req_free(), but that's awkward with the kref indirection - so this patch switches to using refcount_t directly. Link: https://lkml.kernel.org/r/20220704014243.153050-1-kent.overstreet@gma= il.com Signed-off-by: Kent Overstreet Cc: Eric Van Hensbergen Cc: Latchesar Ionkov Signed-off-by: Dominique Martinet Signed-off-by: Sasha Levin --- include/net/9p/client.h | 6 +++--- net/9p/client.c | 19 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/include/net/9p/client.h b/include/net/9p/client.h index ec1d1706f43c..c038c2d73dae 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -76,7 +76,7 @@ enum p9_req_status_t { struct p9_req_t { int status; int t_err; - struct kref refcount; + refcount_t refcount; wait_queue_head_t wq; struct p9_fcall tc; struct p9_fcall rc; @@ -227,12 +227,12 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u= 16 tag); =20 static inline void p9_req_get(struct p9_req_t *r) { - kref_get(&r->refcount); + refcount_inc(&r->refcount); } =20 static inline int p9_req_try_get(struct p9_req_t *r) { - return kref_get_unless_zero(&r->refcount); + return refcount_inc_not_zero(&r->refcount); } =20 int p9_req_put(struct p9_req_t *r); diff --git a/net/9p/client.c b/net/9p/client.c index 8bba0d9cf975..0ee48e8b7220 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -305,7 +305,7 @@ p9_tag_alloc(struct p9_client *c, int8_t type, unsigned= int max_size) * callback), so p9_client_cb eats the second ref there * as the pointer is duplicated directly by virtqueue_add_sgs() */ - refcount_set(&req->refcount.refcount, 2); + refcount_set(&req->refcount, 2); =20 return req; =20 @@ -370,18 +370,15 @@ static int p9_tag_remove(struct p9_client *c, struct = p9_req_t *r) return p9_req_put(r); } =20 -static void p9_req_free(struct kref *ref) -{ - struct p9_req_t *r =3D container_of(ref, struct p9_req_t, refcount); - - p9_fcall_fini(&r->tc); - p9_fcall_fini(&r->rc); - kmem_cache_free(p9_req_cache, r); -} - int p9_req_put(struct p9_req_t *r) { - return kref_put(&r->refcount, p9_req_free); + if (refcount_dec_and_test(&r->refcount)) { + p9_fcall_fini(&r->tc); + p9_fcall_fini(&r->rc); + kmem_cache_free(p9_req_cache, r); + return 1; + } + return 0; } EXPORT_SYMBOL(p9_req_put); =20 --=20 2.35.1