diff options
Diffstat (limited to 'include/linux/iocontext.h')
-rw-r--r-- | include/linux/iocontext.h | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h index 1a3018063034..df38db2ef45b 100644 --- a/include/linux/iocontext.h +++ b/include/linux/iocontext.h | |||
@@ -6,11 +6,7 @@ | |||
6 | #include <linux/workqueue.h> | 6 | #include <linux/workqueue.h> |
7 | 7 | ||
8 | enum { | 8 | enum { |
9 | ICQ_IOPRIO_CHANGED = 1 << 0, | ||
10 | ICQ_CGROUP_CHANGED = 1 << 1, | ||
11 | ICQ_EXITED = 1 << 2, | 9 | ICQ_EXITED = 1 << 2, |
12 | |||
13 | ICQ_CHANGED_MASK = ICQ_IOPRIO_CHANGED | ICQ_CGROUP_CHANGED, | ||
14 | }; | 10 | }; |
15 | 11 | ||
16 | /* | 12 | /* |
@@ -100,6 +96,7 @@ struct io_cq { | |||
100 | */ | 96 | */ |
101 | struct io_context { | 97 | struct io_context { |
102 | atomic_long_t refcount; | 98 | atomic_long_t refcount; |
99 | atomic_t active_ref; | ||
103 | atomic_t nr_tasks; | 100 | atomic_t nr_tasks; |
104 | 101 | ||
105 | /* all the fields below are protected by this lock */ | 102 | /* all the fields below are protected by this lock */ |
@@ -120,29 +117,37 @@ struct io_context { | |||
120 | struct work_struct release_work; | 117 | struct work_struct release_work; |
121 | }; | 118 | }; |
122 | 119 | ||
123 | static inline struct io_context *ioc_task_link(struct io_context *ioc) | 120 | /** |
121 | * get_io_context_active - get active reference on ioc | ||
122 | * @ioc: ioc of interest | ||
123 | * | ||
124 | * Only iocs with active reference can issue new IOs. This function | ||
125 | * acquires an active reference on @ioc. The caller must already have an | ||
126 | * active reference on @ioc. | ||
127 | */ | ||
128 | static inline void get_io_context_active(struct io_context *ioc) | ||
124 | { | 129 | { |
125 | /* | 130 | WARN_ON_ONCE(atomic_long_read(&ioc->refcount) <= 0); |
126 | * if ref count is zero, don't allow sharing (ioc is going away, it's | 131 | WARN_ON_ONCE(atomic_read(&ioc->active_ref) <= 0); |
127 | * a race). | 132 | atomic_long_inc(&ioc->refcount); |
128 | */ | 133 | atomic_inc(&ioc->active_ref); |
129 | if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) { | 134 | } |
130 | atomic_inc(&ioc->nr_tasks); | 135 | |
131 | return ioc; | 136 | static inline void ioc_task_link(struct io_context *ioc) |
132 | } | 137 | { |
138 | get_io_context_active(ioc); | ||
133 | 139 | ||
134 | return NULL; | 140 | WARN_ON_ONCE(atomic_read(&ioc->nr_tasks) <= 0); |
141 | atomic_inc(&ioc->nr_tasks); | ||
135 | } | 142 | } |
136 | 143 | ||
137 | struct task_struct; | 144 | struct task_struct; |
138 | #ifdef CONFIG_BLOCK | 145 | #ifdef CONFIG_BLOCK |
139 | void put_io_context(struct io_context *ioc); | 146 | void put_io_context(struct io_context *ioc); |
147 | void put_io_context_active(struct io_context *ioc); | ||
140 | void exit_io_context(struct task_struct *task); | 148 | void exit_io_context(struct task_struct *task); |
141 | struct io_context *get_task_io_context(struct task_struct *task, | 149 | struct io_context *get_task_io_context(struct task_struct *task, |
142 | gfp_t gfp_flags, int node); | 150 | gfp_t gfp_flags, int node); |
143 | void ioc_ioprio_changed(struct io_context *ioc, int ioprio); | ||
144 | void ioc_cgroup_changed(struct io_context *ioc); | ||
145 | unsigned int icq_get_changed(struct io_cq *icq); | ||
146 | #else | 151 | #else |
147 | struct io_context; | 152 | struct io_context; |
148 | static inline void put_io_context(struct io_context *ioc) { } | 153 | static inline void put_io_context(struct io_context *ioc) { } |