Skip to content
Commit b3abd802 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

lockref: add 'lockref_get_or_lock() helper



This behaves like "lockref_get_not_zero()", but instead of doing nothing
if the count was zero, it returns with the lock held.

This allows callers to revalidate the lockref-protected data structure
if required even if the count was zero to begin with, and possibly
increment the count if it passes muster.

In particular, the dentry code wants this when it wants to turn an
RCU-protected dentry into a stable refcounted one: if the dentry count
it zero, but the sequence number still validates the dentry, we can take
a reference to it.

Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 98474236
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