diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2009-06-22 06:08:21 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2009-06-22 06:08:23 -0400 |
commit | 181d95229b0931ee2ce6aad7348079cbc10e8d05 (patch) | |
tree | 9962496049dad3c4ed5695d09886d0804be51462 /drivers/s390/block | |
parent | e98bbaafcd1c47d30f3245517fb585f1aaaca4db (diff) |
[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>
Diffstat (limited to 'drivers/s390/block')
-rw-r--r-- | drivers/s390/block/dasd.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 99e71536213a..749836668655 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -470,7 +470,7 @@ static int dasd_decrease_state(struct dasd_device *device) | |||
470 | */ | 470 | */ |
471 | static void dasd_change_state(struct dasd_device *device) | 471 | static void dasd_change_state(struct dasd_device *device) |
472 | { | 472 | { |
473 | int rc; | 473 | int rc; |
474 | 474 | ||
475 | if (device->state == device->target) | 475 | if (device->state == device->target) |
476 | /* Already where we want to go today... */ | 476 | /* Already where we want to go today... */ |
@@ -479,8 +479,10 @@ static void dasd_change_state(struct dasd_device *device) | |||
479 | rc = dasd_increase_state(device); | 479 | rc = dasd_increase_state(device); |
480 | else | 480 | else |
481 | rc = dasd_decrease_state(device); | 481 | rc = dasd_decrease_state(device); |
482 | if (rc && rc != -EAGAIN) | 482 | if (rc == -EAGAIN) |
483 | device->target = device->state; | 483 | return; |
484 | if (rc) | ||
485 | device->target = device->state; | ||
484 | 486 | ||
485 | if (device->state == device->target) { | 487 | if (device->state == device->target) { |
486 | wake_up(&dasd_init_waitq); | 488 | wake_up(&dasd_init_waitq); |