Re: [PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
On Wed, Nov 04, 2015 at 09:11:10AM +0800, Bob Liu wrote: > > On 11/04/2015 04:40 AM, Konrad Rzeszutek Wilk wrote: > > On Mon, Nov 02, 2015 at 12:21:41PM +0800, Bob Liu wrote: > >> The number of hardware queues for xen/blkfront is set by parameter > >> 'max_queues'(default 4), while the max value xen/blkback supported is > >> notified > >> through xenstore("multi-queue-max-queues"). > > > > That is not right. > > > > s/The number/The max number/ > > > > The second part: ",while the max value xen/blkback supported is..". I think > > you are trying to say: "it is also capped by the max value that > > the xen/blkback exposes through XenStore key 'multi-queue-max-queues'. > > > >> > >> The negotiated number is the smaller one and would be written back to > >> xenstore > >> as "multi-queue-num-queues", blkback need to read this negotiated number. > > > > s/blkback need to read/blkback needs to read this/ > > > >> > >> Signed-off-by: Bob Liu > >> --- > >> drivers/block/xen-blkfront.c | 166 > >> +++ > >> 1 file changed, 120 insertions(+), 46 deletions(-) > >> > >> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > >> index 8cc5995..23096d7 100644 > >> --- a/drivers/block/xen-blkfront.c > >> +++ b/drivers/block/xen-blkfront.c > >> @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; > >> module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); > >> MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests > >> (default is 32)"); > >> > >> +static unsigned int xen_blkif_max_queues = 4; > >> +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); > >> +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings > >> used per virtual disk"); > >> + > >> /* > >> * Maximum order of pages to be used for the shared ring between front and > >> * backend, 4KB page granularity is used. > >> @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order > >> of pages to be used for the > >> * characters are enough. Define to 20 to keep consist with backend. > >> */ > >> #define RINGREF_NAME_LEN (20) > >> +#define QUEUE_NAME_LEN (12) > > > > Little bit of documentation please. Why 12? Why not 31415 for example? > > I presume it is 'queue-%u' and since so that is 7 + 10 (UINT_MAX is > > 4294967295) = 17! > > > > > >> > >> /* > >> * Per-ring info. > >> @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, > >> u16 sector_size, > >> > >>memset(>tag_set, 0, sizeof(info->tag_set)); > >>info->tag_set.ops = _mq_ops; > >> - info->tag_set.nr_hw_queues = 1; > >> + info->tag_set.nr_hw_queues = info->nr_rings; > >>info->tag_set.queue_depth = BLK_RING_SIZE(info); > >>info->tag_set.numa_node = NUMA_NO_NODE; > >>info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; > >> @@ -1352,6 +1357,51 @@ fail: > >>return err; > >> } > >> > >> +static int write_per_ring_nodes(struct xenbus_transaction xbt, > >> + struct blkfront_ring_info *rinfo, const char > >> *dir) > >> +{ > >> + int err, i; > > > > Please make 'i' be an unsigned int. Especially as you are using '%u' in the > > snprintf. > > > > > >> + const char *message = NULL; > >> + struct blkfront_info *info = rinfo->dev_info; > >> + > >> + if (info->nr_ring_pages == 1) { > >> + err = xenbus_printf(xbt, dir, "ring-ref", "%u", > >> rinfo->ring_ref[0]); > >> + if (err) { > >> + message = "writing ring-ref"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); > > > > Ewww. No. > > > >> + } else { > >> + for (i = 0; i < info->nr_ring_pages; i++) { > >> + char ring_ref_name[RINGREF_NAME_LEN]; > >> + > >> + snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", > >> i); > >> + err = xenbus_printf(xbt, dir, ring_ref_name, > >> + "%u", rinfo->ring_ref[i]); > >> + if (err) { > >> + message = "writing ring-ref"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s: write ring-ref:%d\n", dir, > >> rinfo->ring_ref[i]); > > > > No no please. > > > >> + } > >> + } > >> + > >> + err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); > > > > That is not right. > > > > That only creates one. But the blkif.h says (And the example agrees) > > that there are N 'event-channel' for N-rings. > > > > Shouldn't this be part of the above loop? > > > > No, this loop is only for per-ring each with "multipage". > > The loop you want is.. > > >> + if (err) { > >> + message = "writing event-channel"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s: write
Re: [PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
On 11/04/2015 04:40 AM, Konrad Rzeszutek Wilk wrote: > On Mon, Nov 02, 2015 at 12:21:41PM +0800, Bob Liu wrote: >> The number of hardware queues for xen/blkfront is set by parameter >> 'max_queues'(default 4), while the max value xen/blkback supported is >> notified >> through xenstore("multi-queue-max-queues"). > > That is not right. > > s/The number/The max number/ > > The second part: ",while the max value xen/blkback supported is..". I think > you are trying to say: "it is also capped by the max value that > the xen/blkback exposes through XenStore key 'multi-queue-max-queues'. > >> >> The negotiated number is the smaller one and would be written back to >> xenstore >> as "multi-queue-num-queues", blkback need to read this negotiated number. > > s/blkback need to read/blkback needs to read this/ > >> >> Signed-off-by: Bob Liu >> --- >> drivers/block/xen-blkfront.c | 166 >> +++ >> 1 file changed, 120 insertions(+), 46 deletions(-) >> >> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c >> index 8cc5995..23096d7 100644 >> --- a/drivers/block/xen-blkfront.c >> +++ b/drivers/block/xen-blkfront.c >> @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; >> module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); >> MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests >> (default is 32)"); >> >> +static unsigned int xen_blkif_max_queues = 4; >> +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); >> +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings used >> per virtual disk"); >> + >> /* >> * Maximum order of pages to be used for the shared ring between front and >> * backend, 4KB page granularity is used. >> @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of >> pages to be used for the >> * characters are enough. Define to 20 to keep consist with backend. >> */ >> #define RINGREF_NAME_LEN (20) >> +#define QUEUE_NAME_LEN (12) > > Little bit of documentation please. Why 12? Why not 31415 for example? > I presume it is 'queue-%u' and since so that is 7 + 10 (UINT_MAX is > 4294967295) = 17! > > >> >> /* >> * Per-ring info. >> @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 >> sector_size, >> >> memset(>tag_set, 0, sizeof(info->tag_set)); >> info->tag_set.ops = _mq_ops; >> -info->tag_set.nr_hw_queues = 1; >> +info->tag_set.nr_hw_queues = info->nr_rings; >> info->tag_set.queue_depth = BLK_RING_SIZE(info); >> info->tag_set.numa_node = NUMA_NO_NODE; >> info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; >> @@ -1352,6 +1357,51 @@ fail: >> return err; >> } >> >> +static int write_per_ring_nodes(struct xenbus_transaction xbt, >> +struct blkfront_ring_info *rinfo, const char >> *dir) >> +{ >> +int err, i; > > Please make 'i' be an unsigned int. Especially as you are using '%u' in the > snprintf. > > >> +const char *message = NULL; >> +struct blkfront_info *info = rinfo->dev_info; >> + >> +if (info->nr_ring_pages == 1) { >> +err = xenbus_printf(xbt, dir, "ring-ref", "%u", >> rinfo->ring_ref[0]); >> +if (err) { >> +message = "writing ring-ref"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); > > Ewww. No. > >> +} else { >> +for (i = 0; i < info->nr_ring_pages; i++) { >> +char ring_ref_name[RINGREF_NAME_LEN]; >> + >> +snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", >> i); >> +err = xenbus_printf(xbt, dir, ring_ref_name, >> +"%u", rinfo->ring_ref[i]); >> +if (err) { >> +message = "writing ring-ref"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write ring-ref:%d\n", dir, >> rinfo->ring_ref[i]); > > No no please. > >> +} >> +} >> + >> +err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); > > That is not right. > > That only creates one. But the blkif.h says (And the example agrees) > that there are N 'event-channel' for N-rings. > > Shouldn't this be part of the above loop? > No, this loop is only for per-ring each with "multipage". The loop you want is.. >> +if (err) { >> +message = "writing event-channel"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write event-channel:%d\n", dir, rinfo->evtchn); > > Please no. > >> + >> +return 0; >> + >> +abort_transaction: >> +xenbus_transaction_end(xbt, 1); >> +if (message) >> +xenbus_dev_fatal(info->xbdev, err, "%s", message); >> + >> +return err; >> +} >>
Re: [PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
On 11/04/2015 04:40 AM, Konrad Rzeszutek Wilk wrote: > On Mon, Nov 02, 2015 at 12:21:41PM +0800, Bob Liu wrote: >> The number of hardware queues for xen/blkfront is set by parameter >> 'max_queues'(default 4), while the max value xen/blkback supported is >> notified >> through xenstore("multi-queue-max-queues"). > > That is not right. > > s/The number/The max number/ > > The second part: ",while the max value xen/blkback supported is..". I think > you are trying to say: "it is also capped by the max value that > the xen/blkback exposes through XenStore key 'multi-queue-max-queues'. > >> >> The negotiated number is the smaller one and would be written back to >> xenstore >> as "multi-queue-num-queues", blkback need to read this negotiated number. > > s/blkback need to read/blkback needs to read this/ > >> >> Signed-off-by: Bob Liu>> --- >> drivers/block/xen-blkfront.c | 166 >> +++ >> 1 file changed, 120 insertions(+), 46 deletions(-) >> >> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c >> index 8cc5995..23096d7 100644 >> --- a/drivers/block/xen-blkfront.c >> +++ b/drivers/block/xen-blkfront.c >> @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; >> module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); >> MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests >> (default is 32)"); >> >> +static unsigned int xen_blkif_max_queues = 4; >> +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); >> +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings used >> per virtual disk"); >> + >> /* >> * Maximum order of pages to be used for the shared ring between front and >> * backend, 4KB page granularity is used. >> @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of >> pages to be used for the >> * characters are enough. Define to 20 to keep consist with backend. >> */ >> #define RINGREF_NAME_LEN (20) >> +#define QUEUE_NAME_LEN (12) > > Little bit of documentation please. Why 12? Why not 31415 for example? > I presume it is 'queue-%u' and since so that is 7 + 10 (UINT_MAX is > 4294967295) = 17! > > >> >> /* >> * Per-ring info. >> @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 >> sector_size, >> >> memset(>tag_set, 0, sizeof(info->tag_set)); >> info->tag_set.ops = _mq_ops; >> -info->tag_set.nr_hw_queues = 1; >> +info->tag_set.nr_hw_queues = info->nr_rings; >> info->tag_set.queue_depth = BLK_RING_SIZE(info); >> info->tag_set.numa_node = NUMA_NO_NODE; >> info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; >> @@ -1352,6 +1357,51 @@ fail: >> return err; >> } >> >> +static int write_per_ring_nodes(struct xenbus_transaction xbt, >> +struct blkfront_ring_info *rinfo, const char >> *dir) >> +{ >> +int err, i; > > Please make 'i' be an unsigned int. Especially as you are using '%u' in the > snprintf. > > >> +const char *message = NULL; >> +struct blkfront_info *info = rinfo->dev_info; >> + >> +if (info->nr_ring_pages == 1) { >> +err = xenbus_printf(xbt, dir, "ring-ref", "%u", >> rinfo->ring_ref[0]); >> +if (err) { >> +message = "writing ring-ref"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); > > Ewww. No. > >> +} else { >> +for (i = 0; i < info->nr_ring_pages; i++) { >> +char ring_ref_name[RINGREF_NAME_LEN]; >> + >> +snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", >> i); >> +err = xenbus_printf(xbt, dir, ring_ref_name, >> +"%u", rinfo->ring_ref[i]); >> +if (err) { >> +message = "writing ring-ref"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write ring-ref:%d\n", dir, >> rinfo->ring_ref[i]); > > No no please. > >> +} >> +} >> + >> +err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); > > That is not right. > > That only creates one. But the blkif.h says (And the example agrees) > that there are N 'event-channel' for N-rings. > > Shouldn't this be part of the above loop? > No, this loop is only for per-ring each with "multipage". The loop you want is.. >> +if (err) { >> +message = "writing event-channel"; >> +goto abort_transaction; >> +} >> +pr_info("%s: write event-channel:%d\n", dir, rinfo->evtchn); > > Please no. > >> + >> +return 0; >> + >> +abort_transaction: >> +xenbus_transaction_end(xbt, 1); >> +if (message) >> +xenbus_dev_fatal(info->xbdev, err, "%s", message); >> + >> +
Re: [PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
On Wed, Nov 04, 2015 at 09:11:10AM +0800, Bob Liu wrote: > > On 11/04/2015 04:40 AM, Konrad Rzeszutek Wilk wrote: > > On Mon, Nov 02, 2015 at 12:21:41PM +0800, Bob Liu wrote: > >> The number of hardware queues for xen/blkfront is set by parameter > >> 'max_queues'(default 4), while the max value xen/blkback supported is > >> notified > >> through xenstore("multi-queue-max-queues"). > > > > That is not right. > > > > s/The number/The max number/ > > > > The second part: ",while the max value xen/blkback supported is..". I think > > you are trying to say: "it is also capped by the max value that > > the xen/blkback exposes through XenStore key 'multi-queue-max-queues'. > > > >> > >> The negotiated number is the smaller one and would be written back to > >> xenstore > >> as "multi-queue-num-queues", blkback need to read this negotiated number. > > > > s/blkback need to read/blkback needs to read this/ > > > >> > >> Signed-off-by: Bob Liu> >> --- > >> drivers/block/xen-blkfront.c | 166 > >> +++ > >> 1 file changed, 120 insertions(+), 46 deletions(-) > >> > >> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c > >> index 8cc5995..23096d7 100644 > >> --- a/drivers/block/xen-blkfront.c > >> +++ b/drivers/block/xen-blkfront.c > >> @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; > >> module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); > >> MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests > >> (default is 32)"); > >> > >> +static unsigned int xen_blkif_max_queues = 4; > >> +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); > >> +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings > >> used per virtual disk"); > >> + > >> /* > >> * Maximum order of pages to be used for the shared ring between front and > >> * backend, 4KB page granularity is used. > >> @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order > >> of pages to be used for the > >> * characters are enough. Define to 20 to keep consist with backend. > >> */ > >> #define RINGREF_NAME_LEN (20) > >> +#define QUEUE_NAME_LEN (12) > > > > Little bit of documentation please. Why 12? Why not 31415 for example? > > I presume it is 'queue-%u' and since so that is 7 + 10 (UINT_MAX is > > 4294967295) = 17! > > > > > >> > >> /* > >> * Per-ring info. > >> @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, > >> u16 sector_size, > >> > >>memset(>tag_set, 0, sizeof(info->tag_set)); > >>info->tag_set.ops = _mq_ops; > >> - info->tag_set.nr_hw_queues = 1; > >> + info->tag_set.nr_hw_queues = info->nr_rings; > >>info->tag_set.queue_depth = BLK_RING_SIZE(info); > >>info->tag_set.numa_node = NUMA_NO_NODE; > >>info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; > >> @@ -1352,6 +1357,51 @@ fail: > >>return err; > >> } > >> > >> +static int write_per_ring_nodes(struct xenbus_transaction xbt, > >> + struct blkfront_ring_info *rinfo, const char > >> *dir) > >> +{ > >> + int err, i; > > > > Please make 'i' be an unsigned int. Especially as you are using '%u' in the > > snprintf. > > > > > >> + const char *message = NULL; > >> + struct blkfront_info *info = rinfo->dev_info; > >> + > >> + if (info->nr_ring_pages == 1) { > >> + err = xenbus_printf(xbt, dir, "ring-ref", "%u", > >> rinfo->ring_ref[0]); > >> + if (err) { > >> + message = "writing ring-ref"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); > > > > Ewww. No. > > > >> + } else { > >> + for (i = 0; i < info->nr_ring_pages; i++) { > >> + char ring_ref_name[RINGREF_NAME_LEN]; > >> + > >> + snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", > >> i); > >> + err = xenbus_printf(xbt, dir, ring_ref_name, > >> + "%u", rinfo->ring_ref[i]); > >> + if (err) { > >> + message = "writing ring-ref"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s: write ring-ref:%d\n", dir, > >> rinfo->ring_ref[i]); > > > > No no please. > > > >> + } > >> + } > >> + > >> + err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); > > > > That is not right. > > > > That only creates one. But the blkif.h says (And the example agrees) > > that there are N 'event-channel' for N-rings. > > > > Shouldn't this be part of the above loop? > > > > No, this loop is only for per-ring each with "multipage". > > The loop you want is.. > > >> + if (err) { > >> + message = "writing event-channel"; > >> + goto abort_transaction; > >> + } > >> + pr_info("%s:
[PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
The number of hardware queues for xen/blkfront is set by parameter 'max_queues'(default 4), while the max value xen/blkback supported is notified through xenstore("multi-queue-max-queues"). The negotiated number is the smaller one and would be written back to xenstore as "multi-queue-num-queues", blkback need to read this negotiated number. Signed-off-by: Bob Liu --- drivers/block/xen-blkfront.c | 166 +++ 1 file changed, 120 insertions(+), 46 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 8cc5995..23096d7 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default is 32)"); +static unsigned int xen_blkif_max_queues = 4; +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings used per virtual disk"); + /* * Maximum order of pages to be used for the shared ring between front and * backend, 4KB page granularity is used. @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of pages to be used for the * characters are enough. Define to 20 to keep consist with backend. */ #define RINGREF_NAME_LEN (20) +#define QUEUE_NAME_LEN (12) /* * Per-ring info. @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, memset(>tag_set, 0, sizeof(info->tag_set)); info->tag_set.ops = _mq_ops; - info->tag_set.nr_hw_queues = 1; + info->tag_set.nr_hw_queues = info->nr_rings; info->tag_set.queue_depth = BLK_RING_SIZE(info); info->tag_set.numa_node = NUMA_NO_NODE; info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; @@ -1352,6 +1357,51 @@ fail: return err; } +static int write_per_ring_nodes(struct xenbus_transaction xbt, + struct blkfront_ring_info *rinfo, const char *dir) +{ + int err, i; + const char *message = NULL; + struct blkfront_info *info = rinfo->dev_info; + + if (info->nr_ring_pages == 1) { + err = xenbus_printf(xbt, dir, "ring-ref", "%u", rinfo->ring_ref[0]); + if (err) { + message = "writing ring-ref"; + goto abort_transaction; + } + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); + } else { + for (i = 0; i < info->nr_ring_pages; i++) { + char ring_ref_name[RINGREF_NAME_LEN]; + + snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", i); + err = xenbus_printf(xbt, dir, ring_ref_name, + "%u", rinfo->ring_ref[i]); + if (err) { + message = "writing ring-ref"; + goto abort_transaction; + } + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[i]); + } + } + + err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); + if (err) { + message = "writing event-channel"; + goto abort_transaction; + } + pr_info("%s: write event-channel:%d\n", dir, rinfo->evtchn); + + return 0; + +abort_transaction: + xenbus_transaction_end(xbt, 1); + if (message) + xenbus_dev_fatal(info->xbdev, err, "%s", message); + + return err; +} /* Common code used when first setting up, and when resuming. */ static int talk_to_blkback(struct xenbus_device *dev, @@ -1362,7 +1412,6 @@ static int talk_to_blkback(struct xenbus_device *dev, int err, i; unsigned int max_page_order = 0; unsigned int ring_page_order = 0; - struct blkfront_ring_info *rinfo; err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, "max-ring-page-order", "%u", _page_order); @@ -1374,7 +1423,8 @@ static int talk_to_blkback(struct xenbus_device *dev, } for (i = 0; i < info->nr_rings; i++) { - rinfo = >rinfo[i]; + struct blkfront_ring_info *rinfo = >rinfo[i]; + /* Create shared ring, alloc event channel. */ err = setup_blkring(dev, rinfo); if (err) @@ -1388,45 +1438,51 @@ again: goto destroy_blkring; } - if (info->nr_rings == 1) { - rinfo = >rinfo[0]; - if (info->nr_ring_pages == 1) { - err = xenbus_printf(xbt, dev->nodename, - "ring-ref", "%u", rinfo->ring_ref[0]); - if (err) { -
[PATCH v4 05/10] xen/blkfront: negotiate number of queues/rings to be used with backend
The number of hardware queues for xen/blkfront is set by parameter 'max_queues'(default 4), while the max value xen/blkback supported is notified through xenstore("multi-queue-max-queues"). The negotiated number is the smaller one and would be written back to xenstore as "multi-queue-num-queues", blkback need to read this negotiated number. Signed-off-by: Bob Liu--- drivers/block/xen-blkfront.c | 166 +++ 1 file changed, 120 insertions(+), 46 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 8cc5995..23096d7 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -98,6 +98,10 @@ static unsigned int xen_blkif_max_segments = 32; module_param_named(max, xen_blkif_max_segments, int, S_IRUGO); MODULE_PARM_DESC(max, "Maximum amount of segments in indirect requests (default is 32)"); +static unsigned int xen_blkif_max_queues = 4; +module_param_named(max_queues, xen_blkif_max_queues, uint, S_IRUGO); +MODULE_PARM_DESC(max_queues, "Maximum number of hardware queues/rings used per virtual disk"); + /* * Maximum order of pages to be used for the shared ring between front and * backend, 4KB page granularity is used. @@ -113,6 +117,7 @@ MODULE_PARM_DESC(max_ring_page_order, "Maximum order of pages to be used for the * characters are enough. Define to 20 to keep consist with backend. */ #define RINGREF_NAME_LEN (20) +#define QUEUE_NAME_LEN (12) /* * Per-ring info. @@ -695,7 +700,7 @@ static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size, memset(>tag_set, 0, sizeof(info->tag_set)); info->tag_set.ops = _mq_ops; - info->tag_set.nr_hw_queues = 1; + info->tag_set.nr_hw_queues = info->nr_rings; info->tag_set.queue_depth = BLK_RING_SIZE(info); info->tag_set.numa_node = NUMA_NO_NODE; info->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_SG_MERGE; @@ -1352,6 +1357,51 @@ fail: return err; } +static int write_per_ring_nodes(struct xenbus_transaction xbt, + struct blkfront_ring_info *rinfo, const char *dir) +{ + int err, i; + const char *message = NULL; + struct blkfront_info *info = rinfo->dev_info; + + if (info->nr_ring_pages == 1) { + err = xenbus_printf(xbt, dir, "ring-ref", "%u", rinfo->ring_ref[0]); + if (err) { + message = "writing ring-ref"; + goto abort_transaction; + } + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[0]); + } else { + for (i = 0; i < info->nr_ring_pages; i++) { + char ring_ref_name[RINGREF_NAME_LEN]; + + snprintf(ring_ref_name, RINGREF_NAME_LEN, "ring-ref%u", i); + err = xenbus_printf(xbt, dir, ring_ref_name, + "%u", rinfo->ring_ref[i]); + if (err) { + message = "writing ring-ref"; + goto abort_transaction; + } + pr_info("%s: write ring-ref:%d\n", dir, rinfo->ring_ref[i]); + } + } + + err = xenbus_printf(xbt, dir, "event-channel", "%u", rinfo->evtchn); + if (err) { + message = "writing event-channel"; + goto abort_transaction; + } + pr_info("%s: write event-channel:%d\n", dir, rinfo->evtchn); + + return 0; + +abort_transaction: + xenbus_transaction_end(xbt, 1); + if (message) + xenbus_dev_fatal(info->xbdev, err, "%s", message); + + return err; +} /* Common code used when first setting up, and when resuming. */ static int talk_to_blkback(struct xenbus_device *dev, @@ -1362,7 +1412,6 @@ static int talk_to_blkback(struct xenbus_device *dev, int err, i; unsigned int max_page_order = 0; unsigned int ring_page_order = 0; - struct blkfront_ring_info *rinfo; err = xenbus_scanf(XBT_NIL, info->xbdev->otherend, "max-ring-page-order", "%u", _page_order); @@ -1374,7 +1423,8 @@ static int talk_to_blkback(struct xenbus_device *dev, } for (i = 0; i < info->nr_rings; i++) { - rinfo = >rinfo[i]; + struct blkfront_ring_info *rinfo = >rinfo[i]; + /* Create shared ring, alloc event channel. */ err = setup_blkring(dev, rinfo); if (err) @@ -1388,45 +1438,51 @@ again: goto destroy_blkring; } - if (info->nr_rings == 1) { - rinfo = >rinfo[0]; - if (info->nr_ring_pages == 1) { - err = xenbus_printf(xbt, dev->nodename, - "ring-ref", "%u", rinfo->ring_ref[0]); - if (err) { -