Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c47206e2 authored by Roger Pau Monne's avatar Roger Pau Monne Committed by Jens Axboe
Browse files

xen-blkfront: improve aproximation of required grants per request



Improve the calculation of required grants to process a request by
using nr_phys_segments instead of always assuming a request is going
to use all posible segments.

nr_phys_segments contains the number of scatter-gather DMA addr+len
pairs, which is basically what we put at every granted page.
for_each_sg iterates over the DMA addr+len pairs and uses a grant
page for each of them.

Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
Reviewed-by: default avatarDavid Vrabel <david.vrabel@citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent fbe363c4
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -400,10 +400,13 @@ static int blkif_queue_request(struct request *req)
	if (unlikely(info->connected != BLKIF_STATE_CONNECTED))
		return 1;

	max_grefs = info->max_indirect_segments ?
		    info->max_indirect_segments +
		    INDIRECT_GREFS(info->max_indirect_segments) :
		    BLKIF_MAX_SEGMENTS_PER_REQUEST;
	max_grefs = req->nr_phys_segments;
	if (max_grefs > BLKIF_MAX_SEGMENTS_PER_REQUEST)
		/*
		 * If we are using indirect segments we need to account
		 * for the indirect grefs used in the request.
		 */
		max_grefs += INDIRECT_GREFS(req->nr_phys_segments);

	/* Check if we have enough grants to allocate a requests */
	if (info->persistent_gnts_c < max_grefs) {