Re: [PATCH 5/5] target: Remove transport_do_task_sg_chain() and associated detritus

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2012-03-30 at 11:29 -0700, Roland Dreier wrote:
> From: Roland Dreier <roland@xxxxxxxxxxxxxxx>
> 
> Now that all fabrics are converted over to using se_cmd->t_data_sg
> directly, we can drop the task sg chaining support.  With the modern
> memory allocation in target core, task sg chaining is needless
> overhead -- we would split up the main cmd sglist into pieces, and
> then splice those pieces back together instead of just using the
> original list directly.
> 
> Signed-off-by: Roland Dreier <roland@xxxxxxxxxxxxxxx>
> ---

Applied this patch minus the transport_allocate_data_tasks() specific
parts that conflict with hch's patch to drop task splitting.

Thanks Roland!

--nab

>  drivers/target/target_core_transport.c |   89 +------------------------------
>  include/target/target_core_base.h      |    2 -
>  include/target/target_core_fabric.h    |    7 ---
>  3 files changed, 3 insertions(+), 95 deletions(-)
> 
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index e252925..58315b0 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -3706,76 +3706,6 @@ static inline sector_t transport_limit_task_sectors(
>  	return sectors;
>  }
>  
> -
> -/*
> - * This function can be used by HW target mode drivers to create a linked
> - * scatterlist from all contiguously allocated struct se_task->task_sg[].
> - * This is intended to be called during the completion path by TCM Core
> - * when struct target_core_fabric_ops->check_task_sg_chaining is enabled.
> - */
> -void transport_do_task_sg_chain(struct se_cmd *cmd)
> -{
> -	struct scatterlist *sg_first = NULL;
> -	struct scatterlist *sg_prev = NULL;
> -	int sg_prev_nents = 0;
> -	struct scatterlist *sg;
> -	struct se_task *task;
> -	u32 chained_nents = 0;
> -	int i;
> -
> -	BUG_ON(!cmd->se_tfo->task_sg_chaining);
> -
> -	/*
> -	 * Walk the struct se_task list and setup scatterlist chains
> -	 * for each contiguously allocated struct se_task->task_sg[].
> -	 */
> -	list_for_each_entry(task, &cmd->t_task_list, t_list) {
> -		if (!task->task_sg)
> -			continue;
> -
> -		if (!sg_first) {
> -			sg_first = task->task_sg;
> -			chained_nents = task->task_sg_nents;
> -		} else {
> -			sg_chain(sg_prev, sg_prev_nents, task->task_sg);
> -			chained_nents += task->task_sg_nents;
> -		}
> -		/*
> -		 * For the padded tasks, use the extra SGL vector allocated
> -		 * in transport_allocate_data_tasks() for the sg_prev_nents
> -		 * offset into sg_chain() above.
> -		 *
> -		 * We do not need the padding for the last task (or a single
> -		 * task), but in that case we will never use the sg_prev_nents
> -		 * value below which would be incorrect.
> -		 */
> -		sg_prev_nents = (task->task_sg_nents + 1);
> -		sg_prev = task->task_sg;
> -	}
> -	/*
> -	 * Setup the starting pointer and total t_tasks_sg_linked_no including
> -	 * padding SGs for linking and to mark the end.
> -	 */
> -	cmd->t_tasks_sg_chained = sg_first;
> -	cmd->t_tasks_sg_chained_no = chained_nents;
> -
> -	pr_debug("Setup cmd: %p cmd->t_tasks_sg_chained: %p and"
> -		" t_tasks_sg_chained_no: %u\n", cmd, cmd->t_tasks_sg_chained,
> -		cmd->t_tasks_sg_chained_no);
> -
> -	for_each_sg(cmd->t_tasks_sg_chained, sg,
> -			cmd->t_tasks_sg_chained_no, i) {
> -
> -		pr_debug("SG[%d]: %p page: %p length: %d offset: %d\n",
> -			i, sg, sg_page(sg), sg->length, sg->offset);
> -		if (sg_is_chain(sg))
> -			pr_debug("SG: %p sg_is_chain=1\n", sg);
> -		if (sg_is_last(sg))
> -			pr_debug("SG: %p sg_is_last=1\n", sg);
> -	}
> -}
> -EXPORT_SYMBOL(transport_do_task_sg_chain);
> -
>  /*
>   * Break up cmd into chunks transport can handle
>   */
> @@ -3830,7 +3760,7 @@ transport_allocate_data_tasks(struct se_cmd *cmd,
>  
>  	for (i = 0; i < task_count; i++) {
>  		struct se_task *task;
> -		unsigned int task_size, task_sg_nents_padded;
> +		unsigned int task_size;
>  		struct scatterlist *sg;
>  		unsigned long flags;
>  		int count;
> @@ -3847,27 +3777,14 @@ transport_allocate_data_tasks(struct se_cmd *cmd,
>  		 * in order to calculate the number per task SGL entries
>  		 */
>  		task->task_sg_nents = DIV_ROUND_UP(task->task_size, PAGE_SIZE);
> -		/*
> -		 * Check if the fabric module driver is requesting that all
> -		 * struct se_task->task_sg[] be chained together..  If so,
> -		 * then allocate an extra padding SG entry for linking and
> -		 * marking the end of the chained SGL for every task except
> -		 * the last one for (task_count > 1) operation, or skipping
> -		 * the extra padding for the (task_count == 1) case.
> -		 */
> -		if (cmd->se_tfo->task_sg_chaining && (i < (task_count - 1))) {
> -			task_sg_nents_padded = (task->task_sg_nents + 1);
> -		} else
> -			task_sg_nents_padded = task->task_sg_nents;
> -
>  		task->task_sg = kmalloc(sizeof(struct scatterlist) *
> -					task_sg_nents_padded, GFP_KERNEL);
> +					task->task_sg_nents, GFP_KERNEL);
>  		if (!task->task_sg) {
>  			cmd->se_dev->transport->free_task(task);
>  			return -ENOMEM;
>  		}
>  
> -		sg_init_table(task->task_sg, task_sg_nents_padded);
> +		sg_init_table(task->task_sg, task->task_sg_nents);
>  
>  		task_size = task->task_size;
>  
> diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
> index 2c5c37e..0a09b85 100644
> --- a/include/target/target_core_base.h
> +++ b/include/target/target_core_base.h
> @@ -571,7 +571,6 @@ struct se_cmd {
>  	unsigned char		*t_task_cdb;
>  	unsigned char		__t_task_cdb[TCM_MAX_COMMAND_SIZE];
>  	unsigned long long	t_task_lba;
> -	u32			t_tasks_sg_chained_no;
>  	atomic_t		t_fe_count;
>  	atomic_t		t_se_count;
>  	atomic_t		t_task_cdbs_left;
> @@ -592,7 +591,6 @@ struct se_cmd {
>  	struct completion	t_transport_stop_comp;
>  	struct completion	transport_lun_fe_stop_comp;
>  	struct completion	transport_lun_stop_comp;
> -	struct scatterlist	*t_tasks_sg_chained;
>  
>  	struct work_struct	work;
>  
> diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
> index 13dc827..cc64a94 100644
> --- a/include/target/target_core_fabric.h
> +++ b/include/target/target_core_fabric.h
> @@ -3,12 +3,6 @@
>  
>  struct target_core_fabric_ops {
>  	struct configfs_subsystem *tf_subsys;
> -	/*
> -	 * Optional to signal struct se_task->task_sg[] padding entries
> -	 * for scatterlist chaining using transport_do_task_sg_link(),
> -	 * disabled by default
> -	 */
> -	bool task_sg_chaining;
>  	char *(*get_fabric_name)(void);
>  	u8 (*get_fabric_proto_ident)(struct se_portal_group *);
>  	char *(*tpg_get_wwn)(struct se_portal_group *);
> @@ -124,7 +118,6 @@ int	transport_generic_handle_cdb_map(struct se_cmd *);
>  int	transport_generic_handle_data(struct se_cmd *);
>  int	transport_generic_map_mem_to_cmd(struct se_cmd *cmd,
>  		struct scatterlist *, u32, struct scatterlist *, u32);
> -void	transport_do_task_sg_chain(struct se_cmd *);
>  int	transport_generic_new_cmd(struct se_cmd *);
>  
>  void	transport_generic_process_write(struct se_cmd *);


--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux