From f4d9f0dcf66733229b17a9fe4c6fda97106cde2d Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Wed, 4 Sep 2024 19:26:21 +0200 Subject: [PATCH] Introduce ocf_refcnt_zeroed() Signed-off-by: Robert Baldyga Signed-off-by: Michal Mielewczyk --- src/utils/utils_refcnt.c | 6 ++++++ src/utils/utils_refcnt.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/utils/utils_refcnt.c b/src/utils/utils_refcnt.c index ced88ad..54d0379 100644 --- a/src/utils/utils_refcnt.c +++ b/src/utils/utils_refcnt.c @@ -1,5 +1,6 @@ /* * Copyright(c) 2019-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -68,3 +69,8 @@ bool ocf_refcnt_frozen(struct ocf_refcnt *rc) { return !!env_atomic_read(&rc->freeze); } + +bool ocf_refcnt_zeroed(struct ocf_refcnt *rc) +{ + return (env_atomic_read(&rc->counter) == 0); +} diff --git a/src/utils/utils_refcnt.h b/src/utils/utils_refcnt.h index eca22cc..0871854 100644 --- a/src/utils/utils_refcnt.h +++ b/src/utils/utils_refcnt.h @@ -1,5 +1,6 @@ /* * Copyright(c) 2019-2021 Intel Corporation + * Copyright(c) 2024 Huawei Technologies * SPDX-License-Identifier: BSD-3-Clause */ @@ -40,6 +41,8 @@ void ocf_refcnt_unfreeze(struct ocf_refcnt *rc); bool ocf_refcnt_frozen(struct ocf_refcnt *rc); +bool ocf_refcnt_zeroed(struct ocf_refcnt *rc); + /* Register callback to be called when reference counter drops to 0. * Must be called after counter is frozen. * Cannot be called until previously regsitered callback had fired. */