drivers/xen/blkback: Add the kernel side of the blkback queueing feature.
PATCH 1/1 drivers/xen/blkback: Add the kernel side of the blkback queueing feature.
This is similar to the credit scheduler used in netif, except that it allows occasional burstability (for use with e2fsck as an example).
Signed-off-by William Pitcock <[email protected]>
--- drivers/xen/blkback/blkback.c | 25 +++++++++++++++++++++++++ drivers/xen/blkback/common.h | 5 +++++ drivers/xen/blkback/xenbus.c | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 0 deletions(-)
drivers/xen/blkback/blkback.c +25 -0
@@ -203,6 +203,16 @@ static void print_stats(blkif_t *blkif) blkif->st_oo_req =0 ; } +static void refill_credit (blkif_t *blkif) +{ + blkif->credit_time = jiffies +msecs_to_jiffies (blkif->credit_msec); + blkif->available_credit += blkif->credit_req; + +/* this allows for bursting. */ +if (blkif->available_credit > (blkif->credit_req * blkif->credit_msec)) + blkif->available_credit = blkif->credit_req; +} +int blkif_schedule (void *arg) {blkif_t *blkif = arg;
@@ -230,6 +240,9 @@ int blkif_schedule(void *arg) blkif->waiting_reqs =1 ;unplug_queue (blkif); +if (time_after (jiffies, blkif->credit_time)) +refill_credit (blkif); +if (log_stats &&time_after (jiffies, blkif->st_print))print_stats (blkif); }
@@ -313,11 +326,23 @@ static int do_block_io_op(blkif_t *blkif) rp = blk_rings->common.sring->req_prod;rmb ();/* Ensure we see queued requests up to 'rp'. */ +/* if there's no available request credit right now, and limiting +* is requested, then don't bother with going any further. +*/ +if (blkif->remaining_credit <=0 && blkif->credit_req !=0 ) +return (rc != rp) ?1 :0 ; +while (rc != rp) {if (RING_REQUEST_CONS_OVERFLOW (&blk_rings->common, rc))break ; +/* FIXME: Should we report QoS overages as VBD_OO, or not? */ +if (blkif->credit_req !=0 && --blkif->remaining_credit <=0 ) { + more_to_do =1 ; +break ; + } +if (kthread_should_stop ()) { more_to_do =1 ;break ;
drivers/xen/blkback/common.h +5 -0
@@ -92,6 +92,11 @@ typedef struct blkif_st {grant_handle_t shmem_handle;grant_ref_t shmem_ref; + +int credit_req; +int remaining_credit; +int credit_msec; +unsigned long credit_time; } blkif_t;blkif_t *blkif_alloc (domid_t domid);
drivers/xen/blkback/xenbus.c +41 -0
59 lines not on this page · raw message
Signature · 1 line
1.6.3.3