]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
blkback: Request-processing loop is unbounded and hence requires a
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Jan 2008 16:52:25 +0000 (16:52 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 18 Jan 2008 16:52:25 +0000 (16:52 +0000)
yield point. Also, bad request type is a good cause to sleep for a
short while as the frontend has probably gone mad.

Patch by Steven Smith <steven.smith@eu.citrix.com>

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
drivers/xen/blkback/blkback.c

index d8bce45956d75d33d6a7be1fd19187c0ff31499b..000cb1acd7cca9aba7c5516c5310dcadd563fcad 100644 (file)
@@ -38,6 +38,7 @@
 #include <linux/spinlock.h>
 #include <linux/kthread.h>
 #include <linux/list.h>
+#include <linux/delay.h>
 #include <xen/balloon.h>
 #include <asm/hypervisor.h>
 #include "common.h"
@@ -351,6 +352,9 @@ static int do_block_io_op(blkif_t *blkif)
                        dispatch_rw_block_io(blkif, &req, pending_req);
                        break;
                default:
+                       /* A good sign something is wrong: sleep for a while to
+                        * avoid excessive CPU consumption by a bad guest. */
+                       mdelay(1);
                        DPRINTK("error: unknown block io operation [%d]\n",
                                req.operation);
                        make_response(blkif, req.id, req.operation,
@@ -358,7 +362,11 @@ static int do_block_io_op(blkif_t *blkif)
                        free_req(pending_req);
                        break;
                }
+
+               /* Yield point for this unbounded loop. */
+               cond_resched();
        }
+
        return more_to_do;
 }