Skip to content

Commit 83d5518

Browse files
dhowellsSteve French
authored andcommitted
cifs: Fix FALLOC_FL_ZERO_RANGE by setting i_size if EOF moved
Fix the cifs filesystem implementations of FALLOC_FL_ZERO_RANGE, in smb3_zero_range(), to set i_size after extending the file on the server. Fixes: 72c419d ("cifs: fix smb3_zero_range so it can expand the file-size when required") Cc: [email protected] Signed-off-by: David Howells <[email protected]> Acked-by: Paulo Alcantara <[email protected]> cc: Shyam Prasad N <[email protected]> cc: Rohith Surabattula <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Steve French <[email protected]>
1 parent 9d63509 commit 83d5518

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/smb/client/smb2ops.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3311,6 +3311,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
33113311
struct inode *inode = file_inode(file);
33123312
struct cifsInodeInfo *cifsi = CIFS_I(inode);
33133313
struct cifsFileInfo *cfile = file->private_data;
3314+
unsigned long long new_size;
33143315
long rc;
33153316
unsigned int xid;
33163317
__le64 eof;
@@ -3341,10 +3342,15 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
33413342
/*
33423343
* do we also need to change the size of the file?
33433344
*/
3344-
if (keep_size == false && i_size_read(inode) < offset + len) {
3345-
eof = cpu_to_le64(offset + len);
3345+
new_size = offset + len;
3346+
if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) {
3347+
eof = cpu_to_le64(new_size);
33463348
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
33473349
cfile->fid.volatile_fid, cfile->pid, &eof);
3350+
if (rc >= 0) {
3351+
truncate_setsize(inode, new_size);
3352+
fscache_resize_cookie(cifs_inode_cookie(inode), new_size);
3353+
}
33483354
}
33493355

33503356
zero_range_exit:

0 commit comments

Comments
 (0)