block: prepare elevator to use REQ_OPs.

This patch converts the elevator code to use separate variables
for the operation and flags, and to check req_op for the REQ_OP.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Mike Christie 2016-06-05 14:32:13 -05:00 committed by Jens Axboe
parent cc6e3b1092
commit ba568ea0a2
4 changed files with 8 additions and 9 deletions

View File

@ -1081,7 +1081,7 @@ static struct request *__get_request(struct request_list *rl, int op,
if (unlikely(blk_queue_dying(q))) if (unlikely(blk_queue_dying(q)))
return ERR_PTR(-ENODEV); return ERR_PTR(-ENODEV);
may_queue = elv_may_queue(q, op | op_flags); may_queue = elv_may_queue(q, op, op_flags);
if (may_queue == ELV_MQUEUE_NO) if (may_queue == ELV_MQUEUE_NO)
goto rq_starved; goto rq_starved;

View File

@ -4285,7 +4285,7 @@ static inline int __cfq_may_queue(struct cfq_queue *cfqq)
return ELV_MQUEUE_MAY; return ELV_MQUEUE_MAY;
} }
static int cfq_may_queue(struct request_queue *q, int rw) static int cfq_may_queue(struct request_queue *q, int op, int op_flags)
{ {
struct cfq_data *cfqd = q->elevator->elevator_data; struct cfq_data *cfqd = q->elevator->elevator_data;
struct task_struct *tsk = current; struct task_struct *tsk = current;
@ -4302,7 +4302,7 @@ static int cfq_may_queue(struct request_queue *q, int rw)
if (!cic) if (!cic)
return ELV_MQUEUE_MAY; return ELV_MQUEUE_MAY;
cfqq = cic_to_cfqq(cic, rw_is_sync(rw)); cfqq = cic_to_cfqq(cic, rw_is_sync(op | op_flags));
if (cfqq) { if (cfqq) {
cfq_init_prio_data(cfqq, cic); cfq_init_prio_data(cfqq, cic);

View File

@ -366,8 +366,7 @@ void elv_dispatch_sort(struct request_queue *q, struct request *rq)
list_for_each_prev(entry, &q->queue_head) { list_for_each_prev(entry, &q->queue_head) {
struct request *pos = list_entry_rq(entry); struct request *pos = list_entry_rq(entry);
if ((rq->cmd_flags & REQ_DISCARD) != if ((req_op(rq) == REQ_OP_DISCARD) != (req_op(pos) == REQ_OP_DISCARD))
(pos->cmd_flags & REQ_DISCARD))
break; break;
if (rq_data_dir(rq) != rq_data_dir(pos)) if (rq_data_dir(rq) != rq_data_dir(pos))
break; break;
@ -717,12 +716,12 @@ void elv_put_request(struct request_queue *q, struct request *rq)
e->type->ops.elevator_put_req_fn(rq); e->type->ops.elevator_put_req_fn(rq);
} }
int elv_may_queue(struct request_queue *q, int rw) int elv_may_queue(struct request_queue *q, int op, int op_flags)
{ {
struct elevator_queue *e = q->elevator; struct elevator_queue *e = q->elevator;
if (e->type->ops.elevator_may_queue_fn) if (e->type->ops.elevator_may_queue_fn)
return e->type->ops.elevator_may_queue_fn(q, rw); return e->type->ops.elevator_may_queue_fn(q, op, op_flags);
return ELV_MQUEUE_MAY; return ELV_MQUEUE_MAY;
} }

View File

@ -26,7 +26,7 @@ typedef int (elevator_dispatch_fn) (struct request_queue *, int);
typedef void (elevator_add_req_fn) (struct request_queue *, struct request *); typedef void (elevator_add_req_fn) (struct request_queue *, struct request *);
typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *); typedef struct request *(elevator_request_list_fn) (struct request_queue *, struct request *);
typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *); typedef void (elevator_completed_req_fn) (struct request_queue *, struct request *);
typedef int (elevator_may_queue_fn) (struct request_queue *, int); typedef int (elevator_may_queue_fn) (struct request_queue *, int, int);
typedef void (elevator_init_icq_fn) (struct io_cq *); typedef void (elevator_init_icq_fn) (struct io_cq *);
typedef void (elevator_exit_icq_fn) (struct io_cq *); typedef void (elevator_exit_icq_fn) (struct io_cq *);
@ -134,7 +134,7 @@ extern struct request *elv_former_request(struct request_queue *, struct request
extern struct request *elv_latter_request(struct request_queue *, struct request *); extern struct request *elv_latter_request(struct request_queue *, struct request *);
extern int elv_register_queue(struct request_queue *q); extern int elv_register_queue(struct request_queue *q);
extern void elv_unregister_queue(struct request_queue *q); extern void elv_unregister_queue(struct request_queue *q);
extern int elv_may_queue(struct request_queue *, int); extern int elv_may_queue(struct request_queue *, int, int);
extern void elv_completed_request(struct request_queue *, struct request *); extern void elv_completed_request(struct request_queue *, struct request *);
extern int elv_set_request(struct request_queue *q, struct request *rq, extern int elv_set_request(struct request_queue *q, struct request *rq,
struct bio *bio, gfp_t gfp_mask); struct bio *bio, gfp_t gfp_mask);