ia64/xen-unstable

changeset 2343:36ed4e3fa897

bitkeeper revision 1.1159.51.1 (412cb2756vYHD-1PDPrd90VZuLl1EQ)

Fix netif and blkif interface deferred disconnection. It must occur in
a process context because we call vfree().
author kaf24@labyrinth.cl.cam.ac.uk
date Wed Aug 25 15:38:29 2004 +0000 (2004-08-25)
parents d21069f49572
children 22afa9c3be28
files linux-2.4.27-xen-sparse/include/asm-xen/queues.h linux-2.6.7-xen-sparse/drivers/xen/blkback/common.h linux-2.6.7-xen-sparse/drivers/xen/blkback/interface.c linux-2.6.7-xen-sparse/drivers/xen/netback/common.h linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c
line diff
     1.1 --- a/linux-2.4.27-xen-sparse/include/asm-xen/queues.h	Tue Aug 24 20:06:36 2004 +0000
     1.2 +++ b/linux-2.4.27-xen-sparse/include/asm-xen/queues.h	Wed Aug 25 15:38:29 2004 +0000
     1.3 @@ -10,8 +10,11 @@
     1.4  
     1.5  #define DECLARE_TQUEUE(_name, _fn, _arg) \
     1.6      struct tq_struct _name = { LIST_HEAD_INIT((_name).list), 0, _fn, _arg }
     1.7 +#define DECLARE_WORK(_name, _fn, _arg) DECLARE_TQUEUE(_name, _fn, _arg)
     1.8  
     1.9 -#define DECLARE_WORK(_name, _fn, _arg) DECLARE_TQUEUE(_name, _fn, _arg)
    1.10 +#define work_struct tq_struct
    1.11 +#define INIT_WORK(_work, _fn, _arg) INIT_TQUEUE(_work, _fn, _arg)
    1.12 +
    1.13  #define schedule_work(_w) schedule_task(_w)
    1.14  
    1.15  #endif /* __QUEUES_H__ */
     2.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/blkback/common.h	Tue Aug 24 20:06:36 2004 +0000
     2.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/blkback/common.h	Wed Aug 25 15:38:29 2004 +0000
     2.3 @@ -60,19 +60,21 @@ typedef struct blkif_st {
     2.4      struct list_head blkdev_list;
     2.5      spinlock_t       blk_ring_lock;
     2.6      atomic_t         refcnt;
     2.7 +
     2.8 +    struct work_struct work;
     2.9  } blkif_t;
    2.10  
    2.11  void blkif_create(blkif_be_create_t *create);
    2.12  void blkif_destroy(blkif_be_destroy_t *destroy);
    2.13  void blkif_connect(blkif_be_connect_t *connect);
    2.14  int  blkif_disconnect(blkif_be_disconnect_t *disconnect, u8 rsp_id);
    2.15 -void __blkif_disconnect_complete(blkif_t *blkif);
    2.16 +void blkif_disconnect_complete(blkif_t *blkif);
    2.17  blkif_t *blkif_find_by_handle(domid_t domid, unsigned int handle);
    2.18  #define blkif_get(_b) (atomic_inc(&(_b)->refcnt))
    2.19  #define blkif_put(_b)                             \
    2.20      do {                                          \
    2.21          if ( atomic_dec_and_test(&(_b)->refcnt) ) \
    2.22 -            __blkif_disconnect_complete(_b);      \
    2.23 +            blkif_disconnect_complete(_b);        \
    2.24      } while (0)
    2.25  
    2.26  /* An entry in a list of xen_extents. */
     3.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/blkback/interface.c	Tue Aug 24 20:06:36 2004 +0000
     3.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/blkback/interface.c	Wed Aug 25 15:38:29 2004 +0000
     3.3 @@ -27,13 +27,14 @@ blkif_t *blkif_find_by_handle(domid_t do
     3.4      return blkif;
     3.5  }
     3.6  
     3.7 -void __blkif_disconnect_complete(blkif_t *blkif)
     3.8 +static void __blkif_disconnect_complete(void *arg)
     3.9  {
    3.10 +    blkif_t              *blkif = (blkif_t *)arg;
    3.11      ctrl_msg_t            cmsg;
    3.12      blkif_be_disconnect_t disc;
    3.13  
    3.14      /*
    3.15 -     * These can't be done in __blkif_disconnect() because at that point there
    3.16 +     * These can't be done in blkif_disconnect() because at that point there
    3.17       * may be outstanding requests at the disc whose asynchronous responses
    3.18       * must still be notified to the remote driver.
    3.19       */
    3.20 @@ -67,6 +68,12 @@ void __blkif_disconnect_complete(blkif_t
    3.21      ctrl_if_send_response(&cmsg);
    3.22  }
    3.23  
    3.24 +void blkif_disconnect_complete(blkif_t *blkif)
    3.25 +{
    3.26 +    INIT_WORK(&blkif->work, __blkif_disconnect_complete, (void *)blkif);
    3.27 +    schedule_work(&blkif->work);
    3.28 +}
    3.29 +
    3.30  void blkif_create(blkif_be_create_t *create)
    3.31  {
    3.32      domid_t       domid  = create->domid;
     4.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netback/common.h	Tue Aug 24 20:06:36 2004 +0000
     4.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netback/common.h	Wed Aug 25 15:38:29 2004 +0000
     4.3 @@ -70,19 +70,21 @@ typedef struct netif_st {
     4.4      spinlock_t       rx_lock, tx_lock;
     4.5      struct net_device *dev;
     4.6      struct net_device_stats stats;
     4.7 +
     4.8 +    struct work_struct work;
     4.9  } netif_t;
    4.10  
    4.11  void netif_create(netif_be_create_t *create);
    4.12  void netif_destroy(netif_be_destroy_t *destroy);
    4.13  void netif_connect(netif_be_connect_t *connect);
    4.14  int  netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id);
    4.15 -void __netif_disconnect_complete(netif_t *netif);
    4.16 +void netif_disconnect_complete(netif_t *netif);
    4.17  netif_t *netif_find_by_handle(domid_t domid, unsigned int handle);
    4.18  #define netif_get(_b) (atomic_inc(&(_b)->refcnt))
    4.19  #define netif_put(_b)                             \
    4.20      do {                                          \
    4.21          if ( atomic_dec_and_test(&(_b)->refcnt) ) \
    4.22 -            __netif_disconnect_complete(_b);      \
    4.23 +            netif_disconnect_complete(_b);        \
    4.24      } while (0)
    4.25  
    4.26  void netif_interface_init(void);
     5.1 --- a/linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c	Tue Aug 24 20:06:36 2004 +0000
     5.2 +++ b/linux-2.6.7-xen-sparse/drivers/xen/netback/interface.c	Wed Aug 25 15:38:29 2004 +0000
     5.3 @@ -27,13 +27,14 @@ netif_t *netif_find_by_handle(domid_t do
     5.4      return netif;
     5.5  }
     5.6  
     5.7 -void __netif_disconnect_complete(netif_t *netif)
     5.8 +static void __netif_disconnect_complete(void *arg)
     5.9  {
    5.10 +    netif_t              *netif = (netif_t *)arg;
    5.11      ctrl_msg_t            cmsg;
    5.12      netif_be_disconnect_t disc;
    5.13  
    5.14      /*
    5.15 -     * These can't be done in __netif_disconnect() because at that point there
    5.16 +     * These can't be done in netif_disconnect() because at that point there
    5.17       * may be outstanding requests at the disc whose asynchronous responses
    5.18       * must still be notified to the remote driver.
    5.19       */
    5.20 @@ -70,6 +71,12 @@ void __netif_disconnect_complete(netif_t
    5.21      ctrl_if_send_response(&cmsg);
    5.22  }
    5.23  
    5.24 +void netif_disconnect_complete(netif_t *netif)
    5.25 +{
    5.26 +    INIT_WORK(&netif->work, __netif_disconnect_complete, (void *)netif);
    5.27 +    schedule_work(&netif->work);
    5.28 +}
    5.29 +
    5.30  void netif_create(netif_be_create_t *create)
    5.31  {
    5.32      int                err = 0;