Re: [PATCH] target: Remove first argument of target_{get,put}_sess_cmd()

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

 



On Fri, 2015-04-10 at 14:50 +0200, Bart Van Assche wrote:
> The first argument of these two functions is always identical
> to se_cmd->se_sess so remove the first argument. Additionally,
> drop the _sess part from the names of these two functions.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxx>
> ---
>  drivers/infiniband/ulp/isert/ib_isert.c      |  8 +++---
>  drivers/infiniband/ulp/srpt/ib_srpt.c        | 10 +++----
>  drivers/scsi/qla2xxx/qla_target.c            |  4 +--
>  drivers/scsi/qla2xxx/tcm_qla2xxx.c           |  2 +-
>  drivers/target/iscsi/iscsi_target.c          | 17 ++++++------
>  drivers/target/iscsi/iscsi_target_configfs.c |  2 +-
>  drivers/target/iscsi/iscsi_target_util.c     |  4 +--
>  drivers/target/target_core_tmr.c             |  2 +-
>  drivers/target/target_core_transport.c       | 41 +++++++++++++---------------
>  drivers/vhost/scsi.c                         |  2 +-
>  include/target/target_core_fabric.h          |  4 +--
>  11 files changed, 46 insertions(+), 50 deletions(-)
> 

<SNIP>

> --- a/drivers/target/target_core_transport.c
> +++ b/drivers/target/target_core_transport.c
> @@ -2434,20 +2434,19 @@ int transport_generic_free_cmd(struct se_cmd *cmd, int wait_for_tasks)
>  }
>  EXPORT_SYMBOL(transport_generic_free_cmd);
>  
> -/* target_get_sess_cmd - Add command to active ->sess_cmd_list
> - * @se_sess:	session to reference
> +/* target_get_cmd - Add command to active ->sess_cmd_list
>   * @se_cmd:	command descriptor to add
> - * @ack_kref:	Signal that fabric will perform an ack target_put_sess_cmd()
> + * @ack_kref:	Signal that fabric will perform an ack target_put_cmd()
>   */
> -int target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
> -			       bool ack_kref)
> +int target_get_cmd(struct se_cmd *se_cmd, bool ack_kref)
>  {
> +	struct se_session *se_sess = se_cmd->se_sess;
>  	unsigned long flags;
>  	int ret = 0;
>  
>  	/*
>  	 * Add a second kref if the fabric caller is expecting to handle
> -	 * fabric acknowledgement that requires two target_put_sess_cmd()
> +	 * fabric acknowledgement that requires two target_put_cmd()
>  	 * invocations before se_cmd descriptor release.
>  	 */
>  	if (ack_kref)
> @@ -2463,7 +2462,7 @@ out:
>  	spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
>  	return ret;
>  }
> -EXPORT_SYMBOL(target_get_sess_cmd);
> +EXPORT_SYMBOL(target_get_cmd);

We're adding the reference for the command to the session.

Don't rename functions to something that make it less clear what they're
actually doing.

>  
>  static void target_release_cmd_kref(struct kref *kref)
>  		__releases(&se_cmd->se_sess->sess_cmd_lock)
> @@ -2487,20 +2486,18 @@ static void target_release_cmd_kref(struct kref *kref)
>  	se_cmd->se_tfo->release_cmd(se_cmd);
>  }
>  
> -/* target_put_sess_cmd - Check for active I/O shutdown via kref_put
> - * @se_sess:	session to reference
> +/* target_put_cmd - Check for active I/O shutdown via kref_put
>   * @se_cmd:	command descriptor to drop
>   */
> -int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
> +int target_put_cmd(struct se_cmd *se_cmd)
>  {
> -	if (!se_sess) {
> -		se_cmd->se_tfo->release_cmd(se_cmd);
> -		return 1;
> -	}
> -	return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref,
> -			&se_sess->sess_cmd_lock);

For EXTENDED_COPY, se_sess is always NULL.

Really, stop randomly dropping checks like this without first looking at
why they where put there in the first place.

> +	struct se_session *se_sess = se_cmd->se_sess;
> +
> +	return kref_put_spinlock_irqsave(&se_cmd->cmd_kref,
> +					 target_release_cmd_kref,
> +					 &se_sess->sess_cmd_lock);
>  }
> -EXPORT_SYMBOL(target_put_sess_cmd);
> +EXPORT_SYMBOL(target_put_cmd);
>  

Ditto here, drop the random renames.

There is already an internal transport_put_cmd().

--nab

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