ia64/xen-unstable

changeset 4404:332cd3fd995c

bitkeeper revision 1.1159.258.83 (424c1abd7LgWMiaskLEEAAX7ffdkXQ)

Backport of batched request_queue unplugging in blkback driver.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Mar 31 15:43:57 2005 +0000 (2005-03-31)
parents 1c0462767898
children 198cfa01d71b fead3d49dca1 45651a5b9d0b
files linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 31 09:55:59 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 31 15:43:57 2005 +0000
     1.3 @@ -66,6 +66,19 @@ static PEND_RING_IDX pending_prod, pendi
     1.4  
     1.5  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
     1.6  static kmem_cache_t *buffer_head_cachep;
     1.7 +#else
     1.8 +static request_queue_t *plugged_queue;
     1.9 +void bdev_put(struct block_device *bdev)
    1.10 +{
    1.11 +    request_queue_t *q = plugged_queue;
    1.12 +    /* We might be giving up last reference to plugged queue. Flush if so. */
    1.13 +    if ( (q != NULL) &&
    1.14 +         (q == bdev_get_queue(bdev)) && 
    1.15 +         (cmpxchg(&plugged_queue, q, NULL) == q) )
    1.16 +        blk_run_queue(q);
    1.17 +    /* It's now safe to drop the block device. */
    1.18 +    blkdev_put(bdev);
    1.19 +}
    1.20  #endif
    1.21  
    1.22  static int do_block_io_op(blkif_t *blkif, int max_to_do);
    1.23 @@ -176,9 +189,15 @@ static int blkio_schedule(void *arg)
    1.24              blkif_put(blkif);
    1.25          }
    1.26  
    1.27 +        /* Push the batch through to disc. */
    1.28  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
    1.29 -        /* Push the batch through to disc. */
    1.30          run_task_queue(&tq_disk);
    1.31 +#else
    1.32 +        if ( plugged_queue != NULL )
    1.33 +        {
    1.34 +            blk_run_queue(plugged_queue);
    1.35 +            plugged_queue = NULL;
    1.36 +        }
    1.37  #endif
    1.38      }
    1.39  }
    1.40 @@ -481,6 +500,7 @@ static void dispatch_rw_block_io(blkif_t
    1.41      for ( i = 0; i < nr_psegs; i++ )
    1.42      {
    1.43          struct bio *bio;
    1.44 +        request_queue_t *q;
    1.45  
    1.46          bio = bio_alloc(GFP_ATOMIC, 1);
    1.47          if ( unlikely(bio == NULL) )
    1.48 @@ -500,7 +520,14 @@ static void dispatch_rw_block_io(blkif_t
    1.49              phys_seg[i].nr_sects << 9,
    1.50              phys_seg[i].buffer & ~PAGE_MASK);
    1.51  
    1.52 -        submit_bio(operation | (1 << BIO_RW_SYNC), bio);
    1.53 +        if ( (q = bdev_get_queue(bio->bi_bdev)) != plugged_queue )
    1.54 +        {
    1.55 +            if ( plugged_queue != NULL )
    1.56 +                blk_run_queue(plugged_queue);
    1.57 +            plugged_queue = q;
    1.58 +        }
    1.59 +
    1.60 +        submit_bio(operation, bio);
    1.61      }
    1.62  #endif
    1.63  
     2.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h	Thu Mar 31 09:55:59 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/common.h	Thu Mar 31 15:43:57 2005 +0000
     2.3 @@ -30,8 +30,10 @@
     2.4  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     2.5  typedef struct rb_root rb_root_t;
     2.6  typedef struct rb_node rb_node_t;
     2.7 +extern void bdev_put(struct block_device *bdev);
     2.8  #else
     2.9  struct block_device;
    2.10 +#define bdev_put(_b) ((void)0)
    2.11  #endif
    2.12  
    2.13  typedef struct blkif_st {
     3.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c	Thu Mar 31 09:55:59 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/vbd.c	Thu Mar 31 15:43:57 2005 +0000
     3.3 @@ -150,7 +150,7 @@ void vbd_grow(blkif_be_vbd_grow_t *grow)
     3.4      {
     3.5          DPRINTK("vbd_grow: device %08x doesn't exist.\n", x->extent.device);
     3.6          grow->status = BLKIF_BE_STATUS_EXTENT_NOT_FOUND;
     3.7 -        blkdev_put(x->bdev);
     3.8 +        bdev_put(x->bdev);
     3.9          goto out;
    3.10      }
    3.11  
    3.12 @@ -255,7 +255,7 @@ void vbd_shrink(blkif_be_vbd_shrink_t *s
    3.13      *px = x->next; /* ATOMIC: no need for vbd_lock. */
    3.14  
    3.15  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    3.16 -    blkdev_put(x->bdev);
    3.17 +    bdev_put(x->bdev);
    3.18  #endif
    3.19      kfree(x);
    3.20  
    3.21 @@ -307,7 +307,7 @@ void vbd_destroy(blkif_be_vbd_destroy_t 
    3.22      {
    3.23          t = x->next;
    3.24  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    3.25 -        blkdev_put(x->bdev);
    3.26 +        bdev_put(x->bdev);
    3.27  #endif
    3.28          kfree(x);
    3.29          x = t;
    3.30 @@ -335,7 +335,7 @@ void destroy_all_vbds(blkif_t *blkif)
    3.31          {
    3.32              t = x->next;
    3.33  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    3.34 -            blkdev_put(x->bdev);
    3.35 +            bdev_put(x->bdev);
    3.36  #endif
    3.37              kfree(x);
    3.38              x = t;