linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cifs: add revalidation on FSCTL failure in smb2_duplicate_extents()
@ 2026-08-23 23:26 Frank Sorenson
  2026-08-27  2:06 ` Paulo Alcantara
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Sorenson @ 2026-08-23 23:26 UTC (permalink / raw)
  To: linux-cifs; +Cc: pc, linkinjeon, stable

smb2_duplicate_extents() has no handling for
FSCTL_DUPLICATE_EXTENTS_TO_FILE failure: when the FSCTL fails, local
inode metadata may be stale from the pre-extension or from concurrent
remote writes, but is never refreshed.

Force revalidation on FSCTL failure and use i_size_read() for the
pre-extension check.

Fixes: cfc63fc8126a ("smb3: fix cached file size problems in duplicate extents (reflink)")
Cc: stable@vger.kernel.org
Signed-off-by: Frank Sorenson <sorenson@redhat.com>
---
 fs/smb/client/smb2ops.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 7d6738ffcb80..bea4876b58cb 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -2218,7 +2218,7 @@ smb2_duplicate_extents(const unsigned int xid,
 			       trgtfile->fid.volatile_fid, tcon->tid,
 			       tcon->ses->Suid, src_off, dest_off, len);
 	inode = d_inode(trgtfile->dentry);
-	if (inode->i_size < dest_off + len) {
+	if (i_size_read(inode) < dest_off + len) {
 		rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
 		if (rc)
 			goto duplicate_extents_out;
@@ -2235,7 +2235,10 @@ smb2_duplicate_extents(const unsigned int xid,
 	if (ret_data_len > 0)
 		cifs_dbg(FYI, "Non-zero response length in duplicate extents\n");
 
-	if (rc == 0) {
+	if (rc) {
+		CIFS_I(inode)->time = 0; /* force reval */
+		cifs_invalidate_cache(inode, 0);
+	} else {
 		qrc = SMB2_query_info(xid, tcon, trgtfile->fid.persistent_fid,
 				      trgtfile->fid.volatile_fid, &file_inf);
 		spin_lock(&inode->i_lock);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cifs: add revalidation on FSCTL failure in smb2_duplicate_extents()
  2026-08-23 23:26 [PATCH] cifs: add revalidation on FSCTL failure in smb2_duplicate_extents() Frank Sorenson
@ 2026-08-27  2:06 ` Paulo Alcantara
  0 siblings, 0 replies; 2+ messages in thread
From: Paulo Alcantara @ 2026-08-27  2:06 UTC (permalink / raw)
  To: Frank Sorenson, linux-cifs; +Cc: linkinjeon, stable

Frank Sorenson <sorenson@redhat.com> writes:

> smb2_duplicate_extents() has no handling for
> FSCTL_DUPLICATE_EXTENTS_TO_FILE failure: when the FSCTL fails, local
> inode metadata may be stale from the pre-extension or from concurrent
> remote writes, but is never refreshed.
>
> Force revalidation on FSCTL failure and use i_size_read() for the
> pre-extension check.
> ...

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-27  2:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 23:26 [PATCH] cifs: add revalidation on FSCTL failure in smb2_duplicate_extents() Frank Sorenson
2026-08-27  2:06 ` Paulo Alcantara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).