scsi: target: tcm_loop: Use LIO wq cmd submission helper
authorMike Christie <michael.christie@oracle.com>
Sat, 27 Feb 2021 17:00:00 +0000 (11:00 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 4 Mar 2021 22:37:02 +0000 (17:37 -0500)
Convert loop to use the LIO wq cmd submission helper.

Link: https://lore.kernel.org/r/20210227170006.5077-20-michael.christie@oracle.com
Tested-by: Laurence Oberman <loberman@redhat.com>
Reviewed-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/loopback/tcm_loop.c
drivers/target/loopback/tcm_loop.h

index fb877aec63214338cd5a4774dc45c3ff6c62b78e..2687fd7d45db0fb31a31b8e09f29510775664ab2 100644 (file)
@@ -39,7 +39,6 @@
 
 #define to_tcm_loop_hba(hba)   container_of(hba, struct tcm_loop_hba, dev)
 
-static struct workqueue_struct *tcm_loop_workqueue;
 static struct kmem_cache *tcm_loop_cmd_cache;
 
 static int tcm_loop_hba_no_cnt;
@@ -106,10 +105,8 @@ static struct device_driver tcm_loop_driverfs = {
  */
 static struct device *tcm_loop_primary;
 
-static void tcm_loop_submission_work(struct work_struct *work)
+static void tcm_loop_target_queue_cmd(struct tcm_loop_cmd *tl_cmd)
 {
-       struct tcm_loop_cmd *tl_cmd =
-               container_of(work, struct tcm_loop_cmd, work);
        struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd;
        struct scsi_cmnd *sc = tl_cmd->sc;
        struct tcm_loop_nexus *tl_nexus;
@@ -161,10 +158,10 @@ static void tcm_loop_submission_work(struct work_struct *work)
        if (target_submit_prep(se_cmd, sc->cmnd, scsi_sglist(sc),
                               scsi_sg_count(sc), sgl_bidi, sgl_bidi_count,
                               scsi_prot_sglist(sc), scsi_prot_sg_count(sc),
-                              GFP_NOIO))
+                              GFP_ATOMIC))
                return;
 
-       target_submit(se_cmd);
+       target_queue_submission(se_cmd);
        return;
 
 out_done:
@@ -187,8 +184,8 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
        memset(tl_cmd, 0, sizeof(*tl_cmd));
        tl_cmd->sc = sc;
        tl_cmd->sc_cmd_tag = sc->request->tag;
-       INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
-       queue_work(tcm_loop_workqueue, &tl_cmd->work);
+
+       tcm_loop_target_queue_cmd(tl_cmd);
        return 0;
 }
 
@@ -1160,17 +1157,13 @@ static int __init tcm_loop_fabric_init(void)
 {
        int ret = -ENOMEM;
 
-       tcm_loop_workqueue = alloc_workqueue("tcm_loop", 0, 0);
-       if (!tcm_loop_workqueue)
-               goto out;
-
        tcm_loop_cmd_cache = kmem_cache_create("tcm_loop_cmd_cache",
                                sizeof(struct tcm_loop_cmd),
                                __alignof__(struct tcm_loop_cmd),
                                0, NULL);
        if (!tcm_loop_cmd_cache) {
                pr_debug("kmem_cache_create() for tcm_loop_cmd_cache failed\n");
-               goto out_destroy_workqueue;
+               goto out;
        }
 
        ret = tcm_loop_alloc_core_bus();
@@ -1187,8 +1180,6 @@ out_release_core_bus:
        tcm_loop_release_core_bus();
 out_destroy_cache:
        kmem_cache_destroy(tcm_loop_cmd_cache);
-out_destroy_workqueue:
-       destroy_workqueue(tcm_loop_workqueue);
 out:
        return ret;
 }
@@ -1198,7 +1189,6 @@ static void __exit tcm_loop_fabric_exit(void)
        target_unregister_template(&loop_ops);
        tcm_loop_release_core_bus();
        kmem_cache_destroy(tcm_loop_cmd_cache);
-       destroy_workqueue(tcm_loop_workqueue);
 }
 
 MODULE_DESCRIPTION("TCM loopback virtual Linux/SCSI fabric module");
index d3110909a21389f648bbb72dc9e99265f4cc30c3..437663b3905ca28843b7be4d5618dac7dd48a3cb 100644 (file)
@@ -16,7 +16,6 @@ struct tcm_loop_cmd {
        struct scsi_cmnd *sc;
        /* The TCM I/O descriptor that is accessed via container_of() */
        struct se_cmd tl_se_cmd;
-       struct work_struct work;
        struct completion tmr_done;
        /* Sense buffer that will be mapped into outgoing status */
        unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];