From patchwork Mon Jun 30 15:49:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4451441 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 70FDA9F358 for ; Mon, 30 Jun 2014 15:51:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8032E201C0 for ; Mon, 30 Jun 2014 15:51:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8A4D92021A for ; Mon, 30 Jun 2014 15:51:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752007AbaF3Pv0 (ORCPT ); Mon, 30 Jun 2014 11:51:26 -0400 Received: from mail-qc0-f170.google.com ([209.85.216.170]:44968 "EHLO mail-qc0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750897AbaF3PvZ (ORCPT ); Mon, 30 Jun 2014 11:51:25 -0400 Received: by mail-qc0-f170.google.com with SMTP id l6so7308892qcy.1 for ; Mon, 30 Jun 2014 08:51:24 -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=Gm9mC36MxjGTP1g5Oiy8fvs2FxsTAM9TXUt3SxIRqY0=; b=hpYZx3D8QlgJh2KC0Q//8apyHiYWJOV7ujAyJHnhQ9etkUh4bg+/PJPOswy61MjHU2 3E9qZbk0OEGD/ToNiMwJ9JabKSpw6TPgSTOcyye9IMguFc5AYcVvxgwqD5BiNMl+Fezf JDsn7LkRMQhZQR0+fSMrmR6TWVxo6k5Y16lkHzt8RVjaTUA0M8SymVJaCQxjVItqbqhb gRktFnaAv8mEJIrmvZbLQu495NjP3e8dMS8b2dfKSh/6DtPI4ERyJ//i8DpskgOmMBn7 wMdsTfe7bKEwuETmrKZ2NyrSgEEmoSI1ikhxII5CfMYyb1pBTsUKkszvgCtKz7H6ut9G Xb8Q== X-Gm-Message-State: ALoCoQk451RrEN72Mxydbe8xTtDyAnfF6bW4bGacUbrZnC5dpSZOf34vPaYOPSJcNIiZo/h0EmkT X-Received: by 10.224.38.4 with SMTP id z4mr64403945qad.94.1404143484917; Mon, 30 Jun 2014 08:51:24 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id m1sm32584105qaz.27.2014.06.30.08.51.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jun 2014 08:51:24 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Trond Myklebust Subject: [PATCH v3 037/114] nfsd: Add a struct nfs4_file field to struct nfs4_stid Date: Mon, 30 Jun 2014 11:49:06 -0400 Message-Id: <1404143423-24381-38-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1404143423-24381-1-git-send-email-jlayton@primarydata.com> References: <1404143423-24381-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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 --- fs/nfsd/nfs4state.c | 18 +++++++++--------- fs/nfsd/state.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 380abf2258b3..76066ca9219c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -596,6 +596,8 @@ static void remove_stid(struct nfs4_stid *s) static void nfs4_free_stid(struct kmem_cache *slab, struct nfs4_stid *s) { + if (s->sc_file) + put_nfs4_file(s->sc_file); kmem_cache_free(slab, s); } @@ -603,8 +605,6 @@ void nfs4_put_delegation(struct nfs4_delegation *dp) { if (atomic_dec_and_test(&dp->dl_stid.sc_count)) { - if (dp->dl_file) - put_nfs4_file(dp->dl_file); nfs4_free_stid(deleg_slab, &dp->dl_stid); num_delegations--; } @@ -643,7 +643,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); @@ -3065,8 +3065,8 @@ 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); /* * We can't do this in nfsd_break_deleg_cb because it is @@ -3456,14 +3456,14 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp, int f fl->fl_flags = FL_DELEG; fl->fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; fl->fl_end = OFFSET_MAX; - fl->fl_owner = (fl_owner_t)(dp->dl_file); + fl->fl_owner = (fl_owner_t)(dp->dl_stid.sc_file); fl->fl_pid = current->tgid; return fl; } 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; int status = 0; @@ -3513,7 +3513,7 @@ static int nfs4_set_delegation(struct nfs4_delegation *dp, struct nfs4_file *fp) 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); @@ -4101,7 +4101,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 e1f6b8847670..339f430fd69f 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -84,6 +84,7 @@ struct nfs4_stid { unsigned char sc_type; stateid_t sc_stateid; struct nfs4_client *sc_client; + struct nfs4_file *sc_file; }; struct nfs4_delegation { @@ -91,7 +92,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: */