@@ -377,12 +377,8 @@ static void init_chained_smb2_rsp(struct ksmbd_work *work)
377377 * command in the compound request
378378 */
379379 if (req -> Command == SMB2_CREATE && rsp -> Status == STATUS_SUCCESS ) {
380- work -> compound_fid =
381- le64_to_cpu (((struct smb2_create_rsp * )rsp )->
382- VolatileFileId );
383- work -> compound_pfid =
384- le64_to_cpu (((struct smb2_create_rsp * )rsp )->
385- PersistentFileId );
380+ work -> compound_fid = ((struct smb2_create_rsp * )rsp )-> VolatileFileId ;
381+ work -> compound_pfid = ((struct smb2_create_rsp * )rsp )-> PersistentFileId ;
386382 work -> compound_sid = le64_to_cpu (rsp -> SessionId );
387383 }
388384
@@ -2129,7 +2125,7 @@ static noinline int create_smb2_pipe(struct ksmbd_work *work)
21292125 rsp -> EndofFile = cpu_to_le64 (0 );
21302126 rsp -> FileAttributes = FILE_ATTRIBUTE_NORMAL_LE ;
21312127 rsp -> Reserved2 = 0 ;
2132- rsp -> VolatileFileId = cpu_to_le64 ( id ) ;
2128+ rsp -> VolatileFileId = id ;
21332129 rsp -> PersistentFileId = 0 ;
21342130 rsp -> CreateContextsOffset = 0 ;
21352131 rsp -> CreateContextsLength = 0 ;
@@ -3157,8 +3153,8 @@ int smb2_open(struct ksmbd_work *work)
31573153
31583154 rsp -> Reserved2 = 0 ;
31593155
3160- rsp -> PersistentFileId = cpu_to_le64 ( fp -> persistent_id ) ;
3161- rsp -> VolatileFileId = cpu_to_le64 ( fp -> volatile_id ) ;
3156+ rsp -> PersistentFileId = fp -> persistent_id ;
3157+ rsp -> VolatileFileId = fp -> volatile_id ;
31623158
31633159 rsp -> CreateContextsOffset = 0 ;
31643160 rsp -> CreateContextsLength = 0 ;
@@ -3865,9 +3861,7 @@ int smb2_query_dir(struct ksmbd_work *work)
38653861 goto err_out2 ;
38663862 }
38673863
3868- dir_fp = ksmbd_lookup_fd_slow (work ,
3869- le64_to_cpu (req -> VolatileFileId ),
3870- le64_to_cpu (req -> PersistentFileId ));
3864+ dir_fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
38713865 if (!dir_fp ) {
38723866 rc = - EBADF ;
38733867 goto err_out2 ;
@@ -4088,12 +4082,12 @@ static int smb2_get_info_file_pipe(struct ksmbd_session *sess,
40884082 * Windows can sometime send query file info request on
40894083 * pipe without opening it, checking error condition here
40904084 */
4091- id = le64_to_cpu ( req -> VolatileFileId ) ;
4085+ id = req -> VolatileFileId ;
40924086 if (!ksmbd_session_rpc_method (sess , id ))
40934087 return - ENOENT ;
40944088
40954089 ksmbd_debug (SMB , "FileInfoClass %u, FileId 0x%llx\n" ,
4096- req -> FileInfoClass , le64_to_cpu ( req -> VolatileFileId ) );
4090+ req -> FileInfoClass , req -> VolatileFileId );
40974091
40984092 switch (req -> FileInfoClass ) {
40994093 case FILE_STANDARD_INFORMATION :
@@ -4738,7 +4732,7 @@ static int smb2_get_info_file(struct ksmbd_work *work,
47384732 }
47394733
47404734 if (work -> next_smb2_rcv_hdr_off ) {
4741- if (!has_file_id (le64_to_cpu ( req -> VolatileFileId ) )) {
4735+ if (!has_file_id (req -> VolatileFileId )) {
47424736 ksmbd_debug (SMB , "Compound request set FID = %llu\n" ,
47434737 work -> compound_fid );
47444738 id = work -> compound_fid ;
@@ -4747,8 +4741,8 @@ static int smb2_get_info_file(struct ksmbd_work *work,
47474741 }
47484742
47494743 if (!has_file_id (id )) {
4750- id = le64_to_cpu ( req -> VolatileFileId ) ;
4751- pid = le64_to_cpu ( req -> PersistentFileId ) ;
4744+ id = req -> VolatileFileId ;
4745+ pid = req -> PersistentFileId ;
47524746 }
47534747
47544748 fp = ksmbd_lookup_fd_slow (work , id , pid );
@@ -5113,7 +5107,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
51135107 }
51145108
51155109 if (work -> next_smb2_rcv_hdr_off ) {
5116- if (!has_file_id (le64_to_cpu ( req -> VolatileFileId ) )) {
5110+ if (!has_file_id (req -> VolatileFileId )) {
51175111 ksmbd_debug (SMB , "Compound request set FID = %llu\n" ,
51185112 work -> compound_fid );
51195113 id = work -> compound_fid ;
@@ -5122,8 +5116,8 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
51225116 }
51235117
51245118 if (!has_file_id (id )) {
5125- id = le64_to_cpu ( req -> VolatileFileId ) ;
5126- pid = le64_to_cpu ( req -> PersistentFileId ) ;
5119+ id = req -> VolatileFileId ;
5120+ pid = req -> PersistentFileId ;
51275121 }
51285122
51295123 fp = ksmbd_lookup_fd_slow (work , id , pid );
@@ -5221,7 +5215,7 @@ static noinline int smb2_close_pipe(struct ksmbd_work *work)
52215215 struct smb2_close_req * req = smb2_get_msg (work -> request_buf );
52225216 struct smb2_close_rsp * rsp = smb2_get_msg (work -> response_buf );
52235217
5224- id = le64_to_cpu ( req -> VolatileFileId ) ;
5218+ id = req -> VolatileFileId ;
52255219 ksmbd_session_rpc_close (work -> sess , id );
52265220
52275221 rsp -> StructureSize = cpu_to_le16 (60 );
@@ -5280,7 +5274,7 @@ int smb2_close(struct ksmbd_work *work)
52805274 }
52815275
52825276 if (work -> next_smb2_rcv_hdr_off &&
5283- !has_file_id (le64_to_cpu ( req -> VolatileFileId ) )) {
5277+ !has_file_id (req -> VolatileFileId )) {
52845278 if (!has_file_id (work -> compound_fid )) {
52855279 /* file already closed, return FILE_CLOSED */
52865280 ksmbd_debug (SMB , "file already closed\n" );
@@ -5299,7 +5293,7 @@ int smb2_close(struct ksmbd_work *work)
52995293 work -> compound_pfid = KSMBD_NO_FID ;
53005294 }
53015295 } else {
5302- volatile_id = le64_to_cpu ( req -> VolatileFileId ) ;
5296+ volatile_id = req -> VolatileFileId ;
53035297 }
53045298 ksmbd_debug (SMB , "volatile_id = %llu\n" , volatile_id );
53055299
@@ -5988,7 +5982,7 @@ int smb2_set_info(struct ksmbd_work *work)
59885982 if (work -> next_smb2_rcv_hdr_off ) {
59895983 req = ksmbd_req_buf_next (work );
59905984 rsp = ksmbd_resp_buf_next (work );
5991- if (!has_file_id (le64_to_cpu ( req -> VolatileFileId ) )) {
5985+ if (!has_file_id (req -> VolatileFileId )) {
59925986 ksmbd_debug (SMB , "Compound request set FID = %llu\n" ,
59935987 work -> compound_fid );
59945988 id = work -> compound_fid ;
@@ -6000,8 +5994,8 @@ int smb2_set_info(struct ksmbd_work *work)
60005994 }
60015995
60025996 if (!has_file_id (id )) {
6003- id = le64_to_cpu ( req -> VolatileFileId ) ;
6004- pid = le64_to_cpu ( req -> PersistentFileId ) ;
5997+ id = req -> VolatileFileId ;
5998+ pid = req -> PersistentFileId ;
60055999 }
60066000
60076001 fp = ksmbd_lookup_fd_slow (work , id , pid );
@@ -6079,7 +6073,7 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
60796073 struct smb2_read_req * req = smb2_get_msg (work -> request_buf );
60806074 struct smb2_read_rsp * rsp = smb2_get_msg (work -> response_buf );
60816075
6082- id = le64_to_cpu ( req -> VolatileFileId ) ;
6076+ id = req -> VolatileFileId ;
60836077
60846078 inc_rfc1001_len (work -> response_buf , 16 );
60856079 rpc_resp = ksmbd_rpc_read (work -> sess , id );
@@ -6215,8 +6209,7 @@ int smb2_read(struct ksmbd_work *work)
62156209 goto out ;
62166210 }
62176211
6218- fp = ksmbd_lookup_fd_slow (work , le64_to_cpu (req -> VolatileFileId ),
6219- le64_to_cpu (req -> PersistentFileId ));
6212+ fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
62206213 if (!fp ) {
62216214 err = - ENOENT ;
62226215 goto out ;
@@ -6335,7 +6328,7 @@ static noinline int smb2_write_pipe(struct ksmbd_work *work)
63356328 size_t length ;
63366329
63376330 length = le32_to_cpu (req -> Length );
6338- id = le64_to_cpu ( req -> VolatileFileId ) ;
6331+ id = req -> VolatileFileId ;
63396332
63406333 if (le16_to_cpu (req -> DataOffset ) ==
63416334 offsetof(struct smb2_write_req , Buffer )) {
@@ -6471,8 +6464,7 @@ int smb2_write(struct ksmbd_work *work)
64716464 goto out ;
64726465 }
64736466
6474- fp = ksmbd_lookup_fd_slow (work , le64_to_cpu (req -> VolatileFileId ),
6475- le64_to_cpu (req -> PersistentFileId ));
6467+ fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
64766468 if (!fp ) {
64776469 err = - ENOENT ;
64786470 goto out ;
@@ -6584,12 +6576,9 @@ int smb2_flush(struct ksmbd_work *work)
65846576
65856577 WORK_BUFFERS (work , req , rsp );
65866578
6587- ksmbd_debug (SMB , "SMB2_FLUSH called for fid %llu\n" ,
6588- le64_to_cpu (req -> VolatileFileId ));
6579+ ksmbd_debug (SMB , "SMB2_FLUSH called for fid %llu\n" , req -> VolatileFileId );
65896580
6590- err = ksmbd_vfs_fsync (work ,
6591- le64_to_cpu (req -> VolatileFileId ),
6592- le64_to_cpu (req -> PersistentFileId ));
6581+ err = ksmbd_vfs_fsync (work , req -> VolatileFileId , req -> PersistentFileId );
65936582 if (err )
65946583 goto out ;
65956584
@@ -6804,12 +6793,9 @@ int smb2_lock(struct ksmbd_work *work)
68046793 int prior_lock = 0 ;
68056794
68066795 ksmbd_debug (SMB , "Received lock request\n" );
6807- fp = ksmbd_lookup_fd_slow (work ,
6808- le64_to_cpu (req -> VolatileFileId ),
6809- le64_to_cpu (req -> PersistentFileId ));
6796+ fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
68106797 if (!fp ) {
6811- ksmbd_debug (SMB , "Invalid file id for lock : %llu\n" ,
6812- le64_to_cpu (req -> VolatileFileId ));
6798+ ksmbd_debug (SMB , "Invalid file id for lock : %llu\n" , req -> VolatileFileId );
68136799 err = - ENOENT ;
68146800 goto out2 ;
68156801 }
@@ -7164,8 +7150,8 @@ static int fsctl_copychunk(struct ksmbd_work *work,
71647150
71657151 ci_rsp = (struct copychunk_ioctl_rsp * )& rsp -> Buffer [0 ];
71667152
7167- rsp -> VolatileFileId = cpu_to_le64 ( volatile_id ) ;
7168- rsp -> PersistentFileId = cpu_to_le64 ( persistent_id ) ;
7153+ rsp -> VolatileFileId = volatile_id ;
7154+ rsp -> PersistentFileId = persistent_id ;
71697155 ci_rsp -> ChunksWritten =
71707156 cpu_to_le32 (ksmbd_server_side_copy_max_chunk_count ());
71717157 ci_rsp -> ChunkBytesWritten =
@@ -7379,8 +7365,8 @@ static int fsctl_query_iface_info_ioctl(struct ksmbd_conn *conn,
73797365 if (nii_rsp )
73807366 nii_rsp -> Next = 0 ;
73817367
7382- rsp -> PersistentFileId = cpu_to_le64 ( SMB2_NO_FID ) ;
7383- rsp -> VolatileFileId = cpu_to_le64 ( SMB2_NO_FID ) ;
7368+ rsp -> PersistentFileId = SMB2_NO_FID ;
7369+ rsp -> VolatileFileId = SMB2_NO_FID ;
73847370 return nbytes ;
73857371}
73867372
@@ -7547,9 +7533,7 @@ static int fsctl_request_resume_key(struct ksmbd_work *work,
75477533{
75487534 struct ksmbd_file * fp ;
75497535
7550- fp = ksmbd_lookup_fd_slow (work ,
7551- le64_to_cpu (req -> VolatileFileId ),
7552- le64_to_cpu (req -> PersistentFileId ));
7536+ fp = ksmbd_lookup_fd_slow (work , req -> VolatileFileId , req -> PersistentFileId );
75537537 if (!fp )
75547538 return - ENOENT ;
75557539
@@ -7579,7 +7563,7 @@ int smb2_ioctl(struct ksmbd_work *work)
75797563 if (work -> next_smb2_rcv_hdr_off ) {
75807564 req = ksmbd_req_buf_next (work );
75817565 rsp = ksmbd_resp_buf_next (work );
7582- if (!has_file_id (le64_to_cpu ( req -> VolatileFileId ) )) {
7566+ if (!has_file_id (req -> VolatileFileId )) {
75837567 ksmbd_debug (SMB , "Compound request set FID = %llu\n" ,
75847568 work -> compound_fid );
75857569 id = work -> compound_fid ;
@@ -7590,7 +7574,7 @@ int smb2_ioctl(struct ksmbd_work *work)
75907574 }
75917575
75927576 if (!has_file_id (id ))
7593- id = le64_to_cpu ( req -> VolatileFileId ) ;
7577+ id = req -> VolatileFileId ;
75947578
75957579 if (req -> Flags != cpu_to_le32 (SMB2_0_IOCTL_IS_FSCTL )) {
75967580 rsp -> hdr .Status = STATUS_NOT_SUPPORTED ;
@@ -7656,8 +7640,8 @@ int smb2_ioctl(struct ksmbd_work *work)
76567640 goto out ;
76577641
76587642 nbytes = sizeof (struct validate_negotiate_info_rsp );
7659- rsp -> PersistentFileId = cpu_to_le64 ( SMB2_NO_FID ) ;
7660- rsp -> VolatileFileId = cpu_to_le64 ( SMB2_NO_FID ) ;
7643+ rsp -> PersistentFileId = SMB2_NO_FID ;
7644+ rsp -> VolatileFileId = SMB2_NO_FID ;
76617645 break ;
76627646 case FSCTL_QUERY_NETWORK_INTERFACE_INFO :
76637647 ret = fsctl_query_iface_info_ioctl (conn , rsp , out_buf_len );
@@ -7705,8 +7689,8 @@ int smb2_ioctl(struct ksmbd_work *work)
77057689 (struct copychunk_ioctl_req * )& req -> Buffer [0 ],
77067690 le32_to_cpu (req -> CntCode ),
77077691 le32_to_cpu (req -> InputCount ),
7708- le64_to_cpu ( req -> VolatileFileId ) ,
7709- le64_to_cpu ( req -> PersistentFileId ) ,
7692+ req -> VolatileFileId ,
7693+ req -> PersistentFileId ,
77107694 rsp );
77117695 break ;
77127696 case FSCTL_SET_SPARSE :
0 commit comments