ia64/xen-unstable

changeset 1773:c82c495264af

bitkeeper revision 1.1071.1.4 (40f3fec5bu-VHH-4jBT7Jurn6BIq3Q)

Fix blkif backend driver to work from a kernel thread rather than
from a tasklet.
author kaf24@scramble.cl.cam.ac.uk
date Tue Jul 13 15:24:53 2004 +0000 (2004-07-13)
parents a37ede4b5d41
children 131c48baa117
files linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c
line diff
     1.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c	Tue Jul 13 14:41:24 2004 +0000
     1.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/blkif/backend/main.c	Tue Jul 13 15:24:53 2004 +0000
     1.3 @@ -141,30 +141,44 @@ static void add_to_blkdev_list_tail(blki
     1.4   * SCHEDULER FUNCTIONS
     1.5   */
     1.6  
     1.7 -static void io_schedule(unsigned long unused)
     1.8 +static DECLARE_WAIT_QUEUE_HEAD(io_schedule_wait);
     1.9 +
    1.10 +static int io_schedule(void *arg)
    1.11  {
    1.12 +    DECLARE_WAITQUEUE(wq, current);
    1.13 +
    1.14      blkif_t          *blkif;
    1.15      struct list_head *ent;
    1.16  
    1.17 -    /* Queue up a batch of requests. */
    1.18 -    while ( (NR_PENDING_REQS < MAX_PENDING_REQS) &&
    1.19 -            !list_empty(&io_schedule_list) )
    1.20 +    for ( ; ; )
    1.21      {
    1.22 -        ent = io_schedule_list.next;
    1.23 -        blkif = list_entry(ent, blkif_t, blkdev_list);
    1.24 -        blkif_get(blkif);
    1.25 -        remove_from_blkdev_list(blkif);
    1.26 -        if ( do_block_io_op(blkif, BATCH_PER_DOMAIN) )
    1.27 -            add_to_blkdev_list_tail(blkif);
    1.28 -        blkif_put(blkif);
    1.29 +        /* Wait for work to do. */
    1.30 +        add_wait_queue(&io_schedule_wait, &wq);
    1.31 +        set_current_state(TASK_INTERRUPTIBLE);
    1.32 +        if ( (NR_PENDING_REQS == MAX_PENDING_REQS) || 
    1.33 +             list_empty(&io_schedule_list) )
    1.34 +            schedule();
    1.35 +        __set_current_state(TASK_RUNNING);
    1.36 +        remove_wait_queue(&io_schedule_wait, &wq);
    1.37 +
    1.38 +        /* Queue up a batch of requests. */
    1.39 +        while ( (NR_PENDING_REQS < MAX_PENDING_REQS) &&
    1.40 +                !list_empty(&io_schedule_list) )
    1.41 +        {
    1.42 +            ent = io_schedule_list.next;
    1.43 +            blkif = list_entry(ent, blkif_t, blkdev_list);
    1.44 +            blkif_get(blkif);
    1.45 +            remove_from_blkdev_list(blkif);
    1.46 +            if ( do_block_io_op(blkif, BATCH_PER_DOMAIN) )
    1.47 +                add_to_blkdev_list_tail(blkif);
    1.48 +            blkif_put(blkif);
    1.49 +        }
    1.50 +        
    1.51 +        /* Push the batch through to disc. */
    1.52 +        run_task_queue(&tq_disk);
    1.53      }
    1.54 -
    1.55 -    /* Push the batch through to disc. */
    1.56 -    run_task_queue(&tq_disk);
    1.57  }
    1.58  
    1.59 -static DECLARE_TASKLET(io_schedule_tasklet, io_schedule, 0);
    1.60 -
    1.61  static void maybe_trigger_io_schedule(void)
    1.62  {
    1.63      /*
    1.64 @@ -176,7 +190,7 @@ static void maybe_trigger_io_schedule(vo
    1.65  
    1.66      if ( (NR_PENDING_REQS < (MAX_PENDING_REQS/2)) &&
    1.67           !list_empty(&io_schedule_list) )
    1.68 -        tasklet_schedule(&io_schedule_tasklet);
    1.69 +        wake_up(&io_schedule_wait);
    1.70  }
    1.71  
    1.72  
    1.73 @@ -483,7 +497,7 @@ void blkif_deschedule(blkif_t *blkif)
    1.74      remove_from_blkdev_list(blkif);
    1.75  }
    1.76  
    1.77 -static int __init init_module(void)
    1.78 +static int __init blkif_init(void)
    1.79  {
    1.80      int i;
    1.81  
    1.82 @@ -505,6 +519,9 @@ static int __init init_module(void)
    1.83      spin_lock_init(&io_schedule_list_lock);
    1.84      INIT_LIST_HEAD(&io_schedule_list);
    1.85  
    1.86 +    if ( kernel_thread(io_schedule, 0, CLONE_FS | CLONE_FILES) < 0 )
    1.87 +        BUG();
    1.88 +
    1.89      buffer_head_cachep = kmem_cache_create(
    1.90          "buffer_head_cache", sizeof(struct buffer_head),
    1.91          0, SLAB_HWCACHE_ALIGN, NULL, NULL);
    1.92 @@ -514,10 +531,4 @@ static int __init init_module(void)
    1.93      return 0;
    1.94  }
    1.95  
    1.96 -static void cleanup_module(void)
    1.97 -{
    1.98 -    BUG();
    1.99 -}
   1.100 -
   1.101 -module_init(init_module);
   1.102 -module_exit(cleanup_module);
   1.103 +__initcall(blkif_init);