[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [linux-2.6.18-xen] scsiback/usbback: move cond_resched() invocations to proper place
# HG changeset patch # User Jan Beulich <jbeulich@xxxxxxxx> # Date 1360056413 -3600 # Node ID d732224ce60e45cc43337be0061a20f8ed65e03e # Parent 4b8e7a5d4f89692bca6855ccad3ec5a71611c231 scsiback/usbback: move cond_resched() invocations to proper place The call to cond_resched() must be inside the loop, in order to not expose the host to guest induced soft lockups (due to a close to unbounded loop). Also rate limit printk()-s in those loops as well as in blktap's. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- diff -r 4b8e7a5d4f89 -r d732224ce60e drivers/xen/blktap/common.h --- a/drivers/xen/blktap/common.h Tue Feb 05 10:25:44 2013 +0100 +++ b/drivers/xen/blktap/common.h Tue Feb 05 10:26:53 2013 +0100 @@ -41,7 +41,9 @@ #define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \ __FILE__ , __LINE__ , ## _a ) -#define WPRINTK(fmt, args...) printk(KERN_WARNING "blk_tap: " fmt, ##args) +#define WPRINTK(fmt, args...) \ + ((void)(printk_ratelimit() && \ + printk(KERN_WARNING "blktap: " fmt, ##args))) struct backend_info; diff -r 4b8e7a5d4f89 -r d732224ce60e drivers/xen/scsiback/scsiback.c --- a/drivers/xen/scsiback/scsiback.c Tue Feb 05 10:25:44 2013 +0100 +++ b/drivers/xen/scsiback/scsiback.c Tue Feb 05 10:26:53 2013 +0100 @@ -603,40 +603,36 @@ static int _scsiback_do_cmd_fn(struct vs err = prepare_pending_reqs(info, ring_req, pending_req); - if (err == -EINVAL) { - scsiback_do_resp_with_sense(NULL, (DRIVER_ERROR << 24), - 0, pending_req); - continue; - } else if (err == -ENODEV) { - scsiback_do_resp_with_sense(NULL, (DID_NO_CONNECT << 16), - 0, pending_req); - continue; - } - - if (pending_req->act == VSCSIIF_ACT_SCSI_CDB) { - + switch (err ?: pending_req->act) { + case VSCSIIF_ACT_SCSI_CDB: /* The Host mode is through as for Emulation. */ if (info->feature == VSCSI_TYPE_HOST) scsiback_cmd_exec(pending_req); else scsiback_req_emulation_or_cmdexec(pending_req); + break; + case VSCSIIF_ACT_SCSI_RESET: + scsiback_device_reset_exec(pending_req); + break; + default: + if(!err && printk_ratelimit()) + printk(KERN_ERR "scsiback: invalid request\n"); + scsiback_do_resp_with_sense(NULL, DRIVER_ERROR << 24, + 0, pending_req); + break; + case -ENODEV: + scsiback_do_resp_with_sense(NULL, DID_NO_CONNECT << 16, + 0, pending_req); + break; + } - } else if (pending_req->act == VSCSIIF_ACT_SCSI_RESET) { - scsiback_device_reset_exec(pending_req); - } else { - printk(KERN_ERR "scsiback: invalid parameter for request\n"); - scsiback_do_resp_with_sense(NULL, (DRIVER_ERROR << 24), - 0, pending_req); - continue; - } + /* Yield point for this unbounded loop. */ + cond_resched(); } if (RING_HAS_UNCONSUMED_REQUESTS(ring)) more_to_do = 1; - /* Yield point for this unbounded loop. */ - cond_resched(); - return more_to_do; } diff -r 4b8e7a5d4f89 -r d732224ce60e drivers/xen/usbback/usbback.c --- a/drivers/xen/usbback/usbback.c Tue Feb 05 10:25:44 2013 +0100 +++ b/drivers/xen/usbback/usbback.c Tue Feb 05 10:26:53 2013 +0100 @@ -981,7 +981,9 @@ static int usbbk_start_submit_urb(usbif_ while (rc != rp) { if (RING_REQUEST_CONS_OVERFLOW(urb_ring, rc)) { - printk(KERN_WARNING "RING_REQUEST_CONS_OVERFLOW\n"); + if(printk_ratelimit()) + printk(KERN_WARNING "usbback: " + "RING_REQUEST_CONS_OVERFLOW\n"); break; } @@ -996,12 +998,12 @@ static int usbbk_start_submit_urb(usbif_ dispatch_request_to_pending_reqs(usbif, req, pending_req); + + cond_resched(); } RING_FINAL_CHECK_FOR_REQUESTS(&usbif->urb_ring, more_to_do); - cond_resched(); - return more_to_do; } _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |