aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <lsahlber@redhat.com>2019-03-14 10:08:48 -0400
committerSteve French <stfrench@microsoft.com>2019-03-14 20:32:36 -0400
commitf16994797ea89e572b27f41c554aeac6b1c16048 (patch)
tree6cd28e77b19fbc646d3a8a1e9371fab6e136e095
parentdd0ac2d24bf0b39c0f4f17934a0e1dde2b3a2840 (diff)
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>
-rw-r--r--fs/cifs/smb2ops.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 9a7164c2ea63..1c8d3684bb8b 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2718,6 +2718,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
2718 struct cifsFileInfo *cfile = file->private_data; 2718 struct cifsFileInfo *cfile = file->private_data;
2719 long rc = -EOPNOTSUPP; 2719 long rc = -EOPNOTSUPP;
2720 unsigned int xid; 2720 unsigned int xid;
2721 __le64 eof;
2721 2722
2722 xid = get_xid(); 2723 xid = get_xid();
2723 2724
@@ -2777,9 +2778,18 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
2777 return rc; 2778 return rc;
2778 } 2779 }
2779 2780
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 }
2781 } 2792 }
2782 /* BB: else ... in future add code to extend file and set sparse */
2783 2793
2784 if (rc) 2794 if (rc)
2785 trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, tcon->tid, 2795 trace_smb3_falloc_err(xid, cfile->fid.persistent_fid, tcon->tid,