Skip to contentSkip to conversation

blkmapd: Skip the SCSI ID if the data length is zero

PATCH Superseded Kinglong Mee 3 participants 11 messages Jul 12, 2015 – Jul 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blkmapd: Skip the SCSI ID if the data length is zero

In vmware linux, the iscsi device contains more than one SCSI ID, and, the second one's data length is zero.

blkmapd must skip it, otherwise, some device will be treat as the above one.

---
 utils/blkmapd/device-inq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/blkmapd/device-inq.c +1 -1
index 6b56b67..57fe7a3 100644
@@ -198,7 +198,7 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
-		if ((dev_id->ids & 0xf) < current_id)
+		if ((dev_id->ids & 0xf) < current_id || !dev_id->len)
 			continue;
 		switch (dev_id->ids & 0xf) {
 			/* We process SCSI ID with four ID cases: 0, 1, 2 and 3.
Signature · 1 line
2.4.3
#1 lore raw
Quoted 6 lines · Kinglong Mee

In vmware linux, the iscsi device contains more than one SCSI ID, and, the second one's data length is zero.

blkmapd must skip it, otherwise, some device will be treat as the above one.

Looks good, but can you please add a comment explaining why you're skipping the zero-length EVPD page?

#2 lore raw

PATCH v2 1/1 blkmapd: Skip the SCSI ID if data length is zero

In vmware linux, the iscsi device contains more than one SCSI ID, and, the second one's data length is zero.

If there are two iSCSI devices with the second SCSI ID's data length is zero, the first iSCSI device will record with an invalid SCSI ID as zero length, the second one will be treat as the first one for the SCSI ID is zero length too.

It means the only the first iSCSI device is exist in blkmapd's cache, the request for the second iSCSI device will failed as,

"blkmapd: Could not find disk for device" and,
"bl_resolve_deviceid failed to decode device: 2".

v2, update comments

---
 utils/blkmapd/device-inq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/blkmapd/device-inq.c +1 -1
index 6b56b67..57fe7a3 100644
@@ -198,7 +198,7 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
-		if ((dev_id->ids & 0xf) < current_id)
+		if ((dev_id->ids & 0xf) < current_id || !dev_id->len)
 			continue;
 		switch (dev_id->ids & 0xf) {
 			/* We process SCSI ID with four ID cases: 0, 1, 2 and 3.
Signature · 1 line
2.4.3
#3 lore raw

Re: [PATCH v2] blkmapd: Skip the SCSI ID if data length is zero

Hi Kinglong,

I meant to describe the rational as a comment in the code, not as a more verbose commit log.

#4 lore raw

Re: [PATCH v2] blkmapd: Skip the SCSI ID if data length is zero

Quoted 4 lines · Christoph Hellwig

Hi Kinglong,

I meant to describe the rational as a comment in the code, not as a more verbose commit log.

Sorry for my mistake, I will update it later.
Thanks again.

thanks,
Kinglong Mee

#5 lore raw

PATCH v3 1/1 blkmapd: Skip the SCSI ID if data length is zero

In vmware linux, the iscsi device contains more than one SCSI ID, and the second one's data length is zero.

If there are two iSCSI devices with the second SCSI ID's data length is zero, the first iSCSI device will record with an invalid SCSI ID as zero length, the second one will be treat as the first one for the SCSI ID is zero length too.

It means the only the first iSCSI device is exist in blkmapd's cache, the request for the second iSCSI device will failed as,

"blkmapd: Could not find disk for device" and,
"bl_resolve_deviceid failed to decode device: 2".

v2, update commit log
v3, add a comment in the code

---
 utils/blkmapd/device-inq.c | 4 ++++
 1 file changed, 4 insertions(+)
utils/blkmapd/device-inq.c +4 -0
index 6b56b67..60fe2d3 100644
@@ -198,6 +198,10 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
+		/* Needs an SCSI ID with unique date not zero length */
+		if (!dev_id->len)
+			continue;
+
 		if ((dev_id->ids & 0xf) < current_id)
 			continue;
 		switch (dev_id->ids & 0xf) {
Signature · 1 line
2.4.3
#6 lore raw

Re: [PATCH v3] blkmapd: Skip the SCSI ID if data length is zero

utils/blkmapd/device-inq.c struct bl_serial *bldev_read_serial(int fd, const char *filename) · line 203

Quoted 3 lines
utils/blkmapd/device-inq.c +3 -0
+		/* Needs an SCSI ID with unique date not zero length */
+		if (!dev_id->len)
+			continue;

That explains what the code does, not why it does so.

How about:

/*
* Some buggy targets (e.g. VMWare) export zero length
* EVPD pages, skip them to not confuse the device id
* cache.
*/

#7 lore raw

PATCH v4 1/1 blkmapd: Skip the SCSI ID if data length is zero

In vmware linux, the iscsi device contains more than one SCSI ID, and the second one's data length is zero.

If there are two iSCSI devices with the second SCSI ID's data length is zero, the first iSCSI device will record with an invalid SCSI ID as zero length, the second one will be treat as the first one for the SCSI ID is zero length too.

It means the only the first iSCSI device is exist in blkmapd's cache, the request for the second iSCSI device will failed as,

"blkmapd: Could not find disk for device" and,
"bl_resolve_deviceid failed to decode device: 2".

v2, update comments
v3, add a comment in the code
v4, update comment as Christoph's suggestion

---
 utils/blkmapd/device-inq.c | 7 +++++++
 1 file changed, 7 insertions(+)
utils/blkmapd/device-inq.c +7 -0
index 6b56b67..5c258bd 100644
@@ -198,6 +198,13 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
+		/* Some buggy targets (e.g. VMWare) export zero length
+		 * EVPD pages, skip them to not confuse the device id
+		 * cache.
+		 */
+		if (!dev_id->len)
+			continue;
+
 		if ((dev_id->ids & 0xf) < current_id)
 			continue;
 		switch (dev_id->ids & 0xf) {
Signature · 1 line
2.4.3
#8 lore raw

Re: [PATCH v4] blkmapd: Skip the SCSI ID if data length is zero

Hello,

Quoted 28 lines · Kinglong Mee

In vmware linux, the iscsi device contains more than one SCSI ID, and the second one's data length is zero.

If there are two iSCSI devices with the second SCSI ID's data length is zero, the first iSCSI device will record with an invalid SCSI ID as zero length, the second one will be treat as the first one for the SCSI ID is zero length too.

It means the only the first iSCSI device is exist in blkmapd's cache, the request for the second iSCSI device will failed as,

"blkmapd: Could not find disk for device" and,
"bl_resolve_deviceid failed to decode device: 2".

v2, update comments
v3, add a comment in the code
v4, update comment as Christoph's suggestion

---
 utils/blkmapd/device-inq.c | 7 +++++++
 1 file changed, 7 insertions(+)
utils/blkmapd/device-inq.c +0 -0
index 6b56b67..5c258bd 100644

utils/blkmapd/device-inq.c struct bl_serial *bldev_read_serial(int fd, const char *filename) · line 204

Quoted 7 lines
utils/blkmapd/device-inq.c +4 -0
@@ -198,6 +198,13 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
+		/* Some buggy targets (e.g. VMWare) export zero length
+		 * EVPD pages, skip them to not confuse the device id
+		 * cache.
+		 */

I'll take care of this comment... No need to re-post.

steved.

Quoted 7 lines
utils/blkmapd/device-inq.c +3 -0
+		if (!dev_id->len)
+			continue;
+
 		if ((dev_id->ids & 0xf) < current_id)
 			continue;
 		switch (dev_id->ids & 0xf) {
#9 lore raw

Re: [PATCH v4] blkmapd: Skip the SCSI ID if data length is zero

In reply to Kinglong Mee
Quoted 11 lines · Kinglong Mee

In vmware linux, the iscsi device contains more than one SCSI ID, and the second one's data length is zero.

If there are two iSCSI devices with the second SCSI ID's data length is zero, the first iSCSI device will record with an invalid SCSI ID as zero length, the second one will be treat as the first one for the SCSI ID is zero length too.

It means the only the first iSCSI device is exist in blkmapd's cache, the request for the second iSCSI device will failed as,

Quoted 8 lines

"blkmapd: Could not find disk for device" and,
"bl_resolve_deviceid failed to decode device: 2".

v2, update comments
v3, add a comment in the code
v4, update comment as Christoph's suggestion

Committed...

steved.

Quoted 23 lines
---
 utils/blkmapd/device-inq.c | 7 +++++++
 1 file changed, 7 insertions(+)
utils/blkmapd/device-inq.c +7 -0
index 6b56b67..5c258bd 100644
@@ -198,6 +198,13 @@ struct bl_serial *bldev_read_serial(int fd, const char *filename)
 		dev_id = (struct bl_dev_id *)&(dev_root->data[pos]);
 		pos += (dev_id->len + devid_len);
 
+		/* Some buggy targets (e.g. VMWare) export zero length
+		 * EVPD pages, skip them to not confuse the device id
+		 * cache.
+		 */
+		if (!dev_id->len)
+			continue;
+
 		if ((dev_id->ids & 0xf) < current_id)
 			continue;
 		switch (dev_id->ids & 0xf) {
#10 lore raw

Re: [PATCH v3] blkmapd: Skip the SCSI ID if data length is zero

In reply to Christoph Hellwig
Quoted 6 lines · Christoph Hellwig

utils/blkmapd/device-inq.c struct bl_serial *bldev_read_serial(int fd, const char *filename) · line 203

Quoted 3 lines
utils/blkmapd/device-inq.c +3 -0
+		/* Needs an SCSI ID with unique date not zero length */
+		if (!dev_id->len)
+			continue;

That explains what the code does, not why it does so.

Quoted 8 lines

How about:

/*
* Some buggy targets (e.g. VMWare) export zero length
* EVPD pages, skip them to not confuse the device id
* cache.
*/

I'm not a big fan of calling out vendors in comments. I'm thinking dropping the "buggy" and "(e.g. VMWare)" would be appropriated.

steved.