From patchwork Sun Jul 17 23:58:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Rees X-Patchwork-Id: 985032 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6HNxWJZ030233 for ; Sun, 17 Jul 2011 23:59:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756383Ab1GQX7Y (ORCPT ); Sun, 17 Jul 2011 19:59:24 -0400 Received: from merit-proxy02.merit.edu ([207.75.116.194]:48921 "EHLO merit-proxy02.merit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756323Ab1GQX7X (ORCPT ); Sun, 17 Jul 2011 19:59:23 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by merit-proxy02.merit.edu (Postfix) with ESMTP id B067E2039864; Sun, 17 Jul 2011 19:59:22 -0400 (EDT) X-Virus-Scanned: amavisd-new at merit-proxy02.merit.edu Received: from merit-proxy02.merit.edu ([127.0.0.1]) by localhost (merit-proxy02.merit.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JxsGVjOD5bKf; Sun, 17 Jul 2011 19:59:22 -0400 (EDT) Received: from merit.edu (74-126-0-171.static.123.net [74.126.0.171]) by merit-proxy02.merit.edu (Postfix) with ESMTPSA id E5CDA203984C; Sun, 17 Jul 2011 19:59:21 -0400 (EDT) From: Jim Rees To: Trond Myklebust Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 04/25] NFS41: save layoutcommit cred after first successful layoutget Date: Sun, 17 Jul 2011 19:58:51 -0400 Message-Id: <1310947152-12255-5-git-send-email-rees@umich.edu> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310947152-12255-1-git-send-email-rees@umich.edu> References: <1310947152-12255-1-git-send-email-rees@umich.edu> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 17 Jul 2011 23:59:32 +0000 (UTC) From: Peng Tao Save it in layout header instead of in every segment. Signed-off-by: Peng Tao --- fs/nfs/pnfs.c | 12 ++++++------ fs/nfs/pnfs.h | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index dae19dd..fbebd2a 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -211,6 +211,7 @@ destroy_layout_hdr(struct pnfs_layout_hdr *lo) dprintk("%s: freeing layout cache %p\n", __func__, lo); BUG_ON(!list_empty(&lo->plh_layouts)); NFS_I(lo->plh_inode)->layout = NULL; + put_rpccred(lo->plh_lc_cred); pnfs_free_layout_hdr(lo); } @@ -1007,6 +1008,10 @@ pnfs_update_layout(struct inode *ino, list_del_init(&lo->plh_layouts); spin_unlock(&clp->cl_lock); } + if (first) { + lo->plh_lc_cred = + get_rpccred(ctx->state->owner->so_cred); + } atomic_dec(&lo->plh_outstanding); put_layout_hdr(lo); out: @@ -1386,8 +1391,6 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata) spin_lock(&nfsi->vfs_inode.i_lock); if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { mark_as_dirty = true; - nfsi->layout->plh_lc_cred = - get_rpccred(wdata->args.context->state->owner->so_cred); dprintk("%s: Set layoutcommit for inode %lu ", __func__, wdata->inode->i_ino); } @@ -1421,7 +1424,6 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) { struct nfs4_layoutcommit_data *data; struct nfs_inode *nfsi = NFS_I(inode); - struct rpc_cred *cred; loff_t end_pos; int status = 0; @@ -1449,16 +1451,14 @@ pnfs_layoutcommit_inode(struct inode *inode, bool sync) pnfs_list_write_lseg(inode, &data->lseg_list); end_pos = nfsi->layout->plh_lwb; - cred = nfsi->layout->plh_lc_cred; nfsi->layout->plh_lwb = 0; - nfsi->layout->plh_lc_cred = NULL; memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data, sizeof(nfsi->layout->plh_stateid.data)); spin_unlock(&inode->i_lock); data->args.inode = inode; - data->cred = cred; + data->cred = get_rpccred(nfsi->layout->plh_lc_cred); nfs_fattr_init(&data->fattr); data->args.bitmask = NFS_SERVER(inode)->cache_consistency_bitmask; data->res.fattr = &data->fattr; diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 5f1b532..bddd8b9 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -46,7 +46,6 @@ struct pnfs_layout_segment { atomic_t pls_refcount; unsigned long pls_flags; struct pnfs_layout_hdr *pls_layout; - struct rpc_cred *pls_lc_cred; /* LAYOUTCOMMIT credential */ }; enum pnfs_try_status {