diff options
Diffstat (limited to 'include/linux/iocontext.h')
-rw-r--r-- | include/linux/iocontext.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h index 81a8870ac224..6f1a2608e91f 100644 --- a/include/linux/iocontext.h +++ b/include/linux/iocontext.h | |||
@@ -100,6 +100,7 @@ struct io_cq { | |||
100 | */ | 100 | */ |
101 | struct io_context { | 101 | struct io_context { |
102 | atomic_long_t refcount; | 102 | atomic_long_t refcount; |
103 | atomic_t active_ref; | ||
103 | atomic_t nr_tasks; | 104 | atomic_t nr_tasks; |
104 | 105 | ||
105 | /* all the fields below are protected by this lock */ | 106 | /* all the fields below are protected by this lock */ |
@@ -120,17 +121,34 @@ struct io_context { | |||
120 | struct work_struct release_work; | 121 | struct work_struct release_work; |
121 | }; | 122 | }; |
122 | 123 | ||
123 | static inline void ioc_task_link(struct io_context *ioc) | 124 | /** |
125 | * get_io_context_active - get active reference on ioc | ||
126 | * @ioc: ioc of interest | ||
127 | * | ||
128 | * Only iocs with active reference can issue new IOs. This function | ||
129 | * acquires an active reference on @ioc. The caller must already have an | ||
130 | * active reference on @ioc. | ||
131 | */ | ||
132 | static inline void get_io_context_active(struct io_context *ioc) | ||
124 | { | 133 | { |
125 | WARN_ON_ONCE(atomic_long_read(&ioc->refcount) <= 0); | 134 | WARN_ON_ONCE(atomic_long_read(&ioc->refcount) <= 0); |
126 | WARN_ON_ONCE(atomic_read(&ioc->nr_tasks) <= 0); | 135 | WARN_ON_ONCE(atomic_read(&ioc->active_ref) <= 0); |
127 | atomic_long_inc(&ioc->refcount); | 136 | atomic_long_inc(&ioc->refcount); |
137 | atomic_inc(&ioc->active_ref); | ||
138 | } | ||
139 | |||
140 | static inline void ioc_task_link(struct io_context *ioc) | ||
141 | { | ||
142 | get_io_context_active(ioc); | ||
143 | |||
144 | WARN_ON_ONCE(atomic_read(&ioc->nr_tasks) <= 0); | ||
128 | atomic_inc(&ioc->nr_tasks); | 145 | atomic_inc(&ioc->nr_tasks); |
129 | } | 146 | } |
130 | 147 | ||
131 | struct task_struct; | 148 | struct task_struct; |
132 | #ifdef CONFIG_BLOCK | 149 | #ifdef CONFIG_BLOCK |
133 | void put_io_context(struct io_context *ioc); | 150 | void put_io_context(struct io_context *ioc); |
151 | void put_io_context_active(struct io_context *ioc); | ||
134 | void exit_io_context(struct task_struct *task); | 152 | void exit_io_context(struct task_struct *task); |
135 | struct io_context *get_task_io_context(struct task_struct *task, | 153 | struct io_context *get_task_io_context(struct task_struct *task, |
136 | gfp_t gfp_flags, int node); | 154 | gfp_t gfp_flags, int node); |