@@ -4504,10 +4504,27 @@ smb2_async_writev(struct cifs_writedata *wdata,
45044504 struct kvec iov [1 ];
45054505 struct smb_rqst rqst = { };
45064506 unsigned int total_len ;
4507+ struct cifs_io_parms _io_parms ;
4508+ struct cifs_io_parms * io_parms = NULL ;
45074509
45084510 if (!wdata -> server )
45094511 server = wdata -> server = cifs_pick_channel (tcon -> ses );
45104512
4513+ /*
4514+ * in future we may get cifs_io_parms passed in from the caller,
4515+ * but for now we construct it here...
4516+ */
4517+ _io_parms = (struct cifs_io_parms ) {
4518+ .tcon = tcon ,
4519+ .server = server ,
4520+ .offset = wdata -> offset ,
4521+ .length = wdata -> bytes ,
4522+ .persistent_fid = wdata -> cfile -> fid .persistent_fid ,
4523+ .volatile_fid = wdata -> cfile -> fid .volatile_fid ,
4524+ .pid = wdata -> pid ,
4525+ };
4526+ io_parms = & _io_parms ;
4527+
45114528 rc = smb2_plain_req_init (SMB2_WRITE , tcon , server ,
45124529 (void * * ) & req , & total_len );
45134530 if (rc )
@@ -4517,26 +4534,31 @@ smb2_async_writev(struct cifs_writedata *wdata,
45174534 flags |= CIFS_TRANSFORM_REQ ;
45184535
45194536 shdr = (struct smb2_hdr * )req ;
4520- shdr -> Id .SyncId .ProcessId = cpu_to_le32 (wdata -> cfile -> pid );
4537+ shdr -> Id .SyncId .ProcessId = cpu_to_le32 (io_parms -> pid );
45214538
4522- req -> PersistentFileId = wdata -> cfile -> fid . persistent_fid ;
4523- req -> VolatileFileId = wdata -> cfile -> fid . volatile_fid ;
4539+ req -> PersistentFileId = io_parms -> persistent_fid ;
4540+ req -> VolatileFileId = io_parms -> volatile_fid ;
45244541 req -> WriteChannelInfoOffset = 0 ;
45254542 req -> WriteChannelInfoLength = 0 ;
45264543 req -> Channel = 0 ;
4527- req -> Offset = cpu_to_le64 (wdata -> offset );
4544+ req -> Offset = cpu_to_le64 (io_parms -> offset );
45284545 req -> DataOffset = cpu_to_le16 (
45294546 offsetof(struct smb2_write_req , Buffer ));
45304547 req -> RemainingBytes = 0 ;
45314548
4532- trace_smb3_write_enter (0 /* xid */ , wdata -> cfile -> fid .persistent_fid ,
4533- tcon -> tid , tcon -> ses -> Suid , wdata -> offset , wdata -> bytes );
4549+ trace_smb3_write_enter (0 /* xid */ ,
4550+ io_parms -> persistent_fid ,
4551+ io_parms -> tcon -> tid ,
4552+ io_parms -> tcon -> ses -> Suid ,
4553+ io_parms -> offset ,
4554+ io_parms -> length );
4555+
45344556#ifdef CONFIG_CIFS_SMB_DIRECT
45354557 /*
45364558 * If we want to do a server RDMA read, fill in and append
45374559 * smbd_buffer_descriptor_v1 to the end of write request
45384560 */
4539- if (server -> rdma && !server -> sign && wdata -> bytes >=
4561+ if (server -> rdma && !server -> sign && io_parms -> length >=
45404562 server -> smbd_conn -> rdma_readwrite_threshold ) {
45414563
45424564 struct smbd_buffer_descriptor_v1 * v1 ;
@@ -4590,22 +4612,22 @@ smb2_async_writev(struct cifs_writedata *wdata,
45904612 }
45914613#endif
45924614 cifs_dbg (FYI , "async write at %llu %u bytes\n" ,
4593- wdata -> offset , wdata -> bytes );
4615+ io_parms -> offset , io_parms -> length );
45944616
45954617#ifdef CONFIG_CIFS_SMB_DIRECT
45964618 /* For RDMA read, I/O size is in RemainingBytes not in Length */
45974619 if (!wdata -> mr )
4598- req -> Length = cpu_to_le32 (wdata -> bytes );
4620+ req -> Length = cpu_to_le32 (io_parms -> length );
45994621#else
4600- req -> Length = cpu_to_le32 (wdata -> bytes );
4622+ req -> Length = cpu_to_le32 (io_parms -> length );
46014623#endif
46024624
46034625 if (wdata -> credits .value > 0 ) {
46044626 shdr -> CreditCharge = cpu_to_le16 (DIV_ROUND_UP (wdata -> bytes ,
46054627 SMB2_MAX_BUFFER_SIZE ));
46064628 shdr -> CreditRequest = cpu_to_le16 (le16_to_cpu (shdr -> CreditCharge ) + 8 );
46074629
4608- rc = adjust_credits (server , & wdata -> credits , wdata -> bytes );
4630+ rc = adjust_credits (server , & wdata -> credits , io_parms -> length );
46094631 if (rc )
46104632 goto async_writev_out ;
46114633
@@ -4618,9 +4640,12 @@ smb2_async_writev(struct cifs_writedata *wdata,
46184640
46194641 if (rc ) {
46204642 trace_smb3_write_err (0 /* no xid */ ,
4621- req -> PersistentFileId ,
4622- tcon -> tid , tcon -> ses -> Suid , wdata -> offset ,
4623- wdata -> bytes , rc );
4643+ io_parms -> persistent_fid ,
4644+ io_parms -> tcon -> tid ,
4645+ io_parms -> tcon -> ses -> Suid ,
4646+ io_parms -> offset ,
4647+ io_parms -> length ,
4648+ rc );
46244649 kref_put (& wdata -> refcount , release );
46254650 cifs_stats_fail_inc (tcon , SMB2_WRITE_HE );
46264651 }
0 commit comments