From patchwork Mon Oct 7 15:50:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 2997531 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 A96C09F1E1 for ; Mon, 7 Oct 2013 15:50:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 672212017C for ; Mon, 7 Oct 2013 15:50:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C31A2010E for ; Mon, 7 Oct 2013 15:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752802Ab3JGPu3 (ORCPT ); Mon, 7 Oct 2013 11:50:29 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:35841 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508Ab3JGPu2 (ORCPT ); Mon, 7 Oct 2013 11:50:28 -0400 Received: by mail-wi0-f171.google.com with SMTP id hm2so5045893wib.4 for ; Mon, 07 Oct 2013 08:50:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=NIVSLcA2ERoGBWFt/Kd2Qyu3CVNML0NQq2cJbZlx2yg=; b=aYVoMxnqnaN/vwoT1mI3djFrRNy3NxVHQ+4qt8uxv0hYnoSmOYas/RCA8SRUakXyqU xHbtWI34R1NYAINJzaVcFO5izvf3RndK9BCP6ZJVLxZTjUxPmGi+2OuBdDh23kgjT+5x vXuXUPSc/fTXZrp0TvnLxfunvRKjVs2pItbmErv1LJ/GYvjK/6Qooe4LlneOnbCb+mxN gdJjhjGV9bgq0O9KEJT5+jm040CXyPDBiajPzddG2YVt7QgTQ3U/yFnEn2TYY3rqCPlm Y/eYgzpKroYnTkRo8LrmQXigCuOsCp7FpdgB/C4HO2v1El8pPWn7zh/k5RFsDRiaQ+3d 2rQQ== X-Gm-Message-State: ALoCoQnKVGr88dZUs21QNyDFrltBPIcncfb7IVku7oqmKUbuQckR1OdPd7GHWl4QF7fVd0zYiKFA X-Received: by 10.194.23.8 with SMTP id i8mr1272547wjf.68.1381161027108; Mon, 07 Oct 2013 08:50:27 -0700 (PDT) Received: from bhalevy-lt.il.tonian.com (bzq-80-49-130.static.bezeqint.net. [82.80.49.130]) by mx.google.com with ESMTPSA id q5sm40498709wiz.3.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Oct 2013 08:50:26 -0700 (PDT) Message-ID: <5252D83D.5060504@primarydata.com> Date: Mon, 07 Oct 2013 18:50:21 +0300 From: Benny Halevy User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 MIME-Version: 1.0 To: linux-nfs@vger.kernel.org CC: Christoph Hellwig , Nadav Shemer Subject: [PATCH v2 3/4] SQUASHME: pnfsd: no need for find_file in layout commit/return References: <5251140B.4000203@primarydata.com> <1381045472-30717-1-git-send-email-bhalevy@primarydata.com> In-Reply-To: <1381045472-30717-1-git-send-email-bhalevy@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.1 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 the nfs4_file can be found via the layout stateid. Signed-off-by: Benny Halevy --- fs/nfsd/nfs4pnfsd.c | 64 ++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c index 52fd2d1..474c183 100644 --- a/fs/nfsd/nfs4pnfsd.c +++ b/fs/nfsd/nfs4pnfsd.c @@ -259,7 +259,7 @@ struct sbid_tracker { * Returns zero and the layout state in *lsp, or error. */ static __be32 -nfs4_process_layout_stateid(struct nfs4_client *clp, struct nfs4_file *fp, +nfs4_process_layout_stateid(struct nfs4_client *clp, stateid_t *stateid, unsigned char typemask, struct nfs4_layout_state **lsp) { @@ -267,8 +267,8 @@ struct sbid_tracker { __be32 status; struct nfs4_stid *stid; - dprintk("--> %s clp %p fp %p operation stateid=" STATEID_FMT "\n", - __func__, clp, fp, STATEID_VAL(stateid)); + dprintk("--> %s clp %p operation stateid=" STATEID_FMT "\n", + __func__, clp, STATEID_VAL(stateid)); nfs4_assert_state_locked(); status = nfsd4_lookup_stateid(stateid, typemask, &stid, true, @@ -295,10 +295,7 @@ struct sbid_tracker { dprintk("%s: layout stateid=" STATEID_FMT " ref=%d\n", __func__, STATEID_VAL(&ls->ls_stid.sc_stateid), atomic_read(&ls->ls_ref.refcount)); - if (lsp) - *lsp = ls; - else - put_layout_state(ls); + *lsp = ls; out: dprintk("<-- %s status %d\n", __func__, htonl(status)); @@ -920,30 +917,31 @@ struct super_block * { struct inode *ino = current_fh->fh_dentry->d_inode; struct super_block *sb = ino->i_sb; - struct nfs4_file *fp = NULL; struct nfs4_client *clp; + struct nfs4_layout_state *ls = NULL; __be32 nfserr = NFS4_OK; int status = 0; lcp->res.lc_size_chg = 0; nfs4_lock_state(); - fp = find_file(ino); clp = find_confirmed_client((clientid_t *)&lcp->lc_clientid, true, net_generic(SVC_NET(rqstp), nfsd_net_id)); - if (!fp || !clp) { + if (!clp) { nfserr = nfserr_inval; nfs4_unlock_state(); goto out; } - nfserr = nfs4_process_layout_stateid(clp, fp, &lcp->lc_sid, - NFS4_LAYOUT_STID, NULL); + nfserr = nfs4_process_layout_stateid(clp, &lcp->lc_sid, + NFS4_LAYOUT_STID, &ls); nfs4_unlock_state(); if (nfserr) goto out; if (sb->s_pnfs_op->layout_commit) { + struct nfs4_file *fp = ls->ls_file; + nfs4_file_lo_lock(fp); status = sb->s_pnfs_op->layout_commit(ino, &lcp->args, &lcp->res); nfs4_file_lo_unlock(fp); @@ -980,8 +978,11 @@ struct super_block * } out: - if (fp) - put_nfs4_file(fp); + if (ls) { + nfs4_lock_state(); + put_layout_state(ls); + nfs4_unlock_state(); + } return cpu_to_be32(nfserr); } @@ -1255,26 +1256,15 @@ int nfs4_pnfs_return_layout(struct svc_rqst *rqstp, goto out_unlock; if (lrp->args.lr_return_type == RETURN_FILE) { - fp = find_file(ino); - if (!fp) { - dprintk("%s: RETURN_FILE: no nfs4_file for ino %p:%lu\n", - __func__, ino, ino ? ino->i_ino : 0L); - /* If we had a layout on the file the nfs4_file would - * be referenced and we should have found it. Since we - * don't then it means all layouts were ROC and at this - * point we returned all of them on file close. - */ - goto out_unlock; - } - /* Check the stateid */ dprintk("%s PROCESS LO_STATEID inode %p\n", __func__, ino); - status = nfs4_process_layout_stateid(clp, fp, + status = nfs4_process_layout_stateid(clp, (stateid_t *)&lrp->args.lr_sid, NFS4_LAYOUT_STID, &ls); nfs4_unlock_state(); if (status) goto out; + fp = ls->ls_file; layouts_found = pnfs_return_file_layouts(lrp, ls, 0, &lo_destroy_list); } else { @@ -1283,20 +1273,14 @@ int nfs4_pnfs_return_layout(struct svc_rqst *rqstp, 0, &lo_destroy_list); } - dprintk("pNFS %s: clp %p fp %p layout_type 0x%x iomode %d " + dprintk("pNFS %s: clp %p fp %p ino %lu layout_type 0x%x iomode %d " "return_type %d fsid 0x%llx offset %llu length %llu: " "layouts_found %d\n", - __func__, clp, fp, lrp->args.lr_seg.layout_type, + __func__, clp, fp, ino->i_ino, lrp->args.lr_seg.layout_type, lrp->args.lr_seg.iomode, lrp->args.lr_return_type, ex_fsid, lrp->args.lr_seg.offset, lrp->args.lr_seg.length, layouts_found); - nfs4_lock_state(); - if (ls) - put_layout_state(ls); - destroy_layout_list(&lo_destroy_list); - nfs4_unlock_state(); - /* update layoutrecalls * note: for RETURN_{FSID,ALL}, fp may be NULL */ @@ -1316,10 +1300,14 @@ int nfs4_pnfs_return_layout(struct svc_rqst *rqstp, layoutrecall_list_done_put(&lo_destroy_list); -out: - if (fp) - put_nfs4_file(fp); + /* put_layout_state here as we need to keep a reference on ls_file */ + nfs4_lock_state(); + if (ls) + put_layout_state(ls); + destroy_layout_list(&lo_destroy_list); + nfs4_unlock_state(); +out: dprintk("pNFS %s: exit status %d\n", __func__, status); return status; out_unlock: