aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2006-01-06 03:51:03 -0500
committerJens Axboe <axboe@suse.de>2006-01-06 03:51:03 -0500
commit797e7dbbee0a91fa1349192f18ad5c454997d876 (patch)
treec0d5974f469dd2d3d4f9b15d87d201b61e248f54 /include/linux
parent52d9e675361261a1eb1716b02222ec6177ec342b (diff)
[BLOCK] reimplement handling of barrier request
Reimplement handling of barrier requests. * Flexible handling to deal with various capabilities of target devices. * Retry support for falling back. * Tagged queues which don't support ordered tag can do ordered. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/blkdev.h82
-rw-r--r--include/linux/elevator.h1
2 files changed, 58 insertions, 25 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index a0ce8c585165..15db0f112d0a 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -207,6 +207,7 @@ enum rq_flag_bits {
207 __REQ_SORTED, /* elevator knows about this request */ 207 __REQ_SORTED, /* elevator knows about this request */
208 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ 208 __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */
209 __REQ_HARDBARRIER, /* may not be passed by drive either */ 209 __REQ_HARDBARRIER, /* may not be passed by drive either */
210 __REQ_FUA, /* forced unit access */
210 __REQ_CMD, /* is a regular fs rw request */ 211 __REQ_CMD, /* is a regular fs rw request */
211 __REQ_NOMERGE, /* don't touch this for merging */ 212 __REQ_NOMERGE, /* don't touch this for merging */
212 __REQ_STARTED, /* drive already may have started this one */ 213 __REQ_STARTED, /* drive already may have started this one */
@@ -230,9 +231,7 @@ enum rq_flag_bits {
230 __REQ_PM_SUSPEND, /* suspend request */ 231 __REQ_PM_SUSPEND, /* suspend request */
231 __REQ_PM_RESUME, /* resume request */ 232 __REQ_PM_RESUME, /* resume request */
232 __REQ_PM_SHUTDOWN, /* shutdown request */ 233 __REQ_PM_SHUTDOWN, /* shutdown request */
233 __REQ_BAR_PREFLUSH, /* barrier pre-flush done */ 234 __REQ_ORDERED_COLOR, /* is before or after barrier */
234 __REQ_BAR_POSTFLUSH, /* barrier post-flush */
235 __REQ_BAR_FLUSH, /* rq is the flush request */
236 __REQ_NR_BITS, /* stops here */ 235 __REQ_NR_BITS, /* stops here */
237}; 236};
238 237
@@ -241,6 +240,7 @@ enum rq_flag_bits {
241#define REQ_SORTED (1 << __REQ_SORTED) 240#define REQ_SORTED (1 << __REQ_SORTED)
242#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) 241#define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER)
243#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) 242#define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER)
243#define REQ_FUA (1 << __REQ_FUA)
244#define REQ_CMD (1 << __REQ_CMD) 244#define REQ_CMD (1 << __REQ_CMD)
245#define REQ_NOMERGE (1 << __REQ_NOMERGE) 245#define REQ_NOMERGE (1 << __REQ_NOMERGE)
246#define REQ_STARTED (1 << __REQ_STARTED) 246#define REQ_STARTED (1 << __REQ_STARTED)
@@ -260,9 +260,7 @@ enum rq_flag_bits {
260#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) 260#define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND)
261#define REQ_PM_RESUME (1 << __REQ_PM_RESUME) 261#define REQ_PM_RESUME (1 << __REQ_PM_RESUME)
262#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) 262#define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN)
263#define REQ_BAR_PREFLUSH (1 << __REQ_BAR_PREFLUSH) 263#define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR)
264#define REQ_BAR_POSTFLUSH (1 << __REQ_BAR_POSTFLUSH)
265#define REQ_BAR_FLUSH (1 << __REQ_BAR_FLUSH)
266 264
267/* 265/*
268 * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME 266 * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME
@@ -292,8 +290,7 @@ struct bio_vec;
292typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); 290typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *);
293typedef void (activity_fn) (void *data, int rw); 291typedef void (activity_fn) (void *data, int rw);
294typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); 292typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *);
295typedef int (prepare_flush_fn) (request_queue_t *, struct request *); 293typedef void (prepare_flush_fn) (request_queue_t *, struct request *);
296typedef void (end_flush_fn) (request_queue_t *, struct request *);
297 294
298enum blk_queue_state { 295enum blk_queue_state {
299 Queue_down, 296 Queue_down,
@@ -335,7 +332,6 @@ struct request_queue
335 activity_fn *activity_fn; 332 activity_fn *activity_fn;
336 issue_flush_fn *issue_flush_fn; 333 issue_flush_fn *issue_flush_fn;
337 prepare_flush_fn *prepare_flush_fn; 334 prepare_flush_fn *prepare_flush_fn;
338 end_flush_fn *end_flush_fn;
339 335
340 /* 336 /*
341 * Dispatch queue sorting 337 * Dispatch queue sorting
@@ -420,14 +416,11 @@ struct request_queue
420 /* 416 /*
421 * reserved for flush operations 417 * reserved for flush operations
422 */ 418 */
423 struct request *flush_rq; 419 unsigned int ordered, next_ordered, ordseq;
424 unsigned char ordered; 420 int orderr, ordcolor;
425}; 421 struct request pre_flush_rq, bar_rq, post_flush_rq;
426 422 struct request *orig_bar_rq;
427enum { 423 unsigned int bi_size;
428 QUEUE_ORDERED_NONE,
429 QUEUE_ORDERED_TAG,
430 QUEUE_ORDERED_FLUSH,
431}; 424};
432 425
433#define RQ_INACTIVE (-1) 426#define RQ_INACTIVE (-1)
@@ -445,12 +438,51 @@ enum {
445#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ 438#define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */
446#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ 439#define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */
447#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */ 440#define QUEUE_FLAG_ELVSWITCH 8 /* don't use elevator, just do FIFO */
448#define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ 441
442enum {
443 /*
444 * Hardbarrier is supported with one of the following methods.
445 *
446 * NONE : hardbarrier unsupported
447 * DRAIN : ordering by draining is enough
448 * DRAIN_FLUSH : ordering by draining w/ pre and post flushes
449 * DRAIN_FUA : ordering by draining w/ pre flush and FUA write
450 * TAG : ordering by tag is enough
451 * TAG_FLUSH : ordering by tag w/ pre and post flushes
452 * TAG_FUA : ordering by tag w/ pre flush and FUA write
453 */
454 QUEUE_ORDERED_NONE = 0x00,
455 QUEUE_ORDERED_DRAIN = 0x01,
456 QUEUE_ORDERED_TAG = 0x02,
457
458 QUEUE_ORDERED_PREFLUSH = 0x10,
459 QUEUE_ORDERED_POSTFLUSH = 0x20,
460 QUEUE_ORDERED_FUA = 0x40,
461
462 QUEUE_ORDERED_DRAIN_FLUSH = QUEUE_ORDERED_DRAIN |
463 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH,
464 QUEUE_ORDERED_DRAIN_FUA = QUEUE_ORDERED_DRAIN |
465 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA,
466 QUEUE_ORDERED_TAG_FLUSH = QUEUE_ORDERED_TAG |
467 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_POSTFLUSH,
468 QUEUE_ORDERED_TAG_FUA = QUEUE_ORDERED_TAG |
469 QUEUE_ORDERED_PREFLUSH | QUEUE_ORDERED_FUA,
470
471 /*
472 * Ordered operation sequence
473 */
474 QUEUE_ORDSEQ_STARTED = 0x01, /* flushing in progress */
475 QUEUE_ORDSEQ_DRAIN = 0x02, /* waiting for the queue to be drained */
476 QUEUE_ORDSEQ_PREFLUSH = 0x04, /* pre-flushing in progress */
477 QUEUE_ORDSEQ_BAR = 0x08, /* original barrier req in progress */
478 QUEUE_ORDSEQ_POSTFLUSH = 0x10, /* post-flushing in progress */
479 QUEUE_ORDSEQ_DONE = 0x20,
480};
449 481
450#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags) 482#define blk_queue_plugged(q) test_bit(QUEUE_FLAG_PLUGGED, &(q)->queue_flags)
451#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags) 483#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
452#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags) 484#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
453#define blk_queue_flushing(q) test_bit(QUEUE_FLAG_FLUSH, &(q)->queue_flags) 485#define blk_queue_flushing(q) ((q)->ordseq)
454 486
455#define blk_fs_request(rq) ((rq)->flags & REQ_CMD) 487#define blk_fs_request(rq) ((rq)->flags & REQ_CMD)
456#define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) 488#define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC)
@@ -466,8 +498,7 @@ enum {
466 498
467#define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED) 499#define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED)
468#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) 500#define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER)
469#define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH) 501#define blk_fua_rq(rq) ((rq)->flags & REQ_FUA)
470#define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH)
471 502
472#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) 503#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
473 504
@@ -665,11 +696,12 @@ extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn);
665extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); 696extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *);
666extern void blk_queue_dma_alignment(request_queue_t *, int); 697extern void blk_queue_dma_alignment(request_queue_t *, int);
667extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 698extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
668extern void blk_queue_ordered(request_queue_t *, int); 699extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *);
669extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); 700extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *);
670extern struct request *blk_start_pre_flush(request_queue_t *,struct request *); 701extern int blk_do_ordered(request_queue_t *, struct request **);
671extern int blk_complete_barrier_rq(request_queue_t *, struct request *, int); 702extern unsigned blk_ordered_cur_seq(request_queue_t *);
672extern int blk_complete_barrier_rq_locked(request_queue_t *, struct request *, int); 703extern unsigned blk_ordered_req_seq(struct request *);
704extern void blk_ordered_complete_seq(request_queue_t *, unsigned, int);
673 705
674extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); 706extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *);
675extern void blk_dump_rq_flags(struct request *, char *); 707extern void blk_dump_rq_flags(struct request *, char *);
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index a74c27e460ba..fb80fa44c4dd 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -130,6 +130,7 @@ extern int elv_try_last_merge(request_queue_t *, struct bio *);
130#define ELEVATOR_INSERT_FRONT 1 130#define ELEVATOR_INSERT_FRONT 1
131#define ELEVATOR_INSERT_BACK 2 131#define ELEVATOR_INSERT_BACK 2
132#define ELEVATOR_INSERT_SORT 3 132#define ELEVATOR_INSERT_SORT 3
133#define ELEVATOR_INSERT_REQUEUE 4
133 134
134/* 135/*
135 * return values from elevator_may_queue_fn 136 * return values from elevator_may_queue_fn