Skip to contentSkip to conversation

remove pointless error handling in scsiback

PATCH In review [email protected] 2 participants 5 messages Jul 1, 2014 – Jul 2, 2014 Xen hypervisor interface

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 remove pointless error handling in scsiback

From: Juergen Gross <[email protected]>

It makes no sense to try repeating traversing the lun list in case of a possible mismatch between the original counting of luns and the real processing.

To make things worse, the retry itself was wrong as the number of detected luns was not resetted for the retry leading to the next failing retry at once.

drivers/xen/scsiback/emulate.c +1 -10
diff -r 0251893a7d5a drivers/xen/scsiback/emulate.c
@@ -228,7 +228,6 @@ static void __report_luns(pending_req_t 
 	unsigned int alloc_luns = 0;
 	unsigned int req_bufflen = 0;
 	unsigned int actual_len = 0;
-	unsigned int retry_cnt = 0;
 	int select_report = (int)cmd[2];
 	int i, lun_cnt = 0, lun, upper, err = 0;
 	
@@ -245,7 +244,7 @@ static void __report_luns(pending_req_t 
 	alloc_luns = __nr_luns_under_host(info);
 	alloc_len  = sizeof(struct scsi_lun) * alloc_luns
 				+ VSCSI_REPORT_LUNS_HEADER;
-retry:
+
 	if ((buff = kzalloc(alloc_len, GFP_KERNEL)) == NULL) {
 		printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__);
 		goto fail;
@@ -261,14 +260,6 @@ retry:
 			if (lun_cnt >= alloc_luns) {
 				spin_unlock_irqrestore(&info->v2p_lock,
 							flags);
-
-				if (retry_cnt < VSCSI_REPORT_LUNS_RETRY) {
-					retry_cnt++;
-					if (buff)
-						kfree(buff);
-					goto retry;
-				}
-
 				goto fail;
 			}
#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 17:27, <"[email protected]".non-mime.internet> wrote:

From: Juergen Gross <[email protected]>

It makes no sense to try repeating traversing the lun list in case of a possible mismatch between the original counting of luns and the real processing.

Perhaps the retry logic isn't correct, but with the lock being dropped between the two loops I'm not sure the retry makes no sense. Can you explain?

Jan

Quoted 42 lines

To make things worse, the retry itself was wrong as the number of detected luns was not resetted for the retry leading to the next failing retry at once.

diff -r 0251893a7d5a drivers/xen/scsiback/emulate.c

drivers/xen/scsiback/emulate.c +1 -10
@@ -228,7 +228,6 @@ static void __report_luns(pending_req_t 
 	unsigned int alloc_luns = 0;
 	unsigned int req_bufflen = 0;
 	unsigned int actual_len = 0;
-	unsigned int retry_cnt = 0;
 	int select_report = (int)cmd[2];
 	int i, lun_cnt = 0, lun, upper, err = 0;
 
@@ -245,7 +244,7 @@ static void __report_luns(pending_req_t 
 	alloc_luns = __nr_luns_under_host(info);
 	alloc_len  = sizeof(struct scsi_lun) * alloc_luns
 				+ VSCSI_REPORT_LUNS_HEADER;
-retry:
+
 	if ((buff = kzalloc(alloc_len, GFP_KERNEL)) == NULL) {
 		printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__);
 		goto fail;
@@ -261,14 +260,6 @@ retry:
 			if (lun_cnt >= alloc_luns) {
 				spin_unlock_irqrestore(&info->v2p_lock,
 							flags);
-
-				if (retry_cnt < VSCSI_REPORT_LUNS_RETRY) {
-					retry_cnt++;
-					if (buff)
-						kfree(buff);
-					goto retry;
-				}
-
 				goto fail;
 			}
 
author maintainer
#2 lore raw
Quoted 10 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 17:27, <"[email protected]".non-mime.internet> wrote:

From: Juergen Gross <[email protected]>

It makes no sense to try repeating traversing the lun list in case of a possible mismatch between the original counting of luns and the real processing.

Perhaps the retry logic isn't correct, but with the lock being dropped between the two loops I'm not sure the retry makes no sense. Can you explain?

In theory the number of LUNs could have just changed between counting them and evaluating them. The counting isn't redone, so what's the point of retrying? What are the chances a matching LUN will appear and disappear in just the correct timing?

You could argue the counting should be included in the retry loop. But then doing a limited number of retries is only decreasing the chance of a problem, not eliminating it.

The real fix would be to process the LUNs in the first run without using an intermediate buffer by filling the domU's buffer directly. This would avoid all race conditions.

Juergen

Quoted 54 lines

Jan

Quoted 32 lines

To make things worse, the retry itself was wrong as the number of detected luns was not resetted for the retry leading to the next failing retry at once.

diff -r 0251893a7d5a drivers/xen/scsiback/emulate.c

drivers/xen/scsiback/emulate.c +1 -3
@@ -228,7 +228,6 @@ static void __report_luns(pending_req_t
  	unsigned int alloc_luns = 0;
  	unsigned int req_bufflen = 0;
  	unsigned int actual_len = 0;
-	unsigned int retry_cnt = 0;
  	int select_report = (int)cmd[2];
  	int i, lun_cnt = 0, lun, upper, err = 0;
 
@@ -245,7 +244,7 @@ static void __report_luns(pending_req_t
  	alloc_luns = __nr_luns_under_host(info);
  	alloc_len  = sizeof(struct scsi_lun) * alloc_luns
  				+ VSCSI_REPORT_LUNS_HEADER;
-retry:
+
  	if ((buff = kzalloc(alloc_len, GFP_KERNEL)) == NULL) {
  		printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__);
  		goto fail;
@@ -261,14 +260,6 @@ retry:
  			if (lun_cnt >= alloc_luns) {
  				spin_unlock_irqrestore(&info->v2p_lock,
  							flags);
-

drivers/xen/scsiback/emulate.c retry: · line 265

Quoted 10 lines
drivers/xen/scsiback/emulate.c +0 -7
-				if (retry_cnt < VSCSI_REPORT_LUNS_RETRY) {
-					retry_cnt++;
-					if (buff)
-						kfree(buff);
-					goto retry;
-				}
-
  				goto fail;
  			}
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 20:51, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 17:27, <"[email protected]".non-mime.internet> wrote:

From: Juergen Gross <[email protected]>

It makes no sense to try repeating traversing the lun list in case of a possible mismatch between the original counting of luns and the real processing.

Perhaps the retry logic isn't correct, but with the lock being dropped between the two loops I'm not sure the retry makes no sense. Can you explain?

In theory the number of LUNs could have just changed between counting them and evaluating them. The counting isn't redone, so what's the point of retrying? What are the chances a matching LUN will appear and disappear in just the correct timing?

Quoted 7 lines

You could argue the counting should be included in the retry loop. But then doing a limited number of retries is only decreasing the chance of a problem, not eliminating it.

The real fix would be to process the LUNs in the first run without using an intermediate buffer by filling the domU's buffer directly. This would avoid all race conditions.

I did a little archaeology and managed to spot where the retry (which was added after the initial introduction of pvSCSI) came from. See
http://lists.xenproject.org/archives/html/xen-devel/2008-07/msg00915.html
- effectively you're requesting to revert changeset 610:3bcc901cbd7a, i.e. you would need to (a) say so in the description and (b) explain why the change (and the reasoning having led to it) was wrong. And _if_ we indeed decide to undo this, the file should then also be pruned of the VSCSI_REPORT_LUNS_RETRY definition.

Jan

author maintainer
#4 lore raw
Quoted 26 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 20:51, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 01.07.14 at 17:27, <"[email protected]".non-mime.internet> wrote:

From: Juergen Gross <[email protected]>

It makes no sense to try repeating traversing the lun list in case of a possible mismatch between the original counting of luns and the real processing.

Perhaps the retry logic isn't correct, but with the lock being dropped between the two loops I'm not sure the retry makes no sense. Can you explain?

In theory the number of LUNs could have just changed between counting them and evaluating them. The counting isn't redone, so what's the point of retrying? What are the chances a matching LUN will appear and disappear in just the correct timing?

Quoted 7 lines

You could argue the counting should be included in the retry loop. But then doing a limited number of retries is only decreasing the chance of a problem, not eliminating it.

The real fix would be to process the LUNs in the first run without using an intermediate buffer by filling the domU's buffer directly. This would avoid all race conditions.

Quoted 8 lines

I did a little archaeology and managed to spot where the retry (which was added after the initial introduction of pvSCSI) came from. See
http://lists.xenproject.org/archives/html/xen-devel/2008-07/msg00915.html
- effectively you're requesting to revert changeset 610:3bcc901cbd7a, i.e. you would need to (a) say so in the description and (b) explain why the change (and the reasoning having led to it) was wrong. And _if_ we indeed decide to undo this, the file should then also be pruned of the VSCSI_REPORT_LUNS_RETRY definition.

Okay. I think the reasoning was wrong indeed. After thinking about this some more time I came to the conclusion that multiple failures are not completely unlikely when a target with many LUNs is added while the domU is trying to probe the target (e.g. when the first LUN was detected). The single LUNs will be added to the backend one after another, so the count of matching LUNs will increase rather fast.

I'll respin the patch with a proper description.

Juergen