From patchwork Mon Feb 21 22:30:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benny Halevy X-Patchwork-Id: 578641 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 p1LMTpfn022573 for ; Mon, 21 Feb 2011 22:31:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751340Ab1BUWbE (ORCPT ); Mon, 21 Feb 2011 17:31:04 -0500 Received: from daytona.panasas.com ([67.152.220.89]:47231 "EHLO daytona.panasas.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751118Ab1BUWbC (ORCPT ); Mon, 21 Feb 2011 17:31:02 -0500 Received: from lt.bhalevy.com.com ([172.17.33.184]) by daytona.panasas.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 21 Feb 2011 17:31:02 -0500 From: Benny Halevy To: linux-nfs@vger.kernel.org Cc: Benny Halevy Subject: [PATCH 8/9] pnfs: fix nfs4_asynch_forget_layouts accounting Date: Mon, 21 Feb 2011 14:30:58 -0800 Message-Id: <1298327458-9310-1-git-send-email-bhalevy@panasas.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <4D62E6F3.8000304@panasas.com> References: <4D62E6F3.8000304@panasas.com> X-OriginalArrivalTime: 21 Feb 2011 22:31:02.0088 (UTC) FILETIME=[050B0480:01CBD217] 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]); Mon, 21 Feb 2011 22:31:05 +0000 (UTC) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 8c5f4b4..a10e8e8 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -441,17 +441,22 @@ should_free_lseg(struct pnfs_layout_range *lseg_range, lo_seg_intersecting(lseg_range, recall_range); } -static void mark_lseg_invalid(struct pnfs_layout_segment *lseg, +static bool mark_lseg_invalid(struct pnfs_layout_segment *lseg, struct list_head *tmp_list) { + bool rv; + assert_spin_locked(&lseg->layout->inode->i_lock); - if (test_and_clear_bit(NFS_LSEG_VALID, &lseg->pls_flags)) { + rv = test_and_clear_bit(NFS_LSEG_VALID, &lseg->pls_flags); + if (rv) { /* Remove the reference keeping the lseg in the * list. It will now be removed when all * outstanding io is finished. */ put_lseg_locked(lseg, tmp_list); } + + return rv; } /* Returns false if there was nothing to do, true otherwise */ @@ -652,8 +657,10 @@ bool nfs4_asynch_forget_layouts(struct pnfs_layout_hdr *lo, dprintk("%s\n", __func__); list_for_each_entry_safe(lseg, tmp, &lo->segs, fi_list) if (should_free_lseg(&lseg->range, range)) { - lseg->pls_notify_mask |= (1 << notify_idx); - atomic_inc(notify_count); + if (lseg->pls_notify_mask & (1 << notify_idx)) { + lseg->pls_notify_mask |= (1 << notify_idx); + atomic_inc(notify_count); + } mark_lseg_invalid(lseg, tmp_list); rv = true; }