Skip to content

Commit 6ebfede

Browse files
dhowellssmfrench
authored andcommitted
cifs: Pass unbyteswapped eof value into SMB2_set_eof()
Change SMB2_set_eof() to take eof as CPU order rather than __le64 and pass it directly rather than by pointer. This moves the conversion down into SMB_set_eof() rather than all of its callers and means we don't need to undo it for the traceline. Signed-off-by: David Howells <[email protected]> cc: Jeff Layton <[email protected]> cc: [email protected] Signed-off-by: Steve French <[email protected]>
1 parent 96d566b commit 6ebfede

File tree

3 files changed

+20
-25
lines changed

3 files changed

+20
-25
lines changed

fs/smb/client/smb2ops.c

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,6 @@ static int
19351935
smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
19361936
struct cifsFileInfo *cfile, __u64 size, bool set_alloc)
19371937
{
1938-
__le64 eof = cpu_to_le64(size);
19391938
struct inode *inode;
19401939

19411940
/*
@@ -1952,7 +1951,7 @@ smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon,
19521951
}
19531952

19541953
return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
1955-
cfile->fid.volatile_fid, cfile->pid, &eof);
1954+
cfile->fid.volatile_fid, cfile->pid, size);
19561955
}
19571956

19581957
static int
@@ -3197,7 +3196,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
31973196
unsigned long long new_size;
31983197
long rc;
31993198
unsigned int xid;
3200-
__le64 eof;
32013199

32023200
xid = get_xid();
32033201

@@ -3227,9 +3225,8 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
32273225
*/
32283226
new_size = offset + len;
32293227
if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) {
3230-
eof = cpu_to_le64(new_size);
32313228
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
3232-
cfile->fid.volatile_fid, cfile->pid, &eof);
3229+
cfile->fid.volatile_fid, cfile->pid, new_size);
32333230
if (rc >= 0) {
32343231
truncate_setsize(inode, new_size);
32353232
fscache_resize_cookie(cifs_inode_cookie(inode), new_size);
@@ -3422,7 +3419,7 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
34223419
struct cifsFileInfo *cfile = file->private_data;
34233420
long rc = -EOPNOTSUPP;
34243421
unsigned int xid;
3425-
__le64 eof;
3422+
loff_t new_eof;
34263423

34273424
xid = get_xid();
34283425

@@ -3451,14 +3448,14 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
34513448
if (cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)
34523449
smb2_set_sparse(xid, tcon, cfile, inode, false);
34533450

3454-
eof = cpu_to_le64(off + len);
3451+
new_eof = off + len;
34553452
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
3456-
cfile->fid.volatile_fid, cfile->pid, &eof);
3453+
cfile->fid.volatile_fid, cfile->pid, new_eof);
34573454
if (rc == 0) {
3458-
cifsi->server_eof = off + len;
3459-
cifs_setsize(inode, off + len);
3455+
cifsi->server_eof = new_eof;
3456+
cifs_setsize(inode, new_eof);
34603457
cifs_truncate_page(inode->i_mapping, inode->i_size);
3461-
truncate_setsize(inode, off + len);
3458+
truncate_setsize(inode, new_eof);
34623459
}
34633460
goto out;
34643461
}
@@ -3549,8 +3546,7 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
35493546
struct inode *inode = file_inode(file);
35503547
struct cifsFileInfo *cfile = file->private_data;
35513548
struct cifsInodeInfo *cifsi = CIFS_I(inode);
3552-
__le64 eof;
3553-
loff_t old_eof;
3549+
loff_t old_eof, new_eof;
35543550

35553551
xid = get_xid();
35563552

@@ -3575,9 +3571,9 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
35753571
if (rc < 0)
35763572
goto out_2;
35773573

3578-
eof = cpu_to_le64(old_eof - len);
3574+
new_eof = old_eof - len;
35793575
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
3580-
cfile->fid.volatile_fid, cfile->pid, &eof);
3576+
cfile->fid.volatile_fid, cfile->pid, new_eof);
35813577
if (rc < 0)
35823578
goto out_2;
35833579

@@ -3601,8 +3597,7 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
36013597
unsigned int xid;
36023598
struct cifsFileInfo *cfile = file->private_data;
36033599
struct inode *inode = file_inode(file);
3604-
__le64 eof;
3605-
__u64 count, old_eof;
3600+
__u64 count, old_eof, new_eof;
36063601

36073602
xid = get_xid();
36083603

@@ -3615,20 +3610,20 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
36153610
}
36163611

36173612
count = old_eof - off;
3618-
eof = cpu_to_le64(old_eof + len);
3613+
new_eof = old_eof + len;
36193614

36203615
filemap_invalidate_lock(inode->i_mapping);
3621-
rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof + len - 1);
3616+
rc = filemap_write_and_wait_range(inode->i_mapping, off, new_eof - 1);
36223617
if (rc < 0)
36233618
goto out_2;
36243619
truncate_pagecache_range(inode, off, old_eof);
36253620

36263621
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
3627-
cfile->fid.volatile_fid, cfile->pid, &eof);
3622+
cfile->fid.volatile_fid, cfile->pid, new_eof);
36283623
if (rc < 0)
36293624
goto out_2;
36303625

3631-
truncate_setsize(inode, old_eof + len);
3626+
truncate_setsize(inode, new_eof);
36323627
fscache_resize_cookie(cifs_inode_cookie(inode), i_size_read(inode));
36333628

36343629
rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len);

fs/smb/client/smb2pdu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,18 +5347,18 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
53475347

53485348
int
53495349
SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
5350-
u64 volatile_fid, u32 pid, __le64 *eof)
5350+
u64 volatile_fid, u32 pid, loff_t new_eof)
53515351
{
53525352
struct smb2_file_eof_info info;
53535353
void *data;
53545354
unsigned int size;
53555355

5356-
info.EndOfFile = *eof;
5356+
info.EndOfFile = cpu_to_le64(new_eof);
53575357

53585358
data = &info;
53595359
size = sizeof(struct smb2_file_eof_info);
53605360

5361-
trace_smb3_set_eof(xid, persistent_fid, tcon->tid, tcon->ses->Suid, le64_to_cpu(*eof));
5361+
trace_smb3_set_eof(xid, persistent_fid, tcon->tid, tcon->ses->Suid, new_eof);
53625362

53635363
return send_set_info(xid, tcon, persistent_fid, volatile_fid,
53645364
pid, FILE_END_OF_FILE_INFORMATION, SMB2_O_INFO_FILE,

fs/smb/client/smb2proto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ extern int SMB2_query_directory_init(unsigned int xid, struct cifs_tcon *tcon,
221221
extern void SMB2_query_directory_free(struct smb_rqst *rqst);
222222
extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
223223
u64 persistent_fid, u64 volatile_fid, u32 pid,
224-
__le64 *eof);
224+
loff_t new_eof);
225225
extern int SMB2_set_info_init(struct cifs_tcon *tcon,
226226
struct TCP_Server_Info *server,
227227
struct smb_rqst *rqst,

0 commit comments

Comments
 (0)