From: tuxoko Date: Sat, 8 Oct 2016 03:53:58 +0000 (-0700) Subject: Linux 4.8 compat: Fix RW_READ_HELD X-Git-Tag: zfs-0.8.0-rc1~152^2~76 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2529b3a80e1bf1713c0ecbedb246654a0968b4d2;p=zfs Linux 4.8 compat: Fix RW_READ_HELD 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 Signed-off-by: Chunwei Chen Closes zfsonlinux/zfs#5233 Closes #577 --- diff --git a/include/sys/rwlock.h b/include/sys/rwlock.h index facebe3ba..4197785db 100644 --- a/include/sys/rwlock.h +++ b/include/sys/rwlock.h @@ -114,7 +114,12 @@ spl_rw_lockdep_on_maybe(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