Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1319610ybi; Tue, 16 Jul 2019 13:05:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyY+CnBbz2MkjxGAxeziITP4p+QWiImykNKworLPRqvpevYPo/p0oiwa+2U9Kq+BCRimG7C X-Received: by 2002:a63:125c:: with SMTP id 28mr2938118pgs.255.1563307518577; Tue, 16 Jul 2019 13:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563307518; cv=none; d=google.com; s=arc-20160816; b=L1EMoQ6tOE8A4yTqoCn0yrNHamIlaIVjrG+rE465B7IV4zBy9NszMNpZzYgitwkXQt ZVaqAZLN20zGH5NphT1xxYOf3J4rsPC1AbiMb36pvNgXoQycSu3nNB+7v9fwUSJ8xx/c cS9lYUkuzWZn8gDR+dyleCiF6eWxzFNLGfUOLG0rvBbbXjy/5GgkgaHKreeBziTy7uM1 2frc+Bq+BhoTmuYjAprx4Own1FiHnBpQ6Io7v9oGDiJgRshtVMFQXTtacVHLItmPogoW cnSD+8LxKLTXuOWtR2BTPuX63fmF0CWzLUg7OAcW9weY+03T+RB7ViTKs2AnnaT+AqH2 VEUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cOCU8sNoqfD5V0WDIl6uxH5fLb7ChR5dgo0R85yvsvo=; b=XS+WSvBGMJXOEmTmZ11jHlhLaTrOuzpOjawu6ZJzzwR1GyVg/GPBx0gPhYhXuMRSqW /fm3voAbzT70of+nftaoiv3IwTm+EmNBtU31BnFGoE0Q+T9StQVnjae2RBtiX57YcHUs HK3loELXdZDnzoHMgzdyNrb9KR0ymGU2OX+pJ3y2M+zxtBkj2k3VG0asPFQY6AOPRFsp ys2nSCvsAP8KmeohgIsfJDQ6D6YC+JC0GyBaBOos6+ZCeBmzOabU2fnf37pDIGdfNAoj xXZ/kvwTLAZQ73Ii94DcnwqmTM97aasslpnwY6q4zT4axEx1hRcEu4oNMpzJhtflqCGa ia5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/yQA4zk"; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si19534314pjy.48.2019.07.16.13.05.02; Tue, 16 Jul 2019 13:05:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="J/yQA4zk"; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbfGPUEJ (ORCPT + 99 others); Tue, 16 Jul 2019 16:04:09 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:44002 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728575AbfGPUEJ (ORCPT ); Tue, 16 Jul 2019 16:04:09 -0400 Received: by mail-io1-f65.google.com with SMTP id k20so41977254ios.10 for ; Tue, 16 Jul 2019 13:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=cOCU8sNoqfD5V0WDIl6uxH5fLb7ChR5dgo0R85yvsvo=; b=J/yQA4zksHtaKFSOyLXQHvkb5G28IBu/a1OY6z2fivXBPbHX1hOO6SuSZ9Lj+JV2gw ENg2gMP5zKLTEaObsGF8D3DJ3Bw/ZcASKqbrBXEn5PDqy15kypCQPOEkqECC5tQT6dpT bkKZhRBKBae3vBHO+RGOx4Vp6gOIHQLwjisSm/UMC6QHpvjZG6SAjlepqQ2MAsyLOxi3 T4DEq+ZThhBQspUPH9jZWHf35riBUyKMkFeKS2dlIvVTtcpJuofEhc0jc8m3rEUIYlxo ZhxEehKX6ZpYdzMqXb8S6bQyrr3CwJqC3xXGLSUdfkmbLx0e+S8qtm5tH5pT1QKFZ22C NThg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cOCU8sNoqfD5V0WDIl6uxH5fLb7ChR5dgo0R85yvsvo=; b=oEujjtzKjhZSKIb22LenYVYzA9d4xSsc2VLdm+/dVsrkIS9MlE1ubUbuBBYnCDScKD IkUT9GDRgJ1Y8bi7+9dgB0tAmgTAs2gNarpT23dTD+ZmX4yEMxwvCnpH/vCdsFZKpwZB F08gyjlwzmMF+ar9xL4MFQMxaoXEOqSeZpbhlI1nxyDueowUmVgp0uOHYpySyc34yleQ nBbVPWVvUR9XJ5OdOfpy2iqQgJy0xMCtJOwRYAZYJ3DzksiKfVGXO2uCJBK4O1RT/HXA tANQMIV1qdmaJgc4J7KCNnEQWyPEh3M42F9hlAcR+zdC/XOk7BRwROysYPeLOpxcfyRy yX5g== X-Gm-Message-State: APjAAAV6GQVNu+4z/gXcvW7WmcJbWQUEeuOWnbgbqxU1ONRt+0Gxmopa I4bKjmnEB7cCkjf2C9s5qTMOcPw= X-Received: by 2002:a02:8814:: with SMTP id r20mr38491528jai.115.1563307448116; Tue, 16 Jul 2019 13:04:08 -0700 (PDT) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u4sm24997211iol.59.2019.07.16.13.04.07 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 13:04:07 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] NFSv4: Don't use the zero stateid with layoutget Date: Tue, 16 Jul 2019 16:01:57 -0400 Message-Id: <20190716200157.38583-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190716200157.38583-1-trond.myklebust@hammerspace.com> References: <20190716200157.38583-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org The NFSv4.1 protocol explicitly forbids us from using the zero stateid together with layoutget, so when we see that nfs4_select_rw_stateid() is unable to return a valid delegation, lock or open stateid, then we should initiate recovery and retry. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4state.c | 3 +-- fs/nfs/pnfs.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index f32b02c2bc73..9afd051a4876 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1064,8 +1064,7 @@ int nfs4_select_rw_stateid(struct nfs4_state *state, * choose to use. */ goto out; - nfs4_copy_open_stateid(dst, state); - ret = 0; + ret = nfs4_copy_open_stateid(dst, state) ? 0 : -EAGAIN; out: if (nfs_server_capable(state->inode, NFS_CAP_STATEID_NFSV41)) dst->seqid = 0; diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 56e423cd8180..519b7221e7e8 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1915,6 +1915,7 @@ pnfs_update_layout(struct inode *ino, * stateid. */ if (test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags)) { + int status; /* * The first layoutget for the file. Need to serialize per @@ -1934,13 +1935,19 @@ pnfs_update_layout(struct inode *ino, } first = true; - if (nfs4_select_rw_stateid(ctx->state, + status = nfs4_select_rw_stateid(ctx->state, iomode == IOMODE_RW ? FMODE_WRITE : FMODE_READ, - NULL, &stateid, NULL) != 0) { + NULL, &stateid, NULL); + if (status != 0) { trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, PNFS_UPDATE_LAYOUT_INVALID_OPEN); - goto out_unlock; + if (status != -EAGAIN) + goto out_unlock; + nfs4_schedule_stateid_recovery(server, ctx->state); + pnfs_clear_first_layoutget(lo); + pnfs_put_layout_hdr(lo); + goto lookup_again; } } else { nfs4_stateid_copy(&stateid, &lo->plh_stateid); -- 2.21.0