]> git.proxmox.com Git - mirror_zfs.git/commit
Fix z_xattr_lock/z_teardown_lock inversion
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 21 Dec 2015 17:27:24 +0000 (09:27 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 23 Dec 2015 00:59:20 +0000 (16:59 -0800)
commit2ebc7b72b3989ac53c1753f79eaf71d95419c103
treebbbe40243e34ff75c20edc451ce1c0f89f3f50d5
parent228b461b564532123efbf3f6c595494c8cbe7793
Fix z_xattr_lock/z_teardown_lock inversion

There exists a lock inversion between the z_xattr_lock and the
z_teardown_lock.  Resolve this by taking the z_teardown_lock in
all registered xattr callbacks prior to taking the z_xattr_lock.
This ensures the locks are always taken is the same order thus
preventing a deadlock.  Note the z_teardown_lock is taken again
in zfs_lookup() and this is safe because the z_teardown lock is
a re-entrant read reader/writer lock.

* process-1
zpl_xattr_get -> Takes zp->z_xattr_lock
  __zpl_xattr_get
    zfs_lookup -> Takes zsb->z_teardown_lock in ZFS_ENTER macro

* process-2
zfs_ioc_recv -> Takes zsb->z_teardown_lock in zfs_suspend_fs()
  zfs_resume_fs
    zfs_rezget -> Takes zp->z_xattr_lock

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <tuxoko@gmail.com>
Closes #3943
Closes #3969
Closes #4121
module/zfs/zpl_xattr.c