Whamcloud - gitweb
LU-11617 mdc: fix possible deadlock in chlg_open() 72/33572/3
authorNeilBrown <neilb@suse.com>
Sun, 4 Nov 2018 20:42:51 +0000 (15:42 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 9 Aug 2019 04:41:38 +0000 (04:41 +0000)
commit206b21741b07a10269bbcfdac28743591b64ab2f
tree083d7503b40b71d65db40d1fcd5a95c1aaa2b169
parent544701a782fba39f669e5d764be36755073a1a9a
LU-11617 mdc: fix possible deadlock in chlg_open()

Lockdep reports a possible deadlock between chlg_open() and
mdc_changelog_cdev_init()

mdc_changelog_cdev_init() takes chlg_registered_dev_lock and then
calls misc_register() which takes misc_mtx.
chlg_open() is called while misc_mtx is held, and tries to take
chlg_registered_dev_lock.
If these two functions race, a deadlock can occur as each thread will
hold one of the locks while trying to take the other.

chlg_open() does not need to take a lock.  It only uses the
lock to stablize a list while looking for the matching
chlg_registered_dev, and this can be found directly by examining
file->private_data.

So remove chlg_obd_get(), and use file->private_data to find the
obd_device.
Also ensure the device is fully initialized before calling
misc_register().  This means setting up some list linkage before the
call, and tearing it down if there is an error.

Change-Id: Ibe099f23a08fa3ef846d4ef8fcb85659f8f99245
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/33572
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdc/mdc_changelog.c