From patchwork Tue Apr 12 21:17:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 702221 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 p3CLRcej029328 for ; Tue, 12 Apr 2011 21:27:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932600Ab1DLV1h (ORCPT ); Tue, 12 Apr 2011 17:27:37 -0400 Received: from mx1.netapp.com ([216.240.18.38]:47200 "EHLO mx1.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932568Ab1DLV1h (ORCPT ); Tue, 12 Apr 2011 17:27:37 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 12 Apr 2011 21:27:39 +0000 (UTC) X-Greylist: delayed 575 seconds by postgrey-1.27 at vger.kernel.org; Tue, 12 Apr 2011 17:27:37 EDT X-IronPort-AV: E=Sophos;i="4.64,199,1301900400"; d="scan'208";a="127832807" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx1-out.netapp.com with ESMTP; 12 Apr 2011 14:18:02 -0700 Received: from drosapp.netapp.com (matthewt1lxp.hq.netapp.com [10.58.54.100] (may be forged)) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id p3CLHIw8008412; Tue, 12 Apr 2011 14:17:19 -0700 (PDT) From: Weston Andros Adamson To: andros@netapp.com, trond@netapp.com Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH] Don't mark_inode_dirty_sync() while holding lock Date: Tue, 12 Apr 2011 17:17:08 -0400 Message-Id: <1302643028-76672-1-git-send-email-dros@netapp.com> X-Mailer: git-send-email 1.7.4.2 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org mark_inode_dirty_sync() grabs the same inode lock! race conditions between holding the lock in pnfs_set_layoutcommit() and in mark_inode_dirty_sync() can result in a second call to pnfs_layoutcommit_inode(), but this will be a noop as NFS_INO_LAYOUTCOMMIT won't be set in the second call --- fs/nfs/pnfs.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d9ab972..d71997e 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1004,6 +1004,7 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata) { struct nfs_inode *nfsi = NFS_I(wdata->inode); loff_t end_pos = wdata->args.offset + wdata->res.count; + int mark_as_dirty = false; spin_lock(&nfsi->vfs_inode.i_lock); if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { @@ -1011,13 +1012,18 @@ pnfs_set_layoutcommit(struct nfs_write_data *wdata) get_lseg(wdata->lseg); wdata->lseg->pls_lc_cred = get_rpccred(wdata->args.context->state->owner->so_cred); - mark_inode_dirty_sync(wdata->inode); + mark_as_dirty = true; dprintk("%s: Set layoutcommit for inode %lu ", __func__, wdata->inode->i_ino); } if (end_pos > wdata->lseg->pls_end_pos) wdata->lseg->pls_end_pos = end_pos; spin_unlock(&nfsi->vfs_inode.i_lock); + + /* if pnfs_layoutcommit_inode() runs between inode locks, the next one + * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */ + if (mark_as_dirty) + mark_inode_dirty_sync(wdata->inode); } EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit);