Received: by 10.192.165.148 with SMTP id m20csp576824imm; Wed, 25 Apr 2018 04:33:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqlgSb3UP/Ozc/cEgaAhKOtLp4Ez+7sGXgWvoEHZfz/qiZQGWu+M1Tc1gA5N8k0+HQQGx45 X-Received: by 10.98.19.6 with SMTP id b6mr1846360pfj.58.1524656038216; Wed, 25 Apr 2018 04:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524656038; cv=none; d=google.com; s=arc-20160816; b=DL8XHXNW+YGp8OXh31vLeee/BLncU5StDjmNCAf3uQaLPbYqnEo95fO2pYkAsvfNB7 xxq9dHKEGc2YKHsAppv+WZknxeAL25zkbcwtLZuO+cAftiqpBwIXFnhupoYiLV8Ce2aB bA8bazafhdMXdGe0Urj1WKyqFWKSNujp8ejiewVC4ISbov9gXD5tRAiKS4cGM8Bns38x qJSEEPy3AzsKj3BdB0a7czS6QcAPCUq1B7xzvQmFKWVFMkenohUI020qgbfIXz6a3jhJ IMLBpmck7iUoGUooWy0GBW+/5bBwC6kGy7/3oYRursDwNK8l/w2srirXCDHpuQjdSFtl Vr1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=3yr3WksF0K6KEqbHE1y2ol1JhUNW9b2SxZ2q3CJKMXg=; b=GvkBE+Sf/C7Mes8QUpYbw04LFYgaDmUEHb+oeyadaPJ/2TAFdAAlVnvUreBgXE/YWv GGBzL+oiEui/a83zvh53S2LTVYBtgv1lxnloRMZWcrCTxPgyKEXMKFJ6eZ0/W63pXKn7 c8l4l/k2k8pA/1hBjSRrtb2dWfAa/rmeJBE7EaQv0FxJrKNvHsuY0dVKrc1+bmng/Tf6 8ox2vd71Cxcz9bW4zHboYRMut7EJ13jFLmAmbbhUCO4mjAx/9dB9uU1WIQe8nbWXgVh+ t8AwoCX5zHzu4AD10F1Q+zb7Z2M9cSme0OJD2viFpgWyH1AsiLYdkl9hCJIAe2chVCfD NrMg== ARC-Authentication-Results: i=1; mx.google.com; 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 y11-v6si15707769plg.154.2018.04.25.04.33.43; Wed, 25 Apr 2018 04:33:58 -0700 (PDT) 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; 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 S1753358AbeDYLcl (ORCPT + 99 others); Wed, 25 Apr 2018 07:32:41 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51126 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753266AbeDYKh1 (ORCPT ); Wed, 25 Apr 2018 06:37:27 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1058F481; Wed, 25 Apr 2018 10:37:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 018/183] NFSv4: always set NFS_LOCK_LOST when a lock is lost. Date: Wed, 25 Apr 2018 12:33:58 +0200 Message-Id: <20180425103243.340689265@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: NeilBrown [ Upstream commit dce2630c7da73b0634686bca557cc8945cc450c8 ] There are 2 comments in the NFSv4 code which suggest that SIGLOST should possibly be sent to a process. In these cases a lock has been lost. The current practice is to set NFS_LOCK_LOST so that read/write returns EIO when a lock is lost. So change these comments to code when sets NFS_LOCK_LOST. One case is when lock recovery after apparent server restart fails with NFS4ERR_DENIED, NFS4ERR_RECLAIM_BAD, or NFS4ERRO_RECLAIM_CONFLICT. The other case is when a lock attempt as part of lease recovery fails with NFS4ERR_DENIED. In an ideal world, these should not happen. However I have a packet trace showing an NFSv4.1 session getting NFS4ERR_BADSESSION after an extended network parition. The NFSv4.1 client treats this like server reboot until/unless it get NFS4ERR_NO_GRACE, in which case it switches over to "nograce" recovery mode. In this network trace, the client attempts to recover a lock and the server (incorrectly) reports NFS4ERR_DENIED rather than NFS4ERR_NO_GRACE. This leads to the ineffective comment and the client then continues to write using the OPEN stateid. Signed-off-by: NeilBrown Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/nfs/nfs4proc.c | 12 ++++++++---- fs/nfs/nfs4state.c | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1885,7 +1885,7 @@ static int nfs4_open_reclaim(struct nfs4 return ret; } -static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, int err) +static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, struct file_lock *fl, int err) { switch (err) { default: @@ -1932,7 +1932,11 @@ static int nfs4_handle_delegation_recall return -EAGAIN; case -ENOMEM: case -NFS4ERR_DENIED: - /* kill_proc(fl->fl_pid, SIGLOST, 1); */ + if (fl) { + struct nfs4_lock_state *lsp = fl->fl_u.nfs4_fl.owner; + if (lsp) + set_bit(NFS_LOCK_LOST, &lsp->ls_flags); + } return 0; } return err; @@ -1968,7 +1972,7 @@ int nfs4_open_delegation_recall(struct n err = nfs4_open_recover_helper(opendata, FMODE_READ); } nfs4_opendata_put(opendata); - return nfs4_handle_delegation_recall_error(server, state, stateid, err); + return nfs4_handle_delegation_recall_error(server, state, stateid, NULL, err); } static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata) @@ -6595,7 +6599,7 @@ int nfs4_lock_delegation_recall(struct f if (err != 0) return err; err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); - return nfs4_handle_delegation_recall_error(server, state, stateid, err); + return nfs4_handle_delegation_recall_error(server, state, stateid, fl, err); } struct nfs_release_lockowner_data { --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1447,6 +1447,7 @@ static int nfs4_reclaim_locks(struct nfs struct inode *inode = state->inode; struct nfs_inode *nfsi = NFS_I(inode); struct file_lock *fl; + struct nfs4_lock_state *lsp; int status = 0; struct file_lock_context *flctx = inode->i_flctx; struct list_head *list; @@ -1487,7 +1488,9 @@ restart: case -NFS4ERR_DENIED: case -NFS4ERR_RECLAIM_BAD: case -NFS4ERR_RECLAIM_CONFLICT: - /* kill_proc(fl->fl_pid, SIGLOST, 1); */ + lsp = fl->fl_u.nfs4_fl.owner; + if (lsp) + set_bit(NFS_LOCK_LOST, &lsp->ls_flags); status = 0; } spin_lock(&flctx->flc_lock);