From patchwork Tue Dec 16 19:01:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Haynes X-Patchwork-Id: 5503131 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E7F84BEEA8 for ; Tue, 16 Dec 2014 19:03:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21FC8209C1 for ; Tue, 16 Dec 2014 19:03:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 508BD209C4 for ; Tue, 16 Dec 2014 19:03:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751324AbaLPTDT (ORCPT ); Tue, 16 Dec 2014 14:03:19 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:52168 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbaLPTDS (ORCPT ); Tue, 16 Dec 2014 14:03:18 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so14658485pad.37 for ; Tue, 16 Dec 2014 11:03:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5BBuc92m0V9Su8ImfxxseFQmwgRNMPuxTUMgorRlkaE=; b=czDYOCiGqBxdWnbholGjJE23PM1ULVl0jHBMoDSxPclLPkCojW0usWZ4hrbnF6QTLn sVwEWEeM677HKlqBo8q6C/I/jE9viX0EfQDImp6BDXw4bwLWnMTB1Bo/diLvLt1hdd8H asqba8FvIoxyz7yvnQWawuTcZUHw2nibytGPA6C6noTNhCwTcjSmpuivDuB/OuieLnxF tpZLRIj5Kf/J8Bmb0Kva5290AoeGMNHJGI4YK3yHKI2E2AzZu3N+l/GA12ooFmf7V2dC NXT9Z4H13CcnkXf2ILlTHAVmxFRwqNstDAe045jNtagC5dS320IgvIHdFwSMbTeZBrZd 9XLA== X-Gm-Message-State: ALoCoQneHMIqjTZCuH3DWeuqYTTZLWQox43cCzKYXnzmwFzFmQt1NhttA7NumxdXA6BdDAQnOX9t X-Received: by 10.66.160.2 with SMTP id xg2mr62562124pab.111.1418756598253; Tue, 16 Dec 2014 11:03:18 -0800 (PST) Received: from localhost.localdomain ([50.242.95.105]) by mx.google.com with ESMTPSA id q4sm1620669pdh.79.2014.12.16.11.03.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Dec 2014 11:03:17 -0800 (PST) From: Tom Haynes X-Google-Original-From: Tom Haynes To: Trond Myklebust Cc: Linux NFS Mailing List Subject: [PATCH 39/50] nfs/flexfiles: send layoutreturn before freeing lseg Date: Tue, 16 Dec 2014 11:01:42 -0800 Message-Id: <1418756513-95187-40-git-send-email-loghyr@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1418756513-95187-1-git-send-email-loghyr@primarydata.com> References: <1418756513-95187-1-git-send-email-loghyr@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=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 From: Peng Tao Otherwise we'll lose error tracking information when encoding layoutreturn. Signed-off-by: Peng Tao Signed-off-by: Tom Haynes --- fs/nfs/pnfs.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index e123cfc..35465cb 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -355,7 +355,7 @@ pnfs_layout_need_return(struct pnfs_layout_hdr *lo, return false; list_for_each_entry(s, &lo->plh_segs, pls_list) - if (test_bit(NFS_LSEG_LAYOUTRETURN, &lseg->pls_flags)) + if (s != lseg && test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags)) return false; *stateid = lo->plh_stateid; @@ -386,15 +386,22 @@ pnfs_put_lseg(struct pnfs_layout_segment *lseg) enum pnfs_iomode iomode; pnfs_get_layout_hdr(lo); - pnfs_layout_remove_lseg(lo, lseg); need_return = pnfs_layout_need_return(lo, lseg, &stateid, &iomode); - spin_unlock(&inode->i_lock); - pnfs_free_lseg(lseg); - if (need_return) + if (need_return) { + spin_unlock(&inode->i_lock); + /* hdr reference dropped in nfs4_layoutreturn_release */ pnfs_send_layoutreturn(lo, stateid, iomode); - else + spin_lock(&inode->i_lock); + pnfs_layout_remove_lseg(lo, lseg); + spin_unlock(&inode->i_lock); + pnfs_free_lseg(lseg); + } else { + pnfs_layout_remove_lseg(lo, lseg); + spin_unlock(&inode->i_lock); + pnfs_free_lseg(lseg); pnfs_put_layout_hdr(lo); + } } } EXPORT_SYMBOL_GPL(pnfs_put_lseg);