]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - lib/percpu-refcount.c
percpu-refcount: implement percpu_ref_cancel_init()
authorTejun Heo <tj@kernel.org>
Thu, 13 Jun 2013 03:52:35 +0000 (20:52 -0700)
committerTejun Heo <tj@kernel.org>
Thu, 13 Jun 2013 18:08:27 +0000 (11:08 -0700)
commitbc497bd33b2d6a6f07bc8574b4764edbd7fdffa8
tree2425880399cae042dcb7bf9c4fefdbdaf67f6ab5
parentacac7883ee7bcc32476963bce7baf73d44574dd1
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>
include/linux/percpu-refcount.h
lib/percpu-refcount.c