From 3c5eac6bfb82de9fd1fcab129cf153adee486ebd Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Thu, 11 Aug 2016 09:56:36 +0800 Subject: [PATCH] scsi: return correct data length of VPD page 0xB1 and 0xB2 For VPD page 0xB1 and 0xB2, the scsi target did not return correct value to the initiator, so return the length with correct value. Change-Id: Ic17d804ca00d490fd6a2f833db5c9b73ce8dc160 Signed-off-by: Changpeng Liu --- lib/scsi/scsi_bdev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index 0c73de2fd..d5127db0f 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -618,6 +618,7 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, case SPDK_SPC_VPD_BLOCK_DEV_CHARS: { /* PAGE LENGTH */ hlen = 4; + len = 64 - hlen; to_be16(&data[4], DEFAULT_DISK_ROTATION_RATE); @@ -628,7 +629,7 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, /* Reserved */ memset(&data[8], 0, 64 - 8); - to_be16(vpage->alloc_len, 64 - hlen); + to_be16(vpage->alloc_len, len); break; } @@ -639,9 +640,7 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, } hlen = 4; - - /* PAGE CODE */ - data[1] = SPDK_SPC_VPD_BLOCK_THIN_PROVISION; + len = 7; /* * PAGE LENGTH : if the DP bit is set to one, then the @@ -667,7 +666,7 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task, */ data[6] = SPDK_SCSI_UNMAP_THIN_PROVISIONING; - to_be16(vpage->alloc_len, 7); + to_be16(vpage->alloc_len, len); break; }