Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4134099pxb; Mon, 8 Feb 2021 08:43:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWXmHU/Cp/xjt2AcYSl+XyYBTzMS2Hi1pvMPBoykN9eFvtFoOMJciCsL0Y0JzpRJhFBGnB X-Received: by 2002:a05:6402:1014:: with SMTP id c20mr8445467edu.53.1612802580488; Mon, 08 Feb 2021 08:43:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612802580; cv=none; d=google.com; s=arc-20160816; b=nY/x6CnuAQceCIeIUQ+s9K1L38AoT0eElXc+1sPrbkZtcLlzjpZ05DkWHNL4TnA5N9 ouZApxIBbhWEMdPCxvEMpIgZFhZ0LQ0Ke2HMAva2NO40+x5uIeKoaFREPa9qK2w8SjOZ vn0Rj0aqbyw87L2FwcmIJ4rO3326lUV96qGPI2fkwDigoHgwa39EuYquabWF6uwq8z1I qHkAEu5isEbG9PfS/z1FaHVME1J/WDLC5PkJujRyu1dLeGEtochttEeRM+diUGCaECAp sNZDxn4fmRQQWo/8paVom/xB0yZqxgEKsiOziPd/94x7GvzESi6giWkF2O6+r4V5E0QK ouZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EiLxzBT2sL4Y3PUjbVir6emxlx66QvectYryLZNFu2Y=; b=i4bhK87ZhTlSWqD5aYo2Zl2F0AKaw30QJzjwY4TcgrnWX9ENxzSs86bGm68QN80gfE sKA0GAnfka+fe+STcvrIqwdP+2E15mFU1aZegwQBz1+k/5K+/UUMGnito7Ae9NXtPr8k qw7KtdddYXzKd0b2YFJdbdbFw+0ykTct/tqyGdImD2gwQc6FsEqITMZRtCkEs8AVAkON we2Wlb5WHO05ONEDesKcLW2L/YOd9PSNpqPb1YR6D1X6oM6J4x5aOwrnGdSKY8b5mxMR EGQtJMFvlQt716DOX8Uiz5Wi+fATqjSqnsAg9pnfoRPv4j7rtj+Q1wgSXL18fdjnmpRm qbTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H3XUYA3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs28si12252946ejc.141.2021.02.08.08.42.36; Mon, 08 Feb 2021 08:43:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H3XUYA3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234488AbhBHQjk (ORCPT + 99 others); Mon, 8 Feb 2021 11:39:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:56624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233513AbhBHPOt (ORCPT ); Mon, 8 Feb 2021 10:14:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7F1764ECD; Mon, 8 Feb 2021 15:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797044; bh=81GN6TDcD9uC2LArZDvYnnFtAGNAZm6PGEZzSFS7UDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3XUYA3fxwTaCdkGts2rpAHSol/ZLQylq0814krc4AWxnxRkQvOpabsxUOO2Wqlgb OBYknrFsVIDWETxPDJr16UCwIRoEvNEai8tpki19oo09vIOa5ZNFeRM3yuwBdz/tdD NJ4g0MLuZaJVt9JGlikTdKErolpZp8UTWw8XjhjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Aptel , Shyam Prasad N , Steve French Subject: [PATCH 5.4 39/65] cifs: report error instead of invalid when revalidating a dentry fails Date: Mon, 8 Feb 2021 16:01:11 +0100 Message-Id: <20210208145811.739646660@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145810.230485165@linuxfoundation.org> References: <20210208145810.230485165@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aurelien Aptel commit 21b200d091826a83aafc95d847139b2b0582f6d1 upstream. Assuming - //HOST/a is mounted on /mnt - //HOST/b is mounted on /mnt/b On a slow connection, running 'df' and killing it while it's processing /mnt/b can make cifs_get_inode_info() returns -ERESTARTSYS. This triggers the following chain of events: => the dentry revalidation fail => dentry is put and released => superblock associated with the dentry is put => /mnt/b is unmounted This patch makes cifs_d_revalidate() return the error instead of 0 (invalid) when cifs_revalidate_dentry() fails, except for ENOENT (file deleted) and ESTALE (file recreated). Signed-off-by: Aurelien Aptel Suggested-by: Shyam Prasad N Reviewed-by: Shyam Prasad N CC: stable@vger.kernel.org Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/dir.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -738,6 +738,7 @@ static int cifs_d_revalidate(struct dentry *direntry, unsigned int flags) { struct inode *inode; + int rc; if (flags & LOOKUP_RCU) return -ECHILD; @@ -747,8 +748,25 @@ cifs_d_revalidate(struct dentry *direntr if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode))) CIFS_I(inode)->time = 0; /* force reval */ - if (cifs_revalidate_dentry(direntry)) - return 0; + rc = cifs_revalidate_dentry(direntry); + if (rc) { + cifs_dbg(FYI, "cifs_revalidate_dentry failed with rc=%d", rc); + switch (rc) { + case -ENOENT: + case -ESTALE: + /* + * Those errors mean the dentry is invalid + * (file was deleted or recreated) + */ + return 0; + default: + /* + * Otherwise some unexpected error happened + * report it as-is to VFS layer + */ + return rc; + } + } else { /* * If the inode wasn't known to be a dfs entry when