blk.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. struct io_context *current_io_context(gfp_t gfp_flags, int node);
  37. int ll_back_merge_fn(struct request_queue *q, struct request *req,
  38. struct bio *bio);
  39. int ll_front_merge_fn(struct request_queue *q, struct request *req,
  40. struct bio *bio);
  41. int attempt_back_merge(struct request_queue *q, struct request *rq);
  42. int attempt_front_merge(struct request_queue *q, struct request *rq);
  43. void blk_recalc_rq_segments(struct request *rq);
  44. void blk_recalc_rq_sectors(struct request *rq, int nsect);
  45. void blk_queue_congestion_threshold(struct request_queue *q);
  46. int blk_dev_init(void);
  47. /*
  48. * Return the threshold (number of used requests) at which the queue is
  49. * considered to be congested. It include a little hysteresis to keep the
  50. * context switch rate down.
  51. */
  52. static inline int queue_congestion_on_threshold(struct request_queue *q)
  53. {
  54. return q->nr_congestion_on;
  55. }
  56. /*
  57. * The threshold at which a queue is considered to be uncongested
  58. */
  59. static inline int queue_congestion_off_threshold(struct request_queue *q)
  60. {
  61. return q->nr_congestion_off;
  62. }
  63. #if defined(CONFIG_BLK_DEV_INTEGRITY)
  64. #define rq_for_each_integrity_segment(bvl, _rq, _iter) \
  65. __rq_for_each_bio(_iter.bio, _rq) \
  66. bip_for_each_vec(bvl, _iter.bio->bi_integrity, _iter.i)
  67. #endif /* BLK_DEV_INTEGRITY */
  68. static inline int blk_cpu_to_group(int cpu)
  69. {
  70. #ifdef CONFIG_SCHED_MC
  71. cpumask_t mask = cpu_coregroup_map(cpu);
  72. return first_cpu(mask);
  73. #elif defined(CONFIG_SCHED_SMT)
  74. return first_cpu(per_cpu(cpu_sibling_map, cpu));
  75. #else
  76. return cpu;
  77. #endif
  78. }
  79. #endif