]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtip32xx: Handle safe removal during IO
authorAsai Thambi SP <asamymuthupa@micron.com>
Thu, 25 Feb 2016 05:18:10 +0000 (21:18 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Apr 2016 16:08:51 +0000 (09:08 -0700)
commit 51c6570eb922146470c2fe660c34585414679bd6 upstream.

Flush inflight IOs using fsync_bdev() when the device is safely
removed. Also, block further IOs in device open function.

Signed-off-by: Selvan Mani <smani@micron.com>
Signed-off-by: Rajesh Kumar Sambandam <rsambandam@micron.com>
Signed-off-by: Asai Thambi S P <asamymuthupa@micron.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/mtip32xx/mtip32xx.c
drivers/block/mtip32xx/mtip32xx.h

index 47d96bdf5f9efce7f19f4ea6839d4c5635522bc5..cda3efecab8d5596420dfc8946cd2a5e826a78b5 100644 (file)
@@ -3602,6 +3602,28 @@ static int mtip_block_getgeo(struct block_device *dev,
        return 0;
 }
 
+static int mtip_block_open(struct block_device *dev, fmode_t mode)
+{
+       struct driver_data *dd;
+
+       if (dev && dev->bd_disk) {
+               dd = (struct driver_data *) dev->bd_disk->private_data;
+
+               if (dd) {
+                       if (test_bit(MTIP_DDF_REMOVAL_BIT,
+                                                       &dd->dd_flag)) {
+                               return -ENODEV;
+                       }
+                       return 0;
+               }
+       }
+       return -ENODEV;
+}
+
+void mtip_block_release(struct gendisk *disk, fmode_t mode)
+{
+}
+
 /*
  * Block device operation function.
  *
@@ -3609,6 +3631,8 @@ static int mtip_block_getgeo(struct block_device *dev,
  * layer.
  */
 static const struct block_device_operations mtip_block_ops = {
+       .open           = mtip_block_open,
+       .release        = mtip_block_release,
        .ioctl          = mtip_block_ioctl,
 #ifdef CONFIG_COMPAT
        .compat_ioctl   = mtip_block_compat_ioctl,
@@ -4434,7 +4458,7 @@ static void mtip_pci_remove(struct pci_dev *pdev)
        struct driver_data *dd = pci_get_drvdata(pdev);
        unsigned long flags, to;
 
-       set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
+       set_bit(MTIP_DDF_REMOVAL_BIT, &dd->dd_flag);
 
        spin_lock_irqsave(&dev_lock, flags);
        list_del_init(&dd->online_list);
@@ -4451,12 +4475,18 @@ static void mtip_pci_remove(struct pci_dev *pdev)
        } while (atomic_read(&dd->irq_workers_active) != 0 &&
                time_before(jiffies, to));
 
+       fsync_bdev(dd->bdev);
+
        if (atomic_read(&dd->irq_workers_active) != 0) {
                dev_warn(&dd->pdev->dev,
                        "Completion workers still active!\n");
        }
 
-       blk_mq_stop_hw_queues(dd->queue);
+       if (dd->sr)
+               blk_mq_stop_hw_queues(dd->queue);
+
+       set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
+
        /* Clean up the block layer. */
        mtip_block_remove(dd);
 
index 8635239c521f2978ecd0ac3e8d29497c8c99b9a2..50af742421e27b4c6561041db6c5da9f99c06a19 100644 (file)
@@ -158,6 +158,7 @@ enum {
        MTIP_DDF_RESUME_BIT         = 6,
        MTIP_DDF_INIT_DONE_BIT      = 7,
        MTIP_DDF_REBUILD_FAILED_BIT = 8,
+       MTIP_DDF_REMOVAL_BIT        = 9,
 
        MTIP_DDF_STOP_IO      = ((1 << MTIP_DDF_REMOVE_PENDING_BIT) |
                                (1 << MTIP_DDF_SEC_LOCK_BIT) |