Whamcloud - gitweb
LU-10769 osd-zfs: fix deadlock on osd_object::oo_guard 14/31514/5
authorFan Yong <fan.yong@intel.com>
Mon, 5 Mar 2018 15:39:29 +0000 (23:39 +0800)
committerJohn L. Hammond <john.hammond@intel.com>
Thu, 5 Apr 2018 20:02:03 +0000 (20:02 +0000)
commit0e51abb8a512213b58579e66a9d74133001877ff
tree9f80c2d36b254682579ef2c52e4d8a7faae5bea5
parent98dbdb50a9f2bd7ddcd61588106703c4df961c0a
LU-10769 osd-zfs: fix deadlock on osd_object::oo_guard

There is race condition inside osd-zfs, it may cause deadlock.
Consider the following scenarios:

1) The Thread1 calls osd_attr_set() to set flags on the object.
   The osd_attr_set() will call the osd_xattr_get() with holding
   the read mode semaphore on the object::oo_guard.

2) The Thread2 calls the osd_declare_destroy() to destroy such
   object, it will down_write() on the object::oo_gurad, but be
   blocked by the Thread1's granted read mode semaphore.

3) The osd_xattr_get() triggered by the osd_xattr_set() will also
   down_read() on the object::oo_guard. But it will be blocked by
   the Thread2's pending down_write() request.

Then the Thread1 and the Thread2 deadlock.
This patch makes the osd_attr_set() to call the lockless version
xattr_get osd_xattr_get_internal() to avoid such deadlock.

Master-change: https://review.whamcloud.com/31511

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Iaac2e414b5f1fd197303bb7ec7d5e2763b6f3e9a
Reviewed-on: https://review.whamcloud.com/31514
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
lustre/osd-zfs/osd_internal.h
lustre/osd-zfs/osd_object.c
lustre/osd-zfs/osd_xattr.c