Whamcloud - gitweb
LU-10769 osd-zfs: fix deadlock on osd_object::oo_guard 11/31511/4
authorFan Yong <fan.yong@intel.com>
Mon, 5 Mar 2018 11:35:02 +0000 (19:35 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 8 Mar 2018 17:35:53 +0000 (17:35 +0000)
commit095643bbd1bb7c70061eaddf7b6413c429322b31
tree499b8b73d01647bcb5e598d90536acf353f683bd
parentd79ffa3ff7461d8dcfb831f0024ed093a3f6f104
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.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Iaac2e414b5f1fd197303bb7ec7d5e2763b6f3e9a
Reviewed-on: https://review.whamcloud.com/31511
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/osd-zfs/osd_internal.h
lustre/osd-zfs/osd_object.c