mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 07:01:23 +00:00
locking/atomic, kref: Implement kref_put_lock()
Because home-rolling your own is _awesome_, stop doing it. Provide kref_put_lock(), just like kref_put_mutex() but for a spinlock. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: linux-kernel@vger.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
parent
23b19ec337
commit
0a13cd1a05
2 changed files with 26 additions and 11 deletions
|
@ -126,13 +126,18 @@ EXPORT_SYMBOL_GPL(svc_auth_unregister);
|
|||
static struct hlist_head auth_domain_table[DN_HASHMAX];
|
||||
static DEFINE_SPINLOCK(auth_domain_lock);
|
||||
|
||||
static void auth_domain_release(struct kref *kref)
|
||||
{
|
||||
struct auth_domain *dom = container_of(kref, struct auth_domain, ref);
|
||||
|
||||
hlist_del(&dom->hash);
|
||||
dom->flavour->domain_release(dom);
|
||||
spin_unlock(&auth_domain_lock);
|
||||
}
|
||||
|
||||
void auth_domain_put(struct auth_domain *dom)
|
||||
{
|
||||
if (atomic_dec_and_lock(&dom->ref.refcount, &auth_domain_lock)) {
|
||||
hlist_del(&dom->hash);
|
||||
dom->flavour->domain_release(dom);
|
||||
spin_unlock(&auth_domain_lock);
|
||||
}
|
||||
kref_put_lock(&dom->ref, auth_domain_release, &auth_domain_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(auth_domain_put);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue