Commit 181d9522 authored by Sebastian Ott's avatar Sebastian Ott Committed by Martin Schwidefsky

[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: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent e98bbaaf
...@@ -479,7 +479,9 @@ static void dasd_change_state(struct dasd_device *device) ...@@ -479,7 +479,9 @@ 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) if (rc == -EAGAIN)
return;
if (rc)
device->target = device->state; device->target = device->state;
if (device->state == device->target) { if (device->state == device->target) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment