scst: Make device deletion again synchronous

Some scripts that use the SCST sysfs interface depend on filp_close()
having been called before device deletion via the sysfs interface
finishes. Hence make device deletion again synchronous.


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8510 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2019-08-19 02:59:18 +00:00
parent 377e720b26
commit 740f3a6e63
3 changed files with 16 additions and 0 deletions
+3
View File
@@ -2892,6 +2892,9 @@ struct scst_device {
*/
struct percpu_ref refcnt;
/* Triggered when refcnt drops to zero. */
struct completion *remove_completion;
struct work_struct free_work;
/*
+3
View File
@@ -4218,7 +4218,10 @@ static void scst_free_device(struct work_struct *work)
static void scst_release_device(struct percpu_ref *ref)
{
struct scst_device *dev = container_of(ref, typeof(*dev), refcnt);
struct completion *c = dev->remove_completion;
if (c)
complete(c);
schedule_work(&dev->free_work);
}
+10
View File
@@ -1179,6 +1179,7 @@ static void scst_unregister_device(struct scsi_device *scsidp)
{
struct scst_device *dev;
struct scst_acg_dev *acg_dev, *aa;
DECLARE_COMPLETION_ONSTACK(c);
TRACE_ENTRY();
@@ -1207,6 +1208,8 @@ static void scst_unregister_device(struct scsi_device *scsidp)
scst_acg_del_lun(acg_dev->acg, acg_dev->lun, true);
}
dev->remove_completion = &c;
mutex_unlock(&scst_mutex);
scst_dev_sysfs_del(dev);
@@ -1218,6 +1221,8 @@ static void scst_unregister_device(struct scsi_device *scsidp)
percpu_ref_kill(&dev->refcnt);
percpu_ref_put(&dev->refcnt);
wait_for_completion(&c);
out:
TRACE_EXIT();
return;
@@ -1441,6 +1446,7 @@ void scst_unregister_virtual_device(int id,
{
struct scst_device *d, *dev = NULL;
struct scst_acg_dev *acg_dev, *aa;
DECLARE_COMPLETION_ONSTACK(c);
TRACE_ENTRY();
@@ -1473,6 +1479,8 @@ void scst_unregister_virtual_device(int id,
scst_acg_del_lun(acg_dev->acg, acg_dev->lun, true);
}
dev->remove_completion = &c;
mutex_unlock(&scst_mutex);
scst_dev_sysfs_del(dev);
@@ -1486,6 +1494,8 @@ void scst_unregister_virtual_device(int id,
percpu_ref_kill(&dev->refcnt);
percpu_ref_put(&dev->refcnt);
wait_for_completion(&c);
out:
TRACE_EXIT();
return;