From patchwork Sat Mar 12 07:58:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 659981 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2OJV9wh009564 for ; Thu, 24 Mar 2011 19:31:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933966Ab1CXT1d (ORCPT ); Thu, 24 Mar 2011 15:27:33 -0400 Received: from mx2.netapp.com ([216.240.18.37]:20152 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933958Ab1CXT1b (ORCPT ); Thu, 24 Mar 2011 15:27:31 -0400 X-IronPort-AV: E=Sophos;i="4.63,238,1299484800"; d="scan'208";a="534238633" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 24 Mar 2011 12:27:28 -0700 Received: from localhost.localdomain (goins5-lxp.hq.netapp.com [10.58.63.102] (may be forged)) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id p2OJRQ35028020; Thu, 24 Mar 2011 12:27:27 -0700 (PDT) From: andros@netapp.com To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Andy Adamson Subject: [PATCH 1/2] NFSv4.1 pnfs_layoutcommit_inode fixes Date: Sat, 12 Mar 2011 02:58:09 -0500 Message-Id: <1299916690-2595-1-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.6.6 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 (demeter1.kernel.org [140.211.167.41]); Thu, 24 Mar 2011 19:31:09 +0000 (UTC) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 2a08ca0..ac71125 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -982,6 +982,14 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata) } EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit); +/* + * For the LAYOUT4_NFSV4_1_FILES layout type, NFS_DATA_SYNC WRITEs and + * NFS_UNSTABLE WRITEs with a COMMIT to data servers must store enough + * data to disk to allow the server to recover the data if it crashes. + * LAYOUTCOMMIT is only needed when the NFL4_UFLG_COMMIT_THRU_MDS flag + * is off, and a COMMIT is sent to a data server, or + * if WRITEs to a data server return NFS_DATA_SYNC. + */ int pnfs_layoutcommit_inode(struct inode *inode, int sync) { @@ -994,10 +1002,18 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync) dprintk("--> %s inode %lu\n", __func__, inode->i_ino); + if (!test_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) + return 0; + /* Note kzalloc ensures data->res.seq_res.sr_slot == NULL */ data = kzalloc(sizeof(*data), GFP_NOFS); - spin_lock(&inode->i_lock); + if (!data) { + mark_inode_dirty_sync(inode); + status = -ENOMEM; + goto out; + } + spin_lock(&inode->i_lock); if (!test_and_clear_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { spin_unlock(&inode->i_lock); kfree(data); @@ -1014,16 +1030,8 @@ pnfs_layoutcommit_inode(struct inode *inode, int sync) lseg->pls_end_pos = 0; lseg->pls_lc_cred = NULL; - if (!data) { - put_lseg(lseg); - spin_unlock(&inode->i_lock); - put_rpccred(cred); - status = -ENOMEM; - goto out; - } else { - memcpy(&data->args.stateid.data, nfsi->layout->plh_stateid.data, - sizeof(nfsi->layout->plh_stateid.data)); - } + 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;