From patchwork Mon Dec 7 01:55:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 7779851 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 07248BEEE1 for ; Mon, 7 Dec 2015 01:55:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A9B520528 for ; Mon, 7 Dec 2015 01:55:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BCD920523 for ; Mon, 7 Dec 2015 01:55:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754612AbbLGBzT (ORCPT ); Sun, 6 Dec 2015 20:55:19 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33104 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754263AbbLGBzS (ORCPT ); Sun, 6 Dec 2015 20:55:18 -0500 Received: by pabfh17 with SMTP id fh17so119519957pab.0 for ; Sun, 06 Dec 2015 17:55:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=primarydata-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=CEUxYD1Ish4ASECYWbzl5Zl5dVPz59L7JjJGPfWd10Y=; b=pDztg7M9iaN/jZ2iw3lNJE8B0vvOIj4spTvv2BeigOA6Usd1MB2W+IxeNOxrJWkS2f XbJ1B/LX7UMpyf+DGpHBvB+HuvePtxrQdRRwOb1oTVS/MNP3m8KNuOPWhdDGO63AEdrQ GkbynM7QrdmclNiWH5CQSH+T7NfUAEF1PilBhqq8PlyT3xJ9psYxUSRnLGdXjUGF5uNb t0dpoGcV0oyZ15uCE6ZpGv7KvmNnlXp0LC4ca1giwfooc9bLgFOQv8grGH0ZdfEV0dhL XZav4hLSwyu4NNrBRql8Xag4ohGAvazkcnMzRs3Y6H/hCQVNU7NzNqeAeeiQAlGx/FPK AB0g== 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; bh=CEUxYD1Ish4ASECYWbzl5Zl5dVPz59L7JjJGPfWd10Y=; b=ap7mmzLLEAdShBt/Fw2Y32cJ/VAwJ1O2BBDyEFjGPmnIE6JJTAbSAPJvdScade7E5Z jyzSKjrK86jzu2vOINnxrWQNMzKvSdvRAky34XRrxVk74gbIsbt6mbocgrDwcFXVrp8N vXz9NzM8JNYikH0tCEiSLk7F/v1Cm/8vbxaOE7iGKhr84mGbtqi2rPrquFJJx1iyU1yk bPKZ4FgG1fq8L9ukDvUu/srJEAokSBY04YwZiLbeFom1QFi+vQ/tBsJ+/Hly+h0IrmYO cHjZlO10YrNH9ufBc16nAbdp7xospY87HSPzkm8gB/YsZEvM9CmjefcpuvVVYxx1rOkS keVA== X-Gm-Message-State: ALoCoQmyHu3GGg7Np952FWf4agqc9sPagmVMbaYRvDLDuFmKPNLTwQNy/9E846MZ6szuoVFdOSlo X-Received: by 10.66.227.231 with SMTP id sd7mr40192151pac.60.1449453318081; Sun, 06 Dec 2015 17:55:18 -0800 (PST) Received: from lear.localdomain (63-157-6-18.dia.static.qwest.net. [63.157.6.18]) by smtp.gmail.com with ESMTPSA id xi8sm30618229pab.9.2015.12.06.17.55.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Dec 2015 17:55:17 -0800 (PST) From: Peng Tao To: linux-nfs@vger.kernel.org Cc: Anna Schumaker , Trond.Myklebust@primarydata.com, Peng Tao Subject: [PATCH] NFS42: handle layoutstats stateid error Date: Sun, 6 Dec 2015 20:55:09 -0500 Message-Id: <1449453309-7192-1-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 When server returns layoutstats stateid error, we should invalidate client's layout so that next IO can trigger new layoutget. Signed-off-by: Peng Tao --- fs/nfs/nfs42proc.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 6b1ce98..6e81749 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -204,6 +204,8 @@ static void nfs42_layoutstat_done(struct rpc_task *task, void *calldata) { struct nfs42_layoutstat_data *data = calldata; + struct inode *inode = data->inode; + struct pnfs_layout_hdr *lo; if (!nfs4_sequence_done(task, &data->res.seq_res)) return; @@ -211,12 +213,35 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata) switch (task->tk_status) { case 0: break; + case -NFS4ERR_EXPIRED: + case -NFS4ERR_STALE_STATEID: + case -NFS4ERR_OLD_STATEID: + case -NFS4ERR_BAD_STATEID: + spin_lock(&inode->i_lock); + lo = NFS_I(inode)->layout; + if (lo && nfs4_stateid_match(&data->args.stateid, + &lo->plh_stateid)) { + LIST_HEAD(head); + + /* + * Mark the bad layout state as invalid, then retry + * with the current stateid. + */ + set_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags); + pnfs_mark_matching_lsegs_invalid(lo, &head, NULL); + spin_unlock(&inode->i_lock); + pnfs_free_lseg_list(&head); + } else + spin_unlock(&inode->i_lock); + break; case -ENOTSUPP: case -EOPNOTSUPP: - NFS_SERVER(data->inode)->caps &= ~NFS_CAP_LAYOUTSTATS; + NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS; default: - dprintk("%s server returns %d\n", __func__, task->tk_status); + break; } + + dprintk("%s server returns %d\n", __func__, task->tk_status); } static void