From eb34335f2fead86c4f877a1aef5b3c2180ec7946 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 9 Feb 2021 03:42:26 +0000 Subject: [PATCH] scst: Suppress a warning in scst_cm_update_dev() Suppress the following warning: WARNING: CPU: 0 PID: 6998 at scst/src/scst_copy_mgr.c:2672 scst_cm_update_dev+0xdc/0x110 This warning can be triggered during unregistration of a virtual device with the following test case: 1. Change a parameter of the virtual device, e.g. the USN. 2. Delete the LUN. That triggers the following sequence: 1. vdev_del_device() 2. scst_unregister_virtual_device() 3. scst_acg_del_lun() 4. cancel the work struct associated with vdev_inq_changed_fn(). 5. visk_detach() 6. vdev_del_device() finishes. vdev_inq_changed_fn() may get called after a LUN has been unregistered from the copy manager and before device deletion finishes. Reported-by: Gleb Chesnokov git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9341 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_copy_mgr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_copy_mgr.c b/scst/src/scst_copy_mgr.c index 68e081b8a..fd1f35e62 100644 --- a/scst/src/scst_copy_mgr.c +++ b/scst/src/scst_copy_mgr.c @@ -2669,8 +2669,13 @@ void scst_cm_update_dev(struct scst_device *dev) spin_unlock_bh(&dev->dev_lock); lun = scst_cm_get_lun(dev); - if (WARN_ON_ONCE(lun == SCST_MAX_LUN)) + if (lun == SCST_MAX_LUN) { + /* + * Verify that scst_unregister_virtual_device() is in progress. + */ + WARN_ON_ONCE(!dev->remove_completion); goto out_unblock; + } rc = scst_cm_send_init_inquiry(dev, lun, NULL); if (rc != 0)