Skip to contentSkip to conversation

cifs: Fix non-availability of dedup breaking generic/304

PATCH In review David Howells 3 participants 3 messages Dec 4, 2023 – Dec 5, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Fix non-availability of dedup breaking generic/304

Deduplication isn't supported on cifs, but cifs doesn't reject it, instead treating it as extent duplication/cloning. This can cause generic/304 to go silly and run for hours on end.

Fix cifs to indicate EOPNOTSUPP if REMAP_FILE_DEDUP is set in ->remap_file_range().

Note that it's unclear whether or not commit b073a08016a1 is meant to cause cifs to return an error if REMAP_FILE_DEDUP.

Fixes b073a08016a1 ("cifs: fix that return -EINVAL when do dedupe operation")
cc Steve French <[email protected]>
cc Xiaoli Feng <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
cc Darrick Wong <[email protected]>
---
 fs/smb/client/cifsfs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/client/cifsfs.c +3 -1
index 4d8927b57776..96a65cf9b5ec 100644
@@ -1276,7 +1276,9 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
 	unsigned int xid;
 	int rc;
 
-	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
+	if (remap_flags & REMAP_FILE_DEDUP)
+		return -EOPNOTSUPP;
+	if (remap_flags & ~REMAP_FILE_ADVISORY)
 		return -EINVAL;
 
 	cifs_dbg(FYI, "clone range\n");
#1 lore raw

added missing Signed-off-by line (and also for the two previous patches from David) and added Cc: stable and tentatively merged into cifs-2.6.git for-next pending additional testing

Quoted 44 lines · David Howells

Deduplication isn't supported on cifs, but cifs doesn't reject it, instead treating it as extent duplication/cloning. This can cause generic/304 to go silly and run for hours on end.

Fix cifs to indicate EOPNOTSUPP if REMAP_FILE_DEDUP is set in ->remap_file_range().

Note that it's unclear whether or not commit b073a08016a1 is meant to cause cifs to return an error if REMAP_FILE_DEDUP.

Fixes b073a08016a1 ("cifs: fix that return -EINVAL when do dedupe operation")
cc Steve French <[email protected]>
cc Xiaoli Feng <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
cc Darrick Wong <[email protected]>
---
 fs/smb/client/cifsfs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/client/cifsfs.c +3 -1
index 4d8927b57776..96a65cf9b5ec 100644
@@ -1276,7 +1276,9 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
        unsigned int xid;
        int rc;
 
-       if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
+       if (remap_flags & REMAP_FILE_DEDUP)
+               return -EOPNOTSUPP;
+       if (remap_flags & ~REMAP_FILE_ADVISORY)
                return -EINVAL;
 
        cifs_dbg(FYI, "clone range\n");
Signature · 3 lines
Thanks,

Steve
Reviewed-by on v1 1/1
#2 lore raw
In reply to David Howells
Quoted 3 lines · David Howells

Deduplication isn't supported on cifs, but cifs doesn't reject it, instead treating it as extent duplication/cloning. This can cause generic/304 to go silly and run for hours on end.

This should also mention that it cloning rather than comparing data can cause server-side data corruption in the destination file for the benefit of anyone trying to track down weird data corruption problems....

Quoted 27 lines

Fix cifs to indicate EOPNOTSUPP if REMAP_FILE_DEDUP is set in ->remap_file_range().

Note that it's unclear whether or not commit b073a08016a1 is meant to cause cifs to return an error if REMAP_FILE_DEDUP.

Fixes b073a08016a1 ("cifs: fix that return -EINVAL when do dedupe operation")
cc Steve French <[email protected]>
cc Xiaoli Feng <[email protected]>
cc Shyam Prasad N <[email protected]>
cc Rohith Surabattula <[email protected]>
cc Jeff Layton <[email protected]>
cc Darrick Wong <[email protected]>
---
 fs/smb/client/cifsfs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/client/cifsfs.c +0 -0
index 4d8927b57776..96a65cf9b5ec 100644

fs/smb/client/cifsfs.c static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, · line 1284

Quoted 10 lines
fs/smb/client/cifsfs.c +3 -1
@@ -1276,7 +1276,9 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
 	unsigned int xid;
 	int rc;
 
-	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
+	if (remap_flags & REMAP_FILE_DEDUP)
+		return -EOPNOTSUPP;
+	if (remap_flags & ~REMAP_FILE_ADVISORY)
 		return -EINVAL;
 
 	cifs_dbg(FYI, "clone range\n");

Apart from updating the commit message, the fix looks fine to me.

Signature · 2 lines
Dave Chinner
[email protected]