# HG changeset patch # User t.horikoshi@jp.fujitsu.com # Date 1216719296 -32400 # Node ID d14b91e5361b3109e77c38ed49a294e574f515aa # Parent 2c80783731a23f4718089761a0f4e4a8e635c035 pvscsi: add retry in REPORT_LUN emulation Signed-off-by: Tomonari Horikoshi Signed-off-by: Jun Kamada diff -r 2c80783731a2 -r d14b91e5361b drivers/xen/scsiback/emulate.c --- a/drivers/xen/scsiback/emulate.c Fri Jul 18 11:26:26 2008 +0100 +++ b/drivers/xen/scsiback/emulate.c Tue Jul 22 18:34:56 2008 +0900 @@ -73,8 +73,6 @@ #define VSCSI_MAX_SCSI_OP_CODE 256 static unsigned char bitmap[VSCSI_MAX_SCSI_OP_CODE]; -/* REPORT LUNS Header*/ -#define VSCSI_REPORT_LUNS_HEADER 8 /* @@ -200,6 +198,11 @@ static int __nr_luns_under_host(struct v return (lun_cnt); } + + +/* REPORT LUNS Define*/ +#define VSCSI_REPORT_LUNS_HEADER 8 +#define VSCSI_REPORT_LUNS_RETRY 3 /* quoted scsi_debug.c/resp_report_luns() */ static void __report_luns(pending_req_t *pending_req, void *data) @@ -215,6 +218,7 @@ 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; @@ -231,7 +235,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 = kmalloc(alloc_len, GFP_KERNEL)) == NULL) { printk(KERN_ERR "scsiback:%s kmalloc err\n", __FUNCTION__); goto fail; @@ -246,8 +250,19 @@ static void __report_luns(pending_req_t (entry->v.tgt == target)) { /* check overflow */ - if (lun_cnt >= alloc_luns) + 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; + } lun = entry->v.lun; upper = (lun >> 8) & 0x3f;