Skip to contentSkip to conversation

tcm_loop: Convert to use new optimized TFO->new_cmd_map() caller

PATCH In review Nicholas A. Bellinger 1 participant 1 message Sep 6, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/6 tcm_loop: Convert to use new optimized TFO->new_cmd_map() caller

From: Nicholas Bellinger <[email protected]>

This patch converts the TCM_Loop virtual SCSI LLD fabric module to use the new struct target_core_fabrics_ops->new_cmd_map() caller added in commit f3b8d9dfe00. This allows TCM_Loop to do second stage setup of new struct se_cmd descriptors directly within TCM processing thread context, and allows us to drop it's internal per struct tcm_loop_hba->tl_hba_qobj and ->tl_kthread members.

This means that tcm_loop_processing_thread() processing of seperate TCM_Loop HBA queue in kthreads now goes away, and the original tcm_loop_execute_core_cmd() now becomes the TFO->new_cmd_map() caller at tcm_loop_new_cmd_map(). This function is called directly from TCM backstore processing thread context after se_cmd->transport_add_cmd_to_queue(se_cmd, TRANSPORT_NEW_CMD_MAP) is invoked by tcm_loop_queuecommand() from within interrupt context.

This has been tested so far in KVM guest v2.6.36-rc3 with TCM/FILEIO backstores

---
 drivers/target/tcm_loop/tcm_loop_configfs.c    |   35 +-------
 drivers/target/tcm_loop/tcm_loop_core.h        |    2 -
 drivers/target/tcm_loop/tcm_loop_fabric.c      |   61 --------------
 drivers/target/tcm_loop/tcm_loop_fabric.h      |    2 -
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.c |  100 +++++++-----------------
 drivers/target/tcm_loop/tcm_loop_fabric_scsi.h |    2 +-
 6 files changed, 34 insertions(+), 168 deletions(-)
drivers/target/tcm_loop/tcm_loop_configfs.c +4 -31
index fa4d82a..dd60cbf 100644
@@ -449,17 +449,6 @@ check_len:
 	snprintf(&tl_hba->tl_wwn_address[0], TL_WWN_ADDR_LEN, "%s", &name[off]);
 
 	/*
-	 * Setup the tl_hba->tl_hba_qobj
-	 */
-	tl_hba->tl_hba_qobj = kzalloc(sizeof(struct se_queue_obj), GFP_KERNEL);
-	if (!(tl_hba->tl_hba_qobj)) {
-		kfree(tl_hba);
-		printk("Unable to allocate tl_hba->tl_hba_qobj\n");
-		return ERR_PTR(-ENOMEM);
-	}
-	transport_init_queue_obj(tl_hba->tl_hba_qobj);
-
-	/*
 	 * Call device_register(tl_hba->dev) to register the emulated
 	 * Linux/SCSI LLD of type struct Scsi_Host at tl_hba->sh after
 	 * device_register() callbacks in tcm_loop_driver_probe()
@@ -469,19 +458,6 @@ check_len:
 		goto out;
 
 	sh = tl_hba->sh;
-	/*
-	 * Start up the per struct Scsi_Host tcm_loop processing thread
-	 */
-	tl_hba->tl_kthread = kthread_run(tcm_loop_processing_thread,
-			(void *)tl_hba, "tcm_loop_%d", sh->host_no);
-	if (IS_ERR(tl_hba->tl_kthread)) {
-		printk(KERN_ERR "Unable to start tcm_loop kthread\n");
-		device_unregister(&tl_hba->dev);
-		ret = -ENOMEM;
-		goto out;
-	}
-	wait_for_completion(&tl_hba->tl_hba_qobj->thread_create_comp);
-
 	tcm_loop_hba_no_cnt++;
 	printk(KERN_INFO "TCM_Loop_ConfigFS: Allocated emulated Target"
 		" %s Address: %s at Linux/SCSI Host ID: %d\n",
@@ -489,7 +465,6 @@ check_len:
 
 	return &tl_hba->tl_hba_wwn;
 out:
-	kfree(tl_hba->tl_hba_qobj);
 	kfree(tl_hba);
 	return ERR_PTR(ret);
 }
@@ -500,12 +475,6 @@ void tcm_loop_drop_scsi_hba(
 	struct tcm_loop_hba *tl_hba = container_of(wwn,
 				struct tcm_loop_hba, tl_hba_wwn);
 	int host_no = tl_hba->sh->host_no;
-
-	/*
-	 * Shutdown the per HBA tcm_loop processing kthread
-	 */
-	kthread_stop(tl_hba->tl_kthread);
-	wait_for_completion(&tl_hba->tl_hba_qobj->thread_done_comp);
 	/*
 	 * Call device_unregister() on the original tl_hba->dev.
 	 * tcm_loop_fabric_scsi.c:tcm_loop_release_adapter() will
@@ -590,6 +559,10 @@ int tcm_loop_register_configfs(void)
 	 * virtual memory address mappings
 	 */
 	fabric->tf_ops.alloc_cmd_iovecs = NULL;
+	/*
+	 * Used for setting up remaining TCM resources in process context
+	 */
+	fabric->tf_ops.new_cmd_map = &tcm_loop_new_cmd_map;
 	fabric->tf_ops.check_stop_free = &tcm_loop_check_stop_free;
 	fabric->tf_ops.release_cmd_to_pool = &tcm_loop_deallocate_core_cmd;
 	fabric->tf_ops.release_cmd_direct = &tcm_loop_deallocate_core_cmd;
drivers/target/tcm_loop/tcm_loop_core.h +0 -2
index eaebe89..69906b7 100644
@@ -69,8 +69,6 @@ struct tcm_loop_hba {
 	struct se_lun *tl_hba_lun;
 	struct se_port *tl_hba_lun_sep;
 	struct se_device_s *se_dev_hba_ptr;
-	struct se_queue_obj *tl_hba_qobj;
-	struct task_struct *tl_kthread;
 	struct tcm_loop_nexus *tl_nexus;
 	struct device dev;
 	struct Scsi_Host *sh;
drivers/target/tcm_loop/tcm_loop_fabric.c +0 -61

67 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_fabric.h +0 -2
index dde23c5..eef5165 100644
@@ -41,5 +41,3 @@ extern int tcm_loop_queue_tm_rsp(struct se_cmd *);
 extern u16 tcm_loop_set_fabric_sense_len(struct se_cmd *, u32);
 extern u16 tcm_loop_get_fabric_sense_len(void);
 extern u64 tcm_loop_pack_lun(unsigned int);
-
-extern int tcm_loop_processing_thread(void *);
drivers/target/tcm_loop/tcm_loop_fabric_scsi.c +29 -71

161 lines not on this page · raw message

drivers/target/tcm_loop/tcm_loop_fabric_scsi.h +1 -1
index c93e610..bcba89b 100644
@@ -1,6 +1,6 @@
 extern struct kmem_cache *tcm_loop_cmd_cache;
 
-extern int tcm_loop_execute_core_cmd(struct tcm_loop_cmd *, struct scsi_cmnd *);
+extern int tcm_loop_new_cmd_map(struct se_cmd *);
 extern void tcm_loop_check_stop_free(struct se_cmd *);
 extern void tcm_loop_deallocate_core_cmd(struct se_cmd *);
 extern void tcm_loop_scsi_forget_host(struct Scsi_Host *);
Signature · 1 line
1.5.6.5