Skip to content

Commit 1130b49

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: target: tcm_loop: Use LIO wq cmd submission helper
Convert loop to use the LIO wq cmd submission helper. Link: https://lore.kernel.org/r/[email protected] Tested-by: Laurence Oberman <[email protected]> Reviewed-by: Bodo Stroesser <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e0eb5d3 commit 1130b49

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

drivers/target/loopback/tcm_loop.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#define to_tcm_loop_hba(hba) container_of(hba, struct tcm_loop_hba, dev)
4141

42-
static struct workqueue_struct *tcm_loop_workqueue;
4342
static struct kmem_cache *tcm_loop_cmd_cache;
4443

4544
static int tcm_loop_hba_no_cnt;
@@ -106,10 +105,8 @@ static struct device_driver tcm_loop_driverfs = {
106105
*/
107106
static struct device *tcm_loop_primary;
108107

109-
static void tcm_loop_submission_work(struct work_struct *work)
108+
static void tcm_loop_target_queue_cmd(struct tcm_loop_cmd *tl_cmd)
110109
{
111-
struct tcm_loop_cmd *tl_cmd =
112-
container_of(work, struct tcm_loop_cmd, work);
113110
struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd;
114111
struct scsi_cmnd *sc = tl_cmd->sc;
115112
struct tcm_loop_nexus *tl_nexus;
@@ -161,10 +158,10 @@ static void tcm_loop_submission_work(struct work_struct *work)
161158
if (target_submit_prep(se_cmd, sc->cmnd, scsi_sglist(sc),
162159
scsi_sg_count(sc), sgl_bidi, sgl_bidi_count,
163160
scsi_prot_sglist(sc), scsi_prot_sg_count(sc),
164-
GFP_NOIO))
161+
GFP_ATOMIC))
165162
return;
166163

167-
target_submit(se_cmd);
164+
target_queue_submission(se_cmd);
168165
return;
169166

170167
out_done:
@@ -187,8 +184,8 @@ static int tcm_loop_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *sc)
187184
memset(tl_cmd, 0, sizeof(*tl_cmd));
188185
tl_cmd->sc = sc;
189186
tl_cmd->sc_cmd_tag = sc->request->tag;
190-
INIT_WORK(&tl_cmd->work, tcm_loop_submission_work);
191-
queue_work(tcm_loop_workqueue, &tl_cmd->work);
187+
188+
tcm_loop_target_queue_cmd(tl_cmd);
192189
return 0;
193190
}
194191

@@ -1160,17 +1157,13 @@ static int __init tcm_loop_fabric_init(void)
11601157
{
11611158
int ret = -ENOMEM;
11621159

1163-
tcm_loop_workqueue = alloc_workqueue("tcm_loop", 0, 0);
1164-
if (!tcm_loop_workqueue)
1165-
goto out;
1166-
11671160
tcm_loop_cmd_cache = kmem_cache_create("tcm_loop_cmd_cache",
11681161
sizeof(struct tcm_loop_cmd),
11691162
__alignof__(struct tcm_loop_cmd),
11701163
0, NULL);
11711164
if (!tcm_loop_cmd_cache) {
11721165
pr_debug("kmem_cache_create() for tcm_loop_cmd_cache failed\n");
1173-
goto out_destroy_workqueue;
1166+
goto out;
11741167
}
11751168

11761169
ret = tcm_loop_alloc_core_bus();
@@ -1187,8 +1180,6 @@ static int __init tcm_loop_fabric_init(void)
11871180
tcm_loop_release_core_bus();
11881181
out_destroy_cache:
11891182
kmem_cache_destroy(tcm_loop_cmd_cache);
1190-
out_destroy_workqueue:
1191-
destroy_workqueue(tcm_loop_workqueue);
11921183
out:
11931184
return ret;
11941185
}
@@ -1198,7 +1189,6 @@ static void __exit tcm_loop_fabric_exit(void)
11981189
target_unregister_template(&loop_ops);
11991190
tcm_loop_release_core_bus();
12001191
kmem_cache_destroy(tcm_loop_cmd_cache);
1201-
destroy_workqueue(tcm_loop_workqueue);
12021192
}
12031193

12041194
MODULE_DESCRIPTION("TCM loopback virtual Linux/SCSI fabric module");

drivers/target/loopback/tcm_loop.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ struct tcm_loop_cmd {
1616
struct scsi_cmnd *sc;
1717
/* The TCM I/O descriptor that is accessed via container_of() */
1818
struct se_cmd tl_se_cmd;
19-
struct work_struct work;
2019
struct completion tmr_done;
2120
/* Sense buffer that will be mapped into outgoing status */
2221
unsigned char tl_sense_buf[TRANSPORT_SENSE_BUFFER];

0 commit comments

Comments
 (0)