This function allows checking if the cslist has been dropped before
usage.

https://pmc.acronis.work/browse/VSTOR-76384

Signed-off-by: Yuriy Vasilev <yuriy.vasi...@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_map.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/fuse/kio/pcs/pcs_map.h b/fs/fuse/kio/pcs/pcs_map.h
index cadc106d45c1..b8416712fb69 100644
--- a/fs/fuse/kio/pcs/pcs_map.h
+++ b/fs/fuse/kio/pcs/pcs_map.h
@@ -232,6 +232,18 @@ extern unsigned int cs_enable_fanout;
 
 void cslist_destroy(struct pcs_cs_list * csl);
 
+/* Return:
+ * - true if refcnt incrementation is successful;
+ * - false if refcnt is equal to 0, it indicates that the cslist has been 
dropped
+ *   and it is not safe to use it without acquiring the cs->lock
+ */
+static inline bool try_cslist_get(struct pcs_cs_list *csl)
+{
+       TRACE("csl:%p csl->map:%p refcnt:%d\n", csl, csl->map, 
atomic_read(&csl->refcnt));
+
+       return atomic_inc_not_zero(&csl->refcnt);
+}
+
 static inline void cslist_get(struct pcs_cs_list * csl)
 {
        TRACE("csl:%p csl->map:%p refcnt:%d\n", csl, csl->map, 
atomic_read(&csl->refcnt));
-- 
2.34.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to