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. */