|
@@ -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) {
|