Skip to content

Commit f169947

Browse files
Ronnie SahlbergSteve French
authored andcommitted
cifs: fix incorrect handling of smb2_set_sparse() return in smb3_simple_falloc
smb2_set_sparse does not return -errno, it returns a boolean where true means success. Change this to just ignore the return value just like the other callsites. Additionally add code to handle the case where we must set the file sparse and possibly also extending it. Fixes xfstests: generic/236 generic/350 generic/420 Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent dd0ac2d commit f169947

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/cifs/smb2ops.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2718,6 +2718,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
27182718
struct cifsFileInfo *cfile = file->private_data;
27192719
long rc = -EOPNOTSUPP;
27202720
unsigned int xid;
2721+
__le64 eof;
27212722

27222723
xid = get_xid();
27232724

@@ -2777,9 +2778,18 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
27772778
return rc;
27782779
}
27792780

2780-
rc = smb2_set_sparse(xid, tcon, cfile, inode, false);
2781+
smb2_set_sparse(xid, tcon, cfile, inode, false);
2782+
rc = 0;
2783+
} else {
2784+
smb2_set_sparse(xid, tcon, cfile, inode, false);
2785+
rc = 0;
2786+
if (i_size_read(inode) < off + len) {
2787+
eof = cpu_to_le64(off + len);
2788+
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
2789+
cfile->fid.volatile_fid, cfile->pid,
2790+
&eof);
2791+
}
27812792
}
2782-
/* BB: else ... in future add code to extend file and set sparse */
27832793

27842794
if (rc)
27852795
trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, tcon->tid,

0 commit comments

Comments
 (0)