diff options
author | Stefan Haberland <stefan.haberland@de.ibm.com> | 2009-10-06 04:34:15 -0400 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2009-10-06 04:35:11 -0400 |
commit | 6fca97a958bc3c67566aa91eafc6a5be2e66d6b3 (patch) | |
tree | 9e5ca7c9c3d14c45f469feb58cab15212cee9d6b /drivers | |
parent | af9d2ff9afaae8040dbf09238b2579f92c93579e (diff) |
[S390] dasd: fix race condition in resume code
There is a race while re-reading the device characteristics. After
cleaning the memory area a cqr is build which reads the device
characteristics. This may take a rather long time and the device
characteristics structure is zero during this. Now it could be
possible that the block tasklet starts working and a new cqr will be
build. The build_cp command refers to the device characteristics
structure and this may lead into a divide by zero exception.
Fix this by re-reading the device characteristics into a temporary
structur and copy the data to the original structure. Also take the
ccwdev_lock.
Signed-off-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/s390/block/dasd.c | 5 | ||||
-rw-r--r-- | drivers/s390/block/dasd_eckd.c | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index dad0449475b6..53b8c255360a 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -2508,8 +2508,6 @@ int dasd_generic_restore_device(struct ccw_device *cdev) | |||
2508 | device->stopped &= ~DASD_UNRESUMED_PM; | 2508 | device->stopped &= ~DASD_UNRESUMED_PM; |
2509 | 2509 | ||
2510 | dasd_schedule_device_bh(device); | 2510 | dasd_schedule_device_bh(device); |
2511 | if (device->block) | ||
2512 | dasd_schedule_block_bh(device->block); | ||
2513 | 2511 | ||
2514 | if (device->discipline->restore) | 2512 | if (device->discipline->restore) |
2515 | rc = device->discipline->restore(device); | 2513 | rc = device->discipline->restore(device); |
@@ -2520,6 +2518,9 @@ int dasd_generic_restore_device(struct ccw_device *cdev) | |||
2520 | */ | 2518 | */ |
2521 | device->stopped |= DASD_UNRESUMED_PM; | 2519 | device->stopped |= DASD_UNRESUMED_PM; |
2522 | 2520 | ||
2521 | if (device->block) | ||
2522 | dasd_schedule_block_bh(device->block); | ||
2523 | |||
2523 | dasd_put_device(device); | 2524 | dasd_put_device(device); |
2524 | return 0; | 2525 | return 0; |
2525 | } | 2526 | } |
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index ab3521755588..0be7c15f45c5 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c | |||
@@ -2338,6 +2338,8 @@ static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev, | |||
2338 | /* Calculate number of blocks/records per track. */ | 2338 | /* Calculate number of blocks/records per track. */ |
2339 | blksize = block->bp_block; | 2339 | blksize = block->bp_block; |
2340 | blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize); | 2340 | blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize); |
2341 | if (blk_per_trk == 0) | ||
2342 | return ERR_PTR(-EINVAL); | ||
2341 | /* Calculate record id of first and last block. */ | 2343 | /* Calculate record id of first and last block. */ |
2342 | first_rec = first_trk = blk_rq_pos(req) >> block->s2b_shift; | 2344 | first_rec = first_trk = blk_rq_pos(req) >> block->s2b_shift; |
2343 | first_offs = sector_div(first_trk, blk_per_trk); | 2345 | first_offs = sector_div(first_trk, blk_per_trk); |
@@ -3211,6 +3213,7 @@ int dasd_eckd_pm_freeze(struct dasd_device *device) | |||
3211 | int dasd_eckd_restore_device(struct dasd_device *device) | 3213 | int dasd_eckd_restore_device(struct dasd_device *device) |
3212 | { | 3214 | { |
3213 | struct dasd_eckd_private *private; | 3215 | struct dasd_eckd_private *private; |
3216 | struct dasd_eckd_characteristics temp_rdc_data; | ||
3214 | int is_known, rc; | 3217 | int is_known, rc; |
3215 | struct dasd_uid temp_uid; | 3218 | struct dasd_uid temp_uid; |
3216 | 3219 | ||
@@ -3245,15 +3248,17 @@ int dasd_eckd_restore_device(struct dasd_device *device) | |||
3245 | dasd_eckd_read_features(device); | 3248 | dasd_eckd_read_features(device); |
3246 | 3249 | ||
3247 | /* Read Device Characteristics */ | 3250 | /* Read Device Characteristics */ |
3248 | memset(&private->rdc_data, 0, sizeof(private->rdc_data)); | ||
3249 | rc = dasd_generic_read_dev_chars(device, DASD_ECKD_MAGIC, | 3251 | rc = dasd_generic_read_dev_chars(device, DASD_ECKD_MAGIC, |
3250 | &private->rdc_data, 64); | 3252 | &temp_rdc_data, 64); |
3251 | if (rc) { | 3253 | if (rc) { |
3252 | DBF_EVENT(DBF_WARNING, | 3254 | DBF_EVENT(DBF_WARNING, |
3253 | "Read device characteristics failed, rc=%d for " | 3255 | "Read device characteristics failed, rc=%d for " |
3254 | "device: %s", rc, dev_name(&device->cdev->dev)); | 3256 | "device: %s", rc, dev_name(&device->cdev->dev)); |
3255 | goto out_err; | 3257 | goto out_err; |
3256 | } | 3258 | } |
3259 | spin_lock(get_ccwdev_lock(device->cdev)); | ||
3260 | memcpy(&private->rdc_data, &temp_rdc_data, sizeof(temp_rdc_data)); | ||
3261 | spin_unlock(get_ccwdev_lock(device->cdev)); | ||
3257 | 3262 | ||
3258 | /* add device to alias management */ | 3263 | /* add device to alias management */ |
3259 | dasd_alias_add_device(device); | 3264 | dasd_alias_add_device(device); |