Commit 7d2483a9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] elv_may_queue() API function

Introduces the elv_may_queue() predicate with which the IO scheduler may tell
the generic request layer that we may add another request to this queue.

It is used by the CFQ elevator.
parent 33c66485
...@@ -361,6 +361,16 @@ void elv_put_request(request_queue_t *q, struct request *rq) ...@@ -361,6 +361,16 @@ void elv_put_request(request_queue_t *q, struct request *rq)
e->elevator_put_req_fn(q, rq); e->elevator_put_req_fn(q, rq);
} }
int elv_may_queue(request_queue_t *q, int rw)
{
elevator_t *e = &q->elevator;
if (e->elevator_may_queue_fn)
return e->elevator_may_queue_fn(q, rw);
return 1;
}
int elv_register_queue(struct gendisk *disk) int elv_register_queue(struct gendisk *disk)
{ {
request_queue_t *q = disk->queue; request_queue_t *q = disk->queue;
......
...@@ -1294,7 +1294,7 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask) ...@@ -1294,7 +1294,7 @@ static struct request *get_request(request_queue_t *q, int rw, int gfp_mask)
struct request_list *rl = &q->rq; struct request_list *rl = &q->rq;
spin_lock_irq(q->queue_lock); spin_lock_irq(q->queue_lock);
if (rl->count[rw] == BLKDEV_MAX_RQ) { if (rl->count[rw] == BLKDEV_MAX_RQ || !elv_may_queue(q, rw)) {
spin_unlock_irq(q->queue_lock); spin_unlock_irq(q->queue_lock);
goto out; goto out;
} }
......
...@@ -15,6 +15,8 @@ typedef int (elevator_queue_empty_fn) (request_queue_t *); ...@@ -15,6 +15,8 @@ typedef int (elevator_queue_empty_fn) (request_queue_t *);
typedef void (elevator_remove_req_fn) (request_queue_t *, struct request *); typedef void (elevator_remove_req_fn) (request_queue_t *, struct request *);
typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *); typedef struct request *(elevator_request_list_fn) (request_queue_t *, struct request *);
typedef struct list_head *(elevator_get_sort_head_fn) (request_queue_t *, struct request *); typedef struct list_head *(elevator_get_sort_head_fn) (request_queue_t *, struct request *);
typedef int (elevator_may_queue_fn) (request_queue_t *, int);
typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, int); typedef int (elevator_set_req_fn) (request_queue_t *, struct request *, int);
typedef void (elevator_put_req_fn) (request_queue_t *, struct request *); typedef void (elevator_put_req_fn) (request_queue_t *, struct request *);
...@@ -39,6 +41,8 @@ struct elevator_s ...@@ -39,6 +41,8 @@ struct elevator_s
elevator_set_req_fn *elevator_set_req_fn; elevator_set_req_fn *elevator_set_req_fn;
elevator_put_req_fn *elevator_put_req_fn; elevator_put_req_fn *elevator_put_req_fn;
elevator_may_queue_fn *elevator_may_queue_fn;
elevator_init_fn *elevator_init_fn; elevator_init_fn *elevator_init_fn;
elevator_exit_fn *elevator_exit_fn; elevator_exit_fn *elevator_exit_fn;
...@@ -64,6 +68,7 @@ extern struct request *elv_former_request(request_queue_t *, struct request *); ...@@ -64,6 +68,7 @@ extern struct request *elv_former_request(request_queue_t *, struct request *);
extern struct request *elv_latter_request(request_queue_t *, struct request *); extern struct request *elv_latter_request(request_queue_t *, struct request *);
extern int elv_register_queue(struct gendisk *); extern int elv_register_queue(struct gendisk *);
extern void elv_unregister_queue(struct gendisk *); extern void elv_unregister_queue(struct gendisk *);
extern int elv_may_queue(request_queue_t *, int);
extern int elv_set_request(request_queue_t *, struct request *, int); extern int elv_set_request(request_queue_t *, struct request *, int);
extern void elv_put_request(request_queue_t *, struct request *); extern void elv_put_request(request_queue_t *, struct request *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment