Merge branch 'for-linus' of master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband
[sfrench/cifs-2.6.git] / drivers / s390 / block / dasd.c
index 33157c84d1d3fccbf3a0d14c4d7e083c6355d547..a3bfebcf31efeb72f3a6de690d82f412eaa5218b 100644 (file)
@@ -43,7 +43,6 @@ 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");
 
 /*
@@ -71,10 +70,9 @@ dasd_alloc_device(void)
 {
        struct dasd_device *device;
 
-       device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC);
+       device = kzalloc(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);
 
@@ -151,6 +149,8 @@ dasd_state_new_to_known(struct dasd_device *device)
 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);
@@ -541,33 +541,29 @@ dasd_kmalloc_request(char *magic, int cplength, int datasize,
        struct dasd_ccw_req *cqr;
 
        /* Sanity checks */
-       if ( magic == NULL || datasize > PAGE_SIZE ||
-            (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
-               BUG();
+       BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
+            (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
 
-       cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
+       cqr = kzalloc(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 = kmalloc(cplength*sizeof(struct ccw1),
+               cqr->cpaddr = kcalloc(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 = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
+               cqr->data = kzalloc(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);
@@ -586,9 +582,8 @@ dasd_smalloc_request(char *magic, int cplength, int datasize,
        int size;
 
        /* Sanity checks */
-       if ( magic == NULL || datasize > PAGE_SIZE ||
-            (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
-               BUG();
+       BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
+            (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
 
        size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
        if (cplength > 0)
@@ -892,6 +887,9 @@ 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 */
@@ -1111,6 +1109,19 @@ 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);
@@ -1246,24 +1257,28 @@ __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);
-        /* check FAILFAST */
+       if (cqr->status != DASD_CQR_QUEUED)
+               return;
+       /* Non-temporary stop condition will trigger fail fast */
        if (device->stopped & ~DASD_STOPPED_PENDING &&
-           test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) {
+           test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
+           (!dasd_eer_enabled(device))) {
                cqr->status = DASD_CQR_FAILED;
                dasd_schedule_bh(device);
+               return;
        }
-       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);
-       }
+       /* 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);
 }
 
 /*
@@ -1807,7 +1822,7 @@ dasd_exit(void)
 #ifdef CONFIG_PROC_FS
        dasd_proc_exit();
 #endif
-       dasd_ioctl_exit();
+       dasd_eer_exit();
         if (dasd_page_cache != NULL) {
                kmem_cache_destroy(dasd_page_cache);
                dasd_page_cache = NULL;
@@ -1956,7 +1971,7 @@ int
 dasd_generic_set_offline (struct ccw_device *cdev)
 {
        struct dasd_device *device;
-       int max_count;
+       int max_count, open_count;
 
        device = dasd_device_from_cdev(cdev);
        if (IS_ERR(device))
@@ -1973,10 +1988,16 @@ dasd_generic_set_offline (struct ccw_device *cdev)
         * in the other openers.
         */
        max_count = device->bdev ? 0 : -1;
-       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));
+       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");
                clear_bit(DASD_FLAG_OFFLINE, &device->flags);
                dasd_put_device(device);
                return -EBUSY;
@@ -2004,6 +2025,9 @@ 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. */
@@ -2061,6 +2085,7 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
        put_driver(drv);
 }
 
+
 static int __init
 dasd_init(void)
 {
@@ -2093,7 +2118,7 @@ dasd_init(void)
        rc = dasd_parse();
        if (rc)
                goto failed;
-       rc = dasd_ioctl_init();
+       rc = dasd_eer_init();
        if (rc)
                goto failed;
 #ifdef CONFIG_PROC_FS