diff --git a/module/zfs/zap.c b/module/zfs/zap.c index 454b4be62ed3..005b5d7c5609 100644 --- a/module/zfs/zap.c +++ b/module/zfs/zap.c @@ -129,10 +129,20 @@ zap_tryupgradedir(zap_t *zap, dmu_tx_t *tx) { if (RW_WRITE_HELD(&zap->zap_rwlock)) return (1); + +#ifndef __linux__ + /* + * Unsafe under Linux because the rw_tryupgrade() implementation must + * release the lock before attempting to upgrade. This can result in + * a lock inversion with the l_rwlock unless the leaf lock is dropped + * first and reaquired. Rather than restruct this code disable this + * minor optimization under Linux. + */ if (rw_tryupgrade(&zap->zap_rwlock)) { dmu_buf_will_dirty(zap->zap_dbuf, tx); return (1); } +#endif return (0); }