Skip to content

Commit abe342a

Browse files
Xiubo LiNicholas Bellinger
authored andcommitted
tcmu: Fix wrongly calculating of the base_command_size
The t_data_nents and t_bidi_data_nents are the numbers of the segments, but it couldn't be sure the block size equals to size of the segment. For the worst case, all the blocks are discontiguous and there will need the same number of iovecs, that's to say: blocks == iovs. So here just set the number of iovs to block count needed by tcmu cmd. Tested-by: Ilias Tsitsimpis <iliastsi@arrikto.com> Reviewed-by: Mike Christie <mchristi@redhat.com> Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com> Cc: stable@vger.kernel.org # 3.18+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent ab22d26 commit abe342a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/target/target_core_user.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,13 @@ static inline size_t tcmu_cmd_get_data_length(struct tcmu_cmd *tcmu_cmd)
408408
return data_length;
409409
}
410410

411+
static inline uint32_t tcmu_cmd_get_block_cnt(struct tcmu_cmd *tcmu_cmd)
412+
{
413+
size_t data_length = tcmu_cmd_get_data_length(tcmu_cmd);
414+
415+
return data_length / DATA_BLOCK_SIZE;
416+
}
417+
411418
static sense_reason_t
412419
tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
413420
{
@@ -435,8 +442,7 @@ tcmu_queue_cmd_ring(struct tcmu_cmd *tcmu_cmd)
435442
* expensive to tell how many regions are freed in the bitmap
436443
*/
437444
base_command_size = max(offsetof(struct tcmu_cmd_entry,
438-
req.iov[se_cmd->t_bidi_data_nents +
439-
se_cmd->t_data_nents]),
445+
req.iov[tcmu_cmd_get_block_cnt(tcmu_cmd)]),
440446
sizeof(struct tcmu_cmd_entry));
441447
command_size = base_command_size
442448
+ round_up(scsi_command_size(se_cmd->t_task_cdb), TCMU_OP_ALIGN_SIZE);

0 commit comments

Comments
 (0)