Re: [PATCH 25/42] target: Rename transport_generic_allocate_tasks to _process_cdb

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

 



On Fri, 2011-05-27 at 12:07 -0700, Andy Grover wrote:
> This function doesn't allocate tasks, it copies the cdb into the cmd,
> and analyzes the cdb to determine the scsi command, length etc., and
> sets flags.
> 
> Change fabrics accordingly.
> 
> Also, rename transport_generic_prepare_cdb to transport_clear_cdb_lun,
> which imho is more suitable, at least until there's more that the
> function does besides just that. The very good comment explains why this
> is needed.
> 
> Signed-off-by: Andy Grover <agrover@xxxxxxxxxx>
> ---

Skipping this one along with patch #26 as I agree with Christoph here
that these should really be prefixed with target_*() to start with..

I will get this changed in TCM v4.1 code in the next weeks, and plan for
this as v3.1 mainline target API change.

Thanks,

--nab


>  drivers/infiniband/ulp/srpt/ib_srpt.c           |    2 +-
>  drivers/target/iscsi/iscsi_target.c             |    2 +-
>  drivers/target/loopback/tcm_loop.c              |    6 +---
>  drivers/target/target_core_transport.c          |   29 ++++++++++------------
>  drivers/target/tcm_fc/tfc_cmd.c                 |    2 +-
>  drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c |    2 +-
>  drivers/target/tcm_vhost/tcm_vhost_fabric.c     |    2 +-
>  drivers/target/tcm_vhost/tcm_vhost_scsi.c       |    2 +-
>  include/target/target_core_transport.h          |    2 +-
>  9 files changed, 22 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
> index 054e861..fea48b0 100644
> --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
> +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
> @@ -1794,7 +1794,7 @@ static int srpt_handle_cmd(struct srpt_rdma_ch *ch,
>  				       sizeof(srp_cmd->lun));
>  	if (transport_lookup_cmd_lun(cmd, unpacked_lun) < 0)
>  		goto send_sense;
> -	ret = transport_generic_allocate_tasks(cmd, srp_cmd->cdb);
> +	ret = transport_generic_process_cdb(cmd, srp_cmd->cdb);
>  	if (cmd->se_cmd_flags & SCF_SCSI_RESERVATION_CONFLICT)
>  		srpt_queue_status(cmd);
>  	else if (cmd->se_cmd_flags & SCF_SCSI_CDB_EXCEPTION)
> diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
> index b5b6981..4424b9f 100644
> --- a/drivers/target/iscsi/iscsi_target.c
> +++ b/drivers/target/iscsi/iscsi_target.c
> @@ -1172,7 +1172,7 @@ done:
>  	 * allocate 1->N transport tasks (depending on sector count and
>  	 * maximum request size the physical HBA(s) can handle.
>  	 */
> -	transport_ret = transport_generic_allocate_tasks(SE_CMD(cmd), hdr->cdb);
> +	transport_ret = transport_generic_process_cdb(SE_CMD(cmd), hdr->cdb);
>  	if (transport_ret == -ENOMEM) {
>  		return iscsit_add_reject_from_cmd(
>  				ISCSI_REASON_BOOKMARK_NO_RESOURCES,
> diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
> index e0d97c1..ca6b4d0 100644
> --- a/drivers/target/loopback/tcm_loop.c
> +++ b/drivers/target/loopback/tcm_loop.c
> @@ -145,10 +145,8 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd)
>  	struct scatterlist *sgl_bidi = NULL;
>  	u32 sgl_bidi_count = 0;
>  	int ret;
> -	/*
> -	 * Allocate the necessary tasks to complete the received CDB+data
> -	 */
> -	ret = transport_generic_allocate_tasks(se_cmd, sc->cmnd);
> +
> +	ret = transport_generic_process_cdb(se_cmd, sc->cmnd);
>  	if (ret == -ENOMEM) {
>  		/* Out of Resources */
>  		return PYX_TRANSPORT_LU_COMM_FAILURE;
> diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
> index fd959ac..632e5ea 100644
> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -1629,15 +1629,14 @@ out:
>  }
>  EXPORT_SYMBOL(transport_add_device_to_core_hba);
>  
> -/*	transport_generic_prepare_cdb():
> - *
> - *	Since the Initiator sees iSCSI devices as LUNs,  the SCSI CDB will
> - *	contain the iSCSI LUN in bits 7-5 of byte 1 as per SAM-2.
> - *	The point of this is since we are mapping iSCSI LUNs to
> - *	SCSI Target IDs having a non-zero LUN in the CDB will throw the
> - *	devices and HBAs for a loop.
> +/*
> + * Since the Initiator sees iSCSI devices as LUNs,  the SCSI CDB will
> + * contain the iSCSI LUN in bits 7-5 of byte 1 as per SAM-2.
> + * The point of this is since we are mapping iSCSI LUNs to
> + * SCSI Target IDs having a non-zero LUN in the CDB will throw the
> + * devices and HBAs for a loop.
>   */
> -static inline void transport_generic_prepare_cdb(
> +static inline void transport_clear_cdb_lun(
>  	unsigned char *cdb)
>  {
>  	switch (cdb[0]) {
> @@ -1763,17 +1762,15 @@ EXPORT_SYMBOL(transport_free_se_cmd);
>  
>  static void transport_generic_wait_for_tasks(struct se_cmd *, int, int);
>  
> -/*	transport_generic_allocate_tasks():
> - *
> - *	Called from fabric RX Thread.
> +/*
> + * Called from fabric RX Thread. Copies cdb into cmd, and examines cdb.
> + * See cmd_sequencer().
>   */
> -int transport_generic_allocate_tasks(
> -	struct se_cmd *cmd,
> -	unsigned char *cdb)
> +int transport_generic_process_cdb(struct se_cmd *cmd, unsigned char *cdb)
>  {
>  	int ret;
>  
> -	transport_generic_prepare_cdb(cdb);
> +	transport_clear_cdb_lun(cdb);
>  
>  	/*
>  	 * This is needed for early exceptions.
> @@ -1834,7 +1831,7 @@ int transport_generic_allocate_tasks(
>  	spin_unlock(&cmd->se_lun->lun_sep_lock);
>  	return 0;
>  }
> -EXPORT_SYMBOL(transport_generic_allocate_tasks);
> +EXPORT_SYMBOL(transport_generic_process_cdb);
>  
>  /*
>   * Used by fabric module frontends not defining a TFO->new_cmd_map()
> diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
> index b7f1880..6ad800e 100644
> --- a/drivers/target/tcm_fc/tfc_cmd.c
> +++ b/drivers/target/tcm_fc/tfc_cmd.c
> @@ -617,7 +617,7 @@ static void ft_send_cmd(struct ft_cmd *cmd)
>  		return;
>  	}
>  
> -	ret = transport_generic_allocate_tasks(se_cmd, cmd->cdb);
> +	ret = transport_generic_process_cdb(se_cmd, cmd->cdb);
>  
>  	FT_IO_DBG("r_ctl %x alloc task ret %d\n", fh->fh_r_ctl, ret);
>  	ft_dump_cmd(cmd, __func__);
> diff --git a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
> index 4d08f8b..6aa7ebc 100644
> --- a/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
> +++ b/drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c
> @@ -645,7 +645,7 @@ int tcm_qla2xxx_new_cmd_map(struct se_cmd *se_cmd)
>  	/*
>  	 * Allocate the necessary tasks to complete the received CDB+data
>  	 */
> -	ret = transport_generic_allocate_tasks(se_cmd, cdb);
> +	ret = transport_generic_process_cdb(se_cmd, cdb);
>  	if (ret == -1) {
>  		/* Out of Resources */
>  		transport_send_check_condition_and_sense(se_cmd,
> diff --git a/drivers/target/tcm_vhost/tcm_vhost_fabric.c b/drivers/target/tcm_vhost/tcm_vhost_fabric.c
> index 7e4da7e..e8bc9af 100644
> --- a/drivers/target/tcm_vhost/tcm_vhost_fabric.c
> +++ b/drivers/target/tcm_vhost/tcm_vhost_fabric.c
> @@ -239,7 +239,7 @@ int tcm_vhost_new_cmd_map(struct se_cmd *se_cmd)
>  	/*
>  	 * Allocate the necessary tasks to complete the received CDB+data
>  	 */
> -	ret = transport_generic_allocate_tasks(se_cmd, tv_cmd->tvc_cdb);
> +	ret = transport_generic_process_cdb(se_cmd, tv_cmd->tvc_cdb);
>  	if (ret == -1) {
>  		/* Out of Resources */
>  		return PYX_TRANSPORT_LU_COMM_FAILURE;
> diff --git a/drivers/target/tcm_vhost/tcm_vhost_scsi.c b/drivers/target/tcm_vhost/tcm_vhost_scsi.c
> index 4a01da6..a19c53e 100644
> --- a/drivers/target/tcm_vhost/tcm_vhost_scsi.c
> +++ b/drivers/target/tcm_vhost/tcm_vhost_scsi.c
> @@ -157,7 +157,7 @@ static void vhost_scsi_handle_vq(struct vhost_scsi *vs)
>  		/*
>  		 * Copy in the recieved CDB descriptor into tv_cmd->tvc_cdb
>  		 * that will be used by tcm_vhost_new_cmd_map() and down into
> -		 * transport_generic_allocate_tasks()
> +		 * transport_generic_process_cdb()
>  		 */
>  		memcpy(tv_cmd->tvc_cdb, cdb, scsi_command_size(cdb));
>  		/*
> diff --git a/include/target/target_core_transport.h b/include/target/target_core_transport.h
> index 4bbd88b..0d42d16 100644
> --- a/include/target/target_core_transport.h
> +++ b/include/target/target_core_transport.h
> @@ -164,7 +164,7 @@ extern void transport_init_se_cmd(struct se_cmd *,
>  					struct se_session *, u32, int, int,
>  					unsigned char *);
>  extern void transport_free_se_cmd(struct se_cmd *);
> -extern int transport_generic_allocate_tasks(struct se_cmd *, unsigned char *);
> +extern int transport_generic_process_cdb(struct se_cmd *, unsigned char *);
>  extern int transport_generic_handle_cdb(struct se_cmd *);
>  extern int transport_generic_handle_cdb_map(struct se_cmd *);
>  extern int transport_generic_handle_data(struct se_cmd *);
> -- 
> 1.7.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups "Linux-iSCSI.org Target Development" group.
> To post to this group, send email to linux-iscsi-target-dev@xxxxxxxxxxxxxxxxx
> To unsubscribe from this group, send email to linux-iscsi-target-dev+unsubscribe@xxxxxxxxxxxxxxxxx
> For more options, visit this group at http://groups.google.com/group/linux-iscsi-target-dev?hl=en.
> 

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