Skip to contentSkip to conversation

block: xen-blkback: don't get/put blkif ref for each queue

PATCH In review Bob Liu 2 participants 3 messages Sep 26, 2016

Subsystems (2)
lore
Share & tools
lore

Bob Liu

author
#0 lore raw

PATCH 1/1 block: xen-blkback: don't get/put blkif ref for each queue

xen_blkif_get/put() for each queue is useless, and introduces a bug:

If there is I/O inflight when removing device, xen_blkif_disconnect() will return -EBUSY and xen_blkif_put() not be called.
Which means the references are leaked, then even if I/O completed, the xen_blkif_put() won't call xen_blkif_deferred_free() to free resources anymore.

---
 drivers/block/xen-blkback/xenbus.c |    2 --
 1 file changed, 2 deletions(-)
drivers/block/xen-blkback/xenbus.c +0 -2
index 3cc6d1d..2e1bb6d 100644
@@ -159,7 +159,6 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif)
 		init_waitqueue_head(&ring->shutdown_wq);
 		ring->blkif = blkif;
 		ring->st_print = jiffies;
-		xen_blkif_get(blkif);
 	}
 
 	return 0;
@@ -296,7 +295,6 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
 		BUG_ON(ring->free_pages_num != 0);
 		BUG_ON(ring->persistent_gnt_c != 0);
 		WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
-		xen_blkif_put(blkif);
 	}
 	blkif->nr_ring_pages = 0;
 	/*
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Bob Liu

xen_blkif_get/put() for each queue is useless, and introduces a bug:

If there is I/O inflight when removing device, xen_blkif_disconnect() will return -EBUSY and xen_blkif_put() not be called.
Which means the references are leaked, then even if I/O completed, the xen_blkif_put() won't call xen_blkif_deferred_free() to free resources anymore.

Quoted 27 lines
---
 drivers/block/xen-blkback/xenbus.c |    2 --
 1 file changed, 2 deletions(-)
drivers/block/xen-blkback/xenbus.c +0 -2
index 3cc6d1d..2e1bb6d 100644
@@ -159,7 +159,6 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif)
 		init_waitqueue_head(&ring->shutdown_wq);
 		ring->blkif = blkif;
 		ring->st_print = jiffies;
-		xen_blkif_get(blkif);
 	}
 
 	return 0;
@@ -296,7 +295,6 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
 		BUG_ON(ring->free_pages_num != 0);
 		BUG_ON(ring->persistent_gnt_c != 0);
 		WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
-		xen_blkif_put(blkif);
 	}
 	blkif->nr_ring_pages = 0;
 	/*
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bob Liu
Quoted 8 lines · Bob Liu

xen_blkif_get/put() for each queue is useless, and introduces a bug:

If there is I/O inflight when removing device, xen_blkif_disconnect() will return -EBUSY and xen_blkif_put() not be called.
Which means the references are leaked, then even if I/O completed, the xen_blkif_put() won't call xen_blkif_deferred_free() to free resources anymore.

Quoted 27 lines
---
 drivers/block/xen-blkback/xenbus.c |    2 --
 1 file changed, 2 deletions(-)
drivers/block/xen-blkback/xenbus.c +0 -2
index 3cc6d1d..2e1bb6d 100644
@@ -159,7 +159,6 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif)
 		init_waitqueue_head(&ring->shutdown_wq);
 		ring->blkif = blkif;
 		ring->st_print = jiffies;
-		xen_blkif_get(blkif);
 	}
 
 	return 0;
@@ -296,7 +295,6 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
 		BUG_ON(ring->free_pages_num != 0);
 		BUG_ON(ring->persistent_gnt_c != 0);
 		WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
-		xen_blkif_put(blkif);
 	}
 	blkif->nr_ring_pages = 0;
 	/*
Signature · 1 line
1.7.10.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel