Inside block layer, we need to support to allocate request with RQF_PREEMPT even though queue is frozen. So introduce this helper for checking if queue is frozen. Cc: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- include/linux/percpu-refcount.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index c13dceb87b60..08549bbf4080 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -324,4 +324,21 @@ static inline bool percpu_ref_is_zero(struct percpu_ref *ref) return !atomic_long_read(&ref->count); } +/** + * percpu_ref_is_dead - test whether a percpu refcount is killed + * @ref: percpu_ref to test + * + * Returns %true if @ref is dead + * + * This function is safe to call as long as @ref is between init and exit. + */ +static inline bool percpu_ref_is_dead(struct percpu_ref *ref) +{ + unsigned long __percpu *percpu_count; + + if (__ref_is_percpu(ref, &percpu_count)) + return false; + return ref->percpu_count_ptr & __PERCPU_REF_DEAD; +} + #endif -- 2.9.5