Skip to content

Commit

Permalink
linux 4.11 compat: avoid refcount_t name conflict
Browse files Browse the repository at this point in the history
Linux 4.11 introduces a new type, refcount_t, which conflicts with the
type of the same name defined within ZFS.

Since the ZFS code never refers to the linux type, the ZFS type can be
renamed.

Rather than touching all the ZFS code that uses refcount_t, rename the
type at compile time to zfs_refcount_t via a #define macro.

Fixes #5823

Signed-off-by: Olaf Faaland <[email protected]>
  • Loading branch information
ofaaland committed Feb 27, 2017
1 parent 66eead5 commit a186ade
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
33 changes: 33 additions & 0 deletions include/sys/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,39 @@ typedef struct reference {
uint8_t *ref_removed;
} reference_t;

/*
* Starting with 4.11, the linux kernel defines a refcount_t type of its
* own. This macro effectively renames the refcount_t type defined within
* zfs so that it does not conflict, without requiring that the name of the
* type be changed within the ZFS code. It also renames the functions
* that operate on the type as some of their names likely also conflict, and
* doing this for all cases makes it clearer to anyone changing the interface
* in the future.
*/

#define refcount_t zfs_refcount_t

#define refcount_add zfs_refcount_add
#define refcount_add_many zfs_refcount_add_many
#define refcount_count zfs_refcount_count
#define refcount_create zfs_refcount_create
#define refcount_create_tracked zfs_refcount_create_tracked
#define refcount_create_untracked zfs_refcount_create_untracked
#define refcount_destroy zfs_refcount_destroy
#define refcount_destroy_many zfs_refcount_destroy_many
#define refcount_fini zfs_refcount_fini
#define refcount_held zfs_refcount_held
#define refcount_init zfs_refcount_init
#define refcount_is_zero zfs_refcount_is_zero
#define refcount_not_held zfs_refcount_not_held
#define refcount_remove zfs_refcount_remove
#define refcount_remove_many zfs_refcount_remove_many
#define refcount_transfer zfs_refcount_transfer
#define refcount_transfer_ownership zfs_refcount_transfer_ownership

/*
* end linux 4.11 compat
*/
typedef struct refcount {
kmutex_t rc_mtx;
boolean_t rc_tracked;
Expand Down
3 changes: 2 additions & 1 deletion man/man8/zdb.8
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ transaction type.
.sp .6
.RS 4n
Read the vdev labels from the specified device. \fBzdb -l\fR will return 0 if
valid label was found, 1 if error occured, and 2 if no valid labels were found.
valid configuration nvlist was found, 1 if error occured, and 2 if no valid
labels were found.
.P
If the \fB-u\fR option is also specified, also display the uberblocks on this
device.
Expand Down

0 comments on commit a186ade

Please sign in to comment.