From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 90382356746; Tue, 21 Jul 2026 19:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663627; cv=none; b=XVMzuGTP1V4VfN0wDzrMzc2LTDOkLFnjcbAL0kl1Ut/P+71nxI+kEr9eR1FA5YUGaElIg70d6VovHkoyFmyYKLWj2w5r4tYP6Q2FyJvxQ489nOwyjTrpv/eUMrLjJ5LGER2U1qnZ2t7rw8r2LFoEU4cNFbWt5z3frdaqC2lOYGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784663627; c=relaxed/simple; bh=Cd+5O+QU1qD+2Au0Bi5NLsnUK9sB/6ewlbSMuAUUZDk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gw1zGsOraCtfwqih6YqEF/ITtET3QrRHwZJQf3u8pZ9ltWDhlakpzr1abjL0GkCsvAVOItRO0Nz8OguFa5RoABYgfgMBZkIQp5qJnwFeHHWl1w3R46N91ZC29mzKS7oob8eZkbFtJi/UBJS0KR9ULOA6NXf3C+Lz32kjc6IEmCo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rNnbhfvK; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rNnbhfvK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02A3F1F000E9; Tue, 21 Jul 2026 19:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784663626; bh=nCQ64av0hb6qKFhtszjyEtwj6/hxjPucILhcSFF8QuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rNnbhfvKyrjPTq8qGHpk+LJ+Fw7jEDYlaU+K67notmhCFyaMG91g+jWVbhn8kgL1g z3bTjdR5bKRAPq76Tchd2RbZRwRDLzj+T4EuP+1OlThnh48rGfX2R0R7YTFC6Gg2SY xh3tz9J8XZVqqlIpZczyGME4WLdM2utqqNRPoC5M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shyam Prasad N , Steve French Subject: [PATCH 6.12 0894/1276] cifs: invalidate cfid on unlink/rename/rmdir Date: Tue, 21 Jul 2026 17:22:17 +0200 Message-ID: <20260721152506.050496059@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shyam Prasad N commit f71d68d2b473e47db260c27c98212829590d8bae upstream. Today we do not invalidate the cached_dirent or the entire parent cfid when a dentry in a dir has been removed/moved. This change invalidates the parent cfid so that we don't serve directory contents from the cache. Cc: Signed-off-by: Shyam Prasad N Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/inode.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) --- a/fs/smb/client/inode.c +++ b/fs/smb/client/inode.c @@ -28,6 +28,23 @@ #include "cached_dir.h" #include "reparse.h" +static void cifs_invalidate_cached_dir(struct cifs_tcon *tcon, + struct dentry *parent) +{ + struct cached_fid *parent_cfid = NULL; + + if (!tcon || !parent) + return; + + if (!open_cached_dir_by_dentry(tcon, parent, &parent_cfid)) { + mutex_lock(&parent_cfid->dirents.de_mutex); + parent_cfid->dirents.is_valid = false; + parent_cfid->dirents.is_failed = true; + mutex_unlock(&parent_cfid->dirents.de_mutex); + close_cached_dir(parent_cfid); + } +} + /* * Set parameters for the netfs library */ @@ -2026,6 +2043,9 @@ psx_del_no_retry: cifs_set_file_info(inode, attrs, xid, full_path, origattr); out_reval: + if (!rc && dentry->d_parent) + cifs_invalidate_cached_dir(tcon, dentry->d_parent); + if (inode) { cifs_inode = CIFS_I(inode); cifs_inode->time = 0; /* will force revalidate to get info @@ -2330,13 +2350,14 @@ int cifs_rmdir(struct inode *inode, stru } rc = server->ops->rmdir(xid, tcon, full_path, cifs_sb); - cifs_put_tlink(tlink); if (!rc) { spin_lock(&d_inode(direntry)->i_lock); i_size_write(d_inode(direntry), 0); clear_nlink(d_inode(direntry)); spin_unlock(&d_inode(direntry)->i_lock); + if (direntry->d_parent) + cifs_invalidate_cached_dir(tcon, direntry->d_parent); } cifsInode = CIFS_I(d_inode(direntry)); @@ -2352,6 +2373,7 @@ int cifs_rmdir(struct inode *inode, stru inode_set_ctime_current(d_inode(direntry)); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); + cifs_put_tlink(tlink); rmdir_exit: free_dentry_path(page); @@ -2576,6 +2598,12 @@ unlink_target: } /* force revalidate to go get info when needed */ + if (!rc) { + cifs_invalidate_cached_dir(tcon, source_dentry->d_parent); + if (target_dentry->d_parent != source_dentry->d_parent) + cifs_invalidate_cached_dir(tcon, target_dentry->d_parent); + } + CIFS_I(source_dir)->time = CIFS_I(target_dir)->time = 0; cifs_rename_exit: