Skip to content

Commit

Permalink
tcmur: fix check_iovec_length
Browse files Browse the repository at this point in the history
readsector0 checker for multipath is not working, and the log like:

[DEBUG_SCSI_CMD] tcmu_print_cdb_info:1069 glfs/block0: 28 0 0 0 0 0 0 0 1 0
[ERROR] check_lba_and_length:107: iov len mismatch: iov len 4096, xfer len 1, block size 512
check_lba_and_length:107: iov len mismatch: iov len 4096, xfer len 1, block size 512

This is because in kernel space the sg->length is aligned to the
page size, and also the ringbufer data area's block size. So here
we need to make sure that the iov len is not less than the scsi
command's require.

Signed-off-by: Xiubo Li <[email protected]>
  • Loading branch information
lxbsz committed Sep 29, 2018
1 parent 97a4efd commit 7a6d967
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tcmur_cmd_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ static inline int check_iovec_length(struct tcmu_device *dev,
{
size_t iov_length = tcmu_iovec_length(cmd->iovec, cmd->iov_cnt);

if (iov_length != sectors * tcmu_get_dev_block_size(dev)) {
tcmu_dev_err(dev, "iov len mismatch: iov len %zu, xfer len %u, block size %u\n",
iov_length, sectors, tcmu_get_dev_block_size(dev));
if (iov_length < sectors * tcmu_get_dev_block_size(dev)) {
tcmu_dev_err(dev, "iov size %zu is not enough and needs at least %u\n",
iov_length, sectors * tcmu_get_dev_block_size(dev));
return TCMU_STS_HW_ERR;
}
return TCMU_STS_OK;
Expand Down

1 comment on commit 7a6d967

@bgly
Copy link
Contributor

@bgly bgly commented on 7a6d967 Sep 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Please sign in to comment.