aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/xen-blkback
diff options
context:
space:
mode:
authorBob Liu <bob.liu@oracle.com>2015-11-13 22:12:17 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2016-01-04 12:21:06 -0500
commitd62d86000316d7ef38e1c2e9602c3ce6d1cb57bd (patch)
treeaa9fa8a5fce0608532787214b8f40a5075871a6d /drivers/block/xen-blkback
parent2fb1ef4f1226ea6d6d3481036cabe01a4415b68c (diff)
xen/blkback: get the number of hardware queues/rings from blkfront
Backend advertises "multi-queue-max-queues" to front, also get the negotiated number from "multi-queue-num-queues" written by blkfront. Signed-off-by: Bob Liu <bob.liu@oracle.com> 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.c13
-rw-r--r--drivers/block/xen-blkback/common.h1
-rw-r--r--drivers/block/xen-blkback/xenbus.c34
3 files changed, 42 insertions, 6 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
index 4fd8640d146c..18b27770d80b 100644
--- a/drivers/block/xen-blkback/blkback.c
+++ b/drivers/block/xen-blkback/blkback.c
@@ -84,6 +84,16 @@ MODULE_PARM_DESC(max_persistent_grants,
84 "Maximum number of grants to map persistently"); 84 "Maximum number of grants to map persistently");
85 85
86/* 86/*
87 * Maximum number of rings/queues blkback supports, allow as many queues as there
88 * are CPUs if user has not specified a value.
89 */
90unsigned int xenblk_max_queues;
91module_param_named(max_queues, xenblk_max_queues, uint, 0644);
92MODULE_PARM_DESC(max_queues,
93 "Maximum number of hardware queues per virtual disk." \
94 "By default it is the number of online CPUs.");
95
96/*
87 * Maximum order of pages to be used for the shared ring between front and 97 * Maximum order of pages to be used for the shared ring between front and
88 * backend, 4KB page granularity is used. 98 * backend, 4KB page granularity is used.
89 */ 99 */
@@ -1483,6 +1493,9 @@ static int __init xen_blkif_init(void)
1483 xen_blkif_max_ring_order = XENBUS_MAX_RING_GRANT_ORDER; 1493 xen_blkif_max_ring_order = XENBUS_MAX_RING_GRANT_ORDER;
1484 } 1494 }
1485 1495
1496 if (xenblk_max_queues == 0)
1497 xenblk_max_queues = num_online_cpus();
1498
1486 rc = xen_blkif_interface_init(); 1499 rc = xen_blkif_interface_init();
1487 if (rc) 1500 if (rc)
1488 goto failed_init; 1501 goto failed_init;
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 310eff3cf43f..847444dc1df4 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -46,6 +46,7 @@
46#include <xen/interface/io/protocols.h> 46#include <xen/interface/io/protocols.h>
47 47
48extern unsigned int xen_blkif_max_ring_order; 48extern unsigned int xen_blkif_max_ring_order;
49extern unsigned int xenblk_max_queues;
49/* 50/*
50 * This is the maximum number of segments that would be allowed in indirect 51 * This is the maximum number of segments that would be allowed in indirect
51 * requests. This value will also be passed to the frontend. 52 * requests. This value will also be passed to the frontend.
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index f5bfedd0e948..0d6bb9383a68 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -181,12 +181,6 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
181 blkif->st_print = jiffies; 181 blkif->st_print = jiffies;
182 INIT_WORK(&blkif->persistent_purge_work, xen_blkbk_unmap_purged_grants); 182 INIT_WORK(&blkif->persistent_purge_work, xen_blkbk_unmap_purged_grants);
183 183
184 blkif->nr_rings = 1;
185 if (xen_blkif_alloc_rings(blkif)) {
186 kmem_cache_free(xen_blkif_cachep, blkif);
187 return ERR_PTR(-ENOMEM);
188 }
189
190 return blkif; 184 return blkif;
191} 185}
192 186
@@ -595,6 +589,12 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
595 goto fail; 589 goto fail;
596 } 590 }
597 591
592 /* Multi-queue: advertise how many queues are supported by us.*/
593 err = xenbus_printf(XBT_NIL, dev->nodename,
594 "multi-queue-max-queues", "%u", xenblk_max_queues);
595 if (err)
596 pr_warn("Error writing multi-queue-max-queues\n");
597
598 /* setup back pointer */ 598 /* setup back pointer */
599 be->blkif->be = be; 599 be->blkif->be = be;
600 600
@@ -980,6 +980,7 @@ static int connect_ring(struct backend_info *be)
980 char *xspath; 980 char *xspath;
981 size_t xspathsize; 981 size_t xspathsize;
982 const size_t xenstore_path_ext_size = 11; /* sufficient for "/queue-NNN" */ 982 const size_t xenstore_path_ext_size = 11; /* sufficient for "/queue-NNN" */
983 unsigned int requested_num_queues = 0;
983 984
984 pr_debug("%s %s\n", __func__, dev->otherend); 985 pr_debug("%s %s\n", __func__, dev->otherend);
985 986
@@ -1007,6 +1008,27 @@ static int connect_ring(struct backend_info *be)
1007 be->blkif->vbd.feature_gnt_persistent = pers_grants; 1008 be->blkif->vbd.feature_gnt_persistent = pers_grants;
1008 be->blkif->vbd.overflow_max_grants = 0; 1009 be->blkif->vbd.overflow_max_grants = 0;
1009 1010
1011 /*
1012 * Read the number of hardware queues from frontend.
1013 */
1014 err = xenbus_scanf(XBT_NIL, dev->otherend, "multi-queue-num-queues",
1015 "%u", &requested_num_queues);
1016 if (err < 0) {
1017 requested_num_queues = 1;
1018 } else {
1019 if (requested_num_queues > xenblk_max_queues
1020 || requested_num_queues == 0) {
1021 /* Buggy or malicious guest. */
1022 xenbus_dev_fatal(dev, err,
1023 "guest requested %u queues, exceeding the maximum of %u.",
1024 requested_num_queues, xenblk_max_queues);
1025 return -ENOSYS;
1026 }
1027 }
1028 be->blkif->nr_rings = requested_num_queues;
1029 if (xen_blkif_alloc_rings(be->blkif))
1030 return -ENOMEM;
1031
1010 pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename, 1032 pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename,
1011 be->blkif->nr_rings, be->blkif->blk_protocol, protocol, 1033 be->blkif->nr_rings, be->blkif->blk_protocol, protocol,
1012 pers_grants ? "persistent grants" : ""); 1034 pers_grants ? "persistent grants" : "");