[Drbd-dev] [Patch v1 4/8] Use refcount_t 'atomic' type to implement struct kref

Nick Wang nwang at suse.com
Mon Mar 13 08:23:27 CET 2017


In 10383aea, atomic type for refcount is obsoleted, instead
using refcount_t. Also convert the related call.

Signed-off-by: Nick Wang <nwang at suse.com>
CC: Lars Ellenberg <lars.ellenberg at linbit.com>
CC: Roland Kammerer <roland.kammerer at linbit.com>
CC: drbd-dev at lists.linbit.com 
---
 drbd_wrappers.h           | 5 +++++
 tests/have_refcount_inc.c | 6 ++++++
 2 files changed, 11 insertions(+)
 create mode 100644 tests/have_refcount_inc.c

diff --git a/drbd_wrappers.h b/drbd_wrappers.h
index 1e35aec..cf17d84 100644
--- a/drbd_wrappers.h
+++ b/drbd_wrappers.h
@@ -893,6 +893,11 @@ static inline void blk_queue_write_cache(struct request_queue *q, bool enabled,
 #define REQ_NOIDLE 0
 #endif
 
+#ifndef COMPAT_HAVE_REFCOUNT_INC
+#define refcount_inc(R) atomic_inc(R)
+#define refcount_read(R) atomic_read(R)
+#define refcount_dec_and_test(R) atomic_dec_and_test(R)
+#endif
 
 #ifndef COMPAT_HAVE_BIO_SET_OP_ATTRS /*compat for Linux before 4.8 {{{2 */
 
diff --git a/tests/have_refcount_inc.c b/tests/have_refcount_inc.c
new file mode 100644
index 0000000..38373e7
--- /dev/null
+++ b/tests/have_refcount_inc.c
@@ -0,0 +1,6 @@
+#include <linux/refcount.h>
+
+void test(refcount_t *r)
+{
+	refcount_inc(r);
+}
-- 
1.8.5.6



More information about the drbd-dev mailing list