lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 22 Feb 2016 21:01:57 -0800
From:	Asai Thambi SP <asamymuthupa@...ron.com>
To:	Jens Axboe <axboe@...nel.dk>
CC:	<linux-kernel@...r.kernel.org>,
	Sam Bradshaw <sbradshaw@...ron.com>,
	Selvan Mani <smani@...ron.com>,
	Rajesh Kumar Sambandam <rsambandam@...ron.com>,
	Vignesh Gunasekaran <vgunasekaran@...ron.com>
Subject: [PATCH 07/10] mtip32xx: Handle safe removal during IO


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@...ron.com>
Signed-off-by: Rajesh Kumar Sambandam <rsambandam@...ron.com>
Signed-off-by: Asai Thambi S P <asamymuthupa@...ron.com>
---
 drivers/block/mtip32xx/mtip32xx.c |   34 ++++++++++++++++++++++++++++++++--
 drivers/block/mtip32xx/mtip32xx.h |    1 +
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 7ad3b90..85c1794 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3664,6 +3664,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.
  *
@@ -3671,6 +3693,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,
@@ -4498,7 +4522,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);
@@ -4515,12 +4539,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);
 
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 64bfb82..b6436ce 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -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) |
-- 
1.7.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ