aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@suse.com>2017-01-23 10:11:37 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2017-01-23 13:27:42 -0500
commit3b4f18843e511193e7eb616710e838f5852e661d (patch)
treeabf5739ec8edad0a94594aa2148d132ab2f20867
parentb32728ffef7f233dbdabb3f11814bdf692aaf501 (diff)
xen-blkfront: correct maximum segment accounting
Making use of "max_indirect_segments=" has issues: - blkfront_setup_indirect() may end up with zero psegs when PAGE_SIZE is sufficiently much larger than XEN_PAGE_SIZE - the variable driven by the command line option (xen_blkif_max_segments) has a somewhat different purpose, and hence should namely never end up being zero - as long as the specified value is lower than the legacy default, we better don't use indirect segments at all (or we'd in fact lower throughput) Signed-off-by: Jan Beulich <jbeulich@suse.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--drivers/block/xen-blkfront.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 386b17208605..265f1a7072e9 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2223,7 +2223,7 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo)
2223 } 2223 }
2224 else 2224 else
2225 grants = info->max_indirect_segments; 2225 grants = info->max_indirect_segments;
2226 psegs = grants / GRANTS_PER_PSEG; 2226 psegs = DIV_ROUND_UP(grants, GRANTS_PER_PSEG);
2227 2227
2228 err = fill_grant_buffer(rinfo, 2228 err = fill_grant_buffer(rinfo,
2229 (grants + INDIRECT_GREFS(grants)) * BLK_RING_SIZE(info)); 2229 (grants + INDIRECT_GREFS(grants)) * BLK_RING_SIZE(info));
@@ -2328,8 +2328,11 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
2328 2328
2329 indirect_segments = xenbus_read_unsigned(info->xbdev->otherend, 2329 indirect_segments = xenbus_read_unsigned(info->xbdev->otherend,
2330 "feature-max-indirect-segments", 0); 2330 "feature-max-indirect-segments", 0);
2331 info->max_indirect_segments = min(indirect_segments, 2331 if (indirect_segments > xen_blkif_max_segments)
2332 xen_blkif_max_segments); 2332 indirect_segments = xen_blkif_max_segments;
2333 if (indirect_segments <= BLKIF_MAX_SEGMENTS_PER_REQUEST)
2334 indirect_segments = 0;
2335 info->max_indirect_segments = indirect_segments;
2333} 2336}
2334 2337
2335/* 2338/*
@@ -2652,6 +2655,9 @@ static int __init xlblk_init(void)
2652 if (!xen_domain()) 2655 if (!xen_domain())
2653 return -ENODEV; 2656 return -ENODEV;
2654 2657
2658 if (xen_blkif_max_segments < BLKIF_MAX_SEGMENTS_PER_REQUEST)
2659 xen_blkif_max_segments = BLKIF_MAX_SEGMENTS_PER_REQUEST;
2660
2655 if (xen_blkif_max_ring_order > XENBUS_MAX_RING_GRANT_ORDER) { 2661 if (xen_blkif_max_ring_order > XENBUS_MAX_RING_GRANT_ORDER) {
2656 pr_info("Invalid max_ring_order (%d), will use default max: %d.\n", 2662 pr_info("Invalid max_ring_order (%d), will use default max: %d.\n",
2657 xen_blkif_max_ring_order, XENBUS_MAX_RING_GRANT_ORDER); 2663 xen_blkif_max_ring_order, XENBUS_MAX_RING_GRANT_ORDER);