diff options
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r-- | include/linux/blkdev.h | 96 |
1 files changed, 67 insertions, 29 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a33a31e71bbc..fb0985377421 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -102,7 +102,7 @@ void copy_io_context(struct io_context **pdst, struct io_context **psrc); | |||
102 | void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); | 102 | void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); |
103 | 103 | ||
104 | struct request; | 104 | struct request; |
105 | typedef void (rq_end_io_fn)(struct request *); | 105 | typedef void (rq_end_io_fn)(struct request *, int); |
106 | 106 | ||
107 | struct request_list { | 107 | struct request_list { |
108 | int count[2]; | 108 | int count[2]; |
@@ -184,6 +184,7 @@ struct request { | |||
184 | void *sense; | 184 | void *sense; |
185 | 185 | ||
186 | unsigned int timeout; | 186 | unsigned int timeout; |
187 | int retries; | ||
187 | 188 | ||
188 | /* | 189 | /* |
189 | * For Power Management requests | 190 | * For Power Management requests |
@@ -206,6 +207,7 @@ enum rq_flag_bits { | |||
206 | __REQ_SORTED, /* elevator knows about this request */ | 207 | __REQ_SORTED, /* elevator knows about this request */ |
207 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ | 208 | __REQ_SOFTBARRIER, /* may not be passed by ioscheduler */ |
208 | __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 */ | ||
209 | __REQ_CMD, /* is a regular fs rw request */ | 211 | __REQ_CMD, /* is a regular fs rw request */ |
210 | __REQ_NOMERGE, /* don't touch this for merging */ | 212 | __REQ_NOMERGE, /* don't touch this for merging */ |
211 | __REQ_STARTED, /* drive already may have started this one */ | 213 | __REQ_STARTED, /* drive already may have started this one */ |
@@ -229,9 +231,7 @@ enum rq_flag_bits { | |||
229 | __REQ_PM_SUSPEND, /* suspend request */ | 231 | __REQ_PM_SUSPEND, /* suspend request */ |
230 | __REQ_PM_RESUME, /* resume request */ | 232 | __REQ_PM_RESUME, /* resume request */ |
231 | __REQ_PM_SHUTDOWN, /* shutdown request */ | 233 | __REQ_PM_SHUTDOWN, /* shutdown request */ |
232 | __REQ_BAR_PREFLUSH, /* barrier pre-flush done */ | 234 | __REQ_ORDERED_COLOR, /* is before or after barrier */ |
233 | __REQ_BAR_POSTFLUSH, /* barrier post-flush */ | ||
234 | __REQ_BAR_FLUSH, /* rq is the flush request */ | ||
235 | __REQ_NR_BITS, /* stops here */ | 235 | __REQ_NR_BITS, /* stops here */ |
236 | }; | 236 | }; |
237 | 237 | ||
@@ -240,6 +240,7 @@ enum rq_flag_bits { | |||
240 | #define REQ_SORTED (1 << __REQ_SORTED) | 240 | #define REQ_SORTED (1 << __REQ_SORTED) |
241 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) | 241 | #define REQ_SOFTBARRIER (1 << __REQ_SOFTBARRIER) |
242 | #define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) | 242 | #define REQ_HARDBARRIER (1 << __REQ_HARDBARRIER) |
243 | #define REQ_FUA (1 << __REQ_FUA) | ||
243 | #define REQ_CMD (1 << __REQ_CMD) | 244 | #define REQ_CMD (1 << __REQ_CMD) |
244 | #define REQ_NOMERGE (1 << __REQ_NOMERGE) | 245 | #define REQ_NOMERGE (1 << __REQ_NOMERGE) |
245 | #define REQ_STARTED (1 << __REQ_STARTED) | 246 | #define REQ_STARTED (1 << __REQ_STARTED) |
@@ -259,9 +260,7 @@ enum rq_flag_bits { | |||
259 | #define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) | 260 | #define REQ_PM_SUSPEND (1 << __REQ_PM_SUSPEND) |
260 | #define REQ_PM_RESUME (1 << __REQ_PM_RESUME) | 261 | #define REQ_PM_RESUME (1 << __REQ_PM_RESUME) |
261 | #define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) | 262 | #define REQ_PM_SHUTDOWN (1 << __REQ_PM_SHUTDOWN) |
262 | #define REQ_BAR_PREFLUSH (1 << __REQ_BAR_PREFLUSH) | 263 | #define REQ_ORDERED_COLOR (1 << __REQ_ORDERED_COLOR) |
263 | #define REQ_BAR_POSTFLUSH (1 << __REQ_BAR_POSTFLUSH) | ||
264 | #define REQ_BAR_FLUSH (1 << __REQ_BAR_FLUSH) | ||
265 | 264 | ||
266 | /* | 265 | /* |
267 | * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME | 266 | * State information carried for REQ_PM_SUSPEND and REQ_PM_RESUME |
@@ -291,8 +290,7 @@ struct bio_vec; | |||
291 | typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); | 290 | typedef int (merge_bvec_fn) (request_queue_t *, struct bio *, struct bio_vec *); |
292 | typedef void (activity_fn) (void *data, int rw); | 291 | typedef void (activity_fn) (void *data, int rw); |
293 | typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); | 292 | typedef int (issue_flush_fn) (request_queue_t *, struct gendisk *, sector_t *); |
294 | typedef int (prepare_flush_fn) (request_queue_t *, struct request *); | 293 | typedef void (prepare_flush_fn) (request_queue_t *, struct request *); |
295 | typedef void (end_flush_fn) (request_queue_t *, struct request *); | ||
296 | 294 | ||
297 | enum blk_queue_state { | 295 | enum blk_queue_state { |
298 | Queue_down, | 296 | Queue_down, |
@@ -334,7 +332,6 @@ struct request_queue | |||
334 | activity_fn *activity_fn; | 332 | activity_fn *activity_fn; |
335 | issue_flush_fn *issue_flush_fn; | 333 | issue_flush_fn *issue_flush_fn; |
336 | prepare_flush_fn *prepare_flush_fn; | 334 | prepare_flush_fn *prepare_flush_fn; |
337 | end_flush_fn *end_flush_fn; | ||
338 | 335 | ||
339 | /* | 336 | /* |
340 | * Dispatch queue sorting | 337 | * Dispatch queue sorting |
@@ -419,14 +416,11 @@ struct request_queue | |||
419 | /* | 416 | /* |
420 | * reserved for flush operations | 417 | * reserved for flush operations |
421 | */ | 418 | */ |
422 | struct request *flush_rq; | 419 | unsigned int ordered, next_ordered, ordseq; |
423 | unsigned char ordered; | 420 | int orderr, ordcolor; |
424 | }; | 421 | struct request pre_flush_rq, bar_rq, post_flush_rq; |
425 | 422 | struct request *orig_bar_rq; | |
426 | enum { | 423 | unsigned int bi_size; |
427 | QUEUE_ORDERED_NONE, | ||
428 | QUEUE_ORDERED_TAG, | ||
429 | QUEUE_ORDERED_FLUSH, | ||
430 | }; | 424 | }; |
431 | 425 | ||
432 | #define RQ_INACTIVE (-1) | 426 | #define RQ_INACTIVE (-1) |
@@ -444,12 +438,51 @@ enum { | |||
444 | #define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ | 438 | #define QUEUE_FLAG_REENTER 6 /* Re-entrancy avoidance */ |
445 | #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ | 439 | #define QUEUE_FLAG_PLUGGED 7 /* queue is plugged */ |
446 | #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 */ |
447 | #define QUEUE_FLAG_FLUSH 9 /* doing barrier flush sequence */ | 441 | |
442 | enum { | ||
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 | }; | ||
448 | 481 | ||
449 | #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) |
450 | #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) |
451 | #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) |
452 | #define blk_queue_flushing(q) test_bit(QUEUE_FLAG_FLUSH, &(q)->queue_flags) | 485 | #define blk_queue_flushing(q) ((q)->ordseq) |
453 | 486 | ||
454 | #define blk_fs_request(rq) ((rq)->flags & REQ_CMD) | 487 | #define blk_fs_request(rq) ((rq)->flags & REQ_CMD) |
455 | #define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) | 488 | #define blk_pc_request(rq) ((rq)->flags & REQ_BLOCK_PC) |
@@ -465,8 +498,7 @@ enum { | |||
465 | 498 | ||
466 | #define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED) | 499 | #define blk_sorted_rq(rq) ((rq)->flags & REQ_SORTED) |
467 | #define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) | 500 | #define blk_barrier_rq(rq) ((rq)->flags & REQ_HARDBARRIER) |
468 | #define blk_barrier_preflush(rq) ((rq)->flags & REQ_BAR_PREFLUSH) | 501 | #define blk_fua_rq(rq) ((rq)->flags & REQ_FUA) |
469 | #define blk_barrier_postflush(rq) ((rq)->flags & REQ_BAR_POSTFLUSH) | ||
470 | 502 | ||
471 | #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) | 503 | #define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) |
472 | 504 | ||
@@ -558,7 +590,8 @@ extern void blk_unregister_queue(struct gendisk *disk); | |||
558 | extern void register_disk(struct gendisk *dev); | 590 | extern void register_disk(struct gendisk *dev); |
559 | extern void generic_make_request(struct bio *bio); | 591 | extern void generic_make_request(struct bio *bio); |
560 | extern void blk_put_request(struct request *); | 592 | extern void blk_put_request(struct request *); |
561 | extern void blk_end_sync_rq(struct request *rq); | 593 | extern void __blk_put_request(request_queue_t *, struct request *); |
594 | extern void blk_end_sync_rq(struct request *rq, int error); | ||
562 | extern void blk_attempt_remerge(request_queue_t *, struct request *); | 595 | extern void blk_attempt_remerge(request_queue_t *, struct request *); |
563 | extern struct request *blk_get_request(request_queue_t *, int, gfp_t); | 596 | extern struct request *blk_get_request(request_queue_t *, int, gfp_t); |
564 | extern void blk_insert_request(request_queue_t *, struct request *, int, void *); | 597 | extern void blk_insert_request(request_queue_t *, struct request *, int, void *); |
@@ -579,6 +612,9 @@ extern int blk_rq_map_kern(request_queue_t *, struct request *, void *, unsigned | |||
579 | extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int); | 612 | extern int blk_rq_map_user_iov(request_queue_t *, struct request *, struct sg_iovec *, int); |
580 | extern int blk_execute_rq(request_queue_t *, struct gendisk *, | 613 | extern int blk_execute_rq(request_queue_t *, struct gendisk *, |
581 | struct request *, int); | 614 | struct request *, int); |
615 | extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, | ||
616 | struct request *, int, rq_end_io_fn *); | ||
617 | |||
582 | static inline request_queue_t *bdev_get_queue(struct block_device *bdev) | 618 | static inline request_queue_t *bdev_get_queue(struct block_device *bdev) |
583 | { | 619 | { |
584 | return bdev->bd_disk->queue; | 620 | return bdev->bd_disk->queue; |
@@ -608,7 +644,7 @@ static inline void blk_run_address_space(struct address_space *mapping) | |||
608 | */ | 644 | */ |
609 | extern int end_that_request_first(struct request *, int, int); | 645 | extern int end_that_request_first(struct request *, int, int); |
610 | extern int end_that_request_chunk(struct request *, int, int); | 646 | extern int end_that_request_chunk(struct request *, int, int); |
611 | extern void end_that_request_last(struct request *); | 647 | extern void end_that_request_last(struct request *, int); |
612 | extern void end_request(struct request *req, int uptodate); | 648 | extern void end_request(struct request *req, int uptodate); |
613 | 649 | ||
614 | /* | 650 | /* |
@@ -659,11 +695,12 @@ extern void blk_queue_prep_rq(request_queue_t *, prep_rq_fn *pfn); | |||
659 | extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); | 695 | extern void blk_queue_merge_bvec(request_queue_t *, merge_bvec_fn *); |
660 | extern void blk_queue_dma_alignment(request_queue_t *, int); | 696 | extern void blk_queue_dma_alignment(request_queue_t *, int); |
661 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); | 697 | extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); |
662 | extern void blk_queue_ordered(request_queue_t *, int); | 698 | extern int blk_queue_ordered(request_queue_t *, unsigned, prepare_flush_fn *); |
663 | extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); | 699 | extern void blk_queue_issue_flush_fn(request_queue_t *, issue_flush_fn *); |
664 | extern struct request *blk_start_pre_flush(request_queue_t *,struct request *); | 700 | extern int blk_do_ordered(request_queue_t *, struct request **); |
665 | extern int blk_complete_barrier_rq(request_queue_t *, struct request *, int); | 701 | extern unsigned blk_ordered_cur_seq(request_queue_t *); |
666 | extern int blk_complete_barrier_rq_locked(request_queue_t *, struct request *, int); | 702 | extern unsigned blk_ordered_req_seq(struct request *); |
703 | extern void blk_ordered_complete_seq(request_queue_t *, unsigned, int); | ||
667 | 704 | ||
668 | extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); | 705 | extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); |
669 | extern void blk_dump_rq_flags(struct request *, char *); | 706 | extern void blk_dump_rq_flags(struct request *, char *); |
@@ -696,7 +733,8 @@ extern int blkdev_issue_flush(struct block_device *, sector_t *); | |||
696 | 733 | ||
697 | #define MAX_PHYS_SEGMENTS 128 | 734 | #define MAX_PHYS_SEGMENTS 128 |
698 | #define MAX_HW_SEGMENTS 128 | 735 | #define MAX_HW_SEGMENTS 128 |
699 | #define MAX_SECTORS 255 | 736 | #define SAFE_MAX_SECTORS 255 |
737 | #define BLK_DEF_MAX_SECTORS 1024 | ||
700 | 738 | ||
701 | #define MAX_SEGMENT_SIZE 65536 | 739 | #define MAX_SEGMENT_SIZE 65536 |
702 | 740 | ||