Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2883741rwb; Mon, 15 Aug 2022 13:16:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR46qCaS6zNXpqG0eTMxkvBo5hNwnwt5Lvaa/U6vjNNRUhkZ3jMivc0Tbw1gbMrbshuMZeTg X-Received: by 2002:a17:907:7f8b:b0:734:b422:42e7 with SMTP id qk11-20020a1709077f8b00b00734b42242e7mr11282711ejc.225.1660594562661; Mon, 15 Aug 2022 13:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594562; cv=none; d=google.com; s=arc-20160816; b=g5BpXtFxGi5c0QI0t5Fa1XbPkxZo4I8LqlXWtXfDr+bED3Z7b0sWfgzoatnhgsiAEa WSP1CP3aFEITUgONjI9YcHFcf8PtTqVuSruuP6fInzmXUKYA3xXABF2yAd8XUkXaag+i cHcKfxUkCt1cz0HZl7DiaenXIoEc23GqGR/6EEcp66MRmvrhNK0YehjEHxM8zw/x50iu AIk4pWJ8Q8TzehdmC6w1DI6AuimuuN2fGQy0XX+LBjzPZ0fUjwlJOa36mvBzWjdOwsYF WTDPxtxH+l08uxWj3Foiq9kWSw4nxrUX8DISeMDKtsLclPqOVGUskqMuLD2cqDH1/qIj 3zUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xf7RRu19BMxKiatq3Jg6g86FKNFaEULelygSqURTuSY=; b=NxGzgHvfue4OI9fITFGzMf5/DGYGaWiIIY3vdOBUy4Fup74c+BHUx/8gilvRBZLiX6 6wNXwZ/rKIAldUT1/E9kFLcYAUUZQjCOMUoVacyR9u32nvXkHjczckuN5LWQDNsa0YBD BGrAqHyDvhPknhUvRDlx/f7g2tOxdKjkCELYF9qxHl6gU8M74UtLn9uX8GeryvGzAEVi J9wSU5MhtLPz6j9HZ/9dIw+zKj2/8fW6BOQwkPfipTZmdrkQg8PBRkPYqnsOvMcHLINd Av/xk8klvP4R+o7vKt27xHNdoZFUJz1vf7D9vsyzaPsJxtYIahOfhlUyUFrP9n4KwNCs 5EKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UKjXXR+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dt20-20020a170907729400b00734bc2f6bb1si9455756ejc.801.2022.08.15.13.15.36; Mon, 15 Aug 2022 13:16:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UKjXXR+3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242849AbiHOTgt (ORCPT + 99 others); Mon, 15 Aug 2022 15:36:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344357AbiHOTbX (ORCPT ); Mon, 15 Aug 2022 15:31:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 293F26068E; Mon, 15 Aug 2022 11:44:34 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 29F65611E3; Mon, 15 Aug 2022 18:44:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EB33C433C1; Mon, 15 Aug 2022 18:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589073; bh=W3zPSwdpF9S2bsdG1crbuH3BFIELlcL1I3DqDNyJR7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UKjXXR+3FeivK3G6JZCLs4cbzIX93PX3vKEHrVFL9c9UUJu2F4GlEYQm9+MTJ6MIC XXTekG7FeE/Y3wFjEhvVV1QVnhp2Gx9av90nLB8EtmKOtP5DJMjdE7986/mvJyCSx8 RIwKosIypKxa8FGw6eNQbwLXOuPg/jMzfY3WcdTo= 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.15 605/779] 9p: Drop kref usage Date: Mon, 15 Aug 2022 20:04:09 +0200 Message-Id: <20220815180403.209309203@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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@gmail.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 334dc748fb3f..67c854d07d7e 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h @@ -78,7 +78,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; @@ -229,12 +229,12 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag); static inline void p9_req_get(struct p9_req_t *r) { - kref_get(&r->refcount); + refcount_inc(&r->refcount); } 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); } int p9_req_put(struct p9_req_t *r); diff --git a/net/9p/client.c b/net/9p/client.c index 33a53f016e73..5835fe4aebd7 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -307,7 +307,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); return req; @@ -372,18 +372,15 @@ static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r) return p9_req_put(r); } -static void p9_req_free(struct kref *ref) -{ - struct p9_req_t *r = 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); -- 2.35.1