Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4097157pxb; Mon, 8 Feb 2021 07:53:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYgv14c5g0onjHAmogAal713yreKVOk6yb21w5BpbfEZKePDUuqw5pVcCG6vLnhXY6dVEj X-Received: by 2002:a05:6512:3083:: with SMTP id z3mr10918915lfd.453.1612799626816; Mon, 08 Feb 2021 07:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612799622; cv=none; d=google.com; s=arc-20160816; b=yk8IVdialuiLoEmdGI36po4XkngDZQGU3dPjMZ3Gv7+3ghEHt/HvnQua8tU14nxhGj dqQQ6WBzhr7ChSNwIWgj1h/IFwJmv4jkBg4FdlOTnqRAGDndLUfFSiFTNXM2KnIpCQeu wkhKhgvnpjVxpBn1HeZy2Uw1IFz0vfhiqz83LRlZnA3oRQKLIgBemVgoZ8nPk7DLMCEX 6HmTY5sQKHfneB2IfOK+VdEjzDXkBIfWlnBdrUr7hUaMqPSgji5UgtykIONXlMVEA10l hazXe8fl15PFqOJw2oO/EI9gVw+VrWNiGhIBoLCZRmDPZYxu820LFMh/yEyFaxDlabpD dIAQ== 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=EkRYEYd1gNgw4HTdg0g4fH/BZt+SylC/hC6W2xrv37Y=; b=JOhVXVUajrqS19gfbkFbXYyUCsMhWHvQm41ZPFUIqkjLDlJ4aYuAZtMFXNrAbIazsr LoUH9VtPZM1y+tur3EnIzYm+P+bRnjFq11AYJGF2B9NC6SVkTQ622JKCOPd/PulCnY5K p9RZXyzMUFirv8ibCspAvtnaBx5Q0b5YJRAJYv571eygvRHDfCGyEXtfH9FxEWYFqTzS LHekSIW3mPHY17s+KB0mFkEuCmcKJM61p4Jzz67cGrxcemDHuWuuPZ+QqdbwC2PSxGVL 1fyV/HFC5dAZ5j66vC9K4WeMODHZV+6ToEhoE45MYGAnnSpydPPZaw4XVZYEMIfFx52s 63Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bcND9dn6; 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 fx25si10981636ejb.58.2021.02.08.07.53.18; Mon, 08 Feb 2021 07:53:42 -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=bcND9dn6; 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 S234160AbhBHPw3 (ORCPT + 99 others); Mon, 8 Feb 2021 10:52:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:52064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232502AbhBHPHO (ORCPT ); Mon, 8 Feb 2021 10:07:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9A97164EC7; Mon, 8 Feb 2021 15:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796749; bh=++MMy+Hh6lTqAavbd+e3c/YvswIUkCaoaLV+0AQlVdY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcND9dn6IiJpPPtVeG6C1VpUP0df9P7NXaZmUd+bhYmi+RX3ANM1faA+kzNi/T/ks JMp77LGOdkBNXfaML4tFeidLFacF7q3zXzU7M+RvaWjsj2AagKHCK2cSpsuvLs3mHr CGoWekbefFIVYilXepLmV4RdlFwJ9ArcTXYAvWLA= 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 4.9 31/43] cifs: report error instead of invalid when revalidating a dentry fails Date: Mon, 8 Feb 2021 16:00:57 +0100 Message-Id: <20210208145807.572978438@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.281758651@linuxfoundation.org> References: <20210208145806.281758651@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 @@ -830,6 +830,7 @@ static int cifs_d_revalidate(struct dentry *direntry, unsigned int flags) { struct inode *inode; + int rc; if (flags & LOOKUP_RCU) return -ECHILD; @@ -839,8 +840,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