Skip to contentSkip to conversation

cifs: zero-range does not require the file is sparse

PATCH In review Ronnie Sahlberg 2 participants 2 messages Apr 11, 2019 – Apr 12, 2019

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

PATCH 1/1 cifs: zero-range does not require the file is sparse

Remove the conditional to fail zero-range if the file is not flagged as sparse. You can still zero out a range in SMB2 even for non-sparse files.

Tested with stock windows16 server.

---
 fs/cifs/smb2ops.c | 12 ------------
 1 file changed, 12 deletions(-)
fs/cifs/smb2ops.c +0 -12
index ca952dc3ec75..56e85f46cd82 100644
@@ -2664,18 +2664,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
 			return rc;
 		}
 
-	/*
-	 * Must check if file sparse since fallocate -z (zero range) assumes
-	 * non-sparse allocation
-	 */
-	if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) {
-		rc = -EOPNOTSUPP;
-		trace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid,
-			      ses->Suid, offset, len, rc);
-		free_xid(xid);
-		return rc;
-	}
-
 	cifs_dbg(FYI, "offset %lld len %lld", offset, len);
 
 	fsctl_buf.FileOffset = cpu_to_le64(offset);
Signature · 1 line
2.13.6
#1 lore raw

I verified it fixed 5 xfstests (033, 149, 155, 180, 349)

Quoted 37 lines · Ronnie Sahlberg

Remove the conditional to fail zero-range if the file is not flagged as sparse. You can still zero out a range in SMB2 even for non-sparse files.

Tested with stock windows16 server.

---
 fs/cifs/smb2ops.c | 12 ------------
 1 file changed, 12 deletions(-)
fs/cifs/smb2ops.c +0 -13
index ca952dc3ec75..56e85f46cd82 100644
@@ -2664,18 +2664,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
                        return rc;
                }
 
-       /*
-        * Must check if file sparse since fallocate -z (zero range) assumes
-        * non-sparse allocation
-        */
-       if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) {
-               rc = -EOPNOTSUPP;
-               trace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid,
-                             ses->Suid, offset, len, rc);
-               free_xid(xid);
-               return rc;
-       }
-
        cifs_dbg(FYI, "offset %lld len %lld", offset, len);
 
        fsctl_buf.FileOffset = cpu_to_le64(offset);
--

2.13.6

Signature · 3 lines
Thanks,

Steve