summaryrefslogtreecommitdiffstats
path: root/include/sys
diff options
context:
space:
mode:
authorOlaf Faaland <[email protected]>2017-02-28 16:10:18 -0800
committerBrian Behlendorf <[email protected]>2017-02-28 16:10:18 -0800
commit4859fe796c5b03687a7b2ab3735b882c4f5cad66 (patch)
tree197549665cc7fe999404a268da9fc6d44501b308 /include/sys
parent912e2ba92f45b61df476e7e15da33e0ea3eb0ae5 (diff)
Linux 4.11 compat: avoid refcount_t name conflict
Linux 4.11 introduces a new type, refcount_t, which conflicts with the type of the same name defined within ZFS. Rename the ZFS type zfs_refcount_t. Within the ZFS code, use a macro to cause references to refcount_t to be changed to zfs_refcount_t at compile time. This reduces conflicts when later landing OpenZFS patches. Reviewed-by: George Melikov <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Olaf Faaland <[email protected]> Closes #5823 Closes #5842
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/refcount.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/include/sys/refcount.h b/include/sys/refcount.h
index 3f50cddb6..a96220b29 100644
--- a/include/sys/refcount.h
+++ b/include/sys/refcount.h
@@ -41,6 +41,17 @@ extern "C" {
*/
#define FTAG ((char *)__func__)
+/*
+ * Starting with 4.11, torvalds/linux@f405df5, the linux kernel defines a
+ * refcount_t type of its own. The macro below effectively changes references
+ * in the ZFS code from refcount_t to zfs_refcount_t at compile time, so that
+ * existing code need not be altered, reducing conflicts when landing openZFS
+ * patches.
+ */
+
+#define refcount_t zfs_refcount_t
+#define refcount_add zfs_refcount_add
+
#ifdef ZFS_DEBUG
typedef struct reference {
list_node_t ref_link;
@@ -56,7 +67,7 @@ typedef struct refcount {
list_t rc_removed;
uint64_t rc_count;
uint64_t rc_removed_count;
-} refcount_t;
+} zfs_refcount_t;
/* Note: refcount_t must be initialized with refcount_create[_untracked]() */
@@ -67,7 +78,7 @@ void refcount_destroy(refcount_t *rc);
void refcount_destroy_many(refcount_t *rc, uint64_t number);
int refcount_is_zero(refcount_t *rc);
int64_t refcount_count(refcount_t *rc);
-int64_t refcount_add(refcount_t *rc, void *holder_tag);
+int64_t zfs_refcount_add(refcount_t *rc, void *holder_tag);
int64_t refcount_remove(refcount_t *rc, void *holder_tag);
int64_t refcount_add_many(refcount_t *rc, uint64_t number, void *holder_tag);
int64_t refcount_remove_many(refcount_t *rc, uint64_t number, void *holder_tag);
@@ -92,7 +103,7 @@ typedef struct refcount {
#define refcount_destroy_many(rc, number) ((rc)->rc_count = 0)
#define refcount_is_zero(rc) ((rc)->rc_count == 0)
#define refcount_count(rc) ((rc)->rc_count)
-#define refcount_add(rc, holder) atomic_inc_64_nv(&(rc)->rc_count)
+#define zfs_refcount_add(rc, holder) atomic_inc_64_nv(&(rc)->rc_count)
#define refcount_remove(rc, holder) atomic_dec_64_nv(&(rc)->rc_count)
#define refcount_add_many(rc, number, holder) \
atomic_add_64_nv(&(rc)->rc_count, number)