aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/block/dasd.c
diff options
context:
space:
mode:
authorHorst Hummel <horst.hummel@de.ibm.com>2006-03-08 00:55:39 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-08 17:14:01 -0500
commit90f0094dc607abe384a412bfb7199fb667ab0735 (patch)
tree2cd4c048a95d49a532bd237388f2b50ceb55ceb6 /drivers/s390/block/dasd.c
parentfbcae7eafcf7dfb315602de935d7ca85574e5c11 (diff)
[PATCH] s390: dasd partition detection
DASD allows to open a device as soon as gendisk is registered, which means the device is a fake device (capacity=0) and we do know nothing about blocksize and partitions at that point of time. In case the device is opened by someone, the bdev and inode creation is done with the fake device info and the following partition detection code is just using the wrong data. To avoid this modify the DASD state machine to make sure that the open is rejected until the device analysis is either finished or an unformatted device was detected. Signed-off-by: Horst Hummel <horst.hummel@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/s390/block/dasd.c')
-rw-r--r--drivers/s390/block/dasd.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index af1d5b404cee..33157c84d1d3 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -215,9 +215,10 @@ dasd_state_basic_to_known(struct dasd_device * device)
215 * interrupt for this detection ccw uses the kernel event daemon to 215 * interrupt for this detection ccw uses the kernel event daemon to
216 * trigger the call to dasd_change_state. All this is done in the 216 * trigger the call to dasd_change_state. All this is done in the
217 * discipline code, see dasd_eckd.c. 217 * discipline code, see dasd_eckd.c.
218 * After the analysis ccw is done (do_analysis returned 0 or error) 218 * After the analysis ccw is done (do_analysis returned 0) the block
219 * the block device is setup. Either a fake disk is added to allow 219 * device is setup.
220 * formatting or a proper device request queue is created. 220 * In case the analysis returns an error, the device setup is stopped
221 * (a fake disk was already added to allow formatting).
221 */ 222 */
222static inline int 223static inline int
223dasd_state_basic_to_ready(struct dasd_device * device) 224dasd_state_basic_to_ready(struct dasd_device * device)
@@ -227,13 +228,19 @@ dasd_state_basic_to_ready(struct dasd_device * device)
227 rc = 0; 228 rc = 0;
228 if (device->discipline->do_analysis != NULL) 229 if (device->discipline->do_analysis != NULL)
229 rc = device->discipline->do_analysis(device); 230 rc = device->discipline->do_analysis(device);
230 if (rc) 231 if (rc) {
232 if (rc != -EAGAIN)
233 device->state = DASD_STATE_UNFMT;
231 return rc; 234 return rc;
235 }
236 /* make disk known with correct capacity */
232 dasd_setup_queue(device); 237 dasd_setup_queue(device);
238 set_capacity(device->gdp, device->blocks << device->s2b_shift);
233 device->state = DASD_STATE_READY; 239 device->state = DASD_STATE_READY;
234 if (dasd_scan_partitions(device) != 0) 240 rc = dasd_scan_partitions(device);
241 if (rc)
235 device->state = DASD_STATE_BASIC; 242 device->state = DASD_STATE_BASIC;
236 return 0; 243 return rc;
237} 244}
238 245
239/* 246/*
@@ -254,6 +261,15 @@ dasd_state_ready_to_basic(struct dasd_device * device)
254} 261}
255 262
256/* 263/*
264 * Back to basic.
265 */
266static inline void
267dasd_state_unfmt_to_basic(struct dasd_device * device)
268{
269 device->state = DASD_STATE_BASIC;
270}
271
272/*
257 * Make the device online and schedule the bottom half to start 273 * Make the device online and schedule the bottom half to start
258 * the requeueing of requests from the linux request queue to the 274 * the requeueing of requests from the linux request queue to the
259 * ccw queue. 275 * ccw queue.
@@ -319,8 +335,12 @@ dasd_decrease_state(struct dasd_device *device)
319 if (device->state == DASD_STATE_READY && 335 if (device->state == DASD_STATE_READY &&
320 device->target <= DASD_STATE_BASIC) 336 device->target <= DASD_STATE_BASIC)
321 dasd_state_ready_to_basic(device); 337 dasd_state_ready_to_basic(device);
322 338
323 if (device->state == DASD_STATE_BASIC && 339 if (device->state == DASD_STATE_UNFMT &&
340 device->target <= DASD_STATE_BASIC)
341 dasd_state_unfmt_to_basic(device);
342
343 if (device->state == DASD_STATE_BASIC &&
324 device->target <= DASD_STATE_KNOWN) 344 device->target <= DASD_STATE_KNOWN)
325 dasd_state_basic_to_known(device); 345 dasd_state_basic_to_known(device);
326 346
@@ -1722,7 +1742,7 @@ dasd_open(struct inode *inp, struct file *filp)
1722 goto out; 1742 goto out;
1723 } 1743 }
1724 1744
1725 if (device->state < DASD_STATE_BASIC) { 1745 if (device->state <= DASD_STATE_BASIC) {
1726 DBF_DEV_EVENT(DBF_ERR, device, " %s", 1746 DBF_DEV_EVENT(DBF_ERR, device, " %s",
1727 " Cannot open unrecognized device"); 1747 " Cannot open unrecognized device");
1728 rc = -ENODEV; 1748 rc = -ENODEV;