|
25 | 25 | #include "smb2glob.h"
|
26 | 26 | #include "cifs_ioctl.h"
|
27 | 27 | #include "smbdirect.h"
|
| 28 | +#include "fscache.h" |
28 | 29 | #include "fs_context.h"
|
29 | 30 |
|
30 | 31 | /* Change credits for different ops and return the total number of credits */
|
@@ -3887,29 +3888,38 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
|
3887 | 3888 | {
|
3888 | 3889 | int rc;
|
3889 | 3890 | unsigned int xid;
|
| 3891 | + struct inode *inode; |
3890 | 3892 | struct cifsFileInfo *cfile = file->private_data;
|
| 3893 | + struct cifsInodeInfo *cifsi; |
3891 | 3894 | __le64 eof;
|
3892 | 3895 |
|
3893 | 3896 | xid = get_xid();
|
3894 | 3897 |
|
3895 |
| - if (off >= i_size_read(file->f_inode) || |
3896 |
| - off + len >= i_size_read(file->f_inode)) { |
| 3898 | + inode = d_inode(cfile->dentry); |
| 3899 | + cifsi = CIFS_I(inode); |
| 3900 | + |
| 3901 | + if (off >= i_size_read(inode) || |
| 3902 | + off + len >= i_size_read(inode)) { |
3897 | 3903 | rc = -EINVAL;
|
3898 | 3904 | goto out;
|
3899 | 3905 | }
|
3900 | 3906 |
|
3901 | 3907 | rc = smb2_copychunk_range(xid, cfile, cfile, off + len,
|
3902 |
| - i_size_read(file->f_inode) - off - len, off); |
| 3908 | + i_size_read(inode) - off - len, off); |
3903 | 3909 | if (rc < 0)
|
3904 | 3910 | goto out;
|
3905 | 3911 |
|
3906 |
| - eof = cpu_to_le64(i_size_read(file->f_inode) - len); |
| 3912 | + eof = cpu_to_le64(i_size_read(inode) - len); |
3907 | 3913 | rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
|
3908 | 3914 | cfile->fid.volatile_fid, cfile->pid, &eof);
|
3909 | 3915 | if (rc < 0)
|
3910 | 3916 | goto out;
|
3911 | 3917 |
|
3912 | 3918 | rc = 0;
|
| 3919 | + |
| 3920 | + cifsi->server_eof = i_size_read(inode) - len; |
| 3921 | + truncate_setsize(inode, cifsi->server_eof); |
| 3922 | + fscache_resize_cookie(cifs_inode_cookie(inode), cifsi->server_eof); |
3913 | 3923 | out:
|
3914 | 3924 | free_xid(xid);
|
3915 | 3925 | return rc;
|
|
0 commit comments