hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/target/loopback/tcm_loop.c
....@@ -128,14 +128,6 @@
128128 set_host_byte(sc, DID_ERROR);
129129 goto out_done;
130130 }
131
- if (scsi_bidi_cmnd(sc)) {
132
- struct scsi_data_buffer *sdb = scsi_in(sc);
133
-
134
- sgl_bidi = sdb->table.sgl;
135
- sgl_bidi_count = sdb->table.nents;
136
- se_cmd->se_cmd_flags |= SCF_BIDI;
137
-
138
- }
139131
140132 transfer_length = scsi_transfer_length(sc);
141133 if (!scsi_prot_sg_count(sc) &&
....@@ -304,12 +296,6 @@
304296 return FAILED;
305297 }
306298
307
-static int tcm_loop_slave_alloc(struct scsi_device *sd)
308
-{
309
- blk_queue_flag_set(QUEUE_FLAG_BIDI, sd->request_queue);
310
- return 0;
311
-}
312
-
313299 static struct scsi_host_template tcm_loop_driver_template = {
314300 .show_info = tcm_loop_show_info,
315301 .proc_name = "tcm_loopback",
....@@ -324,8 +310,7 @@
324310 .sg_tablesize = 256,
325311 .cmd_per_lun = 1024,
326312 .max_sectors = 0xFFFF,
327
- .use_clustering = DISABLE_CLUSTERING,
328
- .slave_alloc = tcm_loop_slave_alloc,
313
+ .dma_boundary = PAGE_SIZE - 1,
329314 .module = THIS_MODULE,
330315 .track_queue_depth = 1,
331316 };
....@@ -409,6 +394,7 @@
409394 ret = device_register(&tl_hba->dev);
410395 if (ret) {
411396 pr_err("device_register() failed for tl_hba->dev: %d\n", ret);
397
+ put_device(&tl_hba->dev);
412398 return -ENODEV;
413399 }
414400
....@@ -458,11 +444,6 @@
458444 root_device_unregister(tcm_loop_primary);
459445
460446 pr_debug("Releasing TCM Loop Core BUS\n");
461
-}
462
-
463
-static char *tcm_loop_get_fabric_name(void)
464
-{
465
- return "loopback";
466447 }
467448
468449 static inline struct tcm_loop_tpg *tl_tpg(struct se_portal_group *se_tpg)
....@@ -565,37 +546,15 @@
565546 return 0;
566547 }
567548
568
-static int tcm_loop_write_pending_status(struct se_cmd *se_cmd)
569
-{
570
- return 0;
571
-}
572
-
573
-static int tcm_loop_queue_data_in(struct se_cmd *se_cmd)
549
+static int tcm_loop_queue_data_or_status(const char *func,
550
+ struct se_cmd *se_cmd, u8 scsi_status)
574551 {
575552 struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
576553 struct tcm_loop_cmd, tl_se_cmd);
577554 struct scsi_cmnd *sc = tl_cmd->sc;
578555
579556 pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n",
580
- __func__, sc, sc->cmnd[0]);
581
-
582
- sc->result = SAM_STAT_GOOD;
583
- set_host_byte(sc, DID_OK);
584
- if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
585
- (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT))
586
- scsi_set_resid(sc, se_cmd->residual_count);
587
- sc->scsi_done(sc);
588
- return 0;
589
-}
590
-
591
-static int tcm_loop_queue_status(struct se_cmd *se_cmd)
592
-{
593
- struct tcm_loop_cmd *tl_cmd = container_of(se_cmd,
594
- struct tcm_loop_cmd, tl_se_cmd);
595
- struct scsi_cmnd *sc = tl_cmd->sc;
596
-
597
- pr_debug("%s() called for scsi_cmnd: %p cdb: 0x%02x\n",
598
- __func__, sc, sc->cmnd[0]);
557
+ func, sc, sc->cmnd[0]);
599558
600559 if (se_cmd->sense_buffer &&
601560 ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ||
....@@ -606,7 +565,7 @@
606565 sc->result = SAM_STAT_CHECK_CONDITION;
607566 set_driver_byte(sc, DRIVER_SENSE);
608567 } else
609
- sc->result = se_cmd->scsi_status;
568
+ sc->result = scsi_status;
610569
611570 set_host_byte(sc, DID_OK);
612571 if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) ||
....@@ -614,6 +573,17 @@
614573 scsi_set_resid(sc, se_cmd->residual_count);
615574 sc->scsi_done(sc);
616575 return 0;
576
+}
577
+
578
+static int tcm_loop_queue_data_in(struct se_cmd *se_cmd)
579
+{
580
+ return tcm_loop_queue_data_or_status(__func__, se_cmd, SAM_STAT_GOOD);
581
+}
582
+
583
+static int tcm_loop_queue_status(struct se_cmd *se_cmd)
584
+{
585
+ return tcm_loop_queue_data_or_status(__func__,
586
+ se_cmd, se_cmd->scsi_status);
617587 }
618588
619589 static void tcm_loop_queue_tm_rsp(struct se_cmd *se_cmd)
....@@ -1103,7 +1073,7 @@
11031073 */
11041074 ret = tcm_loop_setup_hba_bus(tl_hba, tcm_loop_hba_no_cnt);
11051075 if (ret)
1106
- goto out;
1076
+ return ERR_PTR(ret);
11071077
11081078 sh = tl_hba->sh;
11091079 tcm_loop_hba_no_cnt++;
....@@ -1149,8 +1119,7 @@
11491119
11501120 static const struct target_core_fabric_ops loop_ops = {
11511121 .module = THIS_MODULE,
1152
- .name = "loopback",
1153
- .get_fabric_name = tcm_loop_get_fabric_name,
1122
+ .fabric_name = "loopback",
11541123 .tpg_get_wwn = tcm_loop_get_endpoint_wwn,
11551124 .tpg_get_tag = tcm_loop_get_tag,
11561125 .tpg_check_demo_mode = tcm_loop_check_demo_mode,
....@@ -1165,7 +1134,6 @@
11651134 .release_cmd = tcm_loop_release_cmd,
11661135 .sess_get_index = tcm_loop_sess_get_index,
11671136 .write_pending = tcm_loop_write_pending,
1168
- .write_pending_status = tcm_loop_write_pending_status,
11691137 .set_default_node_attributes = tcm_loop_set_default_node_attributes,
11701138 .get_cmd_state = tcm_loop_get_cmd_state,
11711139 .queue_data_in = tcm_loop_queue_data_in,