[PATCH] sd: read unmap block limits even if lbpme=0

2017-08-14 Thread tom . ty89
From: Tom Yan Some devices may not be decent enough to report lbpme bit properly even when they do support unmap and report relevant information in the block limits and logical block provisioning VPDs properly (Namely, ASMedia ASM1351, a UAS-SATA bridge). One of the reasons

[PATCH] ata: do not hard code limit in ata_set_lba_range_entries()

2016-08-22 Thread tom . ty89
From: Tom Yan In commit 5c79097a28c2 ("libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit"), it is made sure that ata_set_lba_range_entries() will never be called with a request size (n_block) that is larger than the number of blocks that a 512-byte block

[PATCH v2 1/2] libata-scsi: use dev->max_sectors from libata-core appropriately

2016-08-12 Thread tom . ty89
From: Tom Yan Currently we use dev->max_sectors to set max_hw_sectors, which is actually supposed to be a host controller limit (that get set by the host controller driver like ahci, and if not it would be the fallback SCSI_DEFAULT_MAX_SECTORS). That means we have been doing

[PATCH v2 2/2] sd: check BLK_DEF_MAX_SECTORS against max_dev_sectors

2016-08-12 Thread tom . ty89
From: Tom Yan The SCSI disk driver sets max_sectors to BLK_DEF_MAX_SECTORS when the device does not report Optimal Transfer Length. However, it checks only whether it is smaller than max_hw_sectors, but not max_dev_sectors. Signed-off-by: Tom Yan diff

[PATCH 2/2] sd: check BLK_DEF_MAX_SECTORS against max_dev_sectors

2016-08-12 Thread tom . ty89
From: Tom Yan The SCSI disk driver sets max_sector to BLK_DEF_MAX_SECTORS when the device does not report Optimal Transfer Length. However, it checks only whether it is smaller than max_hw_sectors, but not max_dev_sectors. Signed-off-by: Tom Yan diff

[PATCH 1/2] libata-scsi: use dev->max_sectors from libata-core appropriately

2016-08-12 Thread tom . ty89
From: Tom Yan Currently we use dev->max_sectors to set max_hw_sectors, which is actually supposed to be a host controller limit (that get set by the host controller driver like ahci, and if not it would be the fallback SCSI_DEFAULT_MAX_SECTORS). That means we have been doing

[RFC] sd: dynamically adjust SD_MAX_WS16_BLOCKS as per the actual logical block size

2016-08-11 Thread tom . ty89
From: Tom Yan WRITE SAME (16) command can technically handle up to 32-bit number of blocks. However, since 32-bit is also the limitation of the maximum number of bytes that can be represented in the block layer, the current SD_MAX_WS16_BLOCKS was hence derived from the

[RFC] libata-scsi: make sure Maximum Write Same Length is not too large

2016-08-11 Thread tom . ty89
From: Tom Yan Currently we advertise Maximum Write Same Length based on the maximum number of sectors that one-block TRIM payload can cover. The field are used to derived discard_max_bytes and write_same_max_bytes limits in the block layer, which currently can at max be

[PATCH v2 1/2] libata-scsi: set max_hw_sectors again only when dev->max_sectors is set

2016-08-09 Thread tom . ty89
From: Tom Yan When the request queue is initialized (see __scsi_init_queue() in scsi_lib.c), the block layer limit max_hw_sectors is set to shost->max_sectors, which will be set to the "machine infinity" SCSI_DEFAULT_MAX_SECTORS (currently 1024) if sht->max_sectors is not set

[PATCH v2 2/2] libata-core: do not set dev->max_sectors for LBA48 devices

2016-08-09 Thread tom . ty89
From: Tom Yan Currently block layer limit max_hw_sectors is set to ATA_MAX_SECTORS_LBA48 (65535), for devices with LBA48 support. However, block layer limit max_sectors (which is the effective one; also adjustable, upper-bounded by max_hw_sectors) is set to

[PATCH 1/2] libata-scsi: do not call blk_queue_max_hw_sectors()

2016-08-09 Thread tom . ty89
From: Tom Yan We should just let the scsi driver (hosts.c) call the function. It has better heuristic anyway (i.e. use SCSI_DEFAULT_MAX_SECTORS as fallback when max_sectors is not set). diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 2bdb5da..495d916

[PATCH 2/2] libata: do not set max_sectors for LBA48 device

2016-08-09 Thread tom . ty89
From: Tom Yan Along with commit 1dc8fff24187 ("libata-scsi: do not call blk_queue_max_hw_sectors()"), devices with LBA48 support will have max_sectors set to SCSI_DEFAULT_MAX_SECTORS (currently 1024), by the scsi driver. Note that the "max_sectors" here is actually the block

[PATCH resend v3 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-22 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1.

[PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1.

[PATCH resend v2 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit

[PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, char could be signed char. In that case, bytes larger than 127 would be converted to negative number. For example, 0xff from def_control_mpage[] would become -1.

[PATCH resend v2 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit

[PATCH resend 4/5] libata-scsi: have all checks done before calling ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan The one-page-at-a-time check in ata_scsi_mode_select_xlat() should be done before either of the ata_mselect_*() is called. Also updated the comment. We have more than one mode page that has changeable bit since commit 06dbde5f3a44 ("libata: Implement control

[PATCH resend 5/5] libata-scsi: fix MODE SELECT translation for Control mode page

2016-07-21 Thread tom . ty89
From: Tom Yan scsi_done() was called repeatedly and apparently because of that, the kernel would call trace when we touch the Control mode page: Call Trace: [] dump_stack+0x63/0x81 [] __warn+0xcb/0xf0 [] warn_slowpath_null+0x1d/0x20 [] ata_eh_finish+0xe0/0xf0 [libata]

[PATCH resend 2/5] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit

[PATCH resend 3/5] libata-scsi: fix overflow in mode page copy

2016-07-21 Thread tom . ty89
From: Tom Yan ata_mselect_*() would initialize a char array for storing a copy of the current mode page. However, if char was actually signed char, overflow could occur. For example, `0xff` from def_control_mpage[] would be "truncated" to `-1`. This prevented

[PATCH resend 1/5] libata-scsi: minor cleanup in ata_mselect_*()

2016-07-21 Thread tom . ty89
From: Tom Yan 1. Removed a repeated bit masking in ata_mselect_control() 2. Moved `wce`/`d_sense` assignment below the page validity checks 3. Added/Removed empty lines where appropriate Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c

[PATCH v2] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-19 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit

[PATCH] libata-scsi: fix read-only bits checking in ata_mselect_*()

2016-07-19 Thread tom . ty89
From: Tom Yan Commit 7780081c1f04 ("libata-scsi: Set information sense field for invalid parameter") changed how ata_mselect_*() make sure read-only bits are not modified. The new implementation introduced a bug that the read-only bits in the byte that has a changeable bit

[PATCH v4] libata-scsi: minor cleanup in ata_mselect_*()

2016-07-19 Thread tom . ty89
From: Tom Yan 1. Removed a repeated bit masking in ata_mselect_control() 2. Moved `wce`/`d_sense` assignment below the page validity checks 3. Added/Removed empty lines where appropriate Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c

[PATCH v4] libata-scsi: better style in ata_msense_*()

2016-07-19 Thread tom . ty89
From: Tom Yan `changeable` is the "version" of mode page requested by the user. It will be less confusing/misleading if we do not check it "together" with the setting bits of the drive. Not to mention that we currently have ata_mselect_*() implemented in a way that each of

[RFC 1/3] ata: bump ATA_MAX_SECTORS_LBA48 to 65536

2016-07-12 Thread tom . ty89
From: Tom Yan ATA_MAX_SECTORS_LBA48 is only used for setting the queue limit "max_hw_sectors", which only serves as the cap for "max_sectors", which is in turn the actual limit being used. Therefore, it should be alright for us to bump ATA_MAX_SECTORS_LBA48 to 65536. Also,

[RFC 2/3] ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48}

2016-07-12 Thread tom . ty89
From: Tom Yan Signed-off-by: Tom Yan diff --git a/include/linux/ata.h b/include/linux/ata.h index 24f886c..d4bb802 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -1095,13 +1095,13 @@ static inline bool ata_ok(u8 status) static inline bool

[RFC 3/3] libata-scsi: add optimal transfer length to block limits VPD

2016-07-12 Thread tom . ty89
From: Tom Yan As of commit 6b7e9cde4969 ("sd: Fix rw_max for devices that report an optimal xfer size"), the scsi disk driver (correctly) derive both of the queue limits "io_opt" and "max_sectors" from the optimal transfer length field. In case we would like the two limits

[PATCH v6 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-12 Thread tom . ty89
From: Tom Yan Currently if a WRITE SAME (16) command is issued to the SATL with "number of blocks" that is larger than the "Maximum write same length" (which is the maximum number of blocks per TRIM command allowed in libata, currently 65535 * 512 / 8 blocks), the SATL will

[PATCH v6 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-12 Thread tom . ty89
From: Tom Yan Currently libata statically allows only 1-block (512-byte) payload for each TRIM command. Each payload can carry 64 TRIM ranges since each range requires 8 bytes. It is silly to keep doing the calculation (512 / 8) in different places. Hence, define the new

[PATCH v2 1/2] libata-scsi: fix D_SENSE bit relection in control mode page

2016-07-12 Thread tom . ty89
From: Tom Yan The bit should always be set to 1 when the requested version of page is "changeable" because we've made it so in ata_mselect_control(). Also, it should always be set to 1 if ATA_DFLAG_D_SENSE is set (when the requested version of page is "current" or "default").

[PATCH v2 2/2] libata-scsi: rename ata_msense_ctl_mode() to ata_msense_control()

2016-07-12 Thread tom . ty89
From: Tom Yan To make it consistent with the recently added ata_mselect_control(). We probably shouldn't have the word "mode" in its name anyway, since that's not the case for other ata_msense_*() / ata_mselect_*() either. Signed-off-by: Tom Yan diff

[PATCH] libata-scsi: fix D_SENSE bit relection in control mode page

2016-07-12 Thread tom . ty89
From: Tom Yan The bit should always be set to 1 when the requested version of page is "changeable" because we've made it so in ata_mselect_control(). Also, it should always be set to 1 if ATA_DFLAG_D_SENSE is set (when the requested version of page is "current" or "default").

[PATCH v2] libata-scsi: set correct VERSION field for ZAC devices

2016-07-12 Thread tom . ty89
From: Tom Yan Commit 856c46639309 ("libata: support device-managed ZAC devices") had the line that "bumps" the VERSION field in standard INQUIRY data removed. Add it back and claim SPC-5 version compatibility, which matches with the current version descriptor "SPC-5 (no

[PATCH v3 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index bfec66f..48ea887 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest,

[PATCH v3 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan Without this fix, the DRA bit of the caching mode page would not be updated when the read look-ahead feature is toggled (e.g. with `smartctl --set`), but will only be until, for example, the write cache feature is touched. Signed-off-by: Tom Yan

[PATCH resend 2/2] libata-scsi: correct SPC version descriptor

2016-07-12 Thread tom . ty89
From: Tom Yan The comment suggests we should be having an SPC-3 version descriptor but the 0260h is the code for "SPC-2 (no version claimed)". Correct it to 0300h so that it has the "SPC-3 (no version claimed)" descriptor. Note that we are claiming SPC-3 version

[PATCH resend 1/2] libata-scsi: set CmdQue bit in standard INQUIRY data to 1

2016-07-12 Thread tom . ty89
From: Tom Yan Avoid performance bottleneck when being SCSI pass-through'd to virtual machines with other OSes (e.g. Windows) via virtio-scsi and scsi-block in qemu. Ref.: https://github.com/YanVugenfirer/kvm-guest-drivers-windows/issues/63 Signed-off-by: Tom Yan

[PATCH v2 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index bfec66f..6f7c626 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2424,10 +2424,13 @@ static void modecpy(u8 *dest,

[PATCH v2 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-12 Thread tom . ty89
From: Tom Yan Without this fix, the DRA bit of the caching mode page would not be updated when the read look-ahead feature is toggled (e.g. with `smartctl --set`), but will only be until, for example, the write cache feature is touched. Signed-off-by: Tom Yan

[RFC] libata-scsi: introducing SANITIZE translation

2016-07-07 Thread tom . ty89
From: Tom Yan With this patch, users can make use of the SANITIZE DEVICE feature set through utility like sg_sanitize. Support for BLOCK ERASE, CRYPTOGRAPHIC ERASE and EXIT FAILURE MODE has been implemented. Support for OVERWRITE that involves a parameter list has been left

[PATCH 1/2] libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

2016-07-06 Thread tom . ty89
From: Tom Yan Without this fix, the DRA bit of the caching mode page would not be updated when the read look-ahead feature is toggled (e.g. with `smartctl --set`), but will only be until, for example, the write cache feature is touched. Signed-off-by: Tom Yan

[PATCH 2/2] libata-scsi: better style in ata_msense_caching()

2016-07-06 Thread tom . ty89
From: Tom Yan Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index bfec66f..e3f5751 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2424,10 +2424,12 @@ static void modecpy(u8 *dest,

[PATCH 2/2] libata-scsi: do not return t10 designator if drive has WWN

2016-07-06 Thread tom . ty89
From: Tom Yan SAT (as of sat4r05f.pdf) only requires the t10 designator if the drive does not support/have WWN. Besides, we already have the ATA information VPD. Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c

[PATCH 1/2] libata-scsi: do not return designator for serial number

2016-07-06 Thread tom . ty89
From: Tom Yan SAT (as of sat4r05f.pdf) does not require this vendor specific designator. Besides, we already have the Unit Serial Number VPD. Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index

[PATCH v5 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-06 Thread tom . ty89
From: Tom Yan Currently libata statically allows only 1-block (512-byte) payload for each TRIM command. Each payload can carry 64 TRIM ranges since each range requires 8 bytes. It is silly to keep doing the calculation (512 / 8) in different places. Hence, define the new

[PATCH v5 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-06 Thread tom . ty89
From: Tom Yan Currently if a WRITE SAME (16) command is issued to the SATL with "number of blocks" that is larger than the "Maximum write same length" (which is the maximum number of blocks per TRIM command allowed in libata, currently 65535 * 512 / 8 blocks), the SATL will

[PATCH resend 2/2] libata-scsi: correct cbd to CDB in comment

2016-07-06 Thread tom . ty89
From: Tom Yan It's Command Descriptor Block. Also capitalized it. Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index f1125fd..c9cd216 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@

[PATCH resend 1/2] libata-scsi: do not respond with "invalid field" for FORMAT UNIT

2016-07-06 Thread tom . ty89
From: Tom Yan It does not make sense and is confusing to respond with "Invalid field in CDB" while we have no support at all implemented for FORMAT UNIT. It is decent to let it go to the default, which will respond with "Invalid command operation code" instead.

[PATCH v4 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-06 Thread tom . ty89
From: Tom Yan Currently libata statically allows only 1-block (512-byte) payload for each TRIM command. Each payload can carry 64 TRIM ranges since each range requires 8 bytes. It is silly to keep doing the calculation (512 / 8) in different places. Hence, define the new

[PATCH v4 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-06 Thread tom . ty89
From: Tom Yan Currently if a WRITE SAME (16) command is issued to the SATL with "number of blocks" that is larger than the "Maximum write same length" (which is the maximum number of blocks per TRIM command allowed in libata, currently 65535 * 512 / 8 blocks), the SATL will

[PATCH v3 1/2] libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit

2016-07-06 Thread tom . ty89
From: Tom Yan Currently if a WRITE SAME (16) command is issued to the SATL with "number of blocks" that is larger than the "Maximum write same length" (which is the maximum number of blocks per TRIM command allowed in libata, currently 65535 * 512 / 8 blocks), the SATL will

[PATCH v3 2/2] libata-scsi: avoid repeated calculation of number of TRIM ranges

2016-07-06 Thread tom . ty89
From: Tom Yan Currently libata statically allows only 1-block (512-byte) payload for each TRIM command. Each payload can carry 64 TRIM ranges since each range requires 8 bytes. It is silly to keep doing the calculation (512 / 8) in different places. Hence, define the new

[PATCH v2 1/2] libata-scsi: improve TRIM translation

2016-07-05 Thread tom . ty89
From: Tom Yan Define TRIM_RANGE_SIZE and TRIM_RANGE_NUM so that the corresponding functions can be more generalized. Also, conform to SBC by rejecting WRITE SAME (16) commands with number of blocks that exceeds the limit that is defined in the SATL. Signed-off-by: Tom Yan

[PATCH v2 2/2] libata-scsi: do not respond with "invalid field" for FORMAT UNIT

2016-07-05 Thread tom . ty89
From: Tom Yan It does not make sense and is confusing to respond with "Invalid field in CDB" while we have no support at all implemented for FORMAT UNIT. It is decent to let it go to the default, which will respond with "Invalid command operation code" instead.

[PATCH 1/2] libata-scsi: improve TRIM translation

2016-07-04 Thread tom . ty89
From: Tom Yan Define TRIM_RANGE_SIZE and TRIM_RANGE_NUM so that the corresponding functions can be more generalized. Also, conform SBC by rejecting WRITE SAME (16) commands with number of blocks that exceeds the limit that is defined in the SATL. Signed-off-by: Tom Yan

[PATCH v2 1/1] uas: remove can_queue set in host template

2016-05-23 Thread tom . ty89
From: Tom Yan Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") made qdepth limit set in host template (`.can_queue = MAX_CMNDS`) redundant. Removing it to avoid confusion. Signed-off-by: Tom Yan diff --git

[PATCH 1/1] uas: leave can_queue as MAX_CMNDS if device reports larger qdepth

2016-05-23 Thread tom . ty89
From: Tom Yan Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") made qdepth limit set in host template (`.can_queue = MAX_CMNDS`) useless. Instead of removing the template limit, now we only change limit according to the qdepth reported by the device if

[PATCH 1/1] scsi: bump SCSI_DEFAULT_MAX_SECTORS to SD_DEF_XFER_BLOCKS

2016-05-17 Thread tom . ty89
From: Tom Yan As of commit ca369d51b3e1649be4a72addd6d6a168cfb3f537, max_sectors (rw_max) of a scsi disk can be as high as SD_DEF_XFER_BLOCKS. Therefore, bump SCSI_DEFAULT_MAX_SECTORS to 65535 to make hosts that do not have max_sectors set in their templates benefit from the

[PATCH 1/3] libata-scsi: Set CmdQue=1 when NCQ is enabled

2016-05-02 Thread tom . ty89
From: Tom Yan https://bugzilla.kernel.org/show_bug.cgi?id=105931 This might look trivial at first sight. However, it can be important to have the bit set accordingly when the device/SATL is SCSI-passthrough'd to a virtual machine with scsi-block in qemu:

[PATCH 2/3] libata-scsi: Fix SCSI INQUIRY version descriptor

2016-05-02 Thread tom . ty89
From: Tom Yan https://bugzilla.kernel.org/show_bug.cgi?id=106931 Signed-off-by: Tom Yan diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index cd30f11..0295c38 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@

[PATCH 3/3] libata-scsi: Do not partially report ATA read look-ahead

2016-05-02 Thread tom . ty89
From: Tom Yan Nothing in the kernel actually makes use of the DRA bit in SCSI MODE SENSE. Neither is there a sysfs file (like 'cache_type' for WCE) that allows users to change the bit nor SCSI-ATA Translation that can toggle the ATA feature. Hence removing the MODE SENSE

[PATCH 1/1] sd: fix lbprz discard granularity as expected

2016-03-10 Thread tom . ty89
From: Tom Yan 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 diff --git a/drivers/scsi/sd.c

[PATCH 1/1] sd: do not let LBPME bit stop the VPDs speak

2016-03-08 Thread tom . ty89
From: Tom Yan Some devices have details of their support on unmapping on the Block Limits and/or Logical Block Provisioning VPDs while they do not set the LBPME bit to 1. Though this is required by the SCSI standards, the VPDs are giving even more concrete details about the

[PATCH v2 1/1] sd: add missing scenario for sd_config_write_same

2016-02-26 Thread tom . ty89
From: Tom Yan Example: [root@localhost ~]# sg_opcodes /dev/sdb > /dev/null Report supported operation codes: Illegal request, invalid opcode [root@localhost ~]# sg_vpd -p bl /dev/sdb | grep 'write same' Maximum write same length: 0x0 blocks [root@localhost ~]# cat

[PATCH 2/2] sd: disable write same for SAT as per the comment

2016-02-26 Thread tom . ty89
From: Tom Yan Signed-off-by: Tom Yan diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 1179ec1..951 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2786,7 +2786,7 @@ static void sd_read_write_same(struct scsi_disk *sdkp, unsigned

[PATCH 1/2] sd: add missing scenario for sd_config_write_same

2016-02-26 Thread tom . ty89
From: Tom Yan Example: [root@localhost ~]# sg_opcodes /dev/sdb > /dev/null Report supported operation codes: Illegal request, invalid opcode [root@localhost ~]# sg_vpd -p bl /dev/sdb | grep 'write same' Maximum write same length: 0x0 blocks [root@localhost ~]# cat