From patchwork Thu Dec 1 22:19:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9457161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1854560235 for ; Thu, 1 Dec 2016 22:19:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ACB328540 for ; Thu, 1 Dec 2016 22:19:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3D9F28542; Thu, 1 Dec 2016 22:19:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 669E028540 for ; Thu, 1 Dec 2016 22:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758182AbcLAWTa (ORCPT ); Thu, 1 Dec 2016 17:19:30 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:32971 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753817AbcLAWT3 (ORCPT ); Thu, 1 Dec 2016 17:19:29 -0500 Received: by mail-io0-f195.google.com with SMTP id j92so3934846ioi.0 for ; Thu, 01 Dec 2016 14:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=DH8r6Gzn9HmSFfGuoE9I79N6W2IkCjjywogsQkEOhXc=; b=R6TDlz6nP5+Vk0bs3wcjc7L9hLJVpGnY0x+uG6uI3lq3knFXE0+LSQeaYWRC6jY5IV 4lGQuRozIZErDW01IwQ0Pbg9Xgvme3v40mSyCmoSliTkf1a762AF6R46BKaDJtunWSb5 rndNl0Zk5ZVHKN9s+bDSxuNDtHyFWZ5c0xhAm8x8AX50/jVqzrrNhkxA2MiE9mEqtIbl pz0J7qHZy4lWfinBS6fRKwwH6+BlvL92LaL9jihp13w8RV553+RxzUqCU67ztU2NL6Mp Aa2QdU4VZ/y+4xx+C2PR21ANTN7Ae0QEdqIRdyLmACXog2NAg2bncYwEZazxV7FErFG6 RcRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=DH8r6Gzn9HmSFfGuoE9I79N6W2IkCjjywogsQkEOhXc=; b=VSa4hlrdbwVLYoOInz3r63kTtiAPQfDW2cgLXpRIC9/mJrGyGBC98kXkRVti2wMrvk PGtjRZYGfbRFrhKMHjVdHamixy+4qpsGsEq2JxNmOOZRfkSyzDb0ZcPICL+8I9wKGZvZ 54Jp6pUyflobycql4eZztUJbROscpyCwypWJTJiPSKActrnX2Ewjf8u9b7O9I0+msuGH +bRRft6YrudcNEHsFaTYp+NvmOyL9KD+aVWUW8cY9n7xdzSf1DeEIfEBkQvXwOsWir7H FBn9bH0qFUhxMZn082r8l7BZOVpE2dlZ3dO2xubcjqz+PnG/ldgw/LfDHKAzWKK8lppG 52FA== X-Gm-Message-State: AKaTC01/FelP7iBGnkcOcskn5Lp1Nxz+Obgq4oNmDbno0hKXFwcGKtt5FfgLW4wcilcfrA== X-Received: by 10.107.19.29 with SMTP id b29mr33172553ioj.219.1480630768634; Thu, 01 Dec 2016 14:19:28 -0800 (PST) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id t20sm6532ita.7.2016.12.01.14.19.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 14:19:27 -0800 (PST) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 04/26] pNFS: Force a retry of LAYOUTGET if the stateid doesn't match our cache Date: Thu, 1 Dec 2016 17:19:00 -0500 Message-Id: <20161201221922.15657-5-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161201221922.15657-4-trond.myklebust@primarydata.com> References: <20161201221922.15657-1-trond.myklebust@primarydata.com> <20161201221922.15657-2-trond.myklebust@primarydata.com> <20161201221922.15657-3-trond.myklebust@primarydata.com> <20161201221922.15657-4-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the server sends us a completely new stateid, and the client thinks it already holds a layout, then force a retry of the LAYOUTGET after invalidating the existing layout in order to avoid corruption due to races. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index d4e06b7459f4..9b7e88b7edfc 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1844,7 +1844,10 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) goto out_forget; } - if (nfs4_stateid_match_other(&lo->plh_stateid, &res->stateid)) { + if (!pnfs_layout_is_valid(lo)) { + /* We have a completely new layout */ + pnfs_set_layout_stateid(lo, &res->stateid, true); + } else if (nfs4_stateid_match_other(&lo->plh_stateid, &res->stateid)) { /* existing state ID, make sure the sequence number matches. */ if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { dprintk("%s forget reply due to sequence\n", __func__); @@ -1854,12 +1857,10 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) } else { /* * We got an entirely new state ID. Mark all segments for the - * inode invalid, and don't bother validating the stateid - * sequence number. + * inode invalid, and retry the layoutget */ pnfs_mark_layout_stateid_invalid(lo, &free_me); - - pnfs_set_layout_stateid(lo, &res->stateid, true); + goto out_forget; } pnfs_get_lseg(lseg);