Commit 6ebdf1c79d09ad3d65c714a79db0a0c141a013ba

Authored by Stefan Haberland
Committed by Martin Schwidefsky
1 parent 932f0549f8

s390/dasd: retry partition detection

In case somebody attempted to open the device during online
processing the partition detection ioctl may have failed.

Added a retry loop to avoid not detected partitions.

Signed-off-by: Stefan Haberland <stefan.haberland@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

Showing 1 changed file with 24 additions and 2 deletions Side-by-side Diff

drivers/s390/block/dasd_genhd.c
... ... @@ -99,15 +99,37 @@
99 99 int dasd_scan_partitions(struct dasd_block *block)
100 100 {
101 101 struct block_device *bdev;
  102 + int retry, rc;
102 103  
  104 + retry = 5;
103 105 bdev = bdget_disk(block->gdp, 0);
104   - if (!bdev || blkdev_get(bdev, FMODE_READ, NULL) < 0)
  106 + if (!bdev) {
  107 + DBF_DEV_EVENT(DBF_ERR, block->base, "%s",
  108 + "scan partitions error, bdget returned NULL");
105 109 return -ENODEV;
  110 + }
  111 +
  112 + rc = blkdev_get(bdev, FMODE_READ, NULL);
  113 + if (rc < 0) {
  114 + DBF_DEV_EVENT(DBF_ERR, block->base,
  115 + "scan partitions error, blkdev_get returned %d",
  116 + rc);
  117 + return -ENODEV;
  118 + }
106 119 /*
107 120 * See fs/partition/check.c:register_disk,rescan_partitions
108 121 * Can't call rescan_partitions directly. Use ioctl.
109 122 */
110   - ioctl_by_bdev(bdev, BLKRRPART, 0);
  123 + rc = ioctl_by_bdev(bdev, BLKRRPART, 0);
  124 + while (rc == -EBUSY && retry > 0) {
  125 + schedule();
  126 + rc = ioctl_by_bdev(bdev, BLKRRPART, 0);
  127 + retry--;
  128 + DBF_DEV_EVENT(DBF_ERR, block->base,
  129 + "scan partitions error, retry %d rc %d",
  130 + retry, rc);
  131 + }
  132 +
111 133 /*
112 134 * Since the matching blkdev_put call to the blkdev_get in
113 135 * this function is not called before dasd_destroy_partitions