Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: John Garry <john.garry@linux.dev>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, John Garry <john.g.garry@oracle.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 4/7] scsi: scsi_debug: Split resp_read_dt0()
Date: Fri, 25 Sep 2026 10:06:35 +0100	[thread overview]
Message-ID: <1ffb80b0-c312-4773-8e0e-fd6a59a674f2@linux.dev> (raw)
In-Reply-To: <4b4b537c1a2c95b81d0c8b8f9c4c31e2b9f47369.1790290090.git.bvanassche@acm.org>

On 9/24/26 23:54, Bart Van Assche wrote:
> +/*
> + * Returns the number of bytes transferred, or -1 with *scsi_status set to a
> + * SCSI status code on failure.
> + */
> +static int __resp_read_dt0(struct scsi_cmnd *scp, struct sdeb_store_info *sip,
> +			   u64 lba, u32 num, u32 ei_lba, int *scsi_status)
> +{
> +	u8 *cmd = scp->cmnd;
> +
> +	/* DIX + T10 DIF */
> +	if (unlikely(sdebug_dix && scsi_prot_sg_count(scp))) {
> +		switch (prot_verify_read(scp, lba, num, ei_lba)) {
> +		case 1: /* Guard tag error */
> +			if (cmd[1] >> 5 != 3) { /* RDPROTECT != 3 */
> +				mk_sense_buffer(scp, ABORTED_COMMAND,
> +					LOGICAL_BLOCK_GUARD_CHECK_FAILED);
> +				*scsi_status = check_condition_result;
> +				return -1;
> +			} else if (scp->prot_flags & SCSI_PROT_GUARD_CHECK) {
> +				mk_sense_buffer(scp, ILLEGAL_REQUEST,
> +					LOGICAL_BLOCK_GUARD_CHECK_FAILED);
> +				*scsi_status = illegal_condition_result;
> +				return -1;
> +			}
> +			break;
> +		case 3: /* Reference tag error */
> +			if (cmd[1] >> 5 != 3) { /* RDPROTECT != 3 */
> +				mk_sense_buffer(scp, ABORTED_COMMAND,
> +					LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED);
> +				*scsi_status = check_condition_result;
> +				return -1;
> +			} else if (scp->prot_flags & SCSI_PROT_REF_CHECK) {
> +				mk_sense_buffer(scp, ILLEGAL_REQUEST,
> +					LOGICAL_BLOCK_REFERENCE_TAG_CHECK_FAILED);
> +				*scsi_status = illegal_condition_result;
> +				return -1;
> +			}
> +			break;
> +		}
> +	}
> +
> +	*scsi_status = DID_ERROR << 16;

This just seems odd. We are still setting scsi_status = DID_ERROR << 16 
even if no error. I know that it is not checked (for no error), but it 
is a good practice to make it hold a proper value.

Similar could be said how it is initialized in resp_read_dt0().
> +	return do_device_access(sip, scp, 0, lba, num, 0, false, false);
> +}


  parent reply	other threads:[~2026-09-25  9:06 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 22:54 [PATCH v2 0/7] scsi_debug: Enable lock context analysis Bart Van Assche
2026-09-24 22:54 ` [PATCH v2 1/7] scsi: scsi_debug: Fix a locking bug in resp_write_same() Bart Van Assche
2026-09-25  7:06   ` Christoph Hellwig
2026-09-25  8:43   ` John Garry
2026-09-24 22:54 ` [PATCH v2 2/7] scsi: scsi_debug: Split resp_write_same() Bart Van Assche
2026-09-25  7:08   ` Christoph Hellwig
2026-09-25  8:50   ` John Garry
2026-09-24 22:54 ` [PATCH v2 3/7] scsi: scsi_debug: Split corrupt_lbas() Bart Van Assche
2026-09-25  7:09   ` Christoph Hellwig
2026-09-25  8:55   ` John Garry
2026-09-24 22:54 ` [PATCH v2 4/7] scsi: scsi_debug: Split resp_read_dt0() Bart Van Assche
2026-09-25  7:10   ` Christoph Hellwig
2026-09-25  9:06   ` John Garry [this message]
2026-09-24 22:54 ` [PATCH v2 5/7] scsi: scsi_debug: Split resp_write_dt0() Bart Van Assche
2026-09-25  7:12   ` Christoph Hellwig
2026-09-24 22:54 ` [PATCH v2 6/7] scsi: scsi_debug: Improve lock context annotations Bart Van Assche
2026-09-25  9:15   ` John Garry
2026-09-25 15:55     ` Bart Van Assche
2026-09-24 22:54 ` [PATCH v2 7/7] scsi: core: Enable lock context analysis for the scsi_debug driver Bart Van Assche
2026-09-25  7:13   ` Christoph Hellwig
2026-09-25  9:16   ` John Garry

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=1ffb80b0-c312-4773-8e0e-fd6a59a674f2@linux.dev \
    --to=john.garry@linux.dev \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=john.g.garry@oracle.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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