From patchwork Wed Jul 30 01:34:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4644031 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 42B339F440 for ; Wed, 30 Jul 2014 01:34:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50A882014A for ; Wed, 30 Jul 2014 01:34:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A6AC20142 for ; Wed, 30 Jul 2014 01:34:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754178AbaG3Bey (ORCPT ); Tue, 29 Jul 2014 21:34:54 -0400 Received: from mail-qa0-f45.google.com ([209.85.216.45]:35698 "EHLO mail-qa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752191AbaG3Bey (ORCPT ); Tue, 29 Jul 2014 21:34:54 -0400 Received: by mail-qa0-f45.google.com with SMTP id cm18so577347qab.32 for ; Tue, 29 Jul 2014 18:34:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zePAff2MWeEESYjO1nHejs+OfP8m+fxf52pfNtXQPlw=; b=JdmD9+JvsNOdrtp3/V4fgC8gCCLKwlegb4tlRtaNzZbBmdeyObk96MnfzbXYgW86zm +/Mx/D4UGMbu+ug7iUpE/VRpYcGlS/9bWwMpN1CDPV6bpc9kcPusJvaOpw3+N8yFM3nP d3dlhIuaQao54sutFBt2MM3OZAVoHswUe3gFZ+lllkfVwWscqdk+/CJ2j4c5+s3qB/s/ vv1xt4CCi8cLb5/I5tqkNIQkE81p5DFkCFK2Dql1ZTZtLEVSJGcs+rVHCw4VXCeiy9F7 FingYjaaoBGdKBqg5sW2aurarRyk7m73dbdv/d3wczG9vm7rx6QsPCWvlKeDw4qscgAw G+xQ== X-Gm-Message-State: ALoCoQmI28jfgw3++e4N7UhgAE7VFGqwQqJbA9+S59UvML+4Fx/pNTudAFu/vU/a60YQUBq8dmSL X-Received: by 10.229.235.133 with SMTP id kg5mr1360330qcb.24.1406684093376; Tue, 29 Jul 2014 18:34:53 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id 81sm860946qgw.21.2014.07.29.18.34.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Jul 2014 18:34:52 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, hch@infradead.org, Trond Myklebust Subject: [PATCH v3 03/38] nfsd: Add a struct nfs4_file field to struct nfs4_stid Date: Tue, 29 Jul 2014 21:34:08 -0400 Message-Id: <1406684083-19736-4-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1406684083-19736-1-git-send-email-jlayton@primarydata.com> References: <1406684083-19736-1-git-send-email-jlayton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Trond Myklebust All stateids are associated with a nfs4_file. Let's consolidate. Start by replacing delegation->dl_file with the dl_stid.sc_file Signed-off-by: Trond Myklebust Reviewed-by: Christoph Hellwig --- fs/nfsd/nfs4callback.c | 2 +- fs/nfsd/nfs4state.c | 21 ++++++++++----------- fs/nfsd/state.h | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 8574c708cf8c..e0be57b0f79b 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -337,7 +337,7 @@ static void encode_cb_recall4args(struct xdr_stream *xdr, p = xdr_reserve_space(xdr, 4); *p++ = xdr_zero; /* truncate */ - encode_nfs_fh4(xdr, &dp->dl_file->fi_fhandle); + encode_nfs_fh4(xdr, &dp->dl_stid.sc_file->fi_fhandle); hdr->nops++; } diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 60ab22b6e099..d6b0ef4e90fe 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -515,10 +515,6 @@ static struct nfs4_ol_stateid * nfs4_alloc_stateid(struct nfs4_client *clp) static void nfs4_free_deleg(struct nfs4_stid *stid) { - struct nfs4_delegation *dp = delegstateid(stid); - - if (dp->dl_file) - put_nfs4_file(dp->dl_file); kmem_cache_free(deleg_slab, stid); atomic_long_dec(&num_delegations); } @@ -636,12 +632,15 @@ out_dec: void nfs4_put_stid(struct nfs4_stid *s) { + struct nfs4_file *fp = s->sc_file; struct nfs4_client *clp = s->sc_client; if (!atomic_dec_and_test(&s->sc_count)) return; idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); s->sc_free(s); + if (fp) + put_nfs4_file(fp); } static void nfs4_put_deleg_lease(struct nfs4_file *fp) @@ -677,7 +676,7 @@ hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) static void unhash_delegation_locked(struct nfs4_delegation *dp) { - struct nfs4_file *fp = dp->dl_file; + struct nfs4_file *fp = dp->dl_stid.sc_file; lockdep_assert_held(&state_lock); @@ -3097,10 +3096,10 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type) void nfsd4_prepare_cb_recall(struct nfs4_delegation *dp) { - struct nfs4_client *clp = dp->dl_stid.sc_client; - struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); + struct nfsd_net *nn = net_generic(dp->dl_stid.sc_client->net, + nfsd_net_id); - block_delegations(&dp->dl_file->fi_fhandle); + block_delegations(&dp->dl_stid.sc_file->fi_fhandle); /* * We can't do this in nfsd_break_deleg_cb because it is @@ -3508,7 +3507,7 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_file *fp, int flag) static int nfs4_setlease(struct nfs4_delegation *dp) { - struct nfs4_file *fp = dp->dl_file; + struct nfs4_file *fp = dp->dl_stid.sc_file; struct file_lock *fl; struct file *filp; int status = 0; @@ -3573,7 +3572,7 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh, get_nfs4_file(fp); spin_lock(&state_lock); spin_lock(&fp->fi_lock); - dp->dl_file = fp; + dp->dl_stid.sc_file = fp; if (!fp->fi_lease) { spin_unlock(&fp->fi_lock); spin_unlock(&state_lock); @@ -4167,7 +4166,7 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, if (status) goto out; if (filpp) { - file = dp->dl_file->fi_deleg_file; + file = dp->dl_stid.sc_file->fi_deleg_file; if (!file) { WARN_ON_ONCE(1); status = nfserr_serverfault; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 32c466265ac1..c856601c15f6 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -85,6 +85,7 @@ struct nfs4_stid { unsigned char sc_type; stateid_t sc_stateid; struct nfs4_client *sc_client; + struct nfs4_file *sc_file; void (*sc_free)(struct nfs4_stid *); }; @@ -93,7 +94,6 @@ struct nfs4_delegation { struct list_head dl_perfile; struct list_head dl_perclnt; struct list_head dl_recall_lru; /* delegation recalled */ - struct nfs4_file *dl_file; u32 dl_type; time_t dl_time; /* For recall: */