From patchwork Mon Oct 1 14:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10622263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D8ED1515 for ; Mon, 1 Oct 2018 14:42:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44EA828DDB for ; Mon, 1 Oct 2018 14:42:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38B57290FE; Mon, 1 Oct 2018 14:42:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243C3290FE for ; Mon, 1 Oct 2018 14:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729412AbeJAVUd (ORCPT ); Mon, 1 Oct 2018 17:20:33 -0400 Received: from mail-it1-f180.google.com ([209.85.166.180]:51338 "EHLO mail-it1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729487AbeJAVUd (ORCPT ); Mon, 1 Oct 2018 17:20:33 -0400 Received: by mail-it1-f180.google.com with SMTP id 74-v6so11616676itw.1 for ; Mon, 01 Oct 2018 07:42:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W57GNgqkCOpLeo/mUUd3OvI+Mdmz1+HpFNBkxiS7DWk=; b=lZFuiR7DlDkeLouyFc5+nAEo+YdAEhppqr0Q3htcwM/VdrvMZk74tSf/SXwicHTfVm uhQCMAptNvMjuBY75qs9lJ+6EI26v5q9d7vTfKZYwiui1Dyu5owYgXuXT4973RX0tytp uliNar2aud3yGZ5fFwLcTDCKtwA5eaOp3VQs6EXAXqDKbSlO0ghNx7RmoDtkGplhkjyQ FR28wkRr1LJlBzvfgiQfZSmT2tvnG81q7kfedWv24Vcy2VIIxJKd2HIQkC9mh7+2AmFf 5piTCzzy2I7h+t/7p52CpLh+uhwesMQZ3O6uYIASPk5ej1Hsx+wYw6omQoyca9eRxdtg HJ6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W57GNgqkCOpLeo/mUUd3OvI+Mdmz1+HpFNBkxiS7DWk=; b=Uu4YUhPHRz4ssgZDYeuhW7Dg0FYVWCfhyQnijxO8FSmUkB80TnKNeIzQTrGx2T2M9v povX97h2lO2T8Yf8RjEKzCbbzguSvf5X50D/QGZ5Xo9voiAJtpbeSdrGNykuVLCc4RYG pcVhPpJSS2f5UlvA+eXVdJFPAWeeHQkZPF3bm3FWQdVMe29NJYPHR4c3/+DJJFLrNZAs xvExBqFkB+4l9+pQvnqFtk3ABWnAq7bBfR8T2TlRXZfe8xexd+9EXR/D2VcOlFGG4WDA kWsZvL/b828lMexn2Jjg7IegkZmK/l/QjxIcWgc6S1xX6V7fpWNIlEYInzSG14NE52HA +j+Q== X-Gm-Message-State: ABuFfogIVzBDRZMu768ki07BT3kIYkiZ7NoqU3Tjh3MD+5oynm1obU93 dYY6fZibVIk/7pvZ2iT+kHxxjE4= X-Google-Smtp-Source: ACcGV63eV/61VdFq8793b1TygA94liKoGuksWo2+tcIfO3Z9nuNnR8jcJX1xnI8slH1lB5x4POwLRQ== X-Received: by 2002:a24:1049:: with SMTP id 70-v6mr9672745ity.115.1538404944000; Mon, 01 Oct 2018 07:42:24 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id j75-v6sm2055597itj.33.2018.10.01.07.42.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 07:42:23 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: "J . Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH 05/15] knfsd: Allow lockless lookups of the exports Date: Mon, 1 Oct 2018 10:41:47 -0400 Message-Id: <20181001144157.3515-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181001144157.3515-5-trond.myklebust@hammerspace.com> References: <20181001144157.3515-1-trond.myklebust@hammerspace.com> <20181001144157.3515-2-trond.myklebust@hammerspace.com> <20181001144157.3515-3-trond.myklebust@hammerspace.com> <20181001144157.3515-4-trond.myklebust@hammerspace.com> <20181001144157.3515-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Convert structs svc_expkey and svc_export to allow RCU protected lookups. Signed-off-by: Trond Myklebust --- fs/nfsd/export.c | 14 +++++++------- fs/nfsd/export.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index a1143f7c2201..802993d8912f 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -46,7 +46,7 @@ static void expkey_put(struct kref *ref) !test_bit(CACHE_NEGATIVE, &key->h.flags)) path_put(&key->ek_path); auth_domain_put(key->ek_client); - kfree(key); + kfree_rcu(key, ek_rcu); } static void expkey_request(struct cache_detail *cd, @@ -265,7 +265,7 @@ svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *item) struct cache_head *ch; int hash = svc_expkey_hash(item); - ch = sunrpc_cache_lookup(cd, &item->h, hash); + ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash); if (ch) return container_of(ch, struct svc_expkey, h); else @@ -314,7 +314,7 @@ static void svc_export_put(struct kref *ref) auth_domain_put(exp->ex_client); nfsd4_fslocs_free(&exp->ex_fslocs); kfree(exp->ex_uuid); - kfree(exp); + kfree_rcu(exp, ex_rcu); } static void svc_export_request(struct cache_detail *cd, @@ -780,7 +780,7 @@ svc_export_lookup(struct svc_export *exp) struct cache_head *ch; int hash = svc_export_hash(exp); - ch = sunrpc_cache_lookup(exp->cd, &exp->h, hash); + ch = sunrpc_cache_lookup_rcu(exp->cd, &exp->h, hash); if (ch) return container_of(ch, struct svc_export, h); else @@ -1216,9 +1216,9 @@ static int e_show(struct seq_file *m, void *p) } const struct seq_operations nfs_exports_op = { - .start = cache_seq_start, - .next = cache_seq_next, - .stop = cache_seq_stop, + .start = cache_seq_start_rcu, + .next = cache_seq_next_rcu, + .stop = cache_seq_stop_rcu, .show = e_show, }; diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h index c8b74126ddaa..e7daa1f246f0 100644 --- a/fs/nfsd/export.h +++ b/fs/nfsd/export.h @@ -61,6 +61,7 @@ struct svc_export { u32 ex_layout_types; struct nfsd4_deviceid_map *ex_devid_map; struct cache_detail *cd; + struct rcu_head ex_rcu; }; /* an "export key" (expkey) maps a filehandlefragement to an @@ -75,6 +76,7 @@ struct svc_expkey { u32 ek_fsid[6]; struct path ek_path; + struct rcu_head ek_rcu; }; #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))