]> git.proxmox.com Git - mirror_spl.git/commit
Implement a proper rw_tryupgrade
authorChunwei Chen <david.chen@osnexus.com>
Wed, 25 May 2016 23:35:42 +0000 (16:35 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 31 May 2016 18:44:15 +0000 (11:44 -0700)
commitf58040c0fc8bc6490fcc75db7fc3e709dfc3c656
tree03aaebb8e0e152ade6edb7a9ae14f4b430314797
parentc60a51b640bab61c54f370752750841675730899
Implement a proper rw_tryupgrade

Current rw_tryupgrade does rw_exit and then rw_tryenter(RW_RWITER), and then
does rw_enter(RW_READER) if it fails. This violate the assumption that
rw_tryupgrade should be atomic and could cause extra contention or even lock
inversion.

This patch we implement a proper rw_tryupgrade. For rwsem-spinlock, we take
the spinlock to check rwsem->count and rwsem->wait_list. For normal rwsem, we
use cmpxchg on rwsem->count to change the value from single reader to single
writer.

Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Closes zfsonlinux/zfs#4692
Closes #554
config/spl-build.m4
include/linux/rwsem_compat.h
include/sys/rwlock.h
module/spl/spl-rwlock.c
module/splat/splat-rwlock.c