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 4CBC746D56F; Tue, 21 Jul 2026 18:32:09 +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=1784658730; cv=none; b=MA6kO8nuF4QFBmVY8QGNsDhxJVmvTLGPD6WsEhz00NLXYFOC8SS05yLustUZwgDUDm3nMHfffEf8yp+Llw9W+xMwCZ8isU8mcSYOm7XYFz1pQuIgGatJKs283kRgTVrefCi5ApY9pCJvUMwIKsCI4ZL5Wipj72/4MBikAN0skk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658730; c=relaxed/simple; bh=+3yJV289jdLV1ydVP9KVeNjRUT4eExvooJPsV8fV4Kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BLKaX4JZgip+4s4UEzQ7BpjfPWAgTer3R3lK7XIZj5c0/EGC7wcCFf7aNXtPRiQXu3Ffh995VbWiIgwCqp7Srcppl1gj2GbochEGmXT/TsZhXI1LBjS6KpNaPygXnDNZftYFOXRdfJ0eDfLFhDKXg/skzpPATqACavlo0TF0AP4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=m7v3YpMc; 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="m7v3YpMc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A67B1F000E9; Tue, 21 Jul 2026 18:32:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658728; bh=LvGOqw62CaNK2Cip0ffL8BnEpPD2ZSvCRf2vBpEeVOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m7v3YpMcOSPGf87j1s/MkVXHQuG6lKjCxtkVsx4ZigHfFzNf0d6MQvjCKyUYvEqjQ BUi7VEqyCF6QzA12rV5TLS+x6ed5ov30D2if8mRFm+a7LOheASjCQCztKnd5bbWm/t Xa7lbFOSJNpwC/NTM1qXrp9GPNdIdhd0S7o/HcDA= 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.18 1209/1611] cifs: invalidate cfid on unlink/rename/rmdir Date: Tue, 21 Jul 2026 17:22:05 +0200 Message-ID: <20260721152542.628731829@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-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 */ @@ -2063,6 +2080,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 @@ -2372,7 +2392,6 @@ int cifs_rmdir(struct inode *inode, stru } rc = server->ops->rmdir(xid, tcon, full_path, cifs_sb); - cifs_put_tlink(tlink); cifsInode = CIFS_I(d_inode(direntry)); @@ -2382,6 +2401,8 @@ int cifs_rmdir(struct inode *inode, stru 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); } /* force revalidate to go get info when needed */ @@ -2396,6 +2417,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); @@ -2663,6 +2685,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: