The tcmu sync operation patch made device deletion synchronous, so the uio close will always be done before the unregister, so this patch drops the uneeded refcounting. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/target/target_core_user.c | 43 ++++++++++----------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 345476c..e86ac65 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -106,7 +106,6 @@ struct tcmu_nl_cmd { struct tcmu_dev { struct list_head node; - struct kref kref; struct se_device se_dev; char *name; @@ -1095,7 +1094,6 @@ static struct se_device *tcmu_alloc_device(struct se_hba *hba, const char *name) udev = kzalloc(sizeof(struct tcmu_dev), GFP_KERNEL); if (!udev) return NULL; - kref_init(&udev->kref); udev->name = kstrdup(name, GFP_KERNEL); if (!udev->name) { @@ -1275,24 +1273,6 @@ static int tcmu_open(struct uio_info *info, struct inode *inode) return 0; } -static void tcmu_dev_call_rcu(struct rcu_head *p) -{ - struct se_device *dev = container_of(p, struct se_device, rcu_head); - struct tcmu_dev *udev = TCMU_DEV(dev); - - kfree(udev->uio_info.name); - kfree(udev->name); - kfree(udev); -} - -static void tcmu_dev_kref_release(struct kref *kref) -{ - struct tcmu_dev *udev = container_of(kref, struct tcmu_dev, kref); - struct se_device *dev = &udev->se_dev; - - call_rcu(&dev->rcu_head, tcmu_dev_call_rcu); -} - static int tcmu_release(struct uio_info *info, struct inode *inode) { struct tcmu_dev *udev = container_of(info, struct tcmu_dev, uio_info); @@ -1300,8 +1280,6 @@ static int tcmu_release(struct uio_info *info, struct inode *inode) clear_bit(TCMU_DEV_BIT_OPEN, &udev->flags); pr_debug("close\n"); - /* release ref from configure */ - kref_put(&udev->kref, tcmu_dev_kref_release); return 0; } @@ -1499,12 +1477,6 @@ static int tcmu_configure_device(struct se_device *dev) dev->dev_attrib.emulate_write_cache = 0; dev->dev_attrib.hw_queue_depth = 128; - /* - * Get a ref incase userspace does a close on the uio device before - * LIO has initiated tcmu_free_device. - */ - kref_get(&udev->kref); - ret = tcmu_netlink_event(udev, TCMU_CMD_ADDED_DEVICE, 0, NULL); if (ret) goto err_netlink; @@ -1516,7 +1488,6 @@ static int tcmu_configure_device(struct se_device *dev) return 0; err_netlink: - kref_put(&udev->kref, tcmu_dev_kref_release); uio_unregister_device(&udev->uio_info); err_register: vfree(udev->mb_addr); @@ -1558,12 +1529,17 @@ static void tcmu_blocks_release(struct tcmu_dev *udev) mutex_unlock(&udev->cmdr_lock); } -static void tcmu_free_device(struct se_device *dev) +static void tcmu_dev_call_rcu(struct rcu_head *p) { + struct se_device *dev = container_of(p, struct se_device, rcu_head); struct tcmu_dev *udev = TCMU_DEV(dev); - /* release ref from init */ - kref_put(&udev->kref, tcmu_dev_kref_release); + 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) @@ -1597,6 +1573,9 @@ static void tcmu_destroy_device(struct se_device *dev) tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL); uio_unregister_device(&udev->uio_info); + + kfree(udev->uio_info.name); + kfree(udev->name); } } -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html