mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mike Christie <michael.christie@oracle.com>
To: Yehyeong Lee <yhlee@isslab.korea.ac.kr>, martin.petersen@oracle.com
Cc: cleech@redhat.com, lduncan@suse.com,
	James.Bottomley@HansenPartnership.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] scsi: libiscsi_tcp: check that a read got the data the target claimed
Date: Tue, 6 Oct 2026 19:08:07 -0500	[thread overview]
Message-ID: <5a4e8daf-d00c-47ff-8069-7bc57dd048a6@oracle.com> (raw)
In-Reply-To: <20260814121428.359541-1-yhlee@isslab.korea.ac.kr>

On 8/14/26 7:14 AM, Yehyeong Lee wrote:
> @@ -752,13 +795,25 @@ iscsi_tcp_hdr_dissect(struct iscsi_conn *conn, struct iscsi_hdr *hdr)
>  		rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
>  		spin_unlock(&conn->session->back_lock);
>  		break;
> -	case ISCSI_OP_SCSI_CMD_RSP:
> +	case ISCSI_OP_SCSI_CMD_RSP: {
> +		struct iscsi_scsi_rsp *rsp = (struct iscsi_scsi_rsp *)hdr;
> +
> +		spin_lock(&conn->session->back_lock);
> +		task = iscsi_itt_to_ctask(conn, hdr->itt);
> +		if (task)
> +			rc = iscsi_tcp_check_data_in(task, rsp->flags,
> +						     be32_to_cpu(rsp->residual_count));
> +		spin_unlock(&conn->session->back_lock);
> +		if (rc)
> +			break;
> +
>  		if (tcp_conn->in.datalen) {
>  			iscsi_tcp_data_recv_prep(tcp_conn);
>  			return 0;
>  		}

For the normal case we will grab and drop the lock multiple times.

Could you switch it around where we do:

spin_lock(&conn->session->back_lock);
task = iscsi_itt_to_ctask(conn, hdr->itt);
if (!task) {
	spin_unlock(&conn->session->back_lock);
	return ISCSI_ERR_BAD_ITT;
}

rc = iscsi_tcp_check_data_in(task, rsp->flags,
			     be32_to_cpu(rsp->residual_count));
if (rc) {
	spin_unlock(&conn->session->back_lock);
	return rc;
}

if (tcp_conn->in.datalen) {
	spin_unlock(&conn->session->back_lock);
	iscsi_tcp_data_recv_prep(tcp_conn);
	return 0;
}

rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);
spin_unlock(&conn->session->back_lock);
break;

>  		rc = iscsi_complete_pdu(conn, hdr, NULL, 0);
>  		break;
> +	}
>  	case ISCSI_OP_R2T:
>  		if (ahslen) {
>  			rc = ISCSI_ERR_AHSLEN;
> @@ -998,6 +1053,7 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
>  
>  	BUG_ON(kfifo_len(&tcp_task->r2tqueue));
>  	tcp_task->exp_datasn = 0;
> +	tcp_task->data_in_bytes = 0;
>  
>  	/* Prepare PDU, optionally w/ immediate data */
>  	ISCSI_DBG_TCP(conn, "task deq [itt 0x%x imm %d unsol %d]\n",
> diff --git a/include/scsi/libiscsi_tcp.h b/include/scsi/libiscsi_tcp.h
> index ef53d4bea28a0..b38be23b9e10b 100644
> --- a/include/scsi/libiscsi_tcp.h
> +++ b/include/scsi/libiscsi_tcp.h
> @@ -66,6 +66,7 @@ struct iscsi_tcp_conn {
>  
>  struct iscsi_tcp_task {
>  	uint32_t		exp_datasn;	/* expected target's R2TSN/DataSN */
> +	u32			data_in_bytes;	/* Data-In payload received */

I know we are supposed to use u32, but could you do uint32_t to match the
rest of the code. It just makes it easier to search/review when the code
uses the same style.


>  	int			data_offset;
>  	struct iscsi_r2t_info	*r2t;		/* in progress solict R2T */
>  	struct iscsi_pool	r2tpool;
> -- 
> 2.43.0
> 


  reply	other threads:[~2026-10-07  0:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 12:14 Yehyeong Lee
2026-10-07  0:08 ` Mike Christie [this message]
2026-10-07  0:13 ` Mike Christie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5a4e8daf-d00c-47ff-8069-7bc57dd048a6@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=cleech@redhat.com \
    --cc=lduncan@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=yhlee@isslab.korea.ac.kr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®