Nevertheless, I don't really quite get the sense of the original commit anyway.

Isn't discard granularity the minimum size we can discard? In that
case why would it have anything to do with "read zeroes"?

Suppose we are handling a device reports a discard granularity of 4096
bytes, while logical block size and physical block size are both 512
bytes. For such a device, a single 512-byte discard request should
simply be rejected because it's not allowed by the device. When it's
rejected, it doesn't mean that "the 512-byte block does not read
zeroes after being discarded"; instead, it's just "we did not discard
the 512-byte block as per requested because it's not allowed".

On 10 March 2016 at 16:16,  <[email protected]> wrote:
> From: Tom Yan <[email protected]>
>
> According to its own comment, the discard granularity should
> fixed to the logical block size. However, the actual code has
> it hardcoded as 1 byte. Changing it to logical_block_size.
>
> Signed-off-by: Tom Yan <[email protected]>
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index d749da7..5a5457a 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -648,7 +648,7 @@ static void sd_config_discard(struct scsi_disk *sdkp, 
> unsigned int mode)
>          */
>         if (sdkp->lbprz) {
>                 q->limits.discard_alignment = 0;
> -               q->limits.discard_granularity = 1;
> +               q->limits.discard_granularity = logical_block_size;
>         } else {
>                 q->limits.discard_alignment = sdkp->unmap_alignment *
>                         logical_block_size;
> --
> 2.7.2
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to