scsi: simplify LBA bounds check

Only two comparisons are necessary to ensure the I/O is in range.

Change-Id: I66e93abbf9b25949b3c783a47d26918362f00b93
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/393698
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Daniel Verkamp 2018-01-04 13:32:18 -07:00 committed by Jim Harris
parent e45437aba7
commit 9c47ef85ed

View File

@ -1298,8 +1298,7 @@ spdk_bdev_scsi_read_write_lba_check(struct spdk_scsi_task *task,
uint64_t lba, uint64_t cmd_num_blocks,
uint64_t bdev_num_blocks)
{
if (lba >= bdev_num_blocks || cmd_num_blocks > bdev_num_blocks ||
lba > (bdev_num_blocks - cmd_num_blocks)) {
if (bdev_num_blocks <= lba || bdev_num_blocks - lba < cmd_num_blocks) {
SPDK_DEBUGLOG(SPDK_LOG_SCSI, "end of media\n");
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
SPDK_SCSI_SENSE_ILLEGAL_REQUEST,