Commit 11914a53 authored by Mike Anderson's avatar Mike Anderson Committed by Jens Axboe

block: Add interface to abort queued requests

Signed-off-by: default avatarMike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 242f9dcb
...@@ -153,3 +153,25 @@ void blk_add_timer(struct request *req) ...@@ -153,3 +153,25 @@ void blk_add_timer(struct request *req)
time_before(expiry, q->timeout.expires)) time_before(expiry, q->timeout.expires))
mod_timer(&q->timeout, expiry); mod_timer(&q->timeout, expiry);
} }
/**
* blk_abort_queue -- Abort all request on given queue
* @queue: pointer to queue
*
*/
void blk_abort_queue(struct request_queue *q)
{
unsigned long flags;
struct request *rq, *tmp;
spin_lock_irqsave(q->queue_lock, flags);
elv_abort_queue(q);
list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list)
blk_abort_request(rq);
spin_unlock_irqrestore(q->queue_lock, flags);
}
EXPORT_SYMBOL_GPL(blk_abort_queue);
...@@ -914,6 +914,19 @@ int elv_may_queue(struct request_queue *q, int rw) ...@@ -914,6 +914,19 @@ int elv_may_queue(struct request_queue *q, int rw)
return ELV_MQUEUE_MAY; return ELV_MQUEUE_MAY;
} }
void elv_abort_queue(struct request_queue *q)
{
struct request *rq;
while (!list_empty(&q->queue_head)) {
rq = list_entry_rq(q->queue_head.next);
rq->cmd_flags |= REQ_QUIET;
blk_add_trace_rq(q, rq, BLK_TA_ABORT);
end_queued_request(rq, 0);
}
}
EXPORT_SYMBOL(elv_abort_queue);
void elv_completed_request(struct request_queue *q, struct request *rq) void elv_completed_request(struct request_queue *q, struct request *rq)
{ {
elevator_t *e = q->elevator; elevator_t *e = q->elevator;
......
...@@ -788,6 +788,7 @@ extern int blk_end_request_callback(struct request *rq, int error, ...@@ -788,6 +788,7 @@ extern int blk_end_request_callback(struct request *rq, int error,
extern void blk_complete_request(struct request *); extern void blk_complete_request(struct request *);
extern void __blk_complete_request(struct request *); extern void __blk_complete_request(struct request *);
extern void blk_abort_request(struct request *); extern void blk_abort_request(struct request *);
extern void blk_abort_queue(struct request_queue *);
/* /*
* blk_end_request() takes bytes instead of sectors as a complete size. * blk_end_request() takes bytes instead of sectors as a complete size.
......
...@@ -48,6 +48,7 @@ enum blktrace_act { ...@@ -48,6 +48,7 @@ enum blktrace_act {
__BLK_TA_SPLIT, /* bio was split */ __BLK_TA_SPLIT, /* bio was split */
__BLK_TA_BOUNCE, /* bio was bounced */ __BLK_TA_BOUNCE, /* bio was bounced */
__BLK_TA_REMAP, /* bio was remapped */ __BLK_TA_REMAP, /* bio was remapped */
__BLK_TA_ABORT, /* request aborted */
}; };
/* /*
...@@ -78,6 +79,7 @@ enum blktrace_notify { ...@@ -78,6 +79,7 @@ enum blktrace_notify {
#define BLK_TA_SPLIT (__BLK_TA_SPLIT) #define BLK_TA_SPLIT (__BLK_TA_SPLIT)
#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
#define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE))
#define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY))
#define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY))
......
...@@ -112,6 +112,7 @@ extern struct request *elv_latter_request(struct request_queue *, struct request ...@@ -112,6 +112,7 @@ 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);
extern void elv_abort_queue(struct request_queue *);
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 *, struct request *, gfp_t); extern int elv_set_request(struct request_queue *, struct request *, gfp_t);
extern void elv_put_request(struct request_queue *, struct request *); extern void elv_put_request(struct request_queue *, 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