浏览代码

[S390] dasd: fix refcounting in dasd_change_state

To set a dasd online dasd_change_state is called twice. The first
cycle will schedule initial analysis of the device, set the rc to
-EAGAIN and will not touch the device state any more.
The initial analysis will in turn call dasd_change_state to increase
the state to the final DASD_STATE_ONLINE.

If the dasd_change_state on the second thread outruns the other one
both finish with the state set to DASD_STATE_ONLINE and the device
refcount will be decreased by 2.

Fix this by leaving dasd_change_state on rc == -EAGAIN so that the
refcount will always be decreased by 1.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Sebastian Ott 16 年之前
父节点
当前提交
181d95229b
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      drivers/s390/block/dasd.c

+ 5 - 3
drivers/s390/block/dasd.c

@@ -470,7 +470,7 @@ static int dasd_decrease_state(struct dasd_device *device)
  */
  */
 static void dasd_change_state(struct dasd_device *device)
 static void dasd_change_state(struct dasd_device *device)
 {
 {
-        int rc;
+	int rc;
 
 
 	if (device->state == device->target)
 	if (device->state == device->target)
 		/* Already where we want to go today... */
 		/* Already where we want to go today... */
@@ -479,8 +479,10 @@ static void dasd_change_state(struct dasd_device *device)
 		rc = dasd_increase_state(device);
 		rc = dasd_increase_state(device);
 	else
 	else
 		rc = dasd_decrease_state(device);
 		rc = dasd_decrease_state(device);
-        if (rc && rc != -EAGAIN)
-                device->target = device->state;
+	if (rc == -EAGAIN)
+		return;
+	if (rc)
+		device->target = device->state;
 
 
 	if (device->state == device->target) {
 	if (device->state == device->target) {
 		wake_up(&dasd_init_waitq);
 		wake_up(&dasd_init_waitq);