From patchwork Mon Sep 9 14:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138037 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7DEE4912 for ; Mon, 9 Sep 2019 14:03:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A63421924 for ; Mon, 9 Sep 2019 14:03:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E3gP3ZFx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405099AbfIIODN (ORCPT ); Mon, 9 Sep 2019 10:03:13 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:42250 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405095AbfIIODN (ORCPT ); Mon, 9 Sep 2019 10:03:13 -0400 Received: by mail-io1-f65.google.com with SMTP id n197so28882835iod.9 for ; Mon, 09 Sep 2019 07:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u+xAWTrh/Lsv4sQba0rlaTvUNAip8h2KHmmPmv3mJ88=; b=E3gP3ZFxIipvF6EBMaFd2J9ed+u3c3kfAictPVTGoNMI6N07WG5utT9SnAtcO4YQdB IT+XaUsKXiqTVfhbTk00MWbWwns3+AsdRKPzB4fDEHXXkccaAL0QQozkXDdb9L0mM9MM p645CIq1c/S6di7sEkO9a1gWQSQ9cg1N0/0zbo6nuUXd4M3/lU37IHLjOgw91tBhPYbJ EmIp1EXq+ZLe/A5Y4g6PcisXLrXlSwThR3nXb2+0uxK+ilcKtxqTFylTK9K7bRVOSVYH +T2GecxXrDrvQXaIjg7o5XPlFfqi5aq1bn2NqtomSBiGkCZWB9C7aLQ/2LwenQ9PVMhM LHTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u+xAWTrh/Lsv4sQba0rlaTvUNAip8h2KHmmPmv3mJ88=; b=ewm4nL0utKDOqKiF77hJDdpk1SqYEw9SS8VD7/9hOQ0IkYoDGzuyu6WgFz9s3Xl1TE ddqzmWrlPwkz4gcMNsSOrQ9gzvysH/pWWIA0EEe2mKrV5QreSDUKRa+UzqDTWJsHKZN9 ospyL8/yxzg9CWLyKwTkhPYnbe/IEX/bwSBPsFvOTiBrqsuIQQQ4gHSIkvc+tcuhjmwc 9nQLrRbGUuwCUOEiEL5Jsna/annKDaox3RYx4mJnmu4IZIHXAkxjQKdb/sLVn584aMaS /prNqC8TbFF5/ccjwWOe1J4OSA60S+JoSASEzCeOFhP+KJgVu5tANKhU94+6LD3997+R r3Yg== X-Gm-Message-State: APjAAAVOmbegRTei4wMmwuH+4ryeS/Tz5QlvJHfN9x9HO99s7lnoCUgB 8mVOpbs5NKvxzygPzs7s5/9/4TyGbQ== X-Google-Smtp-Source: APXvYqx6IPetCj5FuSeVV+vMJW+LSlV5g9d4G2SE3N+x8JCIKcRlTesdtRx7oucb3FoG899jl/4DmQ== X-Received: by 2002:a5d:9714:: with SMTP id h20mr21006595iol.294.1568037792635; Mon, 09 Sep 2019 07:03:12 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:12 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/9] pNFS: Ensure we do clear the return-on-close layout stateid on fatal errors Date: Mon, 9 Sep 2019 10:00:56 -0400 Message-Id: <20190909140104.78818-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org IF the server rejected our layout return with a state error such as NFS4ERR_BAD_STATEID, or even a stale inode error, then we do want to clear out all the remaining layout segments and mark that stateid as invalid. Fixes: 1c5bd76d17cca ("pNFS: Enable layoutreturn operation for...") Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 4525d5acae38..0418b198edd3 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1449,10 +1449,15 @@ void pnfs_roc_release(struct nfs4_layoutreturn_args *args, const nfs4_stateid *res_stateid = NULL; struct nfs4_xdr_opaque_data *ld_private = args->ld_private; - if (ret == 0) { - arg_stateid = &args->stateid; + switch (ret) { + case -NFS4ERR_NOMATCHING_LAYOUT: + break; + case 0: if (res->lrs_present) res_stateid = &res->stateid; + /* Fallthrough */ + default: + arg_stateid = &args->stateid; } pnfs_layoutreturn_free_lsegs(lo, arg_stateid, &args->range, res_stateid); From patchwork Mon Sep 9 14:00:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138039 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6D0D912 for ; Mon, 9 Sep 2019 14:03:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9AC7C21924 for ; Mon, 9 Sep 2019 14:03:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sU0bsG0d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405085AbfIIODP (ORCPT ); Mon, 9 Sep 2019 10:03:15 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:45826 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405066AbfIIODO (ORCPT ); Mon, 9 Sep 2019 10:03:14 -0400 Received: by mail-io1-f67.google.com with SMTP id f12so28825352iog.12 for ; Mon, 09 Sep 2019 07:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NYN5Bd9Dd0vS7p9p+LtozvKO/VbaMtj9Dt0A4GBDoyM=; b=sU0bsG0ddHq/A1WhfDx17RCzU1xNxFpPEdvN60DUmOdli5heM0hoARipzomg7LpIvh NfzmfSMDfmkmK9LkchhocxOBqN8BrZZ4QYy/L9wRm5FnuQd+xh4k/qadyDWCtZDf06xR wYdIWW+3Ips2UTZ7nXj0L22Vo8zD0W2tHnaZ7i1xNxAyAd/h/seNXuDTh617I3qJCrZk TVinHBeQVYZCIb4IaE/xVRwu0t03QRjHZ+Lz4AX7FrirqhtTw0b8cyxw7S/1VpVi2CyP TlDnQ77wFCJU8K9V1KRFHM7qnlc0LQ0Cz6KtAxxPWxgJSWyUUJNSXv8T4qDls19QLpTn LzZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NYN5Bd9Dd0vS7p9p+LtozvKO/VbaMtj9Dt0A4GBDoyM=; b=Xg//Oqrey5ATq9OkSPQVHMx9IgLU/GZC0ZwkCgFzyqmVHRmCeEd+9BxacECuYDoCby M7MJx8IT/WKYsPXR4XzjbvkM35fHEdRU/p8U7i0O5wbGDQJLzDB5NtSAlkyvrSgTn+7y VFXyFI6LM9ylsPOPasGmvTO93OG04s4xBzHfNPbJRXNdetkWGA8BcbF8A3eFJ5eAmniv lHWA6Z1LgjIBEjQiP+pe4KPCxlTGWpSaMpEX1FLpwVdSs7k6uF/I1XbHizJe/d/TB9r4 9ksR3kRkpWr0z6jSKTu7IX9I4BvwWlj6YnjVr4hFXKivBKz22jxob2rFGkHfqz5Fu4di KLcQ== X-Gm-Message-State: APjAAAUp/14oZ+tFZnh4UCrXs1wfX3x4SzEaIiL72jd27xpmKoY11/1l ywiX/KHI+vC/yDia5EcdNcDmT6iWoQ== X-Google-Smtp-Source: APXvYqyv0Y/XYJ8FUAH5vxHZXh4cb47TnjBVM2NpYmu0dRiH0Bmr9jF17gUX8wFTB66geKPhGGKYaA== X-Received: by 2002:a05:6638:73d:: with SMTP id j29mr27531439jad.21.1568037793928; Mon, 09 Sep 2019 07:03:13 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:12 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/9] NFSv4: Clean up pNFS return-on-close error handling Date: Mon, 9 Sep 2019 10:00:57 -0400 Message-Id: <20190909140104.78818-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-1-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Both close and delegreturn have identical code to handle pNFS return-on-close. This patch refactors that code and places it in pnfs.c Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 66 +++++++---------------------------------------- fs/nfs/pnfs.c | 27 +++++++++++++++++++ fs/nfs/pnfs.h | 13 ++++++++++ 3 files changed, 50 insertions(+), 56 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 1406858bae6c..fcdfddfd3ab4 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3358,32 +3358,11 @@ static void nfs4_close_done(struct rpc_task *task, void *data) trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status); /* Handle Layoutreturn errors */ - if (calldata->arg.lr_args && task->tk_status != 0) { - switch (calldata->res.lr_ret) { - default: - calldata->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; - break; - case 0: - calldata->arg.lr_args = NULL; - calldata->res.lr_res = NULL; - break; - case -NFS4ERR_OLD_STATEID: - if (nfs4_layoutreturn_refresh_stateid(&calldata->arg.lr_args->stateid, - &calldata->arg.lr_args->range, - calldata->inode)) - goto lr_restart; - /* Fallthrough */ - case -NFS4ERR_ADMIN_REVOKED: - case -NFS4ERR_DELEG_REVOKED: - case -NFS4ERR_EXPIRED: - case -NFS4ERR_BAD_STATEID: - case -NFS4ERR_UNKNOWN_LAYOUTTYPE: - case -NFS4ERR_WRONG_CRED: - calldata->arg.lr_args = NULL; - calldata->res.lr_res = NULL; - goto lr_restart; - } - } + if (pnfs_roc_done(task, calldata->inode, + &calldata->arg.lr_args, + &calldata->res.lr_res, + &calldata->res.lr_ret) == -EAGAIN) + goto out_restart; /* hmm. we are done with the inode, and in the process of freeing * the state_owner. we keep this around to process errors @@ -3430,8 +3409,6 @@ static void nfs4_close_done(struct rpc_task *task, void *data) nfs_refresh_inode(calldata->inode, &calldata->fattr); dprintk("%s: done, ret = %d!\n", __func__, task->tk_status); return; -lr_restart: - calldata->res.lr_ret = 0; out_restart: task->tk_status = 0; rpc_restart_call_prepare(task); @@ -6129,32 +6106,11 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) trace_nfs4_delegreturn_exit(&data->args, &data->res, task->tk_status); /* Handle Layoutreturn errors */ - if (data->args.lr_args && task->tk_status != 0) { - switch(data->res.lr_ret) { - default: - data->res.lr_ret = -NFS4ERR_NOMATCHING_LAYOUT; - break; - case 0: - data->args.lr_args = NULL; - data->res.lr_res = NULL; - break; - case -NFS4ERR_OLD_STATEID: - if (nfs4_layoutreturn_refresh_stateid(&data->args.lr_args->stateid, - &data->args.lr_args->range, - data->inode)) - goto lr_restart; - /* Fallthrough */ - case -NFS4ERR_ADMIN_REVOKED: - case -NFS4ERR_DELEG_REVOKED: - case -NFS4ERR_EXPIRED: - case -NFS4ERR_BAD_STATEID: - case -NFS4ERR_UNKNOWN_LAYOUTTYPE: - case -NFS4ERR_WRONG_CRED: - data->args.lr_args = NULL; - data->res.lr_res = NULL; - goto lr_restart; - } - } + if (pnfs_roc_done(task, data->inode, + &data->args.lr_args, + &data->res.lr_res, + &data->res.lr_ret) == -EAGAIN) + goto out_restart; switch (task->tk_status) { case 0: @@ -6192,8 +6148,6 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) } data->rpc_status = task->tk_status; return; -lr_restart: - data->res.lr_ret = 0; out_restart: task->tk_status = 0; rpc_restart_call_prepare(task); diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0418b198edd3..8769422a12f5 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1440,6 +1440,33 @@ bool pnfs_roc(struct inode *ino, return false; } +int pnfs_roc_done(struct rpc_task *task, struct inode *inode, + struct nfs4_layoutreturn_args **argpp, + struct nfs4_layoutreturn_res **respp, + int *ret) +{ + struct nfs4_layoutreturn_args *arg = *argpp; + int retval = -EAGAIN; + + if (!arg) + return 0; + /* Handle Layoutreturn errors */ + switch (*ret) { + case 0: + retval = 0; + break; + case -NFS4ERR_OLD_STATEID: + if (!nfs4_layoutreturn_refresh_stateid(&arg->stateid, + &arg->range, inode)) + break; + *ret = -NFS4ERR_NOMATCHING_LAYOUT; + return -EAGAIN; + } + *argpp = NULL; + *respp = NULL; + return retval; +} + void pnfs_roc_release(struct nfs4_layoutreturn_args *args, struct nfs4_layoutreturn_res *res, int ret) diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index f15609c003d8..3ef3756d437c 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -282,6 +282,10 @@ bool pnfs_roc(struct inode *ino, struct nfs4_layoutreturn_args *args, struct nfs4_layoutreturn_res *res, const struct cred *cred); +int pnfs_roc_done(struct rpc_task *task, struct inode *inode, + struct nfs4_layoutreturn_args **argpp, + struct nfs4_layoutreturn_res **respp, + int *ret); void pnfs_roc_release(struct nfs4_layoutreturn_args *args, struct nfs4_layoutreturn_res *res, int ret); @@ -701,6 +705,15 @@ pnfs_roc(struct inode *ino, return false; } +static inline int +pnfs_roc_done(struct rpc_task *task, struct inode *inode, + struct nfs4_layoutreturn_args **argpp, + struct nfs4_layoutreturn_res **respp, + int *ret) +{ + return 0; +} + static inline void pnfs_roc_release(struct nfs4_layoutreturn_args *args, struct nfs4_layoutreturn_res *res, From patchwork Mon Sep 9 14:00:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138041 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E709A76 for ; Mon, 9 Sep 2019 14:03:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C468B2196E for ; Mon, 9 Sep 2019 14:03:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o2GOblOS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405095AbfIIODQ (ORCPT ); Mon, 9 Sep 2019 10:03:16 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:35920 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405066AbfIIODQ (ORCPT ); Mon, 9 Sep 2019 10:03:16 -0400 Received: by mail-io1-f65.google.com with SMTP id b136so28946968iof.3 for ; Mon, 09 Sep 2019 07:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J/GVnqkPBoCv5U4dJF5GCvANtn9QnHDChOd9TrjN6yM=; b=o2GOblOSk1Y78G1BrTTKOyzalgknADGSw57v4DYIEA8vNp70AifPW/YRrHJjDWPRPf 8nCOZchMFuNViaT9U0+Y7Vws3SXdTDHZ5uxf8wsFq6jzn71ecNOv7TCkotxbndJDuPvq BGD0fn0o+7I//JVLC1Mv4EyAeC1dumnXlf3H9FW6YA+AyrhdOpu5O8a5kuFvnx5osi36 rYPhbI6HisEG6hYY3uKxMCif1CsCWK0uyQeWIi4mEhxrw/C1Z4XehjOXNbzuHsR93n96 zwWecVFbBH9foN5BWPUtXBbRi4Nya9V9hQAw5/FoCCZYQSGXWwP0ISc8DteryIeKo0OT t6GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J/GVnqkPBoCv5U4dJF5GCvANtn9QnHDChOd9TrjN6yM=; b=BQCp/0vXOxnrLjc42qSPVqCHLl/jT+PcYWUi9KexsBMsTSwb+MsIeWQ+xdulhxvFsO HFjXcGTDMrNtv8dcf1N/f1Bmxh0wVL3SLa5AIAg2dEKsjl1RjFzdGWulFRQ73OXbSPwR BI/fUBvsdZRHZmkGZ8ad9OWXcw1faryfPKo4GNd068XK39BfzXN7Ca/UEZO/PG7LW0IA rzW9Wm4zpfcW+FDaMTvLaSlSLoTHx909sT+yDvx3g/Brq3abSVHCo/BXNNkM2A/MCm/w NvOqGOqQFUHIUMdvmcnHGYjjs6nvExFgHeKxiNop8LOqj1hIwKk7m+fTKuut6F7EMSpo Ekrg== X-Gm-Message-State: APjAAAUUGAOTlmpyg2wIM/7ednaM4OQwUJ+l+TwY3NN57AMQcR/OwKCM tgq8/IYYWYXgOL7o5BSv3yatxUx8PQ== X-Google-Smtp-Source: APXvYqwU2ET+GKCKO0unOKplNixBph9+7uTiYhCDnUmo1ES1f/no4dz4CubloJ/4egLVFXJiDHtO7Q== X-Received: by 2002:a5d:8cc1:: with SMTP id k1mr16154920iot.286.1568037795100; Mon, 09 Sep 2019 07:03:15 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:14 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/9] NFSv4: Handle NFS4ERR_DELAY correctly in return-on-close Date: Mon, 9 Sep 2019 10:00:58 -0400 Message-Id: <20190909140104.78818-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-2-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If the server sends a NFS4ERR_DELAY, then allow the caller to retry. Signed-off-by: Trond Myklebust --- fs/nfs/pnfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 8769422a12f5..6436047dc999 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1455,6 +1455,10 @@ int pnfs_roc_done(struct rpc_task *task, struct inode *inode, case 0: retval = 0; break; + case -NFS4ERR_DELAY: + /* Let the caller handle the retry */ + *ret = -NFS4ERR_NOMATCHING_LAYOUT; + return 0; case -NFS4ERR_OLD_STATEID: if (!nfs4_layoutreturn_refresh_stateid(&arg->stateid, &arg->range, inode)) From patchwork Mon Sep 9 14:00:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138043 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45EA8912 for ; Mon, 9 Sep 2019 14:03:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 245612196E for ; Mon, 9 Sep 2019 14:03:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Vgl0lQkv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405122AbfIIODS (ORCPT ); Mon, 9 Sep 2019 10:03:18 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:32848 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405066AbfIIODS (ORCPT ); Mon, 9 Sep 2019 10:03:18 -0400 Received: by mail-io1-f66.google.com with SMTP id m11so28948406ioo.0 for ; Mon, 09 Sep 2019 07:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mT/Rzj/K1U6LEdiuCQ0lI11+dkVn7b9E0XXmRpME0Iw=; b=Vgl0lQkv2LzLw82kw3EkWUhkQXg+WGCe42683LJIRYDKBcP8vKAvGL+8gIWbVUil3+ F3sTA3QQqls4LWDiExM46hg1To8fWMMIYwWcdelaihBdtdKpIziBF4ClxiHGuosVN8Yh NYz7GQj0fUHNCkH3sXiKW3Tzg5+twBp4HWCQ3iUSjYCIL/yABX40NlSVyrEHbvZfaJ2K 5s6Jqd/E4r9RyHPtvGIJDRHmAqsBiSCQ5abmujabiobGaQXYHR39IVz5agxp8fjAXMcx olXAygYeE0bMREJXjPs397/rb5pGoGHI8mdL92tdYEVdBmb+ryXzUEY0Hswq/ASgFP4K Tkqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mT/Rzj/K1U6LEdiuCQ0lI11+dkVn7b9E0XXmRpME0Iw=; b=mtehkzgp8W7tnwadi8sZ2aKxkuPjTGDzwRceANOlYRDJAJoNuRmYxVaWi0IEjqs8v9 972opgARmcBUhqUFyo+C/xXgwH1n3kXj2CaCBaWZh5xwH27p7zrXgIubjMqLM32jOQ9B ae5q1GU/GTLNrO/kDleRLa1hWp2H0chM6IHxwqEtHYZHu8ZKZifswOndha6cocjb3wTY j+67sAIrRo9F2Hw1YFJTSR525jJ+3S6M9SeMJVCkV1VIzPYncyGT31nVskyP1MrDFmP4 zPx5lJj5XKbdBbbPvIxLZ2k5a24OH8JLJY+pilZAQhYx46M0oxDIvTAvvzRMPZeSSl0F X6yQ== X-Gm-Message-State: APjAAAUPi9Ae35JmLoAgHh+e6JfKxwcsnFZaWlEI181LSBsR6wj5BBXM U5JAwqOGgDwm3zSskyafCB9LmLXleQ== X-Google-Smtp-Source: APXvYqyskAmMygM+ZQXCBUvrxVeqUjjDY5IDPKtSwB0FP48ceAeL/KRd1HOzLrD6KhmkpHJbfPEI2w== X-Received: by 2002:a02:a513:: with SMTP id e19mr13734612jam.56.1568037795805; Mon, 09 Sep 2019 07:03:15 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:15 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/9] NFSv4: Handle RPC level errors in LAYOUTRETURN Date: Mon, 9 Sep 2019 10:00:59 -0400 Message-Id: <20190909140104.78818-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-3-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Handle RPC level errors by assuming that the RPC call was successful. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 9 +++++++++ fs/nfs/pnfs.c | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index fcdfddfd3ab4..a5deb00b5ad1 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9057,6 +9057,15 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) if (!nfs41_sequence_process(task, &lrp->res.seq_res)) return; + /* + * Was there an RPC level error? Assume the call succeeded, + * and that we need to release the layout + */ + if (task->tk_rpc_status != 0 && RPC_WAS_SENT(task)) { + lrp->res.lrs_present = 0; + return; + } + server = NFS_SERVER(lrp->args.inode); switch (task->tk_status) { case -NFS4ERR_OLD_STATEID: diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 6436047dc999..abc7188f1853 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1455,6 +1455,21 @@ int pnfs_roc_done(struct rpc_task *task, struct inode *inode, case 0: retval = 0; break; + case -NFS4ERR_NOMATCHING_LAYOUT: + /* Was there an RPC level error? If not, retry */ + if (task->tk_rpc_status == 0) + break; + /* If the call was not sent, let caller handle it */ + if (!RPC_WAS_SENT(task)) + return 0; + /* + * Otherwise, assume the call succeeded and + * that we need to release the layout + */ + *ret = 0; + (*respp)->lrs_present = 0; + retval = 0; + break; case -NFS4ERR_DELAY: /* Let the caller handle the retry */ *ret = -NFS4ERR_NOMATCHING_LAYOUT; From patchwork Mon Sep 9 14:01:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138045 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BE5C1599 for ; Mon, 9 Sep 2019 14:03:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 59E742196E for ; Mon, 9 Sep 2019 14:03:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ia67wefX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405066AbfIIODS (ORCPT ); Mon, 9 Sep 2019 10:03:18 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:35012 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405119AbfIIODS (ORCPT ); Mon, 9 Sep 2019 10:03:18 -0400 Received: by mail-io1-f67.google.com with SMTP id f4so28185074ion.2 for ; Mon, 09 Sep 2019 07:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=owbPNNcxjT5XKu6v3G4mEstWx8051g6tPkh8ytztNTM=; b=ia67wefXuFxZMgxGJMvrs1gqh8QiaCeHbp2Cvfxt+89TJyUrmNgJqGeohFnCxx5zGG HyIZZI0svLnBGlnZHJxHFFw56qka1Sbsnf6YIsbZX5ZSMjpsUJ/kUGFNYJS56Trw24qr GaLwep7yVriBxxDpFab0LMuUGF/j476Lb0SSzwos5yLjWk4wveJsno1yyFGG7QTxH/t0 y4eUlWekYJ4XozUK1EiOZ1nW+fxJxBLRPO8g6m7QU82UoYs7s2zxaD4GFo7ucaEDnIkC wC5c0qJdFWQAE6/Vu0Qchn1d94hFwugnabwDAtT44joqMOtIgBoGuVRS/Rjjx8oz9LdC ZCXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=owbPNNcxjT5XKu6v3G4mEstWx8051g6tPkh8ytztNTM=; b=alLsCYVTzrOTjg/NjIvjHj8UWH5uoANfJuuWSVDKEZpW0w0yvD61574giOHoDg8hOV rRU70fjKERW0iBL/oFzEFE+5rlnmKzTGFkp8of5AhQV3JWZ3pedfV8D+9Xckpd2hissB DFRcJY8Lx/yucjGEkn/9xyxbk5HNTV9oxL1Gi72WCtgHki0Q/syOpElbeOTOOatzWDBN NQUVogdALKkn8seudNoVAyEcKoZf3D0vOSSBCM6/EZXegHsw4ii2GpsKhYCv2mAXyxYA YxmENYBjI14RfbtgRNSn8gzGkP2ozXhblaSKFQEZ0J/Ys/ccSyaWVF9QGNZ1jFIgolxZ hvkA== X-Gm-Message-State: APjAAAU68kS7LDh6IlFe/dKwWj5JOoybvq1MoimeNQsX+pbCeDZ6cEa7 M+lmLYD0Mk0ruFaTj1cRLOfUW9CeMw== X-Google-Smtp-Source: APXvYqz3w6/AFTGe9IlQeGhQPVKcJfeY5C8H+2s9giEPu3vlWQAshz9FWU6TgLhAC+N19s3lWvPfeQ== X-Received: by 2002:a05:6638:681:: with SMTP id i1mr25367999jab.127.1568037796898; Mon, 09 Sep 2019 07:03:16 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:16 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 5/9] NFSv4: Add a helper to increment stateid seqids Date: Mon, 9 Sep 2019 10:01:00 -0400 Message-Id: <20190909140104.78818-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-4-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add a helper function to increment stateid seqids according to the rules specified in RFC5661 Section 8.2.2. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 3564da1ba8a1..e8f74ed98e42 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -574,6 +574,15 @@ static inline bool nfs4_stateid_is_newer(const nfs4_stateid *s1, const nfs4_stat return (s32)(be32_to_cpu(s1->seqid) - be32_to_cpu(s2->seqid)) > 0; } +static inline void nfs4_stateid_seqid_inc(nfs4_stateid *s1) +{ + u32 seqid = be32_to_cpu(s1->seqid); + + if (++seqid == 0) + ++seqid; + s1->seqid = cpu_to_be32(seqid); +} + static inline bool nfs4_valid_open_stateid(const struct nfs4_state *state) { return test_bit(NFS_STATE_RECOVERY_FAILED, &state->flags) == 0; From patchwork Mon Sep 9 14:01:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3D0276 for ; Mon, 9 Sep 2019 14:03:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A256B2196E for ; Mon, 9 Sep 2019 14:03:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lWL9zRRE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405127AbfIIODU (ORCPT ); Mon, 9 Sep 2019 10:03:20 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:40335 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405124AbfIIODT (ORCPT ); Mon, 9 Sep 2019 10:03:19 -0400 Received: by mail-io1-f67.google.com with SMTP id h144so28855110iof.7 for ; Mon, 09 Sep 2019 07:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yyGDQpMVH1rTLSPHW8HYSc7W3EA/zyjV2dF3PYsHi3Q=; b=lWL9zRREs4pLUigibgs5ZhvSqdkP/8q+dlfV6lbUY8ccn+bzbF9K8kukrUnMYXU9Eh Xt5hi+dBXiJAUgmWWPyjtBRku+ZBv3c+ZA1o35QM7mIp2HeqMsytsd/Kb1U9lYopJNMb Bg6GF8OOx3tS2YKASY2o1qYzeAn/WERt+QEx4EAqyuetHqdUOjrouWuNZ3rQNK7RSB+R qzCVH0hjNosmBiqNT0SIZB//3fP8jY1Or/UgK6hWHmio3ayMqTcnqtsIljb5gQCd4fh4 eeHAKiMJlEXTb6TFvKtxQVf6pJMH2PMsdeoKDM7aMZm32rsEEyb4ysmLIPVFBl2rdfKi j3kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yyGDQpMVH1rTLSPHW8HYSc7W3EA/zyjV2dF3PYsHi3Q=; b=EgLihgJPFbV/Votl++N+1JyLWj+hKj1QVAaf74RU53hNoE/XOd+jqGBQwmZN29DrgG 2p5BQu43kCzyLze6U++gU13DkVle7KU9GxtkSyi5n/XmQ0LuhT3I5Y3k5wi+q39ENC/F 6tO92F0XPwyE4ma3B2bQvgBZsoebE15HiSLqCtRLTgevg4AAXhtJsL9Kui9VXQ43oKr7 YY95wMcwxuwDClnk40FRn+YUb5LX3I8v7svJ3APjkuwCxhB/4TvuSaXQkxw5qUZQhqH3 skM+OO+0fwC0Lmr3FwCSJqeOAlhSaHlIOuRuclUr9ikCuZZ3hFqbjQi8IOMzst2BdQ3a S+ng== X-Gm-Message-State: APjAAAUNHvAu6OvX9B++F6H/Z8lsani0idP21/71rtDF4gNLgV3GIMun diY90p97L482IKr/fQCuptaFwo290w== X-Google-Smtp-Source: APXvYqzBwueqneJEthfGaYdeAWdqKbKHhyVoC2WL3R7OiRwrBoeikgurNjtaw8Rz7Sq2z5090miKog== X-Received: by 2002:a05:6638:155:: with SMTP id y21mr25985045jao.112.1568037798786; Mon, 09 Sep 2019 07:03:18 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:18 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 6/9] pNFS: Handle NFS4ERR_OLD_STATEID on layoutreturn by bumping the state seqid Date: Mon, 9 Sep 2019 10:01:01 -0400 Message-Id: <20190909140104.78818-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-5-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> <20190909140104.78818-5-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If a LAYOUTRETURN receives a reply of NFS4ERR_OLD_STATEID then assume we've missed an update, and just bump the stateid. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 +- fs/nfs/pnfs.c | 18 ++++++++++++++---- fs/nfs/pnfs.h | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a5deb00b5ad1..cbaf6b7ac128 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9069,7 +9069,7 @@ static void nfs4_layoutreturn_done(struct rpc_task *task, void *calldata) server = NFS_SERVER(lrp->args.inode); switch (task->tk_status) { case -NFS4ERR_OLD_STATEID: - if (nfs4_layoutreturn_refresh_stateid(&lrp->args.stateid, + if (nfs4_layout_refresh_old_stateid(&lrp->args.stateid, &lrp->args.range, lrp->args.inode)) goto out_restart; diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index abc7188f1853..bb80034a7661 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -359,9 +359,10 @@ pnfs_clear_lseg_state(struct pnfs_layout_segment *lseg, } /* - * Update the seqid of a layout stateid + * Update the seqid of a layout stateid after receiving + * NFS4ERR_OLD_STATEID */ -bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, +bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, struct pnfs_layout_range *dst_range, struct inode *inode) { @@ -377,7 +378,15 @@ bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, spin_lock(&inode->i_lock); lo = NFS_I(inode)->layout; - if (lo && nfs4_stateid_match_other(dst, &lo->plh_stateid)) { + if (lo && pnfs_layout_is_valid(lo) && + nfs4_stateid_match_other(dst, &lo->plh_stateid)) { + /* Is our call using the most recent seqid? If so, bump it */ + if (!nfs4_stateid_is_newer(&lo->plh_stateid, dst)) { + nfs4_stateid_seqid_inc(dst); + ret = true; + goto out; + } + /* Try to update the seqid to the most recent */ err = pnfs_mark_matching_lsegs_return(lo, &head, &range, 0); if (err != -EBUSY) { dst->seqid = lo->plh_stateid.seqid; @@ -385,6 +394,7 @@ bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, ret = true; } } +out: spin_unlock(&inode->i_lock); pnfs_free_lseg_list(&head); return ret; @@ -1475,7 +1485,7 @@ int pnfs_roc_done(struct rpc_task *task, struct inode *inode, *ret = -NFS4ERR_NOMATCHING_LAYOUT; return 0; case -NFS4ERR_OLD_STATEID: - if (!nfs4_layoutreturn_refresh_stateid(&arg->stateid, + if (!nfs4_layout_refresh_old_stateid(&arg->stateid, &arg->range, inode)) break; *ret = -NFS4ERR_NOMATCHING_LAYOUT; diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 3ef3756d437c..f8a38065c7e4 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -261,7 +261,7 @@ int pnfs_destroy_layouts_byfsid(struct nfs_client *clp, bool is_recall); int pnfs_destroy_layouts_byclid(struct nfs_client *clp, bool is_recall); -bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, +bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, struct pnfs_layout_range *dst_range, struct inode *inode); void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo); @@ -798,7 +798,7 @@ static inline void nfs4_pnfs_v3_ds_connect_unload(void) { } -static inline bool nfs4_layoutreturn_refresh_stateid(nfs4_stateid *dst, +static inline bool nfs4_layout_refresh_old_stateid(nfs4_stateid *dst, struct pnfs_layout_range *dst_range, struct inode *inode) { From patchwork Mon Sep 9 14:01:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138049 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F956912 for ; Mon, 9 Sep 2019 14:03:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6EE8A2196E for ; Mon, 9 Sep 2019 14:03:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l7yesDn0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405124AbfIIODU (ORCPT ); Mon, 9 Sep 2019 10:03:20 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:38649 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405126AbfIIODU (ORCPT ); Mon, 9 Sep 2019 10:03:20 -0400 Received: by mail-io1-f65.google.com with SMTP id k5so3601051iol.5 for ; Mon, 09 Sep 2019 07:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tm3Z204lhcQueHhZs5vFp/leKoUofNIJTGBebGTHcyI=; b=l7yesDn0PKJ0N97K2Q7aNFpVYN75fBcYJ7iEOHWfZdWDF//sP+Z6d9FpWjtnxcNSr+ gyDSjuDm80tNSretPry+2wSgGkQSpvtyohF5PWZd8qiJ1RwiUfrV/XfabFb2ViOA1yTW buOa3YIc0ylcpRHrh+lnIT8CstJZd2tCwQUQkellP9mSgzBxgXCfztqyaFiUviFEHJQ1 i1zHQnut3ZeX+A4FZlUrreINYeQQDFaq9OR9EZg8zR0ZXH9rYBtdLIHFDk1LMQ/4nkav 25A/acH1cGREZKhv3cxBGyBZ6tRPb/q8Eikv3kSTlbbpVqMWjPD/50nqNHpwHEvRfLZN q4Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tm3Z204lhcQueHhZs5vFp/leKoUofNIJTGBebGTHcyI=; b=P8rsMSVAuxBXPfgwWGGVJOoNVFiR+N1bDNkiDVhhRkKy/pidvV/ehI70gMd66tkTq3 /OqIU5oDwkC/+oHrhZtPY+S2wYDSOJQ9orf5wMCzZiL4427cjCPj1x+skHQqYIijsm+7 u7jdLAOq0PTn0b11r8/zscAIEd0AmOeNv5qc5d8VQAy76bIiMEYxbEux/QxJp2mavZUB Mfdywj+WolTLlW+Ef80pMNfE4mZEMTsr1TnQQah1OjWtQejqKXCGBXzTH2ZMuOhcMt/Y 3XWqMhF50dC49/1oPZvEXBA89P0wXUC0qcjg8pmMipi6aAX6B0CwJy5CnWWwsRPU9sr4 hgBQ== X-Gm-Message-State: APjAAAWmXlLi/C3jP9F1EU7oHzDToG7is+H1YMzhvcX2XtF50h1xYebE 9IQSm7iXiviXbXixE4GX3lyRZGVQsg== X-Google-Smtp-Source: APXvYqwBegJSXPQgnQS7GEYW85/wSxyVZjnJUDcbahY5gUDiVbHn9cwqjMA4lQu4vlTitgQdKVo40Q== X-Received: by 2002:a5d:9591:: with SMTP id a17mr14563566ioo.303.1568037799513; Mon, 09 Sep 2019 07:03:19 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:19 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 7/9] NFSv4: Fix OPEN_DOWNGRADE error handling Date: Mon, 9 Sep 2019 10:01:02 -0400 Message-Id: <20190909140104.78818-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-6-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> <20190909140104.78818-5-trond.myklebust@hammerspace.com> <20190909140104.78818-6-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If OPEN_DOWNGRADE returns a state error, then we want to initiate state recovery in addition to marking the stateid as closed. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index cbaf6b7ac128..025dd5efbf34 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3394,7 +3394,9 @@ static void nfs4_close_done(struct rpc_task *task, void *data) task->tk_msg.rpc_cred); /* Fallthrough */ case -NFS4ERR_BAD_STATEID: - break; + if (calldata->arg.fmode == 0) + break; + /* Fallthrough */ default: task->tk_status = nfs4_async_handle_exception(task, server, task->tk_status, &exception); From patchwork Mon Sep 9 14:01:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138051 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEB1D912 for ; Mon, 9 Sep 2019 14:03:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC07821924 for ; Mon, 9 Sep 2019 14:03:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I+GkS99X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405129AbfIIODW (ORCPT ); Mon, 9 Sep 2019 10:03:22 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35945 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405126AbfIIODW (ORCPT ); Mon, 9 Sep 2019 10:03:22 -0400 Received: by mail-io1-f66.google.com with SMTP id b136so28947816iof.3 for ; Mon, 09 Sep 2019 07:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RzLZLmp3WvFdfyW0ZePHs1vz3bQF80svtna2LHv1A6I=; b=I+GkS99Xf//pFDDBp3I0Nvh9kK5DvXPJrsHDt0LTqWIC/ajsFahssyyQMXH6Dj+7/9 Iy1OAkFQyQiwP5TlvkT3nVIeEdweXKxOs45VogWfDtkUhoWj1j/Z1NsBxjZjqRfTbo4g eh7jErdM1zSC//qndGpa5136F46NmBFS8GuOw5vYjVf3g3ZeRVAqAs6HDQlP2blYWBWo vGFmFNCaI+M3UcuSOq0VTGDec3sZLmLGyQZdiAaZ1JI4llrOeet6QFg7/1WQ9OG69/IK x0j8ecVIsWVcGAxogKEIwFvuU60sGq2NFZM900Yhb6/LTAXdzqti+ud8zuqDvv8oU2kT 25hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RzLZLmp3WvFdfyW0ZePHs1vz3bQF80svtna2LHv1A6I=; b=sHpuCbfErQMPVRkAQ1NC5c0Up9J5874fQplLfyqzDTx5iuH9iZTG5fOFlGzUOF5cy/ GpTbn50h54FiS7AP6coLqTrNfxfJIa0oGCOz1j6a3KoG8adlfbL4xGRZus/6x99K13av ybw203vQsG7nT2UzTYm1q8rueUlOSUhb7T+cJhycTo54nmNRK5gaUUNMGcBqhDG4Ee4F F/sT08yX9Bs3IaV8etyQxpHDWA28pFWsYv/geNBTAQ9ryzOtxuIBhvhwKnyOm/1vbVFa MxovXoaoHXFEzUfkUYD/Ns6l6Jr30q48F9O0aVLGMy+D+gYZpy4ZwTtNUd3iWg+sD0xc cZAw== X-Gm-Message-State: APjAAAV9B3XOufrkPB6E5gY0cB9UU0/Drc0lnkfCVO2Tr5mROZFsYVz1 UOxPXsXhlExP05caXWQrmA== X-Google-Smtp-Source: APXvYqyodsVEN1Ki+M6pFFMzX4HQQmtA4Vm4b4k8yOCZC8K87z7ef8SI+Z4Q1qDm3u8axIE0FoO0SA== X-Received: by 2002:a5d:89c1:: with SMTP id a1mr26209316iot.306.1568037800572; Mon, 09 Sep 2019 07:03:20 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:19 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 8/9] NFSv4: Handle NFS4ERR_OLD_STATEID in CLOSE/OPEN_DOWNGRADE Date: Mon, 9 Sep 2019 10:01:03 -0400 Message-Id: <20190909140104.78818-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-7-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> <20190909140104.78818-5-trond.myklebust@hammerspace.com> <20190909140104.78818-6-trond.myklebust@hammerspace.com> <20190909140104.78818-7-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If a CLOSE or OPEN_DOWNGRADE operation receives a NFS4ERR_OLD_STATEID then bump the seqid before resending. Ensure we only bump the seqid by 1. Signed-off-by: Trond Myklebust Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 2 -- fs/nfs/nfs4proc.c | 41 ++++++++++++++++++++++++++++++++++++++--- fs/nfs/nfs4state.c | 16 ---------------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index e8f74ed98e42..16b2e5cc3e94 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -491,8 +491,6 @@ extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl); extern int nfs4_select_rw_stateid(struct nfs4_state *, fmode_t, const struct nfs_lock_context *, nfs4_stateid *, const struct cred **); -extern bool nfs4_refresh_open_stateid(nfs4_stateid *dst, - struct nfs4_state *state); extern bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 025dd5efbf34..49f301198008 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3308,6 +3308,42 @@ nfs4_wait_on_layoutreturn(struct inode *inode, struct rpc_task *task) return pnfs_wait_on_layoutreturn(inode, task); } +/* + * Update the seqid of an open stateid after receiving + * NFS4ERR_OLD_STATEID + */ +static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst, + struct nfs4_state *state) +{ + __be32 seqid_open; + u32 dst_seqid; + bool ret; + int seq; + + for (;;) { + ret = false; + seq = read_seqbegin(&state->seqlock); + if (!nfs4_state_match_open_stateid_other(state, dst)) { + if (read_seqretry(&state->seqlock, seq)) + continue; + break; + } + seqid_open = state->open_stateid.seqid; + dst_seqid = be32_to_cpu(dst->seqid); + + if (read_seqretry(&state->seqlock, seq)) + continue; + if ((s32)(dst_seqid - be32_to_cpu(seqid_open)) >= 0) + dst->seqid = cpu_to_be32(dst_seqid + 1); + else + dst->seqid = seqid_open; + ret = true; + break; + } + + return ret; +} + struct nfs4_closedata { struct inode *inode; struct nfs4_state *state; @@ -3382,7 +3418,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data) break; case -NFS4ERR_OLD_STATEID: /* Did we race with OPEN? */ - if (nfs4_refresh_open_stateid(&calldata->arg.stateid, + if (nfs4_refresh_open_old_stateid(&calldata->arg.stateid, state)) goto out_restart; goto out_release; @@ -3451,8 +3487,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) } else if (is_rdwr) calldata->arg.fmode |= FMODE_READ|FMODE_WRITE; - if (!nfs4_valid_open_stateid(state) || - !nfs4_refresh_open_stateid(&calldata->arg.stateid, state)) + if (!nfs4_valid_open_stateid(state)) call_close = 0; spin_unlock(&state->owner->so_lock); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index cad4e064b328..e23945174da4 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1015,22 +1015,6 @@ static int nfs4_copy_lock_stateid(nfs4_stateid *dst, return ret; } -bool nfs4_refresh_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) -{ - bool ret; - int seq; - - do { - ret = false; - seq = read_seqbegin(&state->seqlock); - if (nfs4_state_match_open_stateid_other(state, dst)) { - dst->seqid = state->open_stateid.seqid; - ret = true; - } - } while (read_seqretry(&state->seqlock, seq)); - return ret; -} - bool nfs4_copy_open_stateid(nfs4_stateid *dst, struct nfs4_state *state) { bool ret; From patchwork Mon Sep 9 14:01:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11138053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8857A76 for ; Mon, 9 Sep 2019 14:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 670DF2196E for ; Mon, 9 Sep 2019 14:03:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pJ2vfWYq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405130AbfIIODX (ORCPT ); Mon, 9 Sep 2019 10:03:23 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:41129 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405126AbfIIODW (ORCPT ); Mon, 9 Sep 2019 10:03:22 -0400 Received: by mail-io1-f68.google.com with SMTP id r26so28823330ioh.8 for ; Mon, 09 Sep 2019 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wy1dUH5bibrhCk/Qm7oofyb/CYs8Ue5YUMfLEdziIqQ=; b=pJ2vfWYq8G4Yq+jADOt3h+BBGFjoXuIvkjwtshXMLhF0xMlme7qnQKgtbsfpruJMGU oOltRKf/njzqBaR3kSVQczDfPMDBGBcp4+kKl/UcSOT73eHqOvWQphRDchDiP6ZnzftW q07o7T+jY4HNayVuw0/5iCZVJ22ynWUBFk2o7xu+nDgYPbBuSMcsuxgv4dCGo+4sva+9 vWWXCdGBHuMJja9UyZYh/16MUsBlUl8TMWhXo5TLG0ttIGt8FKMebcFXrpiGRLb1P5GY Bq/CNkOEAy4jn00jvrHoVarzCrpDbKqJnf44vVMn99kbEvTxumdkfnp3mDCUbT5Ei34H wGWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wy1dUH5bibrhCk/Qm7oofyb/CYs8Ue5YUMfLEdziIqQ=; b=G7Twr7hJuE3xz2g6bO2hY1XneFwpXpBuxkujOBuhZ7ekQbiKIXa07WZENHWz52QQ8j HIoK43XK95s3o8MNKuzjCSNPCa0kgGq7ST/oxBpoeAag8WGGVkOM5T5qiY2NKSkhVMFj 4yKqNaUfoxE4bvQEMNBA95KyswJUejiD04WiVP+heu8G0VYokClG0gokuH9NPNWmw/NY aPsUiB2/8o4VJH5ueYosEzJ2HEHyGtiqshKFvU5XT221HEI5fqBJ/ynE0nQ3lAt1NWZx EApGtqiLlHmFs8PLCAb+5fCrBVEajOZN/X5Qn3heFtrAu2Hw2wAtyVaZ7IkvSjzpSUGF Q1yA== X-Gm-Message-State: APjAAAW+CFz8WlP/XU3j8NYHtT04A4v+/celrJU2CbRFJtuQyb4FsWX5 fLW0FpgG7v2A/nvEGJY3s8aBxW/0Bg== X-Google-Smtp-Source: APXvYqyJ/nOe3FqQ9QTdaIizc1k0XaBNEq1NnVSfPfV7zWPeg+YHjWkWrrqBQwbT6BOISCGu4Z17zA== X-Received: by 2002:a6b:7a07:: with SMTP id h7mr26669923iom.57.1568037801790; Mon, 09 Sep 2019 07:03:21 -0700 (PDT) Received: from localhost.localdomain (50-36-167-63.alma.mi.frontiernet.net. [50.36.167.63]) by smtp.gmail.com with ESMTPSA id h70sm33727176iof.48.2019.09.09.07.03.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 07:03:21 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 9/9] NFSv4: Handle NFS4ERR_OLD_STATEID in LOCKU Date: Mon, 9 Sep 2019 10:01:04 -0400 Message-Id: <20190909140104.78818-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190909140104.78818-8-trond.myklebust@hammerspace.com> References: <20190909140104.78818-1-trond.myklebust@hammerspace.com> <20190909140104.78818-2-trond.myklebust@hammerspace.com> <20190909140104.78818-3-trond.myklebust@hammerspace.com> <20190909140104.78818-4-trond.myklebust@hammerspace.com> <20190909140104.78818-5-trond.myklebust@hammerspace.com> <20190909140104.78818-6-trond.myklebust@hammerspace.com> <20190909140104.78818-7-trond.myklebust@hammerspace.com> <20190909140104.78818-8-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If a LOCKU request receives a NFS4ERR_OLD_STATEID, then bump the seqid before resending. Ensure we only bump the seqid by 1. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 49f301198008..ecfaf4b1ba5d 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6377,6 +6377,42 @@ static int nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock * return err; } +/* + * Update the seqid of a lock stateid after receiving + * NFS4ERR_OLD_STATEID + */ +static bool nfs4_refresh_lock_old_stateid(nfs4_stateid *dst, + struct nfs4_lock_state *lsp) +{ + struct nfs4_state *state = lsp->ls_state; + bool ret = false; + + spin_lock(&state->state_lock); + if (!nfs4_stateid_match_other(dst, &lsp->ls_stateid)) + goto out; + if (!nfs4_stateid_is_newer(&lsp->ls_stateid, dst)) + nfs4_stateid_seqid_inc(dst); + else + dst->seqid = lsp->ls_stateid.seqid; + ret = true; +out: + spin_unlock(&state->state_lock); + return ret; +} + +static bool nfs4_sync_lock_stateid(nfs4_stateid *dst, + struct nfs4_lock_state *lsp) +{ + struct nfs4_state *state = lsp->ls_state; + bool ret; + + spin_lock(&state->state_lock); + ret = !nfs4_stateid_match_other(dst, &lsp->ls_stateid); + nfs4_stateid_copy(dst, &lsp->ls_stateid); + spin_unlock(&state->state_lock); + return ret; +} + struct nfs4_unlockdata { struct nfs_locku_args arg; struct nfs_locku_res res; @@ -6448,10 +6484,14 @@ static void nfs4_locku_done(struct rpc_task *task, void *data) task->tk_msg.rpc_cred); /* Fall through */ case -NFS4ERR_BAD_STATEID: - case -NFS4ERR_OLD_STATEID: case -NFS4ERR_STALE_STATEID: - if (!nfs4_stateid_match(&calldata->arg.stateid, - &calldata->lsp->ls_stateid)) + if (nfs4_sync_lock_stateid(&calldata->arg.stateid, + calldata->lsp)) + rpc_restart_call_prepare(task); + break; + case -NFS4ERR_OLD_STATEID: + if (nfs4_refresh_lock_old_stateid(&calldata->arg.stateid, + calldata->lsp)) rpc_restart_call_prepare(task); break; default: @@ -6474,7 +6514,6 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data) if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0) goto out_wait; - nfs4_stateid_copy(&calldata->arg.stateid, &calldata->lsp->ls_stateid); if (test_bit(NFS_LOCK_INITIALIZED, &calldata->lsp->ls_flags) == 0) { /* Note: exit _without_ running nfs4_locku_done */ goto out_no_action;