/*
* Anticipatory & deadline i/o scheduler.
*
* Copyright (C) 2002 Jens Axboe <axboe@kernel.dk>
* Nick Piggin <nickpiggin@yahoo.com.au>
*
*/
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include <linux/bio.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/compiler.h>
#include <linux/rbtree.h>
#include <linux/interrupt.h>
#define REQ_SYNC 1
#define REQ_ASYNC 0
/*
* See Documentation/block/as-iosched.txt
*/
/*
* max time before a read is submitted.
*/
#define default_read_expire (HZ / 8)
/*
* ditto for writes, these limits are not hard, even
* if the disk is capable of satisfying them.
*/
#define default_write_expire (HZ / 4)
/*
* read_batch_expire describes how long we will allow a stream of reads to
* persist before looking to see whether it is time to switch over to writes.
*/
#define default_read_batch_expire (HZ / 2)
/*
* write_batch_expire describes how long we want a stream of writes to run for.
* This is not a hard limit, but a target we set for the auto-tuning thingy.
* See, the problem is: we can send a lot of writes to disk cache / TCQ in
* a short amount of time...
*/
#define default_write_batch_expire (HZ / 8)
/*
* max time we may wait to anticipate a read (default around 6ms)
*/
#define default_antic_expire ((HZ / 150) ? HZ / 150 : 1)
/*
* Keep track of up to 20ms thinktimes. We can go as big as we like here,
* however huge values tend to interfere and not decay fast enough. A program
* might be in a non-io phase of operation. Waiting on user input for example,
* or doing a lengthy computation. A small penalty can be justified there, and
* will still catch out those processes that constantly have large thinktimes.
*/
#define MAX_THINKTIME (HZ/50UL)
/* Bits in as_io_context.state */
enum as_io_states {
AS_TASK_RUNNING=0,