From patchwork Wed Jun 15 16:31:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fred Isaman X-Patchwork-Id: 882642 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 p5FGVAE0017110 for ; Wed, 15 Jun 2011 16:31:26 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756008Ab1FOQbZ (ORCPT ); Wed, 15 Jun 2011 12:31:25 -0400 Received: from mx2.netapp.com ([216.240.18.37]:34772 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755284Ab1FOQbZ (ORCPT ); Wed, 15 Jun 2011 12:31:25 -0400 X-IronPort-AV: E=Sophos;i="4.65,370,1304319600"; d="scan'208";a="555804433" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 15 Jun 2011 09:31:09 -0700 Received: from localhost.localdomain (macintosh-4.local [10.55.72.175] (may be forged)) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id p5FGV7mh000394; Wed, 15 Jun 2011 09:31:07 -0700 (PDT) From: Fred Isaman To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Fred Isaman Subject: [PATCH 1/1] nfs4.1: prevent race that allowed use of freed layout in _pnfs_return_layout Date: Wed, 15 Jun 2011 12:31:02 -0400 Message-Id: <1308155462-29517-1-git-send-email-iisaman@netapp.com> X-Mailer: git-send-email 1.7.2.1 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]); Wed, 15 Jun 2011 16:31:26 +0000 (UTC) mark_matching_lsegs_invalid could put the last ref to the layout, so the get_layout_hdr needs to be called first. Signed-off-by: Fred Isaman --- fs/nfs/pnfs.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d25f66d..f99f068 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -646,10 +646,10 @@ _pnfs_return_layout(struct inode *ino) return status; } stateid = nfsi->layout->plh_stateid; - mark_matching_lsegs_invalid(lo, &tmp_list, NULL); - lo->plh_block_lgets++; /* Reference matched in nfs4_layoutreturn_release */ get_layout_hdr(lo); + mark_matching_lsegs_invalid(lo, &tmp_list, NULL); + lo->plh_block_lgets++; spin_unlock(&ino->i_lock); pnfs_free_lseg_list(&tmp_list);