diff mbox

[1/2] tcmu: delay freeing the device resources until after deletion

Message ID 1502577017-1236-1-git-send-email-mchristi@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Christie Aug. 12, 2017, 10:30 p.m. UTC
Userspace could still be accessing the ring and might
even still have commands it is trying to complete
(if cmd_time_out != 0, so the kernel has dropped the
cmd/ref count and made the device deletable) when a
deletion is executed.

This moves the userspace deletion to the beginning of the
function so we know once it is done userspace is not
accessing the kernel.

Signed-off-by: Mike Christie <mchristi@redhat.com>
---
 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mike Christie Sept. 1, 2017, 4:21 p.m. UTC | #1
On 08/12/2017 05:30 PM, Mike Christie wrote:
> Userspace could still be accessing the ring and might
> even still have commands it is trying to complete
> (if cmd_time_out != 0, so the kernel has dropped the
> cmd/ref count and made the device deletable) when a
> deletion is executed.
> 
> This moves the userspace deletion to the beginning of the
> function so we know once it is done userspace is not
> accessing the kernel.
> 

Nick, drop this patch for now too. We are discussing some other issues
with this code path here:

https://www.spinics.net/lists/target-devel/msg15970.html


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 7d1da43..db129e9 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1653,6 +1653,8 @@  static void tcmu_destroy_device(struct se_device *dev)
 	bool all_expired = true;
 	int i;
 
+	tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL);
+
 	del_timer_sync(&udev->timeout);
 
 	mutex_lock(&root_udev_mutex);
@@ -1680,8 +1682,6 @@  static void tcmu_destroy_device(struct se_device *dev)
 
 	tcmu_blocks_release(udev);
 
-	tcmu_netlink_event(udev, TCMU_CMD_REMOVED_DEVICE, 0, NULL);
-
 	uio_unregister_device(&udev->uio_info);
 
 	/* release ref from configure */