@@ -764,7 +764,7 @@ static void *__bfq_bic_change_cgroup(struct bfq_data *bfqd,
struct bfq_entity *entity;
unsigned int act_idx;
- for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
+ for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
struct bfq_queue *async_bfqq = bic_to_bfqq(bic, 0, act_idx);
struct bfq_queue *sync_bfqq = bic_to_bfqq(bic, 1, act_idx);
@@ -689,7 +689,7 @@ static void bfq_limit_depth(unsigned int op, struct blk_mq_alloc_data *data)
limit = (limit * depth) >> bfqd->full_depth_shift;
}
- for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
+ for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
struct bfq_queue *bfqq =
bic ? bic_to_bfqq(bic, op_is_sync(op), act_idx) : NULL;
@@ -1829,10 +1829,25 @@ static bool bfq_bfqq_higher_class_or_weight(struct bfq_queue *bfqq,
/* get the index of the actuator that will serve bio */
static unsigned int bfq_actuator_index(struct bfq_data *bfqd, struct bio *bio)
{
- /*
- * Multi-actuator support not complete yet, so always return 0
- * for the moment.
- */
+ struct blk_independent_access_range *iar;
+ unsigned int i;
+ sector_t end;
+
+ if (bfqd->num_ia_ranges == 1)
+ return 0;
+
+ /* bio_end_sector(bio) gives the sector after the last one */
+ end = bio_end_sector(bio) - 1;
+
+ for (i = 0; i < bfqd->num_ia_ranges; i++) {
+ iar = &(bfqd->ia_ranges[i]);
+ if (end >= iar->sector && end < iar->sector + iar->nr_sectors)
+ return i;
+ }
+
+ WARN_ONCE(true,
+ "bfq_actuator_index: bio sector out of ranges: end=%llu\n",
+ end);
return 0;
}
@@ -2477,7 +2492,6 @@ static void bfq_remove_request(struct request_queue *q,
if (rq->cmd_flags & REQ_META)
bfqq->meta_pending--;
-
}
static bool bfq_bio_merge(struct request_queue *q, struct bio *bio,
@@ -2673,7 +2687,7 @@ void bfq_end_wr_async_queues(struct bfq_data *bfqd,
{
int i, j, k;
- for (k = 0; k < BFQ_MAX_ACTUATORS; k++) {
+ for (k = 0; k < bfqd->num_ia_ranges; k++) {
for (i = 0; i < 2; i++)
for (j = 0; j < IOPRIO_NR_LEVELS; j++)
if (bfqg->async_bfqq[i][j][k])
@@ -5432,7 +5446,7 @@ static void bfq_exit_icq(struct io_cq *icq)
if (bfqd)
spin_lock_irqsave(&bfqd->lock, flags);
- for (act_idx = 0; act_idx < BFQ_MAX_ACTUATORS; act_idx++) {
+ for (act_idx = 0; act_idx < bfqd->num_ia_ranges; act_idx++) {
if (bic->stable_merge_bfqq[act_idx])
bfq_put_stable_ref(bic->stable_merge_bfqq[act_idx]);
@@ -7003,7 +7017,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
{
int i, j, k;
- for (k = 0; k < BFQ_MAX_ACTUATORS; k++) {
+ for (k = 0; k < bfqd->num_ia_ranges; k++) {
for (i = 0; i < 2; i++)
for (j = 0; j < IOPRIO_NR_LEVELS; j++)
__bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j][k]);
@@ -7120,6 +7134,7 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
{
struct bfq_data *bfqd;
struct elevator_queue *eq;
+ unsigned int i;
eq = elevator_alloc(q, e);
if (!eq)
@@ -7162,6 +7177,31 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
bfqd->queue = q;
+ /*
+ * If the disk supports multiple actuators, we copy the independent
+ * access ranges from the request queue structure.
+ */
+ spin_lock_irq(&q->queue_lock);
+ if (q->ia_ranges) {
+ /*
+ * Check if the disk ia_ranges size exceeds the current bfq
+ * actuator limit.
+ */
+ if (q->ia_ranges->nr_ia_ranges > BFQ_MAX_ACTUATORS) {
+ pr_crit("nr_ia_ranges higher than act limit: iars=%d, max=%d.\n",
+ q->ia_ranges->nr_ia_ranges, BFQ_MAX_ACTUATORS);
+ pr_crit("Falling back to single actuator mode.\n");
+ bfqd->num_ia_ranges = 1;
+ } else {
+ bfqd->num_ia_ranges = q->ia_ranges->nr_ia_ranges;
+
+ for (i = 0; i < bfqd->num_ia_ranges; i++)
+ bfqd->ia_ranges[i] = q->ia_ranges->ia_range[i];
+ }
+ } else
+ bfqd->num_ia_ranges = 1;
+ spin_unlock_irq(&q->queue_lock);
+
INIT_LIST_HEAD(&bfqd->dispatch);
hrtimer_init(&bfqd->idle_slice_timer, CLOCK_MONOTONIC,
@@ -796,6 +796,18 @@ struct bfq_data {
*/
unsigned int word_depths[2][2];
unsigned int full_depth_shift;
+
+ /*
+ * Number of independent access ranges. This is equal to 1 in
+ * case of single actuator drives.
+ */
+ unsigned int num_ia_ranges;
+
+ /*
+ * Disk independent access ranges for each actuator
+ * in this device.
+ */
+ struct blk_independent_access_range ia_ranges[BFQ_MAX_ACTUATORS];
};
enum bfqq_state_flags {