Re: [PATCH 2/7] target: Add TARGET_SCF_ACK_KREF flag usage

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

 



> This patch adds TARGET_SCF_ACK_KREF for target_submit_cmd() that passes
> a 'ack_kref' parameter into target_get_sess_cmd() to determine when
> the fabric caller is expecting a second kref_put() from fabric
> packet acknowledgement.

The flag name isn't really very descriptive, I'd rather either chose
one that describes why we are doing it, or find a way to drop the
additional reference even for drivers not currently doing it.

> -void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
> +void target_get_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd,
> +			bool ack_kref)
>  {
>  	unsigned long flags;
>  
>  	kref_init(&se_cmd->cmd_kref);
> -	kref_get(&se_cmd->cmd_kref);
> +	/*
> +	 * Add a second kref if the fabric caller is expecting to handle
> +	 * fabric acknowledgement that requires two target_put_sess_cmd()
> +	 * invocations before se_cmd descriptor release.
> +	 */
> +	if (ack_kref == true)
> +		kref_get(&se_cmd->cmd_kref);
>  
>  	spin_lock_irqsave(&se_sess->sess_cmd_lock, flags);
>  	list_add_tail(&se_cmd->se_cmd_list, &se_sess->sess_cmd_list);

Why don't you simply do the kref_get after target_get_sess_cmd has
returned, avoiding the parameter to target_get_sess_cmd?

> +	int rc, flags = (bidi) ? TARGET_SCF_BIDI_OP : 0 | TARGET_SCF_ACK_KREF;

no need for the braces around bidi.

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