All of lore.kernel.org
 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 3/7] scsi: scsi_debug: Split corrupt_lbas()
Date: Fri, 25 Sep 2026 09:55:58 +0100	[thread overview]
Message-ID: <93d9399e-6374-4b94-a26b-40bb8e9e5cc7@linux.dev> (raw)
In-Reply-To: <9484940ad7bb464786c9f52211129015ce8ec006.1790290090.git.bvanassche@acm.org>

On 9/24/26 23:54, Bart Van Assche wrote:
> Move the inner logic of corrupt_lbas() into a new helper function
> __corrupt_lbas() and call it from separate locked and unlocked branches
> in corrupt_lbas(). This patch prepares for enabling context analysis.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: John Garry <john.garry@linux.dev>

> ---
>   drivers/scsi/scsi_debug.c | 42 ++++++++++++++++++++-------------------
>   1 file changed, 22 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index d0d2cbac487b..0f4637d1265a 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4948,39 +4948,26 @@ static int resp_write_tape(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
>   	return 0;
>   }
>   
> -static int corrupt_lbas(struct sdebug_dev_info *devip, u64 lba, u32 num,
> -		u32 nr_bit_errors, s32 reftag_adjust)
> +static int __corrupt_lbas(struct sdeb_store_info *sip, u64 lba, u32 num,
> +			  u32 nr_bit_errors, s32 reftag_adjust)
>   {
> -	struct sdeb_store_info *sip = devip2sip(devip, false);
> -	bool meta_data_locked = false;
>   	u32 block, num_mapped, b, i;
> -	int error = 0;
> -
> -	if (sdebug_dev_is_zoned(devip) ||
> -	    sdebug_dix ||
> -	    scsi_debug_lbp())  {
> -		sdeb_meta_write_lock(sip);
> -		meta_data_locked = true;
> -	}
>   
>   	if (!sip) {
>   		pr_err("can't corrupt with fake_rw\n");
> -		error = -EINVAL;
> -		goto out_unlock;
> +		return -EINVAL;

These checks don't need locking, so could be in corrupt_lbas(). It does 
not make much difference though.

>   	}
>   
>   	if (num > sdebug_capacity || lba > sdebug_capacity - num) {
>   		pr_err("logical blocks out of bounds: %llu:%u", lba, num);
> -		error = -EINVAL;
> -		goto out_unlock;
> +		return -EINVAL;
>   	}
>   
>   	if (scsi_debug_lbp() &&
>   	    (!map_state(sip, lba, &num_mapped) || num > num_mapped)) {
>   		pr_err("can't modify unmapped logical blocks: %llu:%u",
>   			lba, num);
> -		error = -EINVAL;
> -		goto out_unlock;
> +		return -EINVAL;
>   	}
>   
>   	/*
> @@ -5018,9 +5005,24 @@ static int corrupt_lbas(struct sdebug_dev_info *devip, u64 lba, u32 num,
>   	}
>   	sdeb_data_unlock(sip, false);
>   
> -out_unlock:
> -	if (meta_data_locked)
> +	return 0;
> +}
> +
> +static int corrupt_lbas(struct sdebug_dev_info *devip, u64 lba, u32 num,
> +			u32 nr_bit_errors, s32 reftag_adjust)
> +{
> +	struct sdeb_store_info *sip = devip2sip(devip, false);
> +	int error;
> +
> +	if (sdebug_dev_is_zoned(devip) || sdebug_dix || scsi_debug_lbp()) {
> +		sdeb_meta_write_lock(sip);
> +		error = __corrupt_lbas(sip, lba, num, nr_bit_errors,
> +				       reftag_adjust);
>   		sdeb_meta_write_unlock(sip);
> +	} else {
> +		error = __corrupt_lbas(sip, lba, num, nr_bit_errors,
> +				       reftag_adjust);
> +	}
>   	return error;
>   }
>   


  parent reply	other threads:[~2026-09-25  8:56 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 [this message]
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
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=93d9399e-6374-4b94-a26b-40bb8e9e5cc7@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.