Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef IOCONTEXT_H
2#define IOCONTEXT_H
3
4#include <linux/radix-tree.h>
5#include <linux/rcupdate.h>
6
7struct cfq_queue;
8struct cfq_io_context {
9 void *key;
10
11 struct cfq_queue *cfqq[2];
12
13 struct io_context *ioc;
14
15 unsigned long last_end_request;
16
17 unsigned long ttime_total;
18 unsigned long ttime_samples;
19 unsigned long ttime_mean;
20
21 struct list_head queue_list;
22 struct hlist_node cic_list;
23
24 void (*dtor)(struct io_context *); /* destructor */
25 void (*exit)(struct io_context *); /* called on task exit */
26
27 struct rcu_head rcu_head;
28};
29
30/*
31 * I/O subsystem state of the associated processes. It is refcounted
32 * and kmalloc'ed. These could be shared between processes.
33 */
34struct io_context {
35 atomic_long_t refcount;
36 atomic_t nr_tasks;
37
38 /* all the fields below are protected by this lock */
39 spinlock_t lock;
40
41 unsigned short ioprio;
42 unsigned short ioprio_changed;
43
44#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
45 unsigned short cgroup_changed;
46#endif
47
48 /*
49 * For request batching
50 */
51 int nr_batch_requests; /* Number of requests left in the batch */
52 unsigned long last_waited; /* Time last woken after wait for request */
53
54 struct radix_tree_root radix_root;
55 struct hlist_head cic_list;
56 void *ioc_data;
57};
58
59static inline struct io_context *ioc_task_link(struct io_context *ioc)
60{
61 /*
62 * if ref count is zero, don't allow sharing (ioc is going away, it's
63 * a race).
64 */
65 if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
66 atomic_inc(&ioc->nr_tasks);
67 return ioc;
68 }
69
70 return NULL;
71}
72
73struct task_struct;
74#ifdef CONFIG_BLOCK
75int put_io_context(struct io_context *ioc);
76void exit_io_context(struct task_struct *task);
77struct io_context *get_io_context(gfp_t gfp_flags, int node);
78struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
79void copy_io_context(struct io_context **pdst, struct io_context **psrc);
80#else
81static inline void exit_io_context(struct task_struct *task)
82{
83}
84
85struct io_context;
86static inline int put_io_context(struct io_context *ioc)
87{
88 return 1;
89}
90#endif
91
92#endif