* [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer
@ 2021-11-22 6:12 Shin'ichiro Kawasaki
2021-11-22 6:32 ` Damien Le Moal
2021-11-23 3:45 ` Martin K. Petersen
0 siblings, 2 replies; 4+ messages in thread
From: Shin'ichiro Kawasaki @ 2021-11-22 6:12 UTC (permalink / raw)
To: linux-scsi
Cc: Martin K . Petersen, Douglas Gilbert, Damien Le Moal,
Shinichiro Kawasaki
When reset write pointer is requested to scsi_debug devices with zoned
model, positions of write pointers are reset, but the data in the target
zones are not cleared. Read to the zones returns data written before the
reset write pointer. This unexpected left data is confusing and does not
allow using scsi_debug for stale page cache test of the BLKRESETZONE
ioctl. Hence, zero clear the written data in the zones at reset write
pointer.
Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
Changes from v1:
* Zero clear only the written data area in non-empty zones
drivers/scsi/scsi_debug.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 1d0278da9041..1ef9907c479a 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -4653,6 +4653,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
struct sdeb_zone_state *zsp)
{
enum sdebug_z_cond zc;
+ struct sdeb_store_info *sip = devip2sip(devip, false);
if (zbc_zone_is_conv(zsp))
return;
@@ -4664,6 +4665,10 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
if (zsp->z_cond == ZC4_CLOSED)
devip->nr_closed--;
+ if (zsp->z_wp > zsp->z_start)
+ memset(sip->storep + zsp->z_start * sdebug_sector_size, 0,
+ (zsp->z_wp - zsp->z_start) * sdebug_sector_size);
+
zsp->z_non_seq_resource = false;
zsp->z_wp = zsp->z_start;
zsp->z_cond = ZC1_EMPTY;
--
2.33.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer
2021-11-22 6:12 [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer Shin'ichiro Kawasaki
@ 2021-11-22 6:32 ` Damien Le Moal
2021-11-22 18:45 ` Douglas Gilbert
2021-11-23 3:45 ` Martin K. Petersen
1 sibling, 1 reply; 4+ messages in thread
From: Damien Le Moal @ 2021-11-22 6:32 UTC (permalink / raw)
To: Shin'ichiro Kawasaki, linux-scsi
Cc: Martin K . Petersen, Douglas Gilbert, Damien Le Moal
On 2021/11/22 15:12, Shin'ichiro Kawasaki wrote:
> When reset write pointer is requested to scsi_debug devices with zoned
> model, positions of write pointers are reset, but the data in the target
> zones are not cleared. Read to the zones returns data written before the
> reset write pointer. This unexpected left data is confusing and does not
> allow using scsi_debug for stale page cache test of the BLKRESETZONE
> ioctl. Hence, zero clear the written data in the zones at reset write
> pointer.
>
> Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> ---
> Changes from v1:
> * Zero clear only the written data area in non-empty zones
>
> drivers/scsi/scsi_debug.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 1d0278da9041..1ef9907c479a 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4653,6 +4653,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
> struct sdeb_zone_state *zsp)
> {
> enum sdebug_z_cond zc;
> + struct sdeb_store_info *sip = devip2sip(devip, false);
>
> if (zbc_zone_is_conv(zsp))
> return;
> @@ -4664,6 +4665,10 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
> if (zsp->z_cond == ZC4_CLOSED)
> devip->nr_closed--;
>
> + if (zsp->z_wp > zsp->z_start)
> + memset(sip->storep + zsp->z_start * sdebug_sector_size, 0,
> + (zsp->z_wp - zsp->z_start) * sdebug_sector_size);
> +
> zsp->z_non_seq_resource = false;
> zsp->z_wp = zsp->z_start;
> zsp->z_cond = ZC1_EMPTY;
>
Looks good.
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer
2021-11-22 6:32 ` Damien Le Moal
@ 2021-11-22 18:45 ` Douglas Gilbert
0 siblings, 0 replies; 4+ messages in thread
From: Douglas Gilbert @ 2021-11-22 18:45 UTC (permalink / raw)
To: Damien Le Moal, Shin'ichiro Kawasaki, linux-scsi
Cc: Martin K . Petersen, Damien Le Moal
On 2021-11-22 1:32 a.m., Damien Le Moal wrote:
> On 2021/11/22 15:12, Shin'ichiro Kawasaki wrote:
>> When reset write pointer is requested to scsi_debug devices with zoned
>> model, positions of write pointers are reset, but the data in the target
>> zones are not cleared. Read to the zones returns data written before the
>> reset write pointer. This unexpected left data is confusing and does not
>> allow using scsi_debug for stale page cache test of the BLKRESETZONE
>> ioctl. Hence, zero clear the written data in the zones at reset write
>> pointer.
>>
>> Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
>> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
>> ---
>> Changes from v1:
>> * Zero clear only the written data area in non-empty zones
>>
>> drivers/scsi/scsi_debug.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
>> index 1d0278da9041..1ef9907c479a 100644
>> --- a/drivers/scsi/scsi_debug.c
>> +++ b/drivers/scsi/scsi_debug.c
>> @@ -4653,6 +4653,7 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
>> struct sdeb_zone_state *zsp)
>> {
>> enum sdebug_z_cond zc;
>> + struct sdeb_store_info *sip = devip2sip(devip, false);
>>
>> if (zbc_zone_is_conv(zsp))
>> return;
>> @@ -4664,6 +4665,10 @@ static void zbc_rwp_zone(struct sdebug_dev_info *devip,
>> if (zsp->z_cond == ZC4_CLOSED)
>> devip->nr_closed--;
>>
>> + if (zsp->z_wp > zsp->z_start)
>> + memset(sip->storep + zsp->z_start * sdebug_sector_size, 0,
>> + (zsp->z_wp - zsp->z_start) * sdebug_sector_size);
>> +
>> zsp->z_non_seq_resource = false;
>> zsp->z_wp = zsp->z_start;
>> zsp->z_cond = ZC1_EMPTY;
>>
>
> Looks good.
>
> Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Thanks.
Acked-by: Douglas Gilbert <dgilbert@interlog.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer
2021-11-22 6:12 [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer Shin'ichiro Kawasaki
2021-11-22 6:32 ` Damien Le Moal
@ 2021-11-23 3:45 ` Martin K. Petersen
1 sibling, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-11-23 3:45 UTC (permalink / raw)
To: linux-scsi, Shin'ichiro Kawasaki
Cc: Martin K . Petersen, Douglas Gilbert, Damien Le Moal
On Mon, 22 Nov 2021 15:12:23 +0900, Shin'ichiro Kawasaki wrote:
> When reset write pointer is requested to scsi_debug devices with zoned
> model, positions of write pointers are reset, but the data in the target
> zones are not cleared. Read to the zones returns data written before the
> reset write pointer. This unexpected left data is confusing and does not
> allow using scsi_debug for stale page cache test of the BLKRESETZONE
> ioctl. Hence, zero clear the written data in the zones at reset write
> pointer.
>
> [...]
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: scsi_debug: Zero clear zones at reset write pointer
https://git.kernel.org/mkp/scsi/c/2d62253eb1b6
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-23 3:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-22 6:12 [PATCH v2] scsi: scsi_debug: Zero clear zones at reset write pointer Shin'ichiro Kawasaki
2021-11-22 6:32 ` Damien Le Moal
2021-11-22 18:45 ` Douglas Gilbert
2021-11-23 3:45 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox