Re: [PATCH v2 3/5] scsi: sd: Fix data corruption in WRITE SAME(10) discards
From: Chris Down
Date: Sun Nov 29 2026 - 14:26:01 EST
Hi Bart,
Bart Van Assche writes:
>That comment isn't correct for removable devices:
>set_media_not_present() sets sdkp->capacity = 0 without holding
>q->limits_lock and without updating get_capacity(sdkp->disk). It is
>called from sd_check_events() and from sd_spinup_disk() (which runs in
>sd_revalidate_disk() before queue_limits_start_update()).
Thanks, I didn't know that. In v3 I'll have it only say why the check
is made under the lock.
>So on a removable disk with capacity > 2^32 blocks, sd_can_use_ws10()
>can see sdkp->capacity == 0 and allow SD_LBP_WS10 / SD_LBP_ZERO while
>get_capacity(sdkp->disk) is still > 2^32.
I can reproduce that with scsi_debug. In v3 sd_can_use_ws10() will check
the gendisk capacity as well, so both modes are refused there.
Thanks,
Chris