linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / s390 / block / dasd.c
index 25c1ef6..33157c8 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include <linux/config.h>
 #include <linux/kmod.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -42,6 +43,7 @@ MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
                   " Copyright 2000 IBM Corporation");
 MODULE_SUPPORTED_DEVICE("dasd");
+MODULE_PARM(dasd, "1-" __MODULE_STRING(256) "s");
 MODULE_LICENSE("GPL");
 
 /*
@@ -52,7 +54,7 @@ static void dasd_setup_queue(struct dasd_device * device);
 static void dasd_free_queue(struct dasd_device * device);
 static void dasd_flush_request_queue(struct dasd_device *);
 static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
-static int dasd_flush_ccw_queue(struct dasd_device *, int);
+static void dasd_flush_ccw_queue(struct dasd_device *, int);
 static void dasd_tasklet(struct dasd_device *);
 static void do_kick_device(void *data);
 
@@ -60,7 +62,6 @@ static void do_kick_device(void *data);
  * SECTION: Operations on the device structure.
  */
 static wait_queue_head_t dasd_init_waitq;
-static wait_queue_head_t dasd_flush_wq;
 
 /*
  * Allocate memory for a new device structure.
@@ -70,9 +71,10 @@ dasd_alloc_device(void)
 {
        struct dasd_device *device;
 
-       device = kzalloc(sizeof (struct dasd_device), GFP_ATOMIC);
+       device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC);
        if (device == NULL)
                return ERR_PTR(-ENOMEM);
+       memset(device, 0, sizeof (struct dasd_device));
        /* open_count = 0 means device online but not in use */
        atomic_set(&device->open_count, -1);
 
@@ -95,7 +97,7 @@ dasd_alloc_device(void)
        spin_lock_init(&device->mem_lock);
        spin_lock_init(&device->request_queue_lock);
        atomic_set (&device->tasklet_scheduled, 0);
-       tasklet_init(&device->tasklet,
+       tasklet_init(&device->tasklet, 
                     (void (*)(unsigned long)) dasd_tasklet,
                     (unsigned long) device);
        INIT_LIST_HEAD(&device->ccw_queue);
@@ -122,13 +124,13 @@ dasd_free_device(struct dasd_device *device)
 /*
  * Make a new device known to the system.
  */
-static int
+static inline int
 dasd_state_new_to_known(struct dasd_device *device)
 {
        int rc;
 
        /*
-        * As long as the device is not in state DASD_STATE_NEW we want to
+        * As long as the device is not in state DASD_STATE_NEW we want to 
         * keep the reference count > 0.
         */
        dasd_get_device(device);
@@ -146,11 +148,9 @@ dasd_state_new_to_known(struct dasd_device *device)
 /*
  * Let the system forget about a device.
  */
-static int
+static inline void
 dasd_state_known_to_new(struct dasd_device * device)
 {
-       /* Disable extended error reporting for this device. */
-       dasd_eer_disable(device);
        /* Forget the discipline information. */
        if (device->discipline)
                module_put(device->discipline->owner);
@@ -164,13 +164,12 @@ dasd_state_known_to_new(struct dasd_device * device)
 
        /* Give up reference we took in dasd_state_new_to_known. */
        dasd_put_device(device);
-       return 0;
 }
 
 /*
  * Request the irq line for the device.
  */
-static int
+static inline int
 dasd_state_known_to_basic(struct dasd_device * device)
 {
        int rc;
@@ -194,23 +193,17 @@ dasd_state_known_to_basic(struct dasd_device * device)
 /*
  * Release the irq line for the device. Terminate any running i/o.
  */
-static int
+static inline void
 dasd_state_basic_to_known(struct dasd_device * device)
 {
-       int rc;
-
        dasd_gendisk_free(device);
-       rc = dasd_flush_ccw_queue(device, 1);
-       if (rc)
-               return rc;
-
+       dasd_flush_ccw_queue(device, 1);
        DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
        if (device->debug_area != NULL) {
                debug_unregister(device->debug_area);
                device->debug_area = NULL;
        }
        device->state = DASD_STATE_KNOWN;
-       return 0;
 }
 
 /*
@@ -227,7 +220,7 @@ dasd_state_basic_to_known(struct dasd_device * device)
  * In case the analysis returns an error, the device setup is stopped
  * (a fake disk was already added to allow formatting).
  */
-static int
+static inline int
 dasd_state_basic_to_ready(struct dasd_device * device)
 {
        int rc;
@@ -255,31 +248,25 @@ dasd_state_basic_to_ready(struct dasd_device * device)
  * Forget format information. Check if the target level is basic
  * and if it is create fake disk for formatting.
  */
-static int
+static inline void
 dasd_state_ready_to_basic(struct dasd_device * device)
 {
-       int rc;
-
-       rc = dasd_flush_ccw_queue(device, 0);
-       if (rc)
-               return rc;
+       dasd_flush_ccw_queue(device, 0);
        dasd_destroy_partitions(device);
        dasd_flush_request_queue(device);
        device->blocks = 0;
        device->bp_block = 0;
        device->s2b_shift = 0;
        device->state = DASD_STATE_BASIC;
-       return 0;
 }
 
 /*
  * Back to basic.
  */
-static int
+static inline void
 dasd_state_unfmt_to_basic(struct dasd_device * device)
 {
        device->state = DASD_STATE_BASIC;
-       return 0;
 }
 
 /*
@@ -287,7 +274,7 @@ dasd_state_unfmt_to_basic(struct dasd_device * device)
  * the requeueing of requests from the linux request queue to the
  * ccw queue.
  */
-static int
+static inline int
 dasd_state_ready_to_online(struct dasd_device * device)
 {
        device->state = DASD_STATE_ONLINE;
@@ -298,17 +285,16 @@ dasd_state_ready_to_online(struct dasd_device * device)
 /*
  * Stop the requeueing of requests again.
  */
-static int
+static inline void
 dasd_state_online_to_ready(struct dasd_device * device)
 {
        device->state = DASD_STATE_READY;
-       return 0;
 }
 
 /*
  * Device startup state changes.
  */
-static int
+static inline int
 dasd_increase_state(struct dasd_device *device)
 {
        int rc;
@@ -328,11 +314,6 @@ dasd_increase_state(struct dasd_device *device)
            device->target >= DASD_STATE_READY)
                rc = dasd_state_basic_to_ready(device);
 
-       if (!rc &&
-           device->state == DASD_STATE_UNFMT &&
-           device->target > DASD_STATE_UNFMT)
-               rc = -EPERM;
-
        if (!rc &&
            device->state == DASD_STATE_READY &&
            device->target >= DASD_STATE_ONLINE)
@@ -344,37 +325,30 @@ dasd_increase_state(struct dasd_device *device)
 /*
  * Device shutdown state changes.
  */
-static int
+static inline int
 dasd_decrease_state(struct dasd_device *device)
 {
-       int rc;
-
-       rc = 0;
        if (device->state == DASD_STATE_ONLINE &&
            device->target <= DASD_STATE_READY)
-               rc = dasd_state_online_to_ready(device);
-
-       if (!rc &&
-           device->state == DASD_STATE_READY &&
+               dasd_state_online_to_ready(device);
+       
+       if (device->state == DASD_STATE_READY &&
            device->target <= DASD_STATE_BASIC)
-               rc = dasd_state_ready_to_basic(device);
+               dasd_state_ready_to_basic(device);
 
-       if (!rc &&
-           device->state == DASD_STATE_UNFMT &&
+       if (device->state == DASD_STATE_UNFMT &&
            device->target <= DASD_STATE_BASIC)
-               rc = dasd_state_unfmt_to_basic(device);
+               dasd_state_unfmt_to_basic(device);
 
-       if (!rc &&
-           device->state == DASD_STATE_BASIC &&
+       if (device->state == DASD_STATE_BASIC &&
            device->target <= DASD_STATE_KNOWN)
-               rc = dasd_state_basic_to_known(device);
-
-       if (!rc &&
-           device->state == DASD_STATE_KNOWN &&
+               dasd_state_basic_to_known(device);
+       
+       if (device->state == DASD_STATE_KNOWN &&
            device->target <= DASD_STATE_NEW)
-               rc = dasd_state_known_to_new(device);
+               dasd_state_known_to_new(device);
 
-       return rc;
+       return 0;
 }
 
 /*
@@ -567,29 +541,33 @@ dasd_kmalloc_request(char *magic, int cplength, int datasize,
        struct dasd_ccw_req *cqr;
 
        /* Sanity checks */
-       BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
-            (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
+       if ( magic == NULL || datasize > PAGE_SIZE ||
+            (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
+               BUG();
 
-       cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
+       cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
        if (cqr == NULL)
                return ERR_PTR(-ENOMEM);
+       memset(cqr, 0, sizeof(struct dasd_ccw_req));
        cqr->cpaddr = NULL;
        if (cplength > 0) {
-               cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
+               cqr->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
                                      GFP_ATOMIC | GFP_DMA);
                if (cqr->cpaddr == NULL) {
                        kfree(cqr);
                        return ERR_PTR(-ENOMEM);
                }
+               memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
        }
        cqr->data = NULL;
        if (datasize > 0) {
-               cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
+               cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
                if (cqr->data == NULL) {
                        kfree(cqr->cpaddr);
                        kfree(cqr);
                        return ERR_PTR(-ENOMEM);
                }
+               memset(cqr->data, 0, datasize);
        }
        strncpy((char *) &cqr->magic, magic, 4);
        ASCEBC((char *) &cqr->magic, 4);
@@ -608,8 +586,9 @@ dasd_smalloc_request(char *magic, int cplength, int datasize,
        int size;
 
        /* Sanity checks */
-       BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
-            (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
+       if ( magic == NULL || datasize > PAGE_SIZE ||
+            (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
+               BUG();
 
        size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
        if (cplength > 0)
@@ -723,7 +702,6 @@ dasd_term_IO(struct dasd_ccw_req * cqr)
                        cqr->retries--;
                        cqr->status = DASD_CQR_CLEAR;
                        cqr->stopclk = get_clock();
-                       cqr->starttime = 0;
                        DBF_DEV_EVENT(DBF_DEBUG, device,
                                      "terminate cqr %p successful",
                                      cqr);
@@ -914,9 +892,6 @@ dasd_handle_state_change_pending(struct dasd_device *device)
        struct dasd_ccw_req *cqr;
        struct list_head *l, *n;
 
-       /* First of all start sense subsystem status request. */
-       dasd_eer_snss(device);
-
        device->stopped &= ~DASD_STOPPED_PENDING;
 
         /* restart all 'running' IO on queue */
@@ -1001,7 +976,6 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
            irb->scsw.fctl & SCSW_FCTL_CLEAR_FUNC) {
                cqr->status = DASD_CQR_QUEUED;
                dasd_clear_timer(device);
-               wake_up(&dasd_flush_wq);
                dasd_schedule_bh(device);
                return;
        }
@@ -1017,7 +991,7 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
                      ((irb->scsw.cstat << 8) | irb->scsw.dstat), cqr);
 
        /* Find out the appropriate era_action. */
-       if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC)
+       if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) 
                era = dasd_era_fatal;
        else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
                 irb->scsw.cstat == 0 &&
@@ -1027,7 +1001,7 @@ dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
                era = dasd_era_fatal; /* don't recover this request */
        else if (irb->esw.esw0.erw.cons)
                era = device->discipline->examine_error(cqr, irb);
-       else
+       else 
                era = dasd_era_recover;
 
        DBF_DEV_EVENT(DBF_DEBUG, device, "era_code %d", era);
@@ -1137,19 +1111,6 @@ restart:
                        }
                        goto restart;
                }
-
-               /* First of all call extended error reporting. */
-               if (dasd_eer_enabled(device) &&
-                   cqr->status == DASD_CQR_FAILED) {
-                       dasd_eer_write(device, cqr, DASD_EER_FATALERROR);
-
-                       /* restart request  */
-                       cqr->status = DASD_CQR_QUEUED;
-                       cqr->retries = 255;
-                       device->stopped |= DASD_STOPPED_QUIESCE;
-                       goto restart;
-               }
-
                /* Process finished ERP request. */
                if (cqr->refers) {
                        __dasd_process_erp(device, cqr);
@@ -1265,10 +1226,6 @@ __dasd_check_expire(struct dasd_device * device)
        cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
        if (cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) {
                if (time_after_eq(jiffies, cqr->expires + cqr->starttime)) {
-                       DEV_MESSAGE(KERN_ERR, device,
-                                   "internal error - timeout (%is) expired "
-                                   "for cqr %p (%i retries left)",
-                                   (cqr->expires/HZ), cqr, cqr->retries);
                        if (device->discipline->term_IO(cqr) != 0)
                                /* Hmpf, try again in 1/10 sec */
                                dasd_set_timer(device, 10);
@@ -1289,124 +1246,66 @@ __dasd_start_head(struct dasd_device * device)
        if (list_empty(&device->ccw_queue))
                return;
        cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
-       if (cqr->status != DASD_CQR_QUEUED)
-               return;
-       /* Non-temporary stop condition will trigger fail fast */
+        /* check FAILFAST */
        if (device->stopped & ~DASD_STOPPED_PENDING &&
-           test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
-           (!dasd_eer_enabled(device))) {
+           test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) {
                cqr->status = DASD_CQR_FAILED;
                dasd_schedule_bh(device);
-               return;
        }
-       /* Don't try to start requests if device is stopped */
-       if (device->stopped)
-               return;
-
-       rc = device->discipline->start_IO(cqr);
-       if (rc == 0)
-               dasd_set_timer(device, cqr->expires);
-       else if (rc == -EACCES) {
-               dasd_schedule_bh(device);
-       } else
-               /* Hmpf, try again in 1/2 sec */
-               dasd_set_timer(device, 50);
-}
-
-static inline int
-_wait_for_clear(struct dasd_ccw_req *cqr)
-{
-       return (cqr->status == DASD_CQR_QUEUED);
+       if ((cqr->status == DASD_CQR_QUEUED) &&
+           (!device->stopped)) {
+               /* try to start the first I/O that can be started */
+               rc = device->discipline->start_IO(cqr);
+               if (rc == 0)
+                       dasd_set_timer(device, cqr->expires);
+               else if (rc == -EACCES) {
+                       dasd_schedule_bh(device);
+               } else
+                       /* Hmpf, try again in 1/2 sec */
+                       dasd_set_timer(device, 50);
+       }
 }
 
 /*
- * Remove all requests from the ccw queue (all = '1') or only block device
- * requests in case all = '0'.
- * Take care of the erp-chain (chained via cqr->refers) and remove either
- * the whole erp-chain or none of the erp-requests.
- * If a request is currently running, term_IO is called and the request
- * is re-queued. Prior to removing the terminated request we need to wait
- * for the clear-interrupt.
- * In case termination is not possible we stop processing and just finishing
- * the already moved requests.
+ * Remove requests from the ccw queue. 
  */
-static int
+static void
 dasd_flush_ccw_queue(struct dasd_device * device, int all)
 {
-       struct dasd_ccw_req *cqr, *orig, *n;
-       int rc, i;
-
        struct list_head flush_queue;
+       struct list_head *l, *n;
+       struct dasd_ccw_req *cqr;
 
        INIT_LIST_HEAD(&flush_queue);
        spin_lock_irq(get_ccwdev_lock(device->cdev));
-       rc = 0;
-restart:
-       list_for_each_entry_safe(cqr, n, &device->ccw_queue, list) {
-               /* get original request of erp request-chain */
-               for (orig = cqr; orig->refers != NULL; orig = orig->refers);
-
+       list_for_each_safe(l, n, &device->ccw_queue) {
+               cqr = list_entry(l, struct dasd_ccw_req, list);
                /* Flush all request or only block device requests? */
-               if (all == 0 && cqr->callback != dasd_end_request_cb &&
-                   orig->callback != dasd_end_request_cb) {
+               if (all == 0 && cqr->callback == dasd_end_request_cb)
                        continue;
-               }
-               /* Check status and move request to flush_queue */
-               switch (cqr->status) {
-               case DASD_CQR_IN_IO:
-                       rc = device->discipline->term_IO(cqr);
-                       if (rc) {
-                               /* unable to terminate requeust */
-                               DEV_MESSAGE(KERN_ERR, device,
-                                           "dasd flush ccw_queue is unable "
-                                           " to terminate request %p",
-                                           cqr);
-                               /* stop flush processing */
-                               goto finished;
-                       }
-                       break;
-               case DASD_CQR_QUEUED:
-               case DASD_CQR_ERROR:
-                       /* set request to FAILED */
-                       cqr->stopclk = get_clock();
-                       cqr->status = DASD_CQR_FAILED;
-                       break;
-               default: /* do not touch the others */
-                       break;
-               }
-               /* Rechain request (including erp chain) */
-               for (i = 0; cqr != NULL; cqr = cqr->refers, i++) {
-                       cqr->endclk = get_clock();
-                       list_move_tail(&cqr->list, &flush_queue);
-               }
-               if (i > 1)
-                       /* moved more than one request - need to restart */
-                       goto restart;
-       }
-
-finished:
-       spin_unlock_irq(get_ccwdev_lock(device->cdev));
-       /* Now call the callback function of flushed requests */
-restart_cb:
-       list_for_each_entry_safe(cqr, n, &flush_queue, list) {
-               if (cqr->status == DASD_CQR_CLEAR) {
-                       /* wait for clear interrupt! */
-                       wait_event(dasd_flush_wq, _wait_for_clear(cqr));
+               if (cqr->status == DASD_CQR_IN_IO)
+                       device->discipline->term_IO(cqr);
+               if (cqr->status != DASD_CQR_DONE ||
+                   cqr->status != DASD_CQR_FAILED) {
                        cqr->status = DASD_CQR_FAILED;
+                       cqr->stopclk = get_clock();
                }
                /* Process finished ERP request. */
                if (cqr->refers) {
                        __dasd_process_erp(device, cqr);
-                       /* restart list_for_xx loop since dasd_process_erp
-                        * might remove multiple elements */
-                       goto restart_cb;
+                       continue;
                }
-               /* call the callback function */
+               /* Rechain request on device request queue */
                cqr->endclk = get_clock();
+               list_move_tail(&cqr->list, &flush_queue);
+       }
+       spin_unlock_irq(get_ccwdev_lock(device->cdev));
+       /* Now call the callback function of flushed requests */
+       list_for_each_safe(l, n, &flush_queue) {
+               cqr = list_entry(l, struct dasd_ccw_req, list);
                if (cqr->callback != NULL)
                        (cqr->callback)(cqr, cqr->callback_data);
        }
-       return rc;
 }
 
 /*
@@ -1531,23 +1430,23 @@ dasd_sleep_on(struct dasd_ccw_req * cqr)
        wait_queue_head_t wait_q;
        struct dasd_device *device;
        int rc;
-
+       
        device = cqr->device;
        spin_lock_irq(get_ccwdev_lock(device->cdev));
-
+       
        init_waitqueue_head (&wait_q);
        cqr->callback = dasd_wakeup_cb;
        cqr->callback_data = (void *) &wait_q;
        cqr->status = DASD_CQR_QUEUED;
        list_add_tail(&cqr->list, &device->ccw_queue);
-
+       
        /* let the bh start the request to keep them in order */
        dasd_schedule_bh(device);
-
+       
        spin_unlock_irq(get_ccwdev_lock(device->cdev));
 
        wait_event(wait_q, _wait_for_wakeup(cqr));
-
+       
        /* Request status is either done or failed. */
        rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
        return rc;
@@ -1592,8 +1491,10 @@ dasd_sleep_on_interruptible(struct dasd_ccw_req * cqr)
                        if (device->discipline->term_IO) {
                                cqr->retries = -1;
                                device->discipline->term_IO(cqr);
-                               /* wait (non-interruptible) for final status
-                                * because signal ist still pending */
+                               /*nished =
+                                * wait (non-interruptible) for final status
+                                * because signal ist still pending
+                                */
                                spin_unlock_irq(get_ccwdev_lock(device->cdev));
                                wait_event(wait_q, _wait_for_wakeup(cqr));
                                spin_lock_irq(get_ccwdev_lock(device->cdev));
@@ -1626,11 +1527,19 @@ static inline int
 _dasd_term_running_cqr(struct dasd_device *device)
 {
        struct dasd_ccw_req *cqr;
+       int rc;
 
        if (list_empty(&device->ccw_queue))
                return 0;
        cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
-       return device->discipline->term_IO(cqr);
+       rc = device->discipline->term_IO(cqr);
+       if (rc == 0) {
+               /* termination successful */
+               cqr->status = DASD_CQR_QUEUED;
+               cqr->startclk = cqr->stopclk = 0;
+               cqr->starttime = 0;
+       }
+       return rc;
 }
 
 int
@@ -1639,7 +1548,7 @@ dasd_sleep_on_immediatly(struct dasd_ccw_req * cqr)
        wait_queue_head_t wait_q;
        struct dasd_device *device;
        int rc;
-
+       
        device = cqr->device;
        spin_lock_irq(get_ccwdev_lock(device->cdev));
        rc = _dasd_term_running_cqr(device);
@@ -1647,20 +1556,20 @@ dasd_sleep_on_immediatly(struct dasd_ccw_req * cqr)
                spin_unlock_irq(get_ccwdev_lock(device->cdev));
                return rc;
        }
-
+       
        init_waitqueue_head (&wait_q);
        cqr->callback = dasd_wakeup_cb;
        cqr->callback_data = (void *) &wait_q;
        cqr->status = DASD_CQR_QUEUED;
        list_add(&cqr->list, &device->ccw_queue);
-
+       
        /* let the bh start the request to keep them in order */
        dasd_schedule_bh(device);
-
+       
        spin_unlock_irq(get_ccwdev_lock(device->cdev));
 
        wait_event(wait_q, _wait_for_wakeup(cqr));
-
+       
        /* Request status is either done or failed. */
        rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
        return rc;
@@ -1796,11 +1705,14 @@ dasd_flush_request_queue(struct dasd_device * device)
 
        if (!device->request_queue)
                return;
-
+       
        spin_lock_irq(&device->request_queue_lock);
-       while ((req = elv_next_request(device->request_queue))) {
-               blkdev_dequeue_request(req);
+       while (!list_empty(&device->request_queue->queue_head)) {
+               req = elv_next_request(device->request_queue);
+               if (req == NULL)
+                       break;
                dasd_end_request(req, 0);
+               blkdev_dequeue_request(req);
        }
        spin_unlock_irq(&device->request_queue_lock);
 }
@@ -1895,13 +1807,14 @@ dasd_exit(void)
 #ifdef CONFIG_PROC_FS
        dasd_proc_exit();
 #endif
-       dasd_eer_exit();
+       dasd_ioctl_exit();
         if (dasd_page_cache != NULL) {
                kmem_cache_destroy(dasd_page_cache);
                dasd_page_cache = NULL;
        }
        dasd_gendisk_exit();
        dasd_devmap_exit();
+       devfs_remove("dasd");
        if (dasd_debug_area != NULL) {
                debug_unregister(dasd_debug_area);
                dasd_debug_area = NULL;
@@ -1922,34 +1835,15 @@ dasd_generic_probe (struct ccw_device *cdev,
 {
        int ret;
 
-       ret = ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
-       if (ret) {
-               printk(KERN_WARNING
-                      "dasd_generic_probe: could not set ccw-device options "
-                      "for %s\n", cdev->dev.bus_id);
-               return ret;
-       }
        ret = dasd_add_sysfs_files(cdev);
        if (ret) {
                printk(KERN_WARNING
                       "dasd_generic_probe: could not add sysfs entries "
                       "for %s\n", cdev->dev.bus_id);
-               return ret;
+       } else {
+               cdev->handler = &dasd_int_handler;
        }
-       cdev->handler = &dasd_int_handler;
 
-       /*
-        * Automatically online either all dasd devices (dasd_autodetect)
-        * or all devices specified with dasd= parameters during
-        * initial probe.
-        */
-       if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) ||
-           (dasd_autodetect && dasd_busid_known(cdev->dev.bus_id) != 0))
-               ret = ccw_device_set_online(cdev);
-       if (ret)
-               printk(KERN_WARNING
-                      "dasd_generic_probe: could not initially online "
-                      "ccw-device %s\n", cdev->dev.bus_id);
        return ret;
 }
 
@@ -1997,8 +1891,6 @@ dasd_generic_set_online (struct ccw_device *cdev,
        struct dasd_device *device;
        int rc;
 
-       /* first online clears initial online feature flag */
-       dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0);
        device = dasd_create_device(cdev);
        if (IS_ERR(device))
                return PTR_ERR(device);
@@ -2064,7 +1956,7 @@ int
 dasd_generic_set_offline (struct ccw_device *cdev)
 {
        struct dasd_device *device;
-       int max_count, open_count;
+       int max_count;
 
        device = dasd_device_from_cdev(cdev);
        if (IS_ERR(device))
@@ -2081,16 +1973,10 @@ dasd_generic_set_offline (struct ccw_device *cdev)
         * in the other openers.
         */
        max_count = device->bdev ? 0 : -1;
-       open_count = (int) atomic_read(&device->open_count);
-       if (open_count > max_count) {
-               if (open_count > 0)
-                       printk (KERN_WARNING "Can't offline dasd device with "
-                               "open count = %i.\n",
-                               open_count);
-               else
-                       printk (KERN_WARNING "%s",
-                               "Can't offline dasd device due to internal "
-                               "use\n");
+       if (atomic_read(&device->open_count) > max_count) {
+               printk (KERN_WARNING "Can't offline dasd device with open"
+                       " count = %i.\n",
+                       atomic_read(&device->open_count));
                clear_bit(DASD_FLAG_OFFLINE, &device->flags);
                dasd_put_device(device);
                return -EBUSY;
@@ -2118,9 +2004,6 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
        switch (event) {
        case CIO_GONE:
        case CIO_NO_PATH:
-               /* First of all call extended error reporting. */
-               dasd_eer_write(device, NULL, DASD_EER_NOPATH);
-
                if (device->state < DASD_STATE_BASIC)
                        break;
                /* Device is active. We want to keep it. */
@@ -2153,6 +2036,30 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
        return ret;
 }
 
+/*
+ * Automatically online either all dasd devices (dasd_autodetect) or
+ * all devices specified with dasd= parameters.
+ */
+static int
+__dasd_auto_online(struct device *dev, void *data)
+{
+       struct ccw_device *cdev;
+
+       cdev = to_ccwdev(dev);
+       if (dasd_autodetect || dasd_busid_known(cdev->dev.bus_id) == 0)
+               ccw_device_set_online(cdev);
+       return 0;
+}
+
+void
+dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
+{
+       struct device_driver *drv;
+
+       drv = get_driver(&dasd_discipline_driver->driver);
+       driver_for_each_device(drv, NULL, NULL, __dasd_auto_online);
+       put_driver(drv);
+}
 
 static int __init
 dasd_init(void)
@@ -2160,7 +2067,6 @@ dasd_init(void)
        int rc;
 
        init_waitqueue_head(&dasd_init_waitq);
-       init_waitqueue_head(&dasd_flush_wq);
 
        /* register 'common' DASD debug area, used for all DBF_XXX calls */
        dasd_debug_area = debug_register("dasd", 1, 2, 8 * sizeof (long));
@@ -2175,6 +2081,9 @@ dasd_init(void)
 
        dasd_diag_discipline_pointer = NULL;
 
+       rc = devfs_mk_dir("dasd");
+       if (rc)
+               goto failed;
        rc = dasd_devmap_init();
        if (rc)
                goto failed;
@@ -2184,7 +2093,7 @@ dasd_init(void)
        rc = dasd_parse();
        if (rc)
                goto failed;
-       rc = dasd_eer_init();
+       rc = dasd_ioctl_init();
        if (rc)
                goto failed;
 #ifdef CONFIG_PROC_FS
@@ -2231,4 +2140,23 @@ EXPORT_SYMBOL_GPL(dasd_generic_remove);
 EXPORT_SYMBOL_GPL(dasd_generic_notify);
 EXPORT_SYMBOL_GPL(dasd_generic_set_online);
 EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
+EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
 
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only.  This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-indent-level: 4
+ * c-brace-imaginary-offset: 0
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * c-continued-statement-offset: 4
+ * c-continued-brace-offset: 0
+ * indent-tabs-mode: 1
+ * tab-width: 8
+ * End:
+ */