ia64/linux-2.6.18-xen.hg

changeset 618:3bcc901cbd7a

pvscsi: add retry in REPORT_LUN emulation

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
Signed-off-by: Jun Kamada <kama@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 23 09:57:44 2008 +0100 (2008-07-23)
parents 8a3dc4fdb478
children 268d6984c8e2
files drivers/xen/scsiback/emulate.c
line diff
     1.1 --- a/drivers/xen/scsiback/emulate.c	Tue Jul 22 11:59:42 2008 +0100
     1.2 +++ b/drivers/xen/scsiback/emulate.c	Wed Jul 23 09:57:44 2008 +0100
     1.3 @@ -73,8 +73,6 @@
     1.4  #define VSCSI_MAX_SCSI_OP_CODE		256
     1.5  static unsigned char bitmap[VSCSI_MAX_SCSI_OP_CODE];
     1.6  
     1.7 -/* REPORT LUNS Header*/
     1.8 -#define VSCSI_REPORT_LUNS_HEADER	8
     1.9  
    1.10  
    1.11  /*
    1.12 @@ -201,6 +199,11 @@ static int __nr_luns_under_host(struct v
    1.13  	return (lun_cnt);
    1.14  }
    1.15  
    1.16 +
    1.17 +/* REPORT LUNS Define*/
    1.18 +#define VSCSI_REPORT_LUNS_HEADER	8
    1.19 +#define VSCSI_REPORT_LUNS_RETRY		3
    1.20 +
    1.21  /* quoted scsi_debug.c/resp_report_luns() */
    1.22  static void __report_luns(pending_req_t *pending_req, void *data)
    1.23  {
    1.24 @@ -215,6 +218,7 @@ static void __report_luns(pending_req_t 
    1.25  	unsigned int alloc_luns = 0;
    1.26  	unsigned int req_bufflen = 0;
    1.27  	unsigned int actual_len = 0;
    1.28 +	unsigned int retry_cnt = 0;
    1.29  	int select_report = (int)cmd[2];
    1.30  	int i, lun_cnt = 0, lun, upper, err = 0;
    1.31  	
    1.32 @@ -231,7 +235,7 @@ static void __report_luns(pending_req_t 
    1.33  	alloc_luns = __nr_luns_under_host(info);
    1.34  	alloc_len  = sizeof(struct scsi_lun) * alloc_luns
    1.35  				+ VSCSI_REPORT_LUNS_HEADER;
    1.36 -
    1.37 +retry:
    1.38  	if ((buff = kmalloc(alloc_len, GFP_KERNEL)) == NULL) {
    1.39  		printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__);
    1.40  		goto fail;
    1.41 @@ -246,8 +250,19 @@ static void __report_luns(pending_req_t 
    1.42  		    (entry->v.tgt == target)) {
    1.43  			
    1.44  			/* check overflow */
    1.45 -			if (lun_cnt >= alloc_luns)
    1.46 +			if (lun_cnt >= alloc_luns) {
    1.47 +				spin_unlock_irqrestore(&info->v2p_lock,
    1.48 +							flags);
    1.49 +
    1.50 +				if (retry_cnt < VSCSI_REPORT_LUNS_RETRY) {
    1.51 +					retry_cnt++;
    1.52 +					if (buff)
    1.53 +						kfree(buff);
    1.54 +					goto retry;
    1.55 +				}
    1.56 +
    1.57  				goto fail;
    1.58 +			}
    1.59  
    1.60  			lun = entry->v.lun;
    1.61  			upper = (lun >> 8) & 0x3f;