diff options
author | Tejun Heo <tj@kernel.org> | 2013-06-12 23:52:35 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-06-13 14:08:27 -0400 |
commit | bc497bd33b2d6a6f07bc8574b4764edbd7fdffa8 (patch) | |
tree | 2425880399cae042dcb7bf9c4fefdbdaf67f6ab5 /include/linux | |
parent | acac7883ee7bcc32476963bce7baf73d44574dd1 (diff) |
percpu-refcount: implement percpu_ref_cancel_init()
Normally, percpu_ref_init() initializes and percpu_ref_kill()
initiates destruction which completes asynchronously. The
asynchronous destruction can be problematic in init failure path where
the caller wants to destroy half-constructed object - distinguishing
half-constructed objects from the usual release method can be painful
for complex objects.
This patch implements percpu_ref_cancel_init() which synchronously
destroys the percpu_ref without invoking release. To avoid
unintentional misuses, the function requires the ref to have finished
percpu_ref_init() but never used and triggers WARN otherwise.
v2: Explain the weird name and usage restriction in the function
comment.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Kent Overstreet <koverstreet@google.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/percpu-refcount.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 8146aa9cd89e..6d843d60690d 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h | |||
@@ -68,6 +68,7 @@ struct percpu_ref { | |||
68 | 68 | ||
69 | int __must_check percpu_ref_init(struct percpu_ref *ref, | 69 | int __must_check percpu_ref_init(struct percpu_ref *ref, |
70 | percpu_ref_func_t *release); | 70 | percpu_ref_func_t *release); |
71 | void percpu_ref_cancel_init(struct percpu_ref *ref); | ||
71 | void percpu_ref_kill(struct percpu_ref *ref); | 72 | void percpu_ref_kill(struct percpu_ref *ref); |
72 | 73 | ||
73 | #define PCPU_STATUS_BITS 2 | 74 | #define PCPU_STATUS_BITS 2 |