ia64/linux-2.6.18-xen.hg

changeset 663:035670ec617c

blktap: Fix Reconnect demand by Frontend

Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Sep 09 15:13:29 2008 +0100 (2008-09-09)
parents e86f9e05144a
children 888a42f56f65
files drivers/xen/blktap/common.h drivers/xen/blktap/interface.c drivers/xen/blktap/xenbus.c
line diff
     1.1 --- a/drivers/xen/blktap/common.h	Mon Sep 08 14:02:13 2008 +0100
     1.2 +++ b/drivers/xen/blktap/common.h	Tue Sep 09 15:13:29 2008 +0100
     1.3 @@ -89,6 +89,7 @@ typedef struct blkif_st {
     1.4  
     1.5  blkif_t *tap_alloc_blkif(domid_t domid);
     1.6  void tap_blkif_free(blkif_t *blkif);
     1.7 +void tap_blkif_kmem_cache_free(blkif_t *blkif);
     1.8  int tap_blkif_map(blkif_t *blkif, unsigned long shared_page, 
     1.9  		  unsigned int evtchn);
    1.10  void tap_blkif_unmap(blkif_t *blkif);
     2.1 --- a/drivers/xen/blktap/interface.c	Mon Sep 08 14:02:13 2008 +0100
     2.2 +++ b/drivers/xen/blktap/interface.c	Tue Sep 09 15:13:29 2008 +0100
     2.3 @@ -162,8 +162,15 @@ void tap_blkif_free(blkif_t *blkif)
     2.4  {
     2.5  	atomic_dec(&blkif->refcnt);
     2.6  	wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
     2.7 +	atomic_inc(&blkif->refcnt);
     2.8  
     2.9  	tap_blkif_unmap(blkif);
    2.10 +}
    2.11 +
    2.12 +void tap_blkif_kmem_cache_free(blkif_t *blkif)
    2.13 +{
    2.14 +	if (!atomic_dec_and_test(&blkif->refcnt))
    2.15 +		BUG();
    2.16  	kmem_cache_free(blkif_cachep, blkif);
    2.17  }
    2.18  
     3.1 --- a/drivers/xen/blktap/xenbus.c	Mon Sep 08 14:02:13 2008 +0100
     3.2 +++ b/drivers/xen/blktap/xenbus.c	Tue Sep 09 15:13:29 2008 +0100
     3.3 @@ -182,6 +182,7 @@ static int blktap_remove(struct xenbus_d
     3.4  			kthread_stop(be->blkif->xenblkd);
     3.5  		signal_tapdisk(be->blkif->dev_num);
     3.6  		tap_blkif_free(be->blkif);
     3.7 +		tap_blkif_kmem_cache_free(be->blkif);
     3.8  		be->blkif = NULL;
     3.9  	}
    3.10  	kfree(be);
    3.11 @@ -364,6 +365,7 @@ static void tap_frontend_changed(struct 
    3.12  			kthread_stop(be->blkif->xenblkd);
    3.13  			be->blkif->xenblkd = NULL;
    3.14  		}
    3.15 +		tap_blkif_free(be->blkif);
    3.16  		xenbus_switch_state(dev, XenbusStateClosing);
    3.17  		break;
    3.18