Skip to content
Commit bc497bd3 authored by Tejun Heo's avatar Tejun Heo
Browse files

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: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarKent Overstreet <koverstreet@google.com>
parent acac7883
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment