struct bio_rqueue {
struct list_head list;
uint64_t request_count;
bool dirty;
};
struct bio_scheduler {
struct block_device *disk;
struct mutex lock;
uint64_t total_requests;
struct bio_rqueue queues[BIO_SCHED_LEVELS];
bool defer_pending;
};
struct bio_scheduler_ops {
bool (*should_coalesce)(struct block_device *dev, const struct bio_request *a, const struct bio_request *b);
void (*do_coalesce)(struct block_device *dev, struct bio_request *into, struct bio_request *from);
void (*reorder)(struct block_device *dev);
uint32_t max_wait_time[BIO_SCHED_LEVELS];
uint32_t dispatch_threshold;
uint64_t boost_occupance_limit[BIO_SCHED_LEVELS];
uint64_t tick_ms;
uint64_t min_wait_ms;
};
bool noop_should_coalesce(struct block_device *disk, const struct bio_request *a, const struct bio_request *b);
void noop_do_coalesce(struct block_device *disk, struct bio_request *into, struct bio_request *from);
void noop_reorder(struct block_device *disk);
void bio_sched_enqueue(struct block_device *disk, struct bio_request *req);
void bio_sched_dequeue(struct block_device *disk, struct bio_request *req, bool already_locked);
void bio_sched_enqueue_internal(struct bio_scheduler *sched, struct bio_request *req);
void bio_sched_dequeue_internal(struct bio_scheduler *sched, struct bio_request *req);
void bio_sched_dispatch_partial(struct block_device *disk, enum bio_request_priority prio);
void bio_sched_dispatch_all(struct block_device *disk);
void bio_sched_try_early_dispatch(struct bio_scheduler *sched);
bool bio_sched_try_coalesce(struct bio_scheduler *sched);
bool bio_sched_boost_starved(struct bio_scheduler *sched);
struct bio_scheduler * bio_sched_create(struct block_device *disk, struct bio_scheduler_ops *ops);
void update_request_timestamp(struct bio_request *req);
bool submit_if_urgent(struct bio_scheduler *sched, struct bio_request *req);
bool sched_is_empty(struct bio_scheduler *sched);
bool submit_if_skip_sched(struct bio_scheduler *sched, struct bio_request *req);
#define BIO_SCHED_LEVELS 5
#define BIO_SCHED_MAX (BIO_SCHED_LEVELS - 1)
#define BIO_SCHED_STARVATION_BOOST 1
#define BIO_SCHED_BOOST_SHIFT_LIMIT 4
#define BIO_SCHED_COALESCE_SCAN_LIMIT 8
#define BIO_SCHED_MAX_BOOST_SCAN 32
#define BIO_SCHED_MAX_COALESCES 4