On Thu, 2019-02-14 at 22:15 +-0100, Jean Delvare wrote: +AD4 From: Hannes Reinecke +ADw-hare+AEA-suse.com+AD4 +AD4 +AD4 When evaluating the 'block limits' VPD page we need to check if +AD4 the 'lbpme' (logical block provisioning management enable) bit +AD4 is set in the READ CAPACITY (16) output. +AD4 If it isn't we can safely assume that we cannot use DISCARD on +AD4 this device. +AD4 +AD4 +AFs-JD: forward-ported to kernel v4.20+AF0 +AD4 +AD4 Signed-off-by: Hannes Reinecke +ADw-hare+AEA-suse.com+AD4 +AD4 Signed-off-by: Jean Delvare +ADw-jdelvare+AEA-suse.com+AD4 +AD4 --- +AD4 Hannes, please double-check that my forward-port is correct. +AD4 +AD4 drivers/scsi/sd.c +AHw 11 +-+-+-+-+-+-+-+-+-+-- +AD4 1 file changed, 10 insertions(+-), 1 deletion(-) +AD4 +AD4 --- a/drivers/scsi/sd.c +AD4 +-+-+- b/drivers/scsi/sd.c +AD4 +AEAAQA -411,6 +-411,13 +AEAAQA provisioning+AF8-mode+AF8-store(struct device +ACo-d +AD4 if (mode +ADw 0) +AD4 return -EINVAL+ADs +AD4 +AD4 +- /+ACo +AD4 +- +ACo If logical block provisioning isn't enabled we can only +AD4 +- +ACo select 'disable' here. +AD4 +- +ACo-/ +AD4 +- if (+ACE-sdkp-+AD4-lbpme +ACYAJg mode +ACEAPQ SD+AF8-LBP+AF8-DISABLE) +AD4 +- return -EINVAL+ADs +AD4 +- +AD4 sd+AF8-config+AF8-discard(sdkp, mode)+ADs +AD4 +AD4 return count+ADs +AD4 +AEAAQA -2942,8 +-2949,10 +AEAAQA static void sd+AF8-read+AF8-block+AF8-limits(struct +AD4 +AD4 sdkp-+AD4-max+AF8-ws+AF8-blocks +AD0 (u32)get+AF8-unaligned+AF8-be64(+ACY-buffer+AFs-36+AF0)+ADs +AD4 +AD4 - if (+ACE-sdkp-+AD4-lbpme) +AD4 +- if (+ACE-sdkp-+AD4-lbpme) +AHs +AD4 +- sd+AF8-config+AF8-discard(sdkp, SD+AF8-LBP+AF8-DISABLE)+ADs +AD4 goto out+ADs +AD4 +- +AH0 +AD4 +AD4 lba+AF8-count +AD0 get+AF8-unaligned+AF8-be32(+ACY-buffer+AFs-20+AF0)+ADs +AD4 desc+AF8-count +AD0 get+AF8-unaligned+AF8-be32(+ACY-buffer+AFs-24+AF0)+ADs What is the impact of this patch on SATA SSDs? Since these SSDs do not support logical provisioning, does this patch break trim support for these SSDs? Bart.