scst_lib: Improve the use of scst_release_acg_wq

1. Add missing TRACE_ENTRY() to scst_lib_init().
2. Add error handling when scst_release_acg_wq creation fails.
3. Remove unneeded flush_workqueue().
This commit is contained in:
Gleb Chesnokov
2022-10-31 22:58:40 +03:00
parent b3cc617154
commit bff6597767

View File

@@ -15299,9 +15299,6 @@ static void __init scst_scsi_op_list_init(void)
TRACE_BUFFER("scst_scsi_op_list", scst_scsi_op_list,
sizeof(scst_scsi_op_list));
scst_release_acg_wq = create_workqueue("scst_release_acg");
WARN_ON_ONCE(IS_ERR(scst_release_acg_wq));
TRACE_EXIT();
return;
}
@@ -15310,27 +15307,39 @@ int __init scst_lib_init(void)
{
int res = 0;
TRACE_ENTRY();
scst_scsi_op_list_init();
scst_release_acg_wq = create_workqueue("scst_release_acg");
if (unlikely(!scst_release_acg_wq)) {
PRINT_ERROR("Failed to allocate scst_release_acg_wq");
res = -ENOMEM;
goto out;
}
scsi_io_context_cache = kmem_cache_create("scst_scsi_io_context",
sizeof(struct scsi_io_context),
__alignof__(struct scsi_io_context),
SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN, NULL);
if (!scsi_io_context_cache) {
PRINT_ERROR("%s", "Can't init scsi io context cache");
PRINT_ERROR("Can't init scsi io context cache");
res = -ENOMEM;
goto out;
goto free_wq;
}
out:
TRACE_EXIT_RES(res);
return res;
free_wq:
destroy_workqueue(scst_release_acg_wq);
goto out;
}
void scst_lib_exit(void)
{
/* Wait until any ongoing acg->put_work has finished. */
flush_workqueue(scst_release_acg_wq);
/* All pending works will be drained by destroy_workqueue() */
destroy_workqueue(scst_release_acg_wq);
BUILD_BUG_ON(SCST_MAX_CDB_SIZE != MAX_COMMAND_SIZE);