Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] linux 4.11 compat: avoid refcount_t name conflict #5842

Merged
merged 1 commit into from
Mar 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions include/sys/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]() */

Expand All @@ -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);
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/refcount.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
}

int64_t
refcount_add(refcount_t *rc, void *holder)
zfs_refcount_add(refcount_t *rc, void *holder)
{
return (refcount_add_many(rc, 1, holder));
}
Expand Down