diff options
| author | Tejun Heo <tj@kernel.org> | 2012-03-05 16:15:26 -0500 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2012-03-06 15:27:24 -0500 |
| commit | f6e8d01bee036460e03bd4f6a79d014f98ba712e (patch) | |
| tree | acaaab3667e0450f0f05464426c3540c89ce4e18 /include/linux | |
| parent | 3d48749d93a3dce732dd30a14002ab90ec4355f3 (diff) | |
block: add io_context->active_ref
Currently ioc->nr_tasks is used to decide two things - whether an ioc
is done issuing IOs and whether it's shared by multiple tasks. This
patch separate out the first into ioc->active_ref, which is acquired
and released using {get|put}_io_context_active() respectively.
This will be used to associate bio's with a given task. This patch
doesn't introduce any visible behavior change.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux')
| -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 81a8870ac22..6f1a2608e91 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); |
