]> git.baikalelectronics.ru Git - kernel.git/commit
lockref: add 'lockref_get_or_lock() helper
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 2 Sep 2013 18:14:19 +0000 (11:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 2 Sep 2013 18:14:19 +0000 (11:14 -0700)
commit3ca2b7185b68f6785c2309a89622ab00a8ad1dfb
tree0120474080dfd6664a84beae85d3a2a1b0778e24
parent1b799904fa9d0c66e81f8ce7cb6623894a85248f
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: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/lockref.h