Skip to content

Commit

Permalink
Linux 4.8 compat: Fix RW_READ_HELD
Browse files Browse the repository at this point in the history
Linux 4.8, starting from torvalds/linux@19c5d690e, will set owner to 1 when
read held instead of leave it NULL. So we change the condition to
`rw_owner(rwp) <= 1` in RW_READ_HELD.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes openzfs/zfs#5233
Closes openzfs#577
  • Loading branch information
tuxoko authored and behlendorf committed Feb 1, 2017
1 parent f28d157 commit 1e94383
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/sys/rwlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ rw_owner(krwlock_t *rwp)
static inline int
RW_READ_HELD(krwlock_t *rwp)
{
return (spl_rwsem_is_locked(SEM(rwp)) && rw_owner(rwp) == NULL);
/*
* Linux 4.8 will set owner to 1 when read held instead of leave it
* NULL. So we check whether owner <= 1.
*/
return (spl_rwsem_is_locked(SEM(rwp)) &&
(unsigned long)rw_owner(rwp) <= 1);
}

static inline int
Expand Down

0 comments on commit 1e94383

Please sign in to comment.