Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp688482ybv; Thu, 13 Feb 2020 07:48:05 -0800 (PST) X-Google-Smtp-Source: APXvYqwElMu0coFOfNsf+sS6ciX3sC+Rsf+ysI/Qb4XLTuJkxj4THkAD5ziya+es1aig5Bct6A/z X-Received: by 2002:a9d:20a:: with SMTP id 10mr10075374otb.319.1581608885375; Thu, 13 Feb 2020 07:48:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608885; cv=none; d=google.com; s=arc-20160816; b=jeudsENpqWrOBVgJ2zYis57cXY+DCxpMR5KV2hA0xY0pGhBu+UCpY+x6byLGIu+I+/ a5EApDpBq1x9XrPTMbxOesCo6Zf8CVC73TOQtV5tZNHlxxjIR1r/gCIu7Ig1X1i82C7C fXttnuVatiM9cM/wxEIMga33kdZ5MP2L32wwd9fWtLuD4veIOxW7xIHtHMfQZrBOlNCN BImFpCf2eutouJBVt5FWxSopgYSL/5GQ8BokS9Jo942glnknOr26hIynAmYlTdJBiTYx pFmLsHpF3ooo+uEk5b1Qc5KJNxklBKPDGgZN7JCFtnR7ypzVsLVj4/biwSXD7M480wPa EqzQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hh+7DqhsrYjKeQyKm194CwYNovX72z7KKjL8mOzw+4M=; b=oGHuIJovkduQp5FVKU37AQmBXUKo0/U8msd6fZYEbMZptWFR+XtSGjs2bq6As1fLjW Zvji9E612kI5oDDaHY9ZikNcEtmmT33/ijgmynFh1Ujsc7jSYi2CCkkeLjhBVYl23eTQ JJaPIoXsCec7+8jXFsbkOZ3g0h/Oi6iCS3KX67a/0t7FvXgvDNeO5xSC50I3PQZ+lmi0 FqKF0jsPGI+vpVVtS0aGCM/iF7Iok4FBBzgMgaXNOixYgmXeTPRDybvxxfSaefNTgaro 2MWgBXtO2nQyTA8Es3Gbl2tu+NizsX810u10V/A0R2IAnpZj7cPmjHazOKWvH2Jf8eb6 bTLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QZfZmFy4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v24si1259445otn.125.2020.02.13.07.47.53; Thu, 13 Feb 2020 07:48:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=QZfZmFy4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387892AbgBMPqv (ORCPT + 99 others); Thu, 13 Feb 2020 10:46:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:49346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729012AbgBMP1N (ORCPT ); Thu, 13 Feb 2020 10:27:13 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BC592168B; Thu, 13 Feb 2020 15:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607632; bh=wze1R9Sx/IvZWY6+hkwJtRPbxSyVkd0ruGj6bpG/WWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QZfZmFy4judiOplb0/YoeF7isSQoaVx4z38/s66HI8U1IUp4W2bieHhiDIik7A4j5 k/Lc2dCuIZmVTBUuSzdSu4rRnJxa/NlFSIyCiWhvxqsIFewRKuvEkz4+CbYzR41qBZ PcFWdGhOS/CLL7FEVe2rrMZSmxnzsvBDluZPvtH4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robert Milkowski , Anna Schumaker Subject: [PATCH 5.4 33/96] NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals Date: Thu, 13 Feb 2020 07:20:40 -0800 Message-Id: <20200213151851.829774508@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robert Milkowski commit 7dc2993a9e51dd2eee955944efec65bef90265b7 upstream. Currently, each time nfs4_do_fsinfo() is called it will do an implicit NFS4 lease renewal, which is not compliant with the NFS4 specification. This can result in a lease being expired by an NFS server. Commit 83ca7f5ab31f ("NFS: Avoid PUTROOTFH when managing leases") introduced implicit client lease renewal in nfs4_do_fsinfo(), which can result in the NFSv4.0 lease to expire on a server side, and servers returning NFS4ERR_EXPIRED or NFS4ERR_STALE_CLIENTID. This can easily be reproduced by frequently unmounting a sub-mount, then stat'ing it to get it mounted again, which will delay or even completely prevent client from sending RENEW operations if no other NFS operations are issued. Eventually nfs server will expire client's lease and return an error on file access or next RENEW. This can also happen when a sub-mount is automatically unmounted due to inactivity (after nfs_mountpoint_expiry_timeout), then it is mounted again via stat(). This can result in a short window during which client's lease will expire on a server but not on a client. This specific case was observed on production systems. This patch removes the implicit lease renewal from nfs4_do_fsinfo(). Fixes: 83ca7f5ab31f ("NFS: Avoid PUTROOTFH when managing leases") Signed-off-by: Robert Milkowski Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4_fs.h | 4 +--- fs/nfs/nfs4proc.c | 12 ++++++++---- fs/nfs/nfs4renewd.c | 5 +---- fs/nfs/nfs4state.c | 4 +--- 4 files changed, 11 insertions(+), 14 deletions(-) --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -439,9 +439,7 @@ extern void nfs4_schedule_state_renewal( extern void nfs4_renewd_prepare_shutdown(struct nfs_server *); extern void nfs4_kill_renewd(struct nfs_client *); extern void nfs4_renew_state(struct work_struct *); -extern void nfs4_set_lease_period(struct nfs_client *clp, - unsigned long lease, - unsigned long lastrenewed); +extern void nfs4_set_lease_period(struct nfs_client *clp, unsigned long lease); /* nfs4state.c */ --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -5024,16 +5024,13 @@ static int nfs4_do_fsinfo(struct nfs_ser struct nfs4_exception exception = { .interruptible = true, }; - unsigned long now = jiffies; int err; do { err = _nfs4_do_fsinfo(server, fhandle, fsinfo); trace_nfs4_fsinfo(server, fhandle, fsinfo->fattr, err); if (err == 0) { - nfs4_set_lease_period(server->nfs_client, - fsinfo->lease_time * HZ, - now); + nfs4_set_lease_period(server->nfs_client, fsinfo->lease_time * HZ); break; } err = nfs4_handle_exception(server, err, &exception); @@ -6089,6 +6086,7 @@ int nfs4_proc_setclientid(struct nfs_cli .callback_data = &setclientid, .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN, }; + unsigned long now = jiffies; int status; /* nfs_client_id4 */ @@ -6121,6 +6119,9 @@ int nfs4_proc_setclientid(struct nfs_cli clp->cl_acceptor = rpcauth_stringify_acceptor(setclientid.sc_cred); put_rpccred(setclientid.sc_cred); } + + if (status == 0) + do_renew_lease(clp, now); out: trace_nfs4_setclientid(clp, status); dprintk("NFS reply setclientid: %d\n", status); @@ -8204,6 +8205,7 @@ static int _nfs4_proc_exchange_id(struct struct rpc_task *task; struct nfs41_exchange_id_args *argp; struct nfs41_exchange_id_res *resp; + unsigned long now = jiffies; int status; task = nfs4_run_exchange_id(clp, cred, sp4_how, NULL); @@ -8224,6 +8226,8 @@ static int _nfs4_proc_exchange_id(struct if (status != 0) goto out; + do_renew_lease(clp, now); + clp->cl_clientid = resp->clientid; clp->cl_exchange_flags = resp->flags; clp->cl_seqid = resp->seqid; --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c @@ -138,15 +138,12 @@ nfs4_kill_renewd(struct nfs_client *clp) * * @clp: pointer to nfs_client * @lease: new value for lease period - * @lastrenewed: time at which lease was last renewed */ void nfs4_set_lease_period(struct nfs_client *clp, - unsigned long lease, - unsigned long lastrenewed) + unsigned long lease) { spin_lock(&clp->cl_lock); clp->cl_lease_time = lease; - clp->cl_last_renewal = lastrenewed; spin_unlock(&clp->cl_lock); /* Cap maximum reconnect timeout at 1/2 lease period */ --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -91,17 +91,15 @@ static int nfs4_setup_state_renewal(stru { int status; struct nfs_fsinfo fsinfo; - unsigned long now; if (!test_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state)) { nfs4_schedule_state_renewal(clp); return 0; } - now = jiffies; status = nfs4_proc_get_lease_time(clp, &fsinfo); if (status == 0) { - nfs4_set_lease_period(clp, fsinfo.lease_time * HZ, now); + nfs4_set_lease_period(clp, fsinfo.lease_time * HZ); nfs4_schedule_state_renewal(clp); }