aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback
diff options
context:
space:
mode:
authorRoger Pau Monne <roger.pau@citrix.com>2013-04-17 14:18:58 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2013-04-18 09:29:24 -0400
commitbb6acb289fbaac0e99eb552abdefc80a2186ef3f (patch)
tree3204f28656f024bd2a46fcee6d96a075d541d7f5 /drivers/block/xen-blkback
parent3f3aad5e6686ed49242bbf86de378b39f119ec9d (diff)
xen-blkback: move pending handles list from blkbk to pending_req
Moving grant ref handles from blkbk to pending_req will allow us to get rid of the shared blkbk structure. Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: xen-devel@lists.xen.org Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/block/xen-blkback')
-rw-r--r--drivers/block/xen-blkback/blkback.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 17052f74ebe5..ae7dc92ad3cf 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -128,6 +128,7 @@ struct pending_req {
128 struct list_head free_list; 128 struct list_head free_list;
129 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 129 struct page *pages[BLKIF_MAX_SEGMENTS_PER_REQUEST];
130 struct persistent_gnt *persistent_gnts[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 130 struct persistent_gnt *persistent_gnts[BLKIF_MAX_SEGMENTS_PER_REQUEST];
131 grant_handle_t grant_handles[BLKIF_MAX_SEGMENTS_PER_REQUEST];
131}; 132};
132 133
133#define BLKBACK_INVALID_HANDLE (~0) 134#define BLKBACK_INVALID_HANDLE (~0)
@@ -142,8 +143,6 @@ struct xen_blkbk {
142 /* And its spinlock. */ 143 /* And its spinlock. */
143 spinlock_t pending_free_lock; 144 spinlock_t pending_free_lock;
144 wait_queue_head_t pending_free_wq; 145 wait_queue_head_t pending_free_wq;
145 /* And the grant handles that are available. */
146 grant_handle_t *pending_grant_handles;
147}; 146};
148 147
149static struct xen_blkbk *blkbk; 148static struct xen_blkbk *blkbk;
@@ -221,7 +220,7 @@ static inline void shrink_free_pagepool(struct xen_blkif *blkif, int num)
221#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page))) 220#define vaddr(page) ((unsigned long)pfn_to_kaddr(page_to_pfn(page)))
222 221
223#define pending_handle(_req, _seg) \ 222#define pending_handle(_req, _seg) \
224 (blkbk->pending_grant_handles[vaddr_pagenr(_req, _seg)]) 223 (_req->grant_handles[_seg])
225 224
226 225
227static int do_block_io_op(struct xen_blkif *blkif); 226static int do_block_io_op(struct xen_blkif *blkif);
@@ -1304,7 +1303,7 @@ static void make_response(struct xen_blkif *blkif, u64 id,
1304 1303
1305static int __init xen_blkif_init(void) 1304static int __init xen_blkif_init(void)
1306{ 1305{
1307 int i, mmap_pages; 1306 int i;
1308 int rc = 0; 1307 int rc = 0;
1309 1308
1310 if (!xen_domain()) 1309 if (!xen_domain())
@@ -1316,21 +1315,15 @@ static int __init xen_blkif_init(void)
1316 return -ENOMEM; 1315 return -ENOMEM;
1317 } 1316 }
1318 1317
1319 mmap_pages = xen_blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
1320 1318
1321 blkbk->pending_reqs = kzalloc(sizeof(blkbk->pending_reqs[0]) * 1319 blkbk->pending_reqs = kzalloc(sizeof(blkbk->pending_reqs[0]) *
1322 xen_blkif_reqs, GFP_KERNEL); 1320 xen_blkif_reqs, GFP_KERNEL);
1323 blkbk->pending_grant_handles = kmalloc(sizeof(blkbk->pending_grant_handles[0]) *
1324 mmap_pages, GFP_KERNEL);
1325 1321
1326 if (!blkbk->pending_reqs || !blkbk->pending_grant_handles) { 1322 if (!blkbk->pending_reqs) {
1327 rc = -ENOMEM; 1323 rc = -ENOMEM;
1328 goto out_of_memory; 1324 goto out_of_memory;
1329 } 1325 }
1330 1326
1331 for (i = 0; i < mmap_pages; i++) {
1332 blkbk->pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
1333 }
1334 rc = xen_blkif_interface_init(); 1327 rc = xen_blkif_interface_init();
1335 if (rc) 1328 if (rc)
1336 goto failed_init; 1329 goto failed_init;
@@ -1353,7 +1346,6 @@ static int __init xen_blkif_init(void)
1353 pr_alert(DRV_PFX "%s: out of memory\n", __func__); 1346 pr_alert(DRV_PFX "%s: out of memory\n", __func__);
1354 failed_init: 1347 failed_init:
1355 kfree(blkbk->pending_reqs); 1348 kfree(blkbk->pending_reqs);
1356 kfree(blkbk->pending_grant_handles);
1357 kfree(blkbk); 1349 kfree(blkbk);
1358 blkbk = NULL; 1350 blkbk = NULL;
1359 return rc; 1351 return rc;