nvmet: cancel fatal error and flush async work before free controller
authorSagi Grimberg <sagi@grimberg.me>
Sun, 1 Jan 2017 11:41:56 +0000 (13:41 +0200)
committerSagi Grimberg <sagi@grimberg.me>
Thu, 26 Jan 2017 15:45:00 +0000 (17:45 +0200)
Make sure they are not running and we can free the controller
safely.

Signed-off-by: Roy Shterman <roys@lightbitslabs.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/core.c

index 4a367549eb9365ee6be47ad057700ce2c7a3fbae..a327a43f81666a103a3af4fbafe95a74a4449349 100644 (file)
@@ -816,6 +816,9 @@ static void nvmet_ctrl_free(struct kref *ref)
        list_del(&ctrl->subsys_entry);
        mutex_unlock(&subsys->lock);
 
+       flush_work(&ctrl->async_event_work);
+       cancel_work_sync(&ctrl->fatal_err_work);
+
        ida_simple_remove(&subsys->cntlid_ida, ctrl->cntlid);
        nvmet_subsys_put(subsys);