On 05/08/2020 11:10, Damien Le Moal wrote: [...] > > May be something like this would do (not pretty...): > > diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h > index 999f54810926..fba312c8725d 100644 > --- a/drivers/scsi/sd.h > +++ b/drivers/scsi/sd.h > @@ -84,6 +84,7 @@ struct scsi_disk { > u32 *zones_wp_offset; > spinlock_t zones_wp_offset_lock; > u32 *rev_wp_offset; > + struct task_struct *rev_task; > struct mutex rev_mutex; > struct work_struct zone_wp_offset_work; > char *zone_wp_update_buf; > diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c > index 33221d8e9f8f..53f0489c3433 100644 > --- a/drivers/scsi/sd_zbc.c > +++ b/drivers/scsi/sd_zbc.c > @@ -69,7 +69,7 @@ static int sd_zbc_parse_report(struct scsi_disk *sdkp, u8 *buf, > if (ret) > return ret; > > - if (sdkp->rev_wp_offset) > + if (sdkp->rev_wp_offset && current == sdkp->rev_task) > sdkp->rev_wp_offset[idx] = sd_zbc_get_zone_wp_offset(&zone); > > return 0; > @@ -688,10 +688,13 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp) > goto unlock; > } > > + sdkp->rev_task = current; > + > ret = blk_revalidate_disk_zones(disk, sd_zbc_revalidate_zones_cb); > > kvfree(sdkp->rev_wp_offset); > sdkp->rev_wp_offset = NULL; > + sdkp->rev_task = NULL; > > if (ret) { > sdkp->zone_blocks = 0; > > > This is totally untested... > I agree it's not pretty but at least way more readable then what I did. Can't test though, as I haven't managed to provoke the race yet.