This patch reimplements elevator switch. This patch assumes generic dispatch queue patchset is applied. * Each request is tagged with REQ_ELVPRIV flag if it has its elevator private data set. * Requests which doesn't have REQ_ELVPRIV flag set never enter iosched. They are always directly back inserted to dispatch queue. Of course, elevator_put_req_fn is called only for requests which have its REQ_ELVPRIV set. * Request queue maintains the current number of requests which have its elevator data set (elevator_set_req_fn called) in q->rq->elvpriv. * If a request queue has QUEUE_FLAG_BYPASS set, elevator private data is not allocated for new requests. To switch to another iosched, we set QUEUE_FLAG_BYPASS and wait until elvpriv goes to zero; then, we attach the new iosched and clears QUEUE_FLAG_BYPASS. New implementation is much simpler and main code paths are less cluttered, IMHO.
Showing the changes to include/linux/blkdev.h (1 of 3 files). Show all
Unified · Split
| @@ -107,9 +107,9 @@ typedef void (rq_end_io_fn)(struct request *); · 106 unmodified lines | ||
| 107 | 107 | struct request_list { |
| 108 | 108 | int count[2]; |
| 109 | 109 | int starved[2]; |
| 110 | + int elvpriv; | |
| 110 | 111 | mempool_t *rq_pool; |
| 111 | 112 | wait_queue_head_t wait[2]; |
| 112 | − wait_queue_head_t drain; | |
| 113 | 113 | }; |
| 114 | 114 | |
| 115 | 115 | #define BLK_MAX_CDB 16 |
| @@ -211,6 +211,7 @@ enum rq_flag_bits { · 95 unmodified lines | ||
| 211 | 211 | __REQ_STARTED, /* drive already may have started this one */ |
| 212 | 212 | __REQ_DONTPREP, /* don't call prep for this one */ |
| 213 | 213 | __REQ_QUEUED, /* uses queueing */ |
| 214 | + __REQ_ELVPRIV, /* elevator private data attached */ | |
| 214 | 215 | /* |
| 215 | 216 | * for ATA/ATAPI devices |
| 216 | 217 | */ |
| @@ -244,6 +245,7 @@ enum rq_flag_bits { · 27 unmodified lines | ||
| 244 | 245 | #define REQ_STARTED (1 << __REQ_STARTED) |
| 245 | 246 | #define REQ_DONTPREP (1 << __REQ_DONTPREP) |
| 246 | 247 | #define REQ_QUEUED (1 << __REQ_QUEUED) |
| 248 | +#define REQ_ELVPRIV (1 << __REQ_ELVPRIV) | |
| 247 | 249 | #define REQ_PC (1 << __REQ_PC) |
| 248 | 250 | #define REQ_BLOCK_PC (1 << __REQ_BLOCK_PC) |
| 249 | 251 | #define REQ_SENSE (1 << __REQ_SENSE) |
| @@ -413,8 +415,6 @@ struct request_queue · 163 unmodified lines | ||
| 413 | 415 | unsigned int sg_reserved_size; |
| 414 | 416 | int node; |
| 415 | 417 | |
| 416 | − struct list_head drain_list; | |
| 417 | − | |
| 418 | 418 | /* |
| 419 | 419 | * reserved for flush operations |
| 420 | 420 | */ |
| @@ -442,7 +442,7 @@ enum { · 21 unmodified lines | ||
| 442 | 442 | #define QUEUE_FLAG_DEAD 5 /* queue being torn down */ |
| 443 | 443 | #define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ |
| 444 | 444 | #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ |
| 445 | −#define QUEUE_FLAG_DRAIN 8 /* draining queue for sched switch */ | |
| 445 | +#define QUEUE_FLAG_BYPASS 8 /* don't use elevator, just do FIFO */ | |
| 446 | 446 | #define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ |
| 447 | 447 | |
| 448 | 448 | #define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) |
| @@ -668,8 +668,6 @@ extern void blk_dump_rq_flags(struct request *, char *); · 219 unmodified lines | ||
| 668 | 668 | extern void generic_unplug_device(request_queue_t *); |
| 669 | 669 | extern void __generic_unplug_device(request_queue_t *); |
| 670 | 670 | extern long nr_blockdev_pages(void); |
| 671 | −extern void blk_wait_queue_drained(request_queue_t *, int); | |
| 672 | −extern void blk_finish_queue_drain(request_queue_t *); | |
| 673 | 671 | |
| 674 | 672 | int blk_get_queue(request_queue_t *); |
| 675 | 673 | request_queue_t *blk_alloc_queue(int gfp_mask); |