Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4073937pxb; Mon, 8 Feb 2021 07:20:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyloW7NyJ0pA/IBYPnIASWyGNkfHexta0RFKoc4pTYkVWlOew+P42eLBP0mGseVWwy1YgIH X-Received: by 2002:a05:6402:2053:: with SMTP id bc19mr17216088edb.230.1612797608370; Mon, 08 Feb 2021 07:20:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612797608; cv=none; d=google.com; s=arc-20160816; b=eJlyDv36ieRCMQynQDsMc4tZeX1L70EKz+qonGYP7ZPBJifXRtdHvKIeLl7i4xvXvb kQsBsCcgx3ZcNZ6XduOOOgKfix0RiFduS664MT/LGouMQhpO4CmTVkH2+Gl3ZtKPOej7 GwrnR96yP6UVyDsUjS9arT5Sfhad3UPYLJ/j9MVj+k2HvzBoUKqA3qupjetJPml78xm/ N1lHOQBREb3CYdFtQY4zmDn0zNieeW2IlX+RHnks9ENsFDHCSbSi6eCwHoH2WxA/Y/hE amxCsw0jlewWpzz26UXTRxHNxw6eKoq6O18L5gbFyIxbClaWmG31+cky2pGT7Y90d/DI w0kA== 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=2ZjaS45s1hhTZd8csz4gyCHlfm8wkHePXzthiNxUPTY=; b=j5zayicKj6nrXfzjvUHJFTx844Te39ZoqJ3jOrmSUBORDeIsRd/xFYRwq8pHgZg2Db proXvTo7wAiw0ln+T9ZCSRH6SVSQYSWZjxa7vKxJKDWvb6+Xurtym5RZR6QPY0Gl9MpH /ADaLVzDoMznd17S5pvT4wUHRiGM9TbPS0fWet1C12mLAs62TeCmx1KdEErdj9wOqyuX 4Nw4cXTE5kAm08mpifWJ9RlQFWDpM3F4VVRA03I04Moe/bW4wcJkGxvgHUVdXpGd3DN0 g4GWa4jxKurT/eAYOvOakXxtt9ARKCajkZR37Wr/obemLpgO5wBChsvRMx4zSKcIYe/Y ggsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wboeOgQZ; 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 c21si10837587eja.329.2021.02.08.07.19.43; Mon, 08 Feb 2021 07:20:08 -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=wboeOgQZ; 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 S233656AbhBHPSG (ORCPT + 99 others); Mon, 8 Feb 2021 10:18:06 -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 S232859AbhBHPD5 (ORCPT ); Mon, 8 Feb 2021 10:03:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8A5C64E8A; Mon, 8 Feb 2021 15:02:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796572; bh=vI7ctVkbdPVnwQH6bjkIpC1+6VwQIp0RYP3vi4fcqRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wboeOgQZtChrE4IYXCS97c4zzoqciVTxRtNuBCyjDb2BZEWX4vO6E0xbA2BDr+A5Y mqtXSYkT5fGca++EBxFUf78qA0sQN2sd7yXEW84EoEhlRIkTP+OkHrNGN6mNr3ztss hMGaVamTnWJ9OCSDCjpElYkYUk4bwt9wTFvzg0dM= 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.4 28/38] cifs: report error instead of invalid when revalidating a dentry fails Date: Mon, 8 Feb 2021 16:00:50 +0100 Message-Id: <20210208145806.384124458@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145805.279815326@linuxfoundation.org> References: <20210208145805.279815326@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 @@ -831,6 +831,7 @@ static int cifs_d_revalidate(struct dentry *direntry, unsigned int flags) { struct inode *inode; + int rc; if (flags & LOOKUP_RCU) return -ECHILD; @@ -840,8 +841,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