From patchwork Thu Sep 26 18:41:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950331 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3EB9BBFF0B for ; Thu, 26 Sep 2013 18:41:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 40A2A202DD for ; Thu, 26 Sep 2013 18:41:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A5052017B for ; Thu, 26 Sep 2013 18:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754011Ab3IZSlk (ORCPT ); Thu, 26 Sep 2013 14:41:40 -0400 Received: from mail-qe0-f45.google.com ([209.85.128.45]:48619 "EHLO mail-qe0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553Ab3IZSlk (ORCPT ); Thu, 26 Sep 2013 14:41:40 -0400 Received: by mail-qe0-f45.google.com with SMTP id 6so1099819qea.4 for ; Thu, 26 Sep 2013 11:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z8qkcHryYv71Q6D7ffX9MqWk6lnMeXGilBqMOCkDwpE=; b=BO/cWknxh7U9cacCYdNtKmMEWsfftGoPxQkUUS+nbhL0DRt5uxaE7+8w9sf0EgO234 k1ohSHPjsBRCM89NzWboO4l19tJVe1y5AqoPgOJAqk0cKBYxlELgpe4naFh5tDzlAOn/ 79hwCrUdycLNjuITPW9J2BTzV9GTCtGpGn4sgz9u39RAxjYnLLcd6SPE2WXyrz+ozZdp 0wO/xlEAMS/Opc7Bd/N5nFjnr/mxQNhZDXbMAx7AlQ0Z8vYQYLgWo8CtDBprJmeCCmXe wRsoIlckcjyi7Rxrg/X+tTYzjlBUbrVOX5FhRJpFLn2rNVXByR34PUD/xwEyBFJniIYD ooyw== X-Received: by 10.49.131.132 with SMTP id om4mr3724261qeb.2.1380220899803; Thu, 26 Sep 2013 11:41:39 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com.com (nat-pool-bos-u.redhat.com. [66.187.233.207]) by mx.google.com with ESMTPSA id h6sm5125307qej.4.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:41:38 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 26/49] pnfsd: layout state per file tracking Date: Thu, 26 Sep 2013 14:41:37 -0400 Message-Id: <1380220897-13872-1-git-send-email-bhalevy@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <52447EA0.7070004@primarydata.com> References: <52447EA0.7070004@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=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,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 Signed-off-by: Benny Halevy --- fs/nfsd/nfs4pnfsd.c | 15 +++++++++++---- fs/nfsd/nfs4state.c | 3 +++ fs/nfsd/pnfsd.h | 2 ++ fs/nfsd/state.h | 3 +++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c index 2d5ddf7..2c5d30d 100644 --- a/fs/nfsd/nfs4pnfsd.c +++ b/fs/nfsd/nfs4pnfsd.c @@ -120,7 +120,8 @@ struct sbid_tracker { * Note: must be called under the state lock */ static struct nfs4_layout_state * -alloc_init_layout_state(struct nfs4_client *clp, stateid_t *stateid) +alloc_init_layout_state(struct nfs4_client *clp, struct nfs4_file *fp, + stateid_t *stateid) { struct nfs4_layout_state *new; @@ -131,9 +132,13 @@ struct sbid_tracker { kref_init(&new->ls_ref); new->ls_stid.sc_type = NFS4_LAYOUT_STID; INIT_LIST_HEAD(&new->ls_perclnt); + INIT_LIST_HEAD(&new->ls_perfile); new->ls_client = clp; + get_nfs4_file(fp); /* released on destroy_layout_state */ + new->ls_file = fp; spin_lock(&layout_lock); list_add(&new->ls_perclnt, &clp->cl_lo_states); + list_add(&new->ls_perfile, &fp->fi_lo_states); spin_unlock(&layout_lock); return new; } @@ -149,6 +154,7 @@ struct sbid_tracker { { ASSERT_LAYOUT_LOCKED(); list_del_init(&ls->ls_perclnt); + list_del_init(&ls->ls_perfile); } /* @@ -166,6 +172,7 @@ struct sbid_tracker { unhash_layout_state(ls); spin_unlock(&layout_lock); } + put_nfs4_file(ls->ls_file); nfsd4_free_stid(layout_state_slab, &ls->ls_stid); } @@ -212,7 +219,7 @@ struct sbid_tracker { /* Is this the first use of this layout ? */ if (stid->sc_type != NFS4_LAYOUT_STID) { - ls = alloc_init_layout_state(clp, stateid); + ls = alloc_init_layout_state(clp, fp, stateid); if (!ls) { status = nfserr_jukebox; goto out; @@ -266,8 +273,8 @@ static void update_layout_stateid_locked(struct nfs4_layout_state *ls, stateid_t struct nfsd4_layout_seg *seg, stateid_t *stateid) { - dprintk("pNFS %s: lp %p ls %p\n", __func__, - lp, ls); + dprintk("pNFS %s: lp %p ls %p ino %lu\n", __func__, + lp, ls, ls->ls_file->fi_inode->i_ino); memcpy(&lp->lo_seg, seg, sizeof(lp->lo_seg)); get_layout_state(ls); /* put on destroy_layout */ diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 0e2266f..e11d96f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2509,6 +2509,9 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino, fp->fi_lease = NULL; memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); memset(fp->fi_access, 0, sizeof(fp->fi_access)); +#if defined(CONFIG_PNFSD) + INIT_LIST_HEAD(&fp->fi_lo_states); +#endif /* CONFIG_PNFSD */ spin_lock(&recall_lock); hlist_add_head(&fp->fi_hash, &file_hashtbl[hashval]); spin_unlock(&recall_lock); diff --git a/fs/nfsd/pnfsd.h b/fs/nfsd/pnfsd.h index a0363a7..852c250 100644 --- a/fs/nfsd/pnfsd.h +++ b/fs/nfsd/pnfsd.h @@ -46,6 +46,8 @@ struct nfs4_layout_state { struct kref ls_ref; struct list_head ls_perclnt; struct nfs4_client *ls_client; + struct list_head ls_perfile; + struct nfs4_file *ls_file; }; /* outstanding layout */ diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 187d169..1ef09ae 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -405,6 +405,9 @@ struct nfs4_file { atomic_t fi_delegees; struct inode *fi_inode; bool fi_had_conflict; +#if defined(CONFIG_PNFSD) + struct list_head fi_lo_states; +#endif /* CONFIG_PNFSD */ }; /* XXX: for first cut may fall back on returning file that doesn't work