diff options
author | Mike Anderson <andmike@linux.vnet.ibm.com> | 2008-09-13 14:31:27 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:13 -0400 |
commit | 11914a53d2ec2974a565311af327b8983d8c820d (patch) | |
tree | 72713d2661ed56fa5d9e29203541bad32c88a3ba | |
parent | 242f9dcb8ba6f68fcd217a119a7648a4f69290e9 (diff) |
block: Add interface to abort queued requests
Signed-off-by: Mike Anderson <andmike@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/blk-timeout.c | 22 | ||||
-rw-r--r-- | block/elevator.c | 13 | ||||
-rw-r--r-- | include/linux/blkdev.h | 1 | ||||
-rw-r--r-- | include/linux/blktrace_api.h | 2 | ||||
-rw-r--r-- | include/linux/elevator.h | 1 |
5 files changed, 39 insertions, 0 deletions
diff --git a/block/blk-timeout.c b/block/blk-timeout.c index b36d07bf0af..6e5c781c5af 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c | |||
@@ -153,3 +153,25 @@ void blk_add_timer(struct request *req) | |||
153 | time_before(expiry, q->timeout.expires)) | 153 | time_before(expiry, q->timeout.expires)) |
154 | mod_timer(&q->timeout, expiry); | 154 | mod_timer(&q->timeout, expiry); |
155 | } | 155 | } |
156 | |||
157 | /** | ||
158 | * blk_abort_queue -- Abort all request on given queue | ||
159 | * @queue: pointer to queue | ||
160 | * | ||
161 | */ | ||
162 | void blk_abort_queue(struct request_queue *q) | ||
163 | { | ||
164 | unsigned long flags; | ||
165 | struct request *rq, *tmp; | ||
166 | |||
167 | spin_lock_irqsave(q->queue_lock, flags); | ||
168 | |||
169 | elv_abort_queue(q); | ||
170 | |||
171 | list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list) | ||
172 | blk_abort_request(rq); | ||
173 | |||
174 | spin_unlock_irqrestore(q->queue_lock, flags); | ||
175 | |||
176 | } | ||
177 | EXPORT_SYMBOL_GPL(blk_abort_queue); | ||
diff --git a/block/elevator.c b/block/elevator.c index a91fc59edd0..8a74eedc353 100644 --- a/block/elevator.c +++ b/block/elevator.c | |||
@@ -914,6 +914,19 @@ int elv_may_queue(struct request_queue *q, int rw) | |||
914 | return ELV_MQUEUE_MAY; | 914 | return ELV_MQUEUE_MAY; |
915 | } | 915 | } |
916 | 916 | ||
917 | void elv_abort_queue(struct request_queue *q) | ||
918 | { | ||
919 | struct request *rq; | ||
920 | |||
921 | while (!list_empty(&q->queue_head)) { | ||
922 | rq = list_entry_rq(q->queue_head.next); | ||
923 | rq->cmd_flags |= REQ_QUIET; | ||
924 | blk_add_trace_rq(q, rq, BLK_TA_ABORT); | ||
925 | end_queued_request(rq, 0); | ||
926 | } | ||
927 | } | ||
928 | EXPORT_SYMBOL(elv_abort_queue); | ||
929 | |||
917 | void elv_completed_request(struct request_queue *q, struct request *rq) | 930 | void elv_completed_request(struct request_queue *q, struct request *rq) |
918 | { | 931 | { |
919 | elevator_t *e = q->elevator; | 932 | elevator_t *e = q->elevator; |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 067f28b8007..37781d6fe04 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -788,6 +788,7 @@ extern int blk_end_request_callback(struct request *rq, int error, | |||
788 | extern void blk_complete_request(struct request *); | 788 | extern void blk_complete_request(struct request *); |
789 | extern void __blk_complete_request(struct request *); | 789 | extern void __blk_complete_request(struct request *); |
790 | extern void blk_abort_request(struct request *); | 790 | extern void blk_abort_request(struct request *); |
791 | extern void blk_abort_queue(struct request_queue *); | ||
791 | 792 | ||
792 | /* | 793 | /* |
793 | * blk_end_request() takes bytes instead of sectors as a complete size. | 794 | * blk_end_request() takes bytes instead of sectors as a complete size. |
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index 27da2cc682e..dcaf2452ed1 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h | |||
@@ -48,6 +48,7 @@ enum blktrace_act { | |||
48 | __BLK_TA_SPLIT, /* bio was split */ | 48 | __BLK_TA_SPLIT, /* bio was split */ |
49 | __BLK_TA_BOUNCE, /* bio was bounced */ | 49 | __BLK_TA_BOUNCE, /* bio was bounced */ |
50 | __BLK_TA_REMAP, /* bio was remapped */ | 50 | __BLK_TA_REMAP, /* bio was remapped */ |
51 | __BLK_TA_ABORT, /* request aborted */ | ||
51 | }; | 52 | }; |
52 | 53 | ||
53 | /* | 54 | /* |
@@ -78,6 +79,7 @@ enum blktrace_notify { | |||
78 | #define BLK_TA_SPLIT (__BLK_TA_SPLIT) | 79 | #define BLK_TA_SPLIT (__BLK_TA_SPLIT) |
79 | #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) | 80 | #define BLK_TA_BOUNCE (__BLK_TA_BOUNCE) |
80 | #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) | 81 | #define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE)) |
82 | #define BLK_TA_ABORT (__BLK_TA_ABORT | BLK_TC_ACT(BLK_TC_QUEUE)) | ||
81 | 83 | ||
82 | #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) | 84 | #define BLK_TN_PROCESS (__BLK_TN_PROCESS | BLK_TC_ACT(BLK_TC_NOTIFY)) |
83 | #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) | 85 | #define BLK_TN_TIMESTAMP (__BLK_TN_TIMESTAMP | BLK_TC_ACT(BLK_TC_NOTIFY)) |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index bb791c311a5..92f6f634e3e 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -112,6 +112,7 @@ extern struct request *elv_latter_request(struct request_queue *, struct request | |||
112 | extern int elv_register_queue(struct request_queue *q); | 112 | extern int elv_register_queue(struct request_queue *q); |
113 | extern void elv_unregister_queue(struct request_queue *q); | 113 | extern void elv_unregister_queue(struct request_queue *q); |
114 | extern int elv_may_queue(struct request_queue *, int); | 114 | extern int elv_may_queue(struct request_queue *, int); |
115 | extern void elv_abort_queue(struct request_queue *); | ||
115 | extern void elv_completed_request(struct request_queue *, struct request *); | 116 | extern void elv_completed_request(struct request_queue *, struct request *); |
116 | extern int elv_set_request(struct request_queue *, struct request *, gfp_t); | 117 | extern int elv_set_request(struct request_queue *, struct request *, gfp_t); |
117 | extern void elv_put_request(struct request_queue *, struct request *); | 118 | extern void elv_put_request(struct request_queue *, struct request *); |