From patchwork Thu Sep 26 18:41:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2950321 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 27849BFF0B for ; Thu, 26 Sep 2013 18:41:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B205202DD for ; Thu, 26 Sep 2013 18:41:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BDB9B202E6 for ; Thu, 26 Sep 2013 18:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754010Ab3IZSlh (ORCPT ); Thu, 26 Sep 2013 14:41:37 -0400 Received: from mail-qa0-f44.google.com ([209.85.216.44]:33956 "EHLO mail-qa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753553Ab3IZSlg (ORCPT ); Thu, 26 Sep 2013 14:41:36 -0400 Received: by mail-qa0-f44.google.com with SMTP id j7so4653499qaq.10 for ; Thu, 26 Sep 2013 11:41:35 -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=OMJcN6bS94Kk5QnsdQtRDngwbXzMrzAe+obIFO4tLw0=; b=Fm25vmff+HApzU9vXeS2nPTpdLj+eGryeNzUOFAXNJWXeXliR5OX3+Ih39+vt1HEBY iQoKViJLW0NpaoLcQbtHHA1x0HbtbfM0ehZaTsSRl4Sbid0WkcSJ/OUIrDo3CyfY9yVN mRD0tzoyZPMUIc8ECGWfvNjacbMUuUCkNCSGo1F3SuduMRDLZj/umFTRZTd7UvSlxAPM VjAFMDGImkdxo2RssMgaAOC0PZNz7XQ/KE7RYUQhB7ZO1k5pmgMeOBC07zF+vlFQOc+e kZl3wgpCJhHAwEdQx4bo//Bqd4uhTUpop2qUPkDgqz0rA1eQ63m/kS1X2/s/F9rQDOV9 kMIA== X-Received: by 10.224.20.132 with SMTP id f4mr8859931qab.42.1380220895876; Thu, 26 Sep 2013 11:41:35 -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 f5sm5117837qev.8.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 26 Sep 2013 11:41:35 -0700 (PDT) From: Benny Halevy To: " J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH RFC v0 25/49] pnfsd: layout state per client tracking Date: Thu, 26 Sep 2013 14:41:33 -0400 Message-Id: <1380220893-13824-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 List the layout state on the respective file and client structures and list all layout segments associated with the layout state on the respective layout state structure. Use the layout state list (lo_layouts) for looking up the layout. Signed-off-by: Benny Halevy --- fs/nfsd/nfs4pnfsd.c | 40 +++++++++++++++++++++++++++++++++++++--- fs/nfsd/nfs4state.c | 3 +++ fs/nfsd/pnfsd.h | 4 ++++ fs/nfsd/state.h | 3 +++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c index e28c396..2d5ddf7 100644 --- a/fs/nfsd/nfs4pnfsd.c +++ b/fs/nfsd/nfs4pnfsd.c @@ -130,6 +130,11 @@ struct sbid_tracker { return new; kref_init(&new->ls_ref); new->ls_stid.sc_type = NFS4_LAYOUT_STID; + INIT_LIST_HEAD(&new->ls_perclnt); + new->ls_client = clp; + spin_lock(&layout_lock); + list_add(&new->ls_perclnt, &clp->cl_lo_states); + spin_unlock(&layout_lock); return new; } @@ -139,6 +144,13 @@ struct sbid_tracker { kref_get(&ls->ls_ref); } +static void +unhash_layout_state(struct nfs4_layout_state *ls) +{ + ASSERT_LAYOUT_LOCKED(); + list_del_init(&ls->ls_perclnt); +} + /* * Note: must be called under the state lock */ @@ -149,6 +161,11 @@ struct sbid_tracker { container_of(kref, struct nfs4_layout_state, ls_ref); nfsd4_remove_stid(&ls->ls_stid); + if (!list_empty(&ls->ls_perclnt)) { + spin_lock(&layout_lock); + unhash_layout_state(ls); + spin_unlock(&layout_lock); + } nfsd4_free_stid(layout_state_slab, &ls->ls_stid); } @@ -234,13 +251,30 @@ struct sbid_tracker { kmem_cache_free(pnfs_layout_slab, lp); } +static void update_layout_stateid_locked(struct nfs4_layout_state *ls, stateid_t *sid) +{ + update_stateid(&(ls)->ls_stid.sc_stateid); + memcpy((sid), &(ls)->ls_stid.sc_stateid, sizeof(stateid_t)); + dprintk("%s Updated ls_stid to %d on layoutstate %p\n", + __func__, sid->si_generation, ls); +} + static void init_layout(struct nfs4_layout *lp, - struct nfsd4_layout_seg *seg) + struct nfs4_layout_state *ls, + struct svc_fh *current_fh, + struct nfsd4_layout_seg *seg, + stateid_t *stateid) { - dprintk("pNFS %s: lp %p\n", __func__, lp); + dprintk("pNFS %s: lp %p ls %p\n", __func__, + lp, ls); memcpy(&lp->lo_seg, seg, sizeof(lp->lo_seg)); + get_layout_state(ls); /* put on destroy_layout */ + lp->lo_state = ls; + spin_lock(&layout_lock); + update_layout_stateid_locked(ls, stateid); + spin_unlock(&layout_lock); dprintk("pNFS %s end\n", __func__); } @@ -443,7 +477,7 @@ struct super_block * lgp->lg_seg = res.lg_seg; lgp->lg_roc = res.lg_return_on_close; - init_layout(lp, &res.lg_seg); + init_layout(lp, ls, lgp->lg_fhp, &res.lg_seg, &lgp->lg_sid); out_unlock: if (ls) put_layout_state(ls); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index fa292bb..0e2266f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1363,6 +1363,9 @@ static struct nfs4_client *create_client(struct xdr_netobj name, INIT_LIST_HEAD(&clp->cl_idhash); INIT_LIST_HEAD(&clp->cl_openowners); INIT_LIST_HEAD(&clp->cl_delegations); +#if defined(CONFIG_PNFSD) + INIT_LIST_HEAD(&clp->cl_lo_states); +#endif /* CONFIG_PNFSD */ INIT_LIST_HEAD(&clp->cl_lru); INIT_LIST_HEAD(&clp->cl_callbacks); INIT_LIST_HEAD(&clp->cl_revoked); diff --git a/fs/nfsd/pnfsd.h b/fs/nfsd/pnfsd.h index c2360e4..a0363a7 100644 --- a/fs/nfsd/pnfsd.h +++ b/fs/nfsd/pnfsd.h @@ -44,10 +44,14 @@ struct nfs4_layout_state { struct nfs4_stid ls_stid; /* must be first field */ struct kref ls_ref; + struct list_head ls_perclnt; + struct nfs4_client *ls_client; }; /* outstanding layout */ struct nfs4_layout { + struct list_head lo_perstate; + struct nfs4_layout_state *lo_state; struct nfsd4_layout_seg lo_seg; }; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 8c6e097..187d169 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -291,6 +291,9 @@ struct nfs4_client { struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */ /* wait here for slots */ struct net *net; +#if defined(CONFIG_PNFSD) + struct list_head cl_lo_states; /* outstanding layout states */ +#endif /* CONFIG_PNFSD */ }; /* struct nfs4_client_reset