From 6a34f10d815c9be4d334e904356bcafb034b5e1b Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Fri, 10 Feb 2012 02:12:15 +0000 Subject: [PATCH] Cleanup suggested by Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4118 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/dev_handlers/scst_vdisk.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index f91a96f4e..dcc607d8b 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -4569,7 +4569,7 @@ static int vdev_sysfs_process_get_filename(struct scst_sysfs_work_item *work) * under scst_vdisk_mutex. */ while (!mutex_trylock(&scst_vdisk_mutex)) { - if ((volatile bool)(dev->dev_unregistering)) { + if (dev->dev_unregistering) { TRACE_MGMT_DBG("Skipping being unregistered dev %s", dev->virt_name); res = -ENOENT; @@ -4580,6 +4580,18 @@ static int vdev_sysfs_process_get_filename(struct scst_sysfs_work_item *work) goto out_put; } msleep(100); + /* + * We need to reread dev_unregistering from memory, hence + * prevent compiler from putting it in a register. Generally, + * it shouldn't happen, because the compiler isn't allowed to do + * such a transformation if any functions that can cause side + * effects are called between successive accesses, but let's be + * on the safe side. We can't cast dev_unregistering to + * volatile, because it has no effect we need, and can't cast + * it to *(volatile bool*)&, because it isn't possible to get + * address of a bit field. + */ + barrier(); } virt_dev = dev->dh_priv;