From patchwork Wed Jan 18 17:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106718 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 D03C6C38159 for ; Wed, 18 Jan 2023 17:32:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230430AbjARRc1 (ORCPT ); Wed, 18 Jan 2023 12:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbjARRcH (ORCPT ); Wed, 18 Jan 2023 12:32:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2B456EFD for ; Wed, 18 Jan 2023 09:31:44 -0800 (PST) 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 D043EB81E10 for ; Wed, 18 Jan 2023 17:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FC61C433F0; Wed, 18 Jan 2023 17:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063101; bh=tHUoDe+UiNuLd1wUzBbJUcrJ//0mAOo7aXIr5Vwu1o8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AN20NHHQ2/KV8s8G6VVF2DmlSSIjcxUunPHfeeGEd92MaGjp+KGrgnqMrt0qRtfgL 6vptc0cITLOLL5gulfXLnar9YcWTd0AYRyhDGdpLCCqw5oUcp1w5FNL4pE0odo5bWl p7N55ZxxEdNIvoNFRpQtVt9Dh7WxhwIutP+k0K+43R91PGU1RWj9W+Sjd9XKLQB6l+ yZpSusw2jcJrO1Bp3MKPszOR6i8+Hfnpv5XArBLeeouXCp4LNE4jE4mb5zWlYTmm5S dl14QHNF4xIM8AZHHjdSl7MFrdl8DfIgKnFrENsZ1pfCkR0QSstAmKmFmdPXs3hRx5 RzoUr2NNHAzSw== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/6] nfsd: don't take nfsd4_copy ref for OP_OFFLOAD_STATUS Date: Wed, 18 Jan 2023 12:31:34 -0500 Message-Id: <20230118173139.71846-2-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We're not doing any blocking operations for OP_OFFLOAD_STATUS, so taking and putting a reference is a waste of effort. Take the client lock, search for the copy and fetch the wr_bytes_written field and return. Also, make find_async_copy a static function. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 35 ++++++++++++++++++++++++----------- fs/nfsd/state.h | 2 -- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 62b9d6c1b18b..731c2b22f163 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1823,23 +1823,34 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto out; } -struct nfsd4_copy * -find_async_copy(struct nfs4_client *clp, stateid_t *stateid) +static struct nfsd4_copy * +find_async_copy_locked(struct nfs4_client *clp, stateid_t *stateid) { struct nfsd4_copy *copy; - spin_lock(&clp->async_lock); + lockdep_assert_held(&clp->async_lock); + list_for_each_entry(copy, &clp->async_copies, copies) { if (memcmp(©->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE)) continue; - refcount_inc(©->refcount); - spin_unlock(&clp->async_lock); return copy; } - spin_unlock(&clp->async_lock); return NULL; } +static struct nfsd4_copy * +find_async_copy(struct nfs4_client *clp, stateid_t *stateid) +{ + struct nfsd4_copy *copy; + + spin_lock(&clp->async_lock); + copy = find_async_copy_locked(clp, stateid); + if (copy) + refcount_inc(©->refcount); + spin_unlock(&clp->async_lock); + return copy; +} + static __be32 nfsd4_offload_cancel(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, @@ -1924,22 +1935,24 @@ nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, nfsd_file_put(nf); return status; } + static __be32 nfsd4_offload_status(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { struct nfsd4_offload_status *os = &u->offload_status; - __be32 status = 0; + __be32 status = nfs_ok; struct nfsd4_copy *copy; struct nfs4_client *clp = cstate->clp; - copy = find_async_copy(clp, &os->stateid); - if (copy) { + spin_lock(&clp->async_lock); + copy = find_async_copy_locked(clp, &os->stateid); + if (copy) os->count = copy->cp_res.wr_bytes_written; - nfs4_put_copy(copy); - } else + else status = nfserr_bad_stateid; + spin_unlock(&clp->async_lock); return status; } diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index e94634d30591..d49d3060ed4f 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -705,8 +705,6 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn); void put_nfs4_file(struct nfs4_file *fi); -extern struct nfsd4_copy * -find_async_copy(struct nfs4_client *clp, stateid_t *staetid); extern void nfs4_put_cpntf_state(struct nfsd_net *nn, struct nfs4_cpntf_state *cps); extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st, From patchwork Wed Jan 18 17:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106713 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 7D7C9C32793 for ; Wed, 18 Jan 2023 17:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbjARRcV (ORCPT ); Wed, 18 Jan 2023 12:32:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230392AbjARRcF (ORCPT ); Wed, 18 Jan 2023 12:32:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F41C6599B4 for ; Wed, 18 Jan 2023 09:31:42 -0800 (PST) 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 9058061937 for ; Wed, 18 Jan 2023 17:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3208C433EF; Wed, 18 Jan 2023 17:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063102; bh=yPiywXRNcT7TdD6zbyP1NHsB6cTGRS/CnB5JB7qsoNc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V450X0ZJnBo7e1VJ/RxtybNto8orTLn3YQAjqBAWelR/nNFpf/gW66TDLFchrdS7n 7IMnIDXrQCGags/N4ZtsV3U+bVshxmFin7wYh4tv83/aRGPOwTyFrNy1jpOKdGQHKw Evji3x83/JyCi7j8Q88ZORcq4NfQBxpLdUkkBB+Ift88T2Y0o/W61vj9KGxc1YaVmP YasEVn0Q1u8SIxWuY0HVWFHRVRvQKBI5Ezoiqg8iWixRqU+1LXDC/4cSBC9uIhUzUu 1qhDUNwX6HC8zmp9rGNgcQtIZSoxYYNBBarOYwGwT5vQCNPzCCniAylWqOX5qrv0LB lSW/16Oi3mz5A== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/6] nfsd: eliminate find_deleg_file_locked Date: Wed, 18 Jan 2023 12:31:35 -0500 Message-Id: <20230118173139.71846-3-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org We really don't need an accessor function here. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 4dd0e8dbcbfa..57f24e3e46a0 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -686,15 +686,6 @@ static struct nfsd_file *find_any_file_locked(struct nfs4_file *f) return NULL; } -static struct nfsd_file *find_deleg_file_locked(struct nfs4_file *f) -{ - lockdep_assert_held(&f->fi_lock); - - if (f->fi_deleg_file) - return f->fi_deleg_file; - return NULL; -} - static atomic_long_t num_delegations; unsigned long max_delegations; @@ -2703,7 +2694,7 @@ static int nfs4_show_deleg(struct seq_file *s, struct nfs4_stid *st) ds = delegstateid(st); nf = st->sc_file; spin_lock(&nf->fi_lock); - file = find_deleg_file_locked(nf); + file = nf->fi_deleg_file; if (!file) goto out; From patchwork Wed Jan 18 17:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106714 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 701D6C46467 for ; Wed, 18 Jan 2023 17:32:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbjARRcW (ORCPT ); Wed, 18 Jan 2023 12:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230434AbjARRcF (ORCPT ); Wed, 18 Jan 2023 12:32:05 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313E359B4B for ; Wed, 18 Jan 2023 09:31:43 -0800 (PST) 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 BFB246194A for ; Wed, 18 Jan 2023 17:31:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42B3CC433F2; Wed, 18 Jan 2023 17:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063102; bh=vxQxIGJj2mtOgx+ZLWjaxruc0XAFN+T/yKwcGmDuHgE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pm7wiUEhs0mq5G5aqHdHEsgnLdA1bXq3qCfJ8cE8tYLaV9p6vLWS9yJOcxn6cZbsO 873GClIqpk8HDhlKk4Yi5/wbrthd/JOnZMq9HLhSpQkb4EFSSyv++IW+RDC55pY0lF a7DMILXHFgtjEXvuhe1cBZ+sh4mnkbxtNmEh/6O9yUWT5sm+nNmbNmy1h5kV3H2Ct9 hAPMT/Jwyh5Kr03AXCbIuRD7jA33sn+xiQW8N8eoSFIceaIDEqyA+IxMYXliXZUJQP TcXZu7iwObKdQ00N+cZcaxjtHt4Fj9MzggnOTlFHu/r+d8WZ/egthclC7Cs4HOPRsd YrGyDvyZxyJdw== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/6] nfsd: simplify the delayed disposal list code Date: Wed, 18 Jan 2023 12:31:36 -0500 Message-Id: <20230118173139.71846-4-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When queueing a dispose list to the appropriate "freeme" lists, it pointlessly queues the objects one at a time to an intermediate list. Remove a few helpers and just open code a list_move to make it more clear and efficient. Better document the resulting functions with kerneldoc comments. Signed-off-by: Jeff Layton --- fs/nfsd/filecache.c | 63 +++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 58ac93e7e680..a2bc4bd90b9a 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -513,49 +513,25 @@ nfsd_file_dispose_list(struct list_head *dispose) } } -static void -nfsd_file_list_remove_disposal(struct list_head *dst, - struct nfsd_fcache_disposal *l) -{ - spin_lock(&l->lock); - list_splice_init(&l->freeme, dst); - spin_unlock(&l->lock); -} - -static void -nfsd_file_list_add_disposal(struct list_head *files, struct net *net) -{ - struct nfsd_net *nn = net_generic(net, nfsd_net_id); - struct nfsd_fcache_disposal *l = nn->fcache_disposal; - - spin_lock(&l->lock); - list_splice_tail_init(files, &l->freeme); - spin_unlock(&l->lock); - queue_work(nfsd_filecache_wq, &l->work); -} - -static void -nfsd_file_list_add_pernet(struct list_head *dst, struct list_head *src, - struct net *net) -{ - struct nfsd_file *nf, *tmp; - - list_for_each_entry_safe(nf, tmp, src, nf_lru) { - if (nf->nf_net == net) - list_move_tail(&nf->nf_lru, dst); - } -} - +/** + * nfsd_file_dispose_list_delayed - move list of dead files to net's freeme list + * @dispose: list of nfsd_files to be disposed + * + * Transfers each file to the "freeme" list for its nfsd_net, to eventually + * be disposed of by the per-net garbage collector. + */ static void nfsd_file_dispose_list_delayed(struct list_head *dispose) { - LIST_HEAD(list); - struct nfsd_file *nf; - while(!list_empty(dispose)) { - nf = list_first_entry(dispose, struct nfsd_file, nf_lru); - nfsd_file_list_add_pernet(&list, dispose, nf->nf_net); - nfsd_file_list_add_disposal(&list, nf->nf_net); + struct nfsd_file *nf = list_first_entry(dispose, + struct nfsd_file, nf_lru); + struct nfsd_net *nn = net_generic(nf->nf_net, nfsd_net_id); + struct nfsd_fcache_disposal *l = nn->fcache_disposal; + + spin_lock(&l->lock); + list_move_tail(&nf->nf_lru, &l->freeme); + spin_unlock(&l->lock); } } @@ -765,8 +741,8 @@ nfsd_file_close_inode_sync(struct inode *inode) * nfsd_file_delayed_close - close unused nfsd_files * @work: dummy * - * Walk the LRU list and destroy any entries that have not been used since - * the last scan. + * Scrape the freeme list for this nfsd_net, and then dispose of them + * all. */ static void nfsd_file_delayed_close(struct work_struct *work) @@ -775,7 +751,10 @@ nfsd_file_delayed_close(struct work_struct *work) struct nfsd_fcache_disposal *l = container_of(work, struct nfsd_fcache_disposal, work); - nfsd_file_list_remove_disposal(&head, l); + spin_lock(&l->lock); + list_splice_init(&l->freeme, &head); + spin_unlock(&l->lock); + nfsd_file_dispose_list(&head); } From patchwork Wed Jan 18 17:31:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106716 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 23CF7C32793 for ; Wed, 18 Jan 2023 17:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbjARRcY (ORCPT ); Wed, 18 Jan 2023 12:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjARRcG (ORCPT ); Wed, 18 Jan 2023 12:32:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5F372410C for ; Wed, 18 Jan 2023 09:31:43 -0800 (PST) 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 4625761944 for ; Wed, 18 Jan 2023 17:31:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6C02C433D2; Wed, 18 Jan 2023 17:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063103; bh=2DX01B1JGxHfUZczB1DPpcTkQOI/O73Nyk/fLGuGKQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXlAR9WGfwRK+asGYNRXx2Fmb3rKfWfzkh6FdgFbrDdkXqfdC5XTL7K1KtTJYlxD6 F9G6MX8738Vr//iFlRbsigZy51cCunp99GDoagNXgXT31OTS8UcNlyUbTx8SdCfwDf 5ke0hbLYv2c8a4mv/cxJIt5eXHOIdV4/ycB1SlJAJx6D0WKhmgq5RT7XwPAt7kiSGe n0O5VCX8iVxi9+Q1tOzXLViCX08GXw1o64Rh1Oc/DnMNmhGQ1sWAql2ekgVM8mcNmm SSzRnvLz5wLRfOQhudo99O2HC3R+yNJNs+7rAz8MoFlvIbFImoJvM94SauBClvO0Cx Gd7m2epcOskAg== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/6] nfsd: don't take/put an extra reference when putting a file Date: Wed, 18 Jan 2023 12:31:37 -0500 Message-Id: <20230118173139.71846-5-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The last thing that filp_close does is an fput, so don't bother taking and putting the extra reference. Signed-off-by: Jeff Layton --- fs/nfsd/filecache.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index a2bc4bd90b9a..f604dd8109e4 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -401,11 +401,8 @@ nfsd_file_free(struct nfsd_file *nf) if (nf->nf_mark) nfsd_file_mark_put(nf->nf_mark); - if (nf->nf_file) { - get_file(nf->nf_file); + if (nf->nf_file) filp_close(nf->nf_file, NULL); - fput(nf->nf_file); - } /* * If this item is still linked via nf_lru, that's a bug. From patchwork Wed Jan 18 17:31:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106717 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 B2B87C38147 for ; Wed, 18 Jan 2023 17:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229618AbjARRcZ (ORCPT ); Wed, 18 Jan 2023 12:32:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbjARRcG (ORCPT ); Wed, 18 Jan 2023 12:32:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA14B4A1CA for ; Wed, 18 Jan 2023 09:31:44 -0800 (PST) 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 3D2506193C for ; Wed, 18 Jan 2023 17:31:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56DD4C433F0; Wed, 18 Jan 2023 17:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063103; bh=qXd7UofDAndibDp5dcB6hRuW3pUs9PniI5D9/6geaVc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gdBFDZaO7yW/4uXTgWXUO0usuu/vK3cD6mY6xwHac+O8qki9wvmuGAPbcu/6ChQvh sPLpmud9SdYrTY3K5pfOUlo+a3umYgG87o/+5VqMEju/yzwckOU1P6DoBa+pQ2H2ZH H2HwdCbuTNN+Qi1QKdqOoonaXUo6B2NS93F6w0d6c5pkJpg3oSf857E1SBvG8JqdtZ vgFgmMTOA9ZF6ApXSD4Nv1QvasrySe4xytofpd1b6u/pVSWfdtapvCj/yrCGCLQQIl 0jx53nwrSYTcQueOeoArgktnY7+XMuvOxQy6+hkuEe6hTdSDU4htpLd2OQfzftDrD6 RBW7hbf4OgmTA== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 5/6] nfsd: add some kerneldoc comments for stateid preprocessing functions Date: Wed, 18 Jan 2023 12:31:38 -0500 Message-Id: <20230118173139.71846-6-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 57f24e3e46a0..06a95f25c522 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -6539,8 +6539,19 @@ void nfs4_put_cpntf_state(struct nfsd_net *nn, struct nfs4_cpntf_state *cps) spin_unlock(&nn->s2s_cp_lock); } -/* - * Checks for stateid operations +/** + * nfs4_preprocess_stateid_op - find and prep stateid for an operation + * @rqstp: incoming request from client + * @cstate: current compound state + * @fhp: filehandle associated with requested stateid + * @stateid: stateid (provided by client) + * @flags: flags describing type of operation to be done + * @nfp: optional nfsd_file return pointer (may be NULL) + * @cstid: optional returned nfs4_stid pointer (may be NULL) + * + * Given info from the client, look up a nfs4_stid for the operation. On + * success, it returns a reference to the nfs4_stid and/or the nfsd_file + * associated with it. */ __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp, @@ -6729,8 +6740,18 @@ static __be32 nfs4_seqid_op_checks(struct nfsd4_compound_state *cstate, stateid_ return status; } -/* - * Checks for sequence id mutating operations. +/** + * nfs4_preprocess_seqid_op - find and prep an ol_stateid for a seqid-morphing op + * @cstate: compund state + * @seqid: seqid (provided by client) + * @stateid: stateid (provided by client) + * @typemask: mask of allowable types for this operation + * @stpp: return pointer for the stateid found + * @nn: net namespace for request + * + * Given a stateid+seqid from a client, look up an nfs4_ol_stateid and + * return it in @stpp. On a nfs_ok return, the returned stateid will + * have its st_mutex locked. */ static __be32 nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, From patchwork Wed Jan 18 17:31:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13106719 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 66704C32793 for ; Wed, 18 Jan 2023 17:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230212AbjARRc1 (ORCPT ); Wed, 18 Jan 2023 12:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbjARRcH (ORCPT ); Wed, 18 Jan 2023 12:32:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAE413801D for ; Wed, 18 Jan 2023 09:31:46 -0800 (PST) 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 79D3AB81E14 for ; Wed, 18 Jan 2023 17:31:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB6E2C433EF; Wed, 18 Jan 2023 17:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674063104; bh=3kNURuXV5VsUjoqAAWDksFKLe/DfV9UoeeIFj3Rmj8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xj9NFwb3KmwaLoKkhDcLeLqcbqqKspcZ1CcwGytjWjYDK2LQmPRWlsCuM0QhikYA6 yYYGUdFvA7ItKrXmkMNqzwZbAs71x8vo1V36EPPDsM24/B4JjUY5uFzERVTtNoSUxD 5r8Kaud+/6ueT7lwK4OZ7CsJ7zV5gyup1hnD1MRu5TIVkYHIwB2g8pg5pj4Vj0BojU KK8TzlGJ8o/WSvNTa/N2GgDkNM67eTB2F2gBKB3LPh6pfGEhxKc1/DAU7mqi5RT+Z1 Y6lbl047TmXagPHPluBHvAJjbt6b/0CXJ6R2zbz4sOFVajdGd4GP1+wyx/ZzSckYJu SIRm6y5059WNQ== From: Jeff Layton To: chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 6/6] nfsd: eliminate __nfs4_get_fd Date: Wed, 18 Jan 2023 12:31:39 -0500 Message-Id: <20230118173139.71846-7-jlayton@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230118173139.71846-1-jlayton@kernel.org> References: <20230118173139.71846-1-jlayton@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This is wrapper is pointless, and just obscures what's going on. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 06a95f25c522..e61b878a4b45 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -599,12 +599,6 @@ put_nfs4_file(struct nfs4_file *fi) } } -static struct nfsd_file * -__nfs4_get_fd(struct nfs4_file *f, int oflag) -{ - return nfsd_file_get(f->fi_fds[oflag]); -} - static struct nfsd_file * find_writeable_file_locked(struct nfs4_file *f) { @@ -612,9 +606,9 @@ find_writeable_file_locked(struct nfs4_file *f) lockdep_assert_held(&f->fi_lock); - ret = __nfs4_get_fd(f, O_WRONLY); + ret = nfsd_file_get(f->fi_fds[O_WRONLY]); if (!ret) - ret = __nfs4_get_fd(f, O_RDWR); + ret = nfsd_file_get(f->fi_fds[O_RDWR]); return ret; } @@ -637,9 +631,9 @@ find_readable_file_locked(struct nfs4_file *f) lockdep_assert_held(&f->fi_lock); - ret = __nfs4_get_fd(f, O_RDONLY); + ret = nfsd_file_get(f->fi_fds[O_RDONLY]); if (!ret) - ret = __nfs4_get_fd(f, O_RDWR); + ret = nfsd_file_get(f->fi_fds[O_RDWR]); return ret; } @@ -663,11 +657,11 @@ find_any_file(struct nfs4_file *f) if (!f) return NULL; spin_lock(&f->fi_lock); - ret = __nfs4_get_fd(f, O_RDWR); + ret = nfsd_file_get(f->fi_fds[O_RDWR]); if (!ret) { - ret = __nfs4_get_fd(f, O_WRONLY); + ret = nfsd_file_get(f->fi_fds[O_WRONLY]); if (!ret) - ret = __nfs4_get_fd(f, O_RDONLY); + ret = nfsd_file_get(f->fi_fds[O_RDONLY]); } spin_unlock(&f->fi_lock); return ret;