diff mbox

[11/12] target: move rcu call to the core target code

Message ID 1498080791-13565-12-git-send-email-mchristi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Christie June 21, 2017, 9:33 p.m. UTC
With the last patch to tcmu, there is no need to have each backend
module do their own rcu calls for freeing the device. This patch
moves it to target core.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 drivers/target/target_core_device.c | 9 ++++++++-
 drivers/target/target_core_file.c   | 8 +-------
 drivers/target/target_core_iblock.c | 8 +-------
 drivers/target/target_core_pscsi.c  | 8 +-------
 drivers/target/target_core_user.c   | 8 +-------
 5 files changed, 12 insertions(+), 29 deletions(-)
diff mbox

Patch

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 4052b22..3743d47 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1050,6 +1050,13 @@  int target_configure_device(struct se_device *dev)
 	return ret;
 }
 
+static void target_free_device_call_rcu(struct rcu_head *p)
+{
+	struct se_device *dev = container_of(p, struct se_device, rcu_head);
+
+	dev->transport->free_device(dev);
+}
+
 void target_free_device(struct se_device *dev)
 {
 	struct se_hba *hba = dev->se_hba;
@@ -1078,7 +1085,7 @@  void target_free_device(struct se_device *dev)
 	if (dev->transport->free_prot)
 		dev->transport->free_prot(dev);
 
-	dev->transport->free_device(dev);
+	call_rcu(&dev->rcu_head, target_free_device_call_rcu);
 }
 
 int core_dev_setup_virtual_lun0(void)
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 50f2355..c8c2207 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -227,19 +227,13 @@  static int fd_configure_device(struct se_device *dev)
 	return ret;
 }
 
-static void fd_dev_call_rcu(struct rcu_head *p)
+static void fd_free_device(struct se_device *dev)
 {
-	struct se_device *dev = container_of(p, struct se_device, rcu_head);
 	struct fd_dev *fd_dev = FD_DEV(dev);
 
 	kfree(fd_dev);
 }
 
-static void fd_free_device(struct se_device *dev)
-{
-	call_rcu(&dev->rcu_head, fd_dev_call_rcu);
-}
-
 static void fd_destroy_device(struct se_device *dev)
 {
 	struct fd_dev *fd_dev = FD_DEV(dev);
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index a5e16f7..bc36d7b 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -180,19 +180,13 @@  static int iblock_configure_device(struct se_device *dev)
 	return ret;
 }
 
-static void iblock_dev_call_rcu(struct rcu_head *p)
+static void iblock_free_device(struct se_device *dev)
 {
-	struct se_device *dev = container_of(p, struct se_device, rcu_head);
 	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
 
 	kfree(ib_dev);
 }
 
-static void iblock_free_device(struct se_device *dev)
-{
-	call_rcu(&dev->rcu_head, iblock_dev_call_rcu);
-}
-
 static void iblock_destroy_device(struct se_device *dev)
 {
 	struct iblock_dev *ib_dev = IBLOCK_DEV(dev);
diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index 7d944b2..b29518c 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -554,19 +554,13 @@  static int pscsi_configure_device(struct se_device *dev)
 	return -ENODEV;
 }
 
-static void pscsi_dev_call_rcu(struct rcu_head *p)
+static void pscsi_free_device(struct se_device *dev)
 {
-	struct se_device *dev = container_of(p, struct se_device, rcu_head);
 	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
 
 	kfree(pdv);
 }
 
-static void pscsi_free_device(struct se_device *dev)
-{
-	call_rcu(&dev->rcu_head, pscsi_dev_call_rcu);
-}
-
 static void pscsi_destroy_device(struct se_device *dev)
 {
 	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index d65888e..0a1dd3b 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1529,19 +1529,13 @@  static void tcmu_blocks_release(struct tcmu_dev *udev)
 	mutex_unlock(&udev->cmdr_lock);
 }
 
-static void tcmu_dev_call_rcu(struct rcu_head *p)
+static void tcmu_free_device(struct se_device *dev)
 {
-	struct se_device *dev = container_of(p, struct se_device, rcu_head);
 	struct tcmu_dev *udev = TCMU_DEV(dev);
 
 	kfree(udev);
 }
 
-static void tcmu_free_device(struct se_device *dev)
-{
-	call_rcu(&dev->rcu_head, tcmu_dev_call_rcu);
-}
-
 static void tcmu_destroy_device(struct se_device *dev)
 {
 	struct tcmu_dev *udev = TCMU_DEV(dev);