From: Frank Sorenson <sorenson@redhat.com>
To: linux-cifs@vger.kernel.org, pc@manguebit.org, stfrench@microsoft.com
Cc: stable@vger.kernel.org, Huiwen He <hehuiwen@kylinos.cn>,
David Howells <dhowells@redhat.com>,
Paulo Alcantara <pc@manguebit.com>
Subject: [PATCH 1/3] cifs: use cifs_invalidate_cache() in cifs_do_truncate() for O_TRUNC
Date: Tue, 28 Jul 2026 16:14:36 -0500 [thread overview]
Message-ID: <20260728211438.3859107-2-sorenson@redhat.com> (raw)
In-Reply-To: <20260728211438.3859107-1-sorenson@redhat.com>
cifs_setsize() now calls fscache_resize_cookie() since commit
fa724e235cfd ("cifs: add fscache_resize_cookie() to cifs_setsize()").
However, cifs_do_truncate() is called from cifs_open() before
fscache_use_cookie() activates the cookie, so the fscache cookie is
still quiescent at this point. fscache_begin_operation() requires
FSCACHE_COOKIE_IS_CACHING to be set and returns failure for a quiescent
cookie, making fscache_resize_cookie() a null operation in this path.
The correct fix for this path is cifs_invalidate_cache(), which calls
fscache_invalidate(). Unlike fscache_resize_cookie(), fscache_invalidate()
works on quiescent cookies: it unconditionally increments inval_counter
and sets FSCACHE_COOKIE_NO_DATA_TO_READ, ensuring that stale cached data
is not served once the cookie is later activated by fscache_use_cookie().
Truncation to zero leaves no valid cached data, making invalidation the
correct semantic. No inode lock is required for cifs_invalidate_cache().
Fixes: fa724e235cfd ("cifs: add fscache_resize_cookie() to cifs_setsize()")
Cc: stable@vger.kernel.org
Cc: Huiwen He <hehuiwen@kylinos.cn>
Cc: David Howells <dhowells@redhat.com>
Cc: Paulo Alcantara <pc@manguebit.com>
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
fs/smb/client/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index ac89c1ba56b1..389083f9ce00 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -1016,6 +1016,7 @@ static int cifs_do_truncate(const unsigned int xid, struct dentry *dentry)
if (!rc) {
netfs_resize_file(&cinode->netfs, 0, true);
cifs_setsize(inode, 0);
+ cifs_invalidate_cache(inode, 0);
}
}
if (cfile)
--
2.55.0
next prev parent reply other threads:[~2026-07-28 21:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 21:14 [PATCH 0/3] cifs: follow-on fixes and cleanup after fscache_resize_cookie() consolidation Frank Sorenson
2026-07-28 21:14 ` Frank Sorenson [this message]
2026-07-29 4:20 ` [PATCH 1/3] cifs: use cifs_invalidate_cache() in cifs_do_truncate() for O_TRUNC Huiwen He
2026-07-29 13:52 ` Frank Sorenson
2026-07-28 21:14 ` [PATCH 2/3] cifs: remove redundant size-update block in cifs_remap_file_range() Frank Sorenson
2026-07-28 21:14 ` [PATCH 3/3] cifs: remove dead size-update blocks in cifs_setattr_unix/nounix Frank Sorenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260728211438.3859107-2-sorenson@redhat.com \
--to=sorenson@redhat.com \
--cc=dhowells@redhat.com \
--cc=hehuiwen@kylinos.cn \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@manguebit.com \
--cc=pc@manguebit.org \
--cc=stable@vger.kernel.org \
--cc=stfrench@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox