summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2003-07-04 19:37:19 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-07-04 19:37:19 -0700
commit16f88dbdbffa3dc52b959706e6a311a932b51ed6 (patch)
tree388bc4d9ad1e53f456d830fc8b5ac6145b7b51e6 /include
parent80af89ca709d4dfe41178abe29217a0fefa1af12 (diff)
[PATCH] generic io contexts
From: Nick Piggin <piggin@cyberone.com.au> Generalise the AS-specific per-process IO context so that other IO schedulers could use it.
Diffstat (limited to 'include')
-rw-r--r--include/linux/blkdev.h44
-rw-r--r--include/linux/sched.h6
2 files changed, 47 insertions, 3 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d3a8f6ecd806..13116a7a7969 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -24,6 +24,50 @@ struct request_pm_state;
#define BLKDEV_MIN_RQ 4
#define BLKDEV_MAX_RQ 128 /* Default maximum */
+/*
+ * This is the per-process anticipatory I/O scheduler state.
+ */
+struct as_io_context {
+ spinlock_t lock;
+
+ void (*dtor)(struct as_io_context *aic); /* destructor */
+ void (*exit)(struct as_io_context *aic); /* called on task exit */
+
+ unsigned long state;
+ atomic_t nr_queued; /* queued reads & sync writes */
+ atomic_t nr_dispatched; /* number of requests gone to the drivers */
+
+ /* IO History tracking */
+ /* Thinktime */
+ unsigned long last_end_request;
+ unsigned long ttime_total;
+ unsigned long ttime_samples;
+ unsigned long ttime_mean;
+ /* Layout pattern */
+ long seek_samples;
+ sector_t last_request_pos;
+ sector_t seek_total;
+ sector_t seek_mean;
+};
+
+/*
+ * This is the per-process I/O subsystem state. It is refcounted and
+ * kmalloc'ed. Currently all fields are modified in process io context
+ * (apart from the atomic refcount), so require no locking.
+ */
+struct io_context {
+ atomic_t refcount;
+ pid_t pid;
+
+ struct as_io_context *aic;
+};
+
+void put_io_context(struct io_context *ioc);
+void exit_io_context(void);
+struct io_context *get_io_context(void);
+void copy_io_context(struct io_context **pdst, struct io_context **psrc);
+void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
+
struct request_list {
int count[2];
mempool_t *rq_pool;
diff --git a/include/linux/sched.h b/include/linux/sched.h
index e29f9606c2aa..750f2a12cada 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -321,8 +321,8 @@ struct k_itimer {
};
-struct as_io_context; /* Anticipatory scheduler */
-void exit_as_io_context(void);
+struct io_context; /* See blkdev.h */
+void exit_io_context(void);
struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
@@ -452,7 +452,7 @@ struct task_struct {
struct dentry *proc_dentry;
struct backing_dev_info *backing_dev_info;
- struct as_io_context *as_io_context;
+ struct io_context *io_context;
unsigned long ptrace_message;
siginfo_t *last_siginfo; /* For ptrace use. */