blk.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef BLK_INTERNAL_H
  2. #define BLK_INTERNAL_H
  3. /* Amount of time in which a process may batch requests */
  4. #define BLK_BATCH_TIME (HZ/50UL)
  5. /* Number of requests a "batching" process may submit */
  6. #define BLK_BATCH_REQ 32
  7. extern struct kmem_cache *blk_requestq_cachep;
  8. extern struct kobj_type blk_queue_ktype;
  9. void init_request_from_bio(struct request *req, struct bio *bio);
  10. void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
  11. struct bio *bio);
  12. void __blk_queue_free_tags(struct request_queue *q);
  13. void blk_unplug_work(struct work_struct *work);
  14. void blk_unplug_timeout(unsigned long data);
  15. void blk_rq_timed_out_timer(unsigned long data);
  16. void blk_delete_timer(struct request *);
  17. void blk_add_timer(struct request *);
  18. /*
  19. * Internal atomic flags for request handling
  20. */
  21. enum rq_atomic_flags {
  22. REQ_ATOM_COMPLETE = 0,
  23. };
  24. /*
  25. * EH timer and IO completion will both attempt to 'grab' the request, make
  26. * sure that only one of them suceeds
  27. */
  28. static inline int blk_mark_rq_complete(struct request *rq)
  29. {
  30. return test_and_set_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
  31. }
  32. static inline void blk_clear_rq_complete(struct request *rq)
  33. {
  34. clear_bit(REQ_ATOM_COMPLETE, &rq->atomic_flags);
  35. }
  36. #ifdef CONFIG_FAIL_IO_TIMEOUT
  37. int blk_should_fake_timeout(struct request_queue *);
  38. ssize_t part_timeout_show(struct device *, struct device_attribute *, char *);
  39. ssize_t part_timeout_store(struct device *, struct device_attribute *,
  40. const char *, size_t);
  41. #else
  42. static inline int blk_should_fake_timeout(struct request_queue *q)
  43. {
  44. return 0;
  45. }
  46. #endif
  47. struct io_context *current_io_context(gfp_t gfp_flags, int node);
  48. int ll_back_merge_fn(struct request_queue *q, struct request *req,
  49. struct bio *bio);
  50. int ll_front_merge_fn(struct request_queue *q, struct request *req,
  51. struct bio *bio);
  52. int attempt_back_merge(struct request_queue *q, struct request *rq);
  53. int attempt_front_merge(struct request_queue *q, struct request *rq);
  54. void blk_recalc_rq_segments(struct request *rq);
  55. void blk_recalc_rq_sectors(struct request *rq, int nsect);
  56. void blk_queue_congestion_threshold(struct request_queue *q);
  57. int blk_dev_init(void);
  58. /*
  59. * Return the threshold (number of used requests) at which the queue is
  60. * considered to be congested. It include a little hysteresis to keep the
  61. * context switch rate down.
  62. */
  63. static inline int queue_congestion_on_threshold(struct request_queue *q)
  64. {
  65. return q->nr_congestion_on;
  66. }
  67. /*
  68. * The threshold at which a queue is considered to be uncongested
  69. */
  70. static inline int queue_congestion_off_threshold(struct request_queue *q)
  71. {
  72. return q->nr_congestion_off;
  73. }
  74. #if defined(CONFIG_BLK_DEV_INTEGRITY)
  75. #define rq_for_each_integrity_segment(bvl, _rq, _iter) \
  76. __rq_for_each_bio(_iter.bio, _rq) \
  77. bip_for_each_vec(bvl, _iter.bio->bi_integrity, _iter.i)
  78. #endif /* BLK_DEV_INTEGRITY */
  79. static inline int blk_cpu_to_group(int cpu)
  80. {
  81. #ifdef CONFIG_SCHED_MC
  82. cpumask_t mask = cpu_coregroup_map(cpu);
  83. return first_cpu(mask);
  84. #elif defined(CONFIG_SCHED_SMT)
  85. return first_cpu(per_cpu(cpu_sibling_map, cpu));
  86. #else
  87. return cpu;
  88. #endif
  89. }
  90. #endif