s390/dasd: Simplify code in format logic
authorJan Höppner <hoeppner@linux.vnet.ibm.com>
Mon, 21 Sep 2015 15:32:11 +0000 (17:32 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Mon, 7 Mar 2016 12:11:58 +0000 (13:11 +0100)
Currently, dasd_format is calling the format logic of a DASD discipline
with PAV enabled. If that fails with an error code of -EAGAIN the value
of retries is decremented and the discipline function is called with PAV
turned off.

The loop is supposed to try this up to 255 times until success. However,
-EAGAIN can only occur once here and therefore the loop will never reach
the 255 retries.

So, replace the unnecessarily complicated loop logic and simply try again
without PAV enabled in case of an -EAGAIN error.

Signed-off-by: Jan Höppner <hoeppner@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dasd_ioctl.c

index 02837d0ad942e8258157df3095e1568f5a52ea90..16bb5ec4b30b49deeed982db1c6a20f6173fb758 100644 (file)
@@ -203,9 +203,7 @@ static int
 dasd_format(struct dasd_block *block, struct format_data_t *fdata)
 {
        struct dasd_device *base;
-       int enable_pav = 1;
-       int rc, retries;
-       int start, stop;
+       int rc;
 
        base = block->base;
        if (base->discipline->format_device == NULL)
@@ -233,30 +231,11 @@ dasd_format(struct dasd_block *block, struct format_data_t *fdata)
                bdput(bdev);
        }
 
-       retries = 255;
-       /* backup start- and endtrack for retries */
-       start = fdata->start_unit;
-       stop = fdata->stop_unit;
-       do {
-               rc = base->discipline->format_device(base, fdata, enable_pav);
-               if (rc) {
-                       if (rc == -EAGAIN) {
-                               retries--;
-                               /* disable PAV in case of errors */
-                               enable_pav = 0;
-                               fdata->start_unit = start;
-                               fdata->stop_unit = stop;
-                       } else
-                               return rc;
-               } else
-                       /* success */
-                       break;
-       } while (retries);
-
-       if (!retries)
-               return -EIO;
-       else
-               return 0;
+       rc = base->discipline->format_device(base, fdata, 1);
+       if (rc == -EAGAIN)
+               rc = base->discipline->format_device(base, fdata, 0);
+
+       return rc;
 }
 
 /*