Re: [PATCH 40/42] target: Remove fabric callback to allocate iovecs

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

 



On Fri, 2011-05-27 at 12:07 -0700, Andy Grover wrote:
> iscsi is the only one to use it, and by allocating it from
> iscsit_alloc_buffs we are covered.
> 
> Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
> ---

Looks good.  Committed as 80a47d96245

Thanks Andy!

--nab

>  drivers/target/iscsi/iscsi_target.c          |   25 ++++++++++++++++++++++++-
>  drivers/target/iscsi/iscsi_target_configfs.c |   22 ----------------------
>  drivers/target/loopback/tcm_loop.c           |    7 -------
>  drivers/target/target_core_transport.c       |   13 -------------
>  include/target/target_core_fabric_ops.h      |    5 -----
>  5 files changed, 24 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index 72a24b7..a36064b 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -760,6 +760,23 @@ static void iscsit_ack_from_expstatsn(struct iscsi_conn *conn, u32 exp_statsn)
>  	spin_unlock_bh(&conn->cmd_lock);
>  }
>  
> +static int iscsit_allocate_iovecs(struct iscsi_cmd *cmd)
> +{
> +	u32 iov_count = (cmd->se_cmd.t_tasks_se_num == 0) ? 1 :
> +				cmd->se_cmd.t_tasks_se_num;
> +
> +	iov_count += TRANSPORT_IOV_DATA_BUFFER;
> +
> +	cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL);
> +	if (!cmd->iov_data) {
> +		printk(KERN_ERR "WTF\n");
> +		return -ENOMEM;
> +	}
> +
> +	cmd->orig_iov_data_count = iov_count;
> +	return 0;
> +}
> +
>  #define ceil(x, y) \
>  	({ unsigned long __x = (x), __y = (y); (__x + __y - 1) / __y; })
>  
> @@ -771,7 +788,12 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
>  	int i;
>  	void *buf;
>  	void *cur;
> -	struct page *page;
> +	int ret;
> +
> +	/* Even no-length cmds need some iovecs, apparently? */
> +	ret = iscsit_allocate_iovecs(cmd);
> +	if (ret < 0)
> +		return ret;
>  
>  	if (!length)
>  		return 0;
> @@ -810,6 +832,7 @@ static int iscsit_alloc_buffs(struct iscsi_cmd *cmd)
>  		i = 0;
>  		while (length) {
>  			int buf_size = min_t(int, length, PAGE_SIZE);
> +			struct page *page;
>  
>  			page = alloc_page(GFP_KERNEL);
>  			if (!page)
> diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
> index aed9eaf..4d712cf 100644
> --- a/drivers/target/iscsi/iscsi_target_configfs.c
> +++ b/drivers/target/iscsi/iscsi_target_configfs.c
> @@ -1770,22 +1770,6 @@ static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
>  	iscsit_set_default_node_attribues(acl);
>  }
>  
> -static int iscsi_allocate_iovecs_for_cmd(struct se_cmd *se_cmd)
> -{
> -	struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
> -	u32 iov_count = (se_cmd->t_tasks_se_num == 0) ? 1 :
> -				se_cmd->t_tasks_se_num;
> -
> -	iov_count += TRANSPORT_IOV_DATA_BUFFER;
> -
> -	cmd->iov_data = kzalloc(iov_count * sizeof(struct kvec), GFP_KERNEL);
> -	if (!cmd->iov_data)
> -		return -ENOMEM;
> -
> -	cmd->orig_iov_data_count = iov_count;
> -	return 0;
> -}
> -
>  static void lio_release_cmd_direct(struct se_cmd *se_cmd)
>  {
>  	struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
> @@ -1837,12 +1821,6 @@ int iscsi_target_register_configfs(void)
>  	fabric->tf_ops.tpg_alloc_fabric_acl = &lio_tpg_alloc_fabric_acl;
>  	fabric->tf_ops.tpg_release_fabric_acl = &lio_tpg_release_fabric_acl;
>  	fabric->tf_ops.tpg_get_inst_index = &lio_tpg_get_inst_index;
> -	/*
> -	 * Use our local iscsi_allocate_iovecs_for_cmd() for the extra
> -	 * callback in transport_generic_new_cmd() to allocate
> -	 * iscsi_cmd->iov_data[] for Linux/Net kernel sockets operations.
> -	 */
> -	fabric->tf_ops.alloc_cmd_iovecs = &iscsi_allocate_iovecs_for_cmd;
>  	fabric->tf_ops.release_cmd_to_pool = &lio_release_cmd;
>  	fabric->tf_ops.release_cmd_direct = &lio_release_cmd_direct;
>  	fabric->tf_ops.shutdown_session = &lio_tpg_shutdown_session;
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index ca6b4d0..5217137 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -1419,13 +1419,6 @@ static int tcm_loop_register_configfs(void)
>  					&tcm_loop_tpg_release_fabric_acl;
>  	fabric->tf_ops.tpg_get_inst_index = &tcm_loop_get_inst_index;
>  	/*
> -	 * Since tcm_loop is mapping physical memory from Linux/SCSI
> -	 * struct scatterlist arrays for each struct scsi_cmnd I/O,
> -	 * we do not need TCM to allocate a iovec array for
> -	 * 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;
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index 8365b44..3c2c74f 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -4677,7 +4677,6 @@ transport_map_control_cmd_to_task(struct se_cmd *cmd)
>  	 */
>  static int transport_new_cmd(struct se_cmd *cmd)
>  {
> -	struct se_portal_group *se_tpg;
>  	struct se_task *task;
>  	struct se_device *dev = cmd->se_dev;
>  	int ret = 0;
> @@ -4698,18 +4697,6 @@ static int transport_new_cmd(struct se_cmd *cmd)
>  	if (ret < 0)
>  		return ret;
>  
> -	/*
> -	 * Determine if the calling TCM fabric module is talking to
> -	 * Linux/NET via kernel sockets and needs to allocate a
> -	 * struct iovec array to complete the struct se_cmd
> -	 */
> -	se_tpg = cmd->se_lun->lun_sep->sep_tpg;
> -	if (se_tpg->se_tpg_tfo->alloc_cmd_iovecs != NULL) {
> -		ret = se_tpg->se_tpg_tfo->alloc_cmd_iovecs(cmd);
> -		if (ret < 0)
> -			return PYX_TRANSPORT_OUT_OF_MEMORY_RESOURCES;
> -	}
> -
>  	if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) {
>  		list_for_each_entry(task, &cmd->t_task_list, t_list) {
>  			if (atomic_read(&task->task_sent))
> diff --git a/include/target/target_core_fabric_ops.h b/include/target/target_core_fabric_ops.h
> index dc78f77..b383f3d 100644
> --- a/include/target/target_core_fabric_ops.h
> +++ b/include/target/target_core_fabric_ops.h
> @@ -39,11 +39,6 @@ struct target_core_fabric_ops {
>  	 */
>  	int (*new_cmd_map)(struct se_cmd *);
>  	/*
> -	 * Optional function pointer for TCM fabric modules that use
> -	 * Linux/NET sockets to allocate struct iovec array to struct se_cmd
> -	 */
> -	int (*alloc_cmd_iovecs)(struct se_cmd *);
> -	/*
>  	 * Optional to release struct se_cmd and fabric dependent allocated
>  	 * I/O descriptor in transport_cmd_check_stop()
>  	 */
> -- 
> 1.7.1
> 

--
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