Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1467348 > unrolled thread
| Started by | Shaun Tancheff <shaun@tancheff.com> |
|---|---|
| First post | 2016-08-22 06:30 +0200 |
| Last post | 2016-08-22 23:00 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v6 3/4] SCT Write Same / DSM Trim Shaun Tancheff <shaun@tancheff.com> - 2016-08-22 06:30 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Hannes Reinecke <hare@suse.de> - 2016-08-22 08:40 +0200
[PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim Shaun Tancheff <shaun@tancheff.com> - 2016-08-24 21:10 +0200
Re: [PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-25 09:20 +0200
Re: [PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim Shaun Tancheff <shaun.tancheff@seagate.com> - 2016-08-25 10:50 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-22 10:40 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-22 10:40 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Shaun Tancheff <shaun.tancheff@seagate.com> - 2016-08-22 17:10 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-22 19:10 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Shaun Tancheff <shaun.tancheff@seagate.com> - 2016-08-22 20:10 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-22 21:00 +0200
Re: [PATCH v6 3/4] SCT Write Same / DSM Trim Tom Yan <tom.ty89@gmail.com> - 2016-08-22 23:00 +0200
| From | Shaun Tancheff <shaun@tancheff.com> |
|---|---|
| Date | 2016-08-22 06:30 +0200 |
| Subject | [PATCH v6 3/4] SCT Write Same / DSM Trim |
| Message-ID | <s8P22-1r7-19@gated-at.bofh.it> |
Correct handling of devices with sector_size other that 512 bytes.
Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
---
In the case of a 4Kn device sector_size it is possible to describe a much
larger DSM Trim than the current fixed default of 512 bytes.
This patch assumes the minimum descriptor is sector_size and fills out
the descriptor accordingly.
The ACS-2 specification is quite clear that the DSM command payload is
sized as number of 512 byte transfers so a 4Kn device will operate
correctly without this patch.
v5:
- Added support for a sector_size descriptor other than 512 bytes.
drivers/ata/libata-scsi.c | 85 +++++++++++++++++++++++++++++++----------------
1 file changed, 57 insertions(+), 28 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index ebf1a04..37f456e 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3283,7 +3283,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
/**
* ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim
* @cmd: SCSI command being translated
- * @num: Maximum number of entries (nominally 64).
+ * @trmax: Maximum number of entries that will fit in sector_size bytes.
* @sector: Starting sector
* @count: Total Range of request in logical sectors
*
@@ -3298,63 +3298,80 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
* LBA's should be sorted order and not overlap.
*
* NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET
+ *
+ * Return: Number of bytes copied into sglist.
*/
-static unsigned int ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 num,
- u64 sector, u32 count)
+static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
+ u64 sector, u32 count)
{
- __le64 *buffer;
- u32 i = 0, used_bytes;
+ struct scsi_device *sdp = cmd->device;
+ size_t len = sdp->sector_size;
+ size_t r;
+ __le64 *buf;
+ u32 i = 0;
unsigned long flags;
- BUILD_BUG_ON(512 > ATA_SCSI_RBUF_SIZE);
+ WARN_ON(len > ATA_SCSI_RBUF_SIZE);
+
+ if (len > ATA_SCSI_RBUF_SIZE)
+ len = ATA_SCSI_RBUF_SIZE;
spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
- buffer = ((void *)ata_scsi_rbuf);
- while (i < num) {
+ buf = ((void *)ata_scsi_rbuf);
+ memset(buf, 0, len);
+ while (i < trmax) {
u64 entry = sector |
((u64)(count > 0xffff ? 0xffff : count) << 48);
- buffer[i++] = __cpu_to_le64(entry);
+ buf[i++] = __cpu_to_le64(entry);
if (count <= 0xffff)
break;
count -= 0xffff;
sector += 0xffff;
}
-
- used_bytes = ALIGN(i * 8, 512);
- memset(buffer + i, 0, used_bytes - i * 8);
- sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buffer, 512);
+ r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
- return used_bytes;
+ return r;
}
/**
* ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same
* @cmd: SCSI command being translated
* @lba: Starting sector
- * @num: Number of logical sectors to be zero'd.
+ * @num: Number of sectors to be zero'd.
*
- * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted
+ * Rewrite the WRITE SAME payload to be an SCT Write Same formatted
* descriptor.
* NOTE: Writes a pattern (0's) in the foreground.
- * Large write-same requents can timeout.
+ *
+ * Return: Number of bytes copied into sglist.
*/
-static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
+static size_t ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
{
- u16 *sctpg;
+ struct scsi_device *sdp = cmd->device;
+ size_t len = sdp->sector_size;
+ size_t r;
+ u16 *buf;
unsigned long flags;
spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
- sctpg = ((void *)ata_scsi_rbuf);
+ buf = ((void *)ata_scsi_rbuf);
+
+ put_unaligned_le16(0x0002, &buf[0]); /* SCT_ACT_WRITE_SAME */
+ put_unaligned_le16(0x0101, &buf[1]); /* WRITE PTRN FG */
+ put_unaligned_le64(lba, &buf[2]);
+ put_unaligned_le64(num, &buf[6]);
+ put_unaligned_le32(0u, &buf[10]); /* pattern */
+
+ WARN_ON(len > ATA_SCSI_RBUF_SIZE);
- put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */
- put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */
- put_unaligned_le64(lba, &sctpg[2]);
- put_unaligned_le64(num, &sctpg[6]);
- put_unaligned_le32(0u, &sctpg[10]);
+ if (len > ATA_SCSI_RBUF_SIZE)
+ len = ATA_SCSI_RBUF_SIZE;
- sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512);
+ r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
+
+ return r;
}
/**
@@ -3371,11 +3388,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
{
struct ata_taskfile *tf = &qc->tf;
struct scsi_cmnd *scmd = qc->scsicmd;
+ struct scsi_device *sdp = scmd->device;
+ size_t len = sdp->sector_size;
struct ata_device *dev = qc->dev;
const u8 *cdb = scmd->cmnd;
u64 block;
u32 n_block;
- const u32 trmax = ATA_MAX_TRIM_RNUM;
+ const u32 trmax = len >> 3;
u32 size;
u16 fp;
u8 bp = 0xff;
@@ -3420,8 +3439,16 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
if (!scsi_sg_count(scmd))
goto invalid_param_len;
+ /*
+ * size must match sector size in bytes
+ * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
+ * is defined as number of 512 byte blocks to be transferred.
+ */
if (unmap) {
size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
+ if (size != len)
+ goto invalid_param_len;
+
if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
/* Newer devices support queued TRIM commands */
tf->protocol = ATA_PROT_NCQ;
@@ -3441,7 +3468,9 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
tf->command = ATA_CMD_DSM;
}
} else {
- ata_format_sct_write_same(scmd, block, n_block);
+ size = ata_format_sct_write_same(scmd, block, n_block);
+ if (size != len)
+ goto invalid_param_len;
tf->hob_feature = 0;
tf->feature = 0;
--
2.9.3
[toc] | [next] | [standalone]
| From | Hannes Reinecke <hare@suse.de> |
|---|---|
| Date | 2016-08-22 08:40 +0200 |
| Message-ID | <s8R3P-2Dz-3@gated-at.bofh.it> |
| In reply to | #1467348 |
On 08/22/2016 06:23 AM, Shaun Tancheff wrote:
> Correct handling of devices with sector_size other that 512 bytes.
>
> Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
> ---
> In the case of a 4Kn device sector_size it is possible to describe a much
> larger DSM Trim than the current fixed default of 512 bytes.
>
> This patch assumes the minimum descriptor is sector_size and fills out
> the descriptor accordingly.
>
> The ACS-2 specification is quite clear that the DSM command payload is
> sized as number of 512 byte transfers so a 4Kn device will operate
> correctly without this patch.
>
Can you please reshuffle the description to have the 'Signed-off-by'
line following the entire description?
This makes things easier to read and avoid the last part of the
description being killed by overzealous patch programs.
THX.
> v5:
> - Added support for a sector_size descriptor other than 512 bytes.
>
> drivers/ata/libata-scsi.c | 85 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 57 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index ebf1a04..37f456e 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3283,7 +3283,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim
> * @cmd: SCSI command being translated
> - * @num: Maximum number of entries (nominally 64).
> + * @trmax: Maximum number of entries that will fit in sector_size bytes.
> * @sector: Starting sector
> * @count: Total Range of request in logical sectors
> *
> @@ -3298,63 +3298,80 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> * LBA's should be sorted order and not overlap.
> *
> * NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static unsigned int ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 num,
> - u64 sector, u32 count)
> +static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
> + u64 sector, u32 count)
> {
> - __le64 *buffer;
> - u32 i = 0, used_bytes;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + __le64 *buf;
> + u32 i = 0;
> unsigned long flags;
>
> - BUILD_BUG_ON(512 > ATA_SCSI_RBUF_SIZE);
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
> +
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - buffer = ((void *)ata_scsi_rbuf);
> - while (i < num) {
> + buf = ((void *)ata_scsi_rbuf);
> + memset(buf, 0, len);
> + while (i < trmax) {
> u64 entry = sector |
> ((u64)(count > 0xffff ? 0xffff : count) << 48);
> - buffer[i++] = __cpu_to_le64(entry);
> + buf[i++] = __cpu_to_le64(entry);
> if (count <= 0xffff)
> break;
> count -= 0xffff;
> sector += 0xffff;
> }
> -
> - used_bytes = ALIGN(i * 8, 512);
> - memset(buffer + i, 0, used_bytes - i * 8);
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buffer, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
>
> - return used_bytes;
> + return r;
> }
>
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same
> * @cmd: SCSI command being translated
> * @lba: Starting sector
> - * @num: Number of logical sectors to be zero'd.
> + * @num: Number of sectors to be zero'd.
> *
> - * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted
> + * Rewrite the WRITE SAME payload to be an SCT Write Same formatted
> * descriptor.
> * NOTE: Writes a pattern (0's) in the foreground.
> - * Large write-same requents can timeout.
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> +static size_t ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> {
> - u16 *sctpg;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + u16 *buf;
> unsigned long flags;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - sctpg = ((void *)ata_scsi_rbuf);
> + buf = ((void *)ata_scsi_rbuf);
> +
> + put_unaligned_le16(0x0002, &buf[0]); /* SCT_ACT_WRITE_SAME */
> + put_unaligned_le16(0x0101, &buf[1]); /* WRITE PTRN FG */
> + put_unaligned_le64(lba, &buf[2]);
> + put_unaligned_le64(num, &buf[6]);
> + put_unaligned_le32(0u, &buf[10]); /* pattern */
> +
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
>
> - put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */
> - put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */
> - put_unaligned_le64(lba, &sctpg[2]);
> - put_unaligned_le64(num, &sctpg[6]);
> - put_unaligned_le32(0u, &sctpg[10]);
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
> +
> + return r;
> }
>
> /**
> @@ -3371,11 +3388,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> {
> struct ata_taskfile *tf = &qc->tf;
> struct scsi_cmnd *scmd = qc->scsicmd;
> + struct scsi_device *sdp = scmd->device;
> + size_t len = sdp->sector_size;
> struct ata_device *dev = qc->dev;
> const u8 *cdb = scmd->cmnd;
> u64 block;
> u32 n_block;
> - const u32 trmax = ATA_MAX_TRIM_RNUM;
> + const u32 trmax = len >> 3;
> u32 size;
> u16 fp;
> u8 bp = 0xff;
> @@ -3420,8 +3439,16 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> if (!scsi_sg_count(scmd))
> goto invalid_param_len;
>
> + /*
> + * size must match sector size in bytes
> + * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
> + * is defined as number of 512 byte blocks to be transferred.
> + */
> if (unmap) {
> size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
> +
> if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
> /* Newer devices support queued TRIM commands */
> tf->protocol = ATA_PROT_NCQ;
> @@ -3441,7 +3468,9 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> tf->command = ATA_CMD_DSM;
> }
> } else {
> - ata_format_sct_write_same(scmd, block, n_block);
> + size = ata_format_sct_write_same(scmd, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
>
> tf->hob_feature = 0;
> tf->feature = 0;
>
Why is this not folded into the previous patches?
This mostly patches code which you've already modified and/or initiated,
right?
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
[toc] | [prev] | [next] | [standalone]
| From | Shaun Tancheff <shaun@tancheff.com> |
|---|---|
| Date | 2016-08-24 21:10 +0200 |
| Subject | [PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim |
| Message-ID | <s9LIK-6vI-9@gated-at.bofh.it> |
| In reply to | #1467391 |
Correct handling of devices with sector_size other that 512 bytes.
In the case of a 4Kn device sector_size it is possible to describe a much
larger DSM Trim than the current fixed default of 512 bytes.
This patch assumes the minimum descriptor is sector_size and fills out
the descriptor accordingly.
The ACS-2 specification is quite clear that the DSM command payload is
sized as number of 512 byte transfers so a 4Kn device will operate
correctly without this patch.
Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
---
v5:
- Reshuffled descripton.
- Added support for a sector_size descriptor other than 512 bytes.
drivers/ata/libata-scsi.c | 85 +++++++++++++++++++++++++++++++----------------
1 file changed, 57 insertions(+), 28 deletions(-)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index ebf1a04..37f456e 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3283,7 +3283,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
/**
* ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim
* @cmd: SCSI command being translated
- * @num: Maximum number of entries (nominally 64).
+ * @trmax: Maximum number of entries that will fit in sector_size bytes.
* @sector: Starting sector
* @count: Total Range of request in logical sectors
*
@@ -3298,63 +3298,80 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
* LBA's should be sorted order and not overlap.
*
* NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET
+ *
+ * Return: Number of bytes copied into sglist.
*/
-static unsigned int ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 num,
- u64 sector, u32 count)
+static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
+ u64 sector, u32 count)
{
- __le64 *buffer;
- u32 i = 0, used_bytes;
+ struct scsi_device *sdp = cmd->device;
+ size_t len = sdp->sector_size;
+ size_t r;
+ __le64 *buf;
+ u32 i = 0;
unsigned long flags;
- BUILD_BUG_ON(512 > ATA_SCSI_RBUF_SIZE);
+ WARN_ON(len > ATA_SCSI_RBUF_SIZE);
+
+ if (len > ATA_SCSI_RBUF_SIZE)
+ len = ATA_SCSI_RBUF_SIZE;
spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
- buffer = ((void *)ata_scsi_rbuf);
- while (i < num) {
+ buf = ((void *)ata_scsi_rbuf);
+ memset(buf, 0, len);
+ while (i < trmax) {
u64 entry = sector |
((u64)(count > 0xffff ? 0xffff : count) << 48);
- buffer[i++] = __cpu_to_le64(entry);
+ buf[i++] = __cpu_to_le64(entry);
if (count <= 0xffff)
break;
count -= 0xffff;
sector += 0xffff;
}
-
- used_bytes = ALIGN(i * 8, 512);
- memset(buffer + i, 0, used_bytes - i * 8);
- sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buffer, 512);
+ r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
- return used_bytes;
+ return r;
}
/**
* ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same
* @cmd: SCSI command being translated
* @lba: Starting sector
- * @num: Number of logical sectors to be zero'd.
+ * @num: Number of sectors to be zero'd.
*
- * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted
+ * Rewrite the WRITE SAME payload to be an SCT Write Same formatted
* descriptor.
* NOTE: Writes a pattern (0's) in the foreground.
- * Large write-same requents can timeout.
+ *
+ * Return: Number of bytes copied into sglist.
*/
-static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
+static size_t ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
{
- u16 *sctpg;
+ struct scsi_device *sdp = cmd->device;
+ size_t len = sdp->sector_size;
+ size_t r;
+ u16 *buf;
unsigned long flags;
spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
- sctpg = ((void *)ata_scsi_rbuf);
+ buf = ((void *)ata_scsi_rbuf);
+
+ put_unaligned_le16(0x0002, &buf[0]); /* SCT_ACT_WRITE_SAME */
+ put_unaligned_le16(0x0101, &buf[1]); /* WRITE PTRN FG */
+ put_unaligned_le64(lba, &buf[2]);
+ put_unaligned_le64(num, &buf[6]);
+ put_unaligned_le32(0u, &buf[10]); /* pattern */
+
+ WARN_ON(len > ATA_SCSI_RBUF_SIZE);
- put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */
- put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */
- put_unaligned_le64(lba, &sctpg[2]);
- put_unaligned_le64(num, &sctpg[6]);
- put_unaligned_le32(0u, &sctpg[10]);
+ if (len > ATA_SCSI_RBUF_SIZE)
+ len = ATA_SCSI_RBUF_SIZE;
- sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512);
+ r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
+
+ return r;
}
/**
@@ -3371,11 +3388,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
{
struct ata_taskfile *tf = &qc->tf;
struct scsi_cmnd *scmd = qc->scsicmd;
+ struct scsi_device *sdp = scmd->device;
+ size_t len = sdp->sector_size;
struct ata_device *dev = qc->dev;
const u8 *cdb = scmd->cmnd;
u64 block;
u32 n_block;
- const u32 trmax = ATA_MAX_TRIM_RNUM;
+ const u32 trmax = len >> 3;
u32 size;
u16 fp;
u8 bp = 0xff;
@@ -3420,8 +3439,16 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
if (!scsi_sg_count(scmd))
goto invalid_param_len;
+ /*
+ * size must match sector size in bytes
+ * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
+ * is defined as number of 512 byte blocks to be transferred.
+ */
if (unmap) {
size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
+ if (size != len)
+ goto invalid_param_len;
+
if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
/* Newer devices support queued TRIM commands */
tf->protocol = ATA_PROT_NCQ;
@@ -3441,7 +3468,9 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
tf->command = ATA_CMD_DSM;
}
} else {
- ata_format_sct_write_same(scmd, block, n_block);
+ size = ata_format_sct_write_same(scmd, block, n_block);
+ if (size != len)
+ goto invalid_param_len;
tf->hob_feature = 0;
tf->feature = 0;
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-25 09:20 +0200 |
| Subject | Re: [PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim |
| Message-ID | <s9X7c-6ey-23@gated-at.bofh.it> |
| In reply to | #1469657 |
Really please just drop this patch. There is no rational reason for
you to associate the maximum payload size to the logical sector size.
And please stop using the ATA SCSI Response Buffer (ata_scsi_rbuf)
that is used for response to the SCSI layer for SCSI commands that
won't really interact with the ATA device (i.e. triggers an ATA
command), while ata_format_sct_write_same() and
ata_scsi_write_same_xlat() are used for constructing payload that is
going to be send to the ATA device. Can't you even see that these are
of different direction to different layer?
On 25 August 2016 at 02:08, Shaun Tancheff <shaun@tancheff.com> wrote:
> Correct handling of devices with sector_size other that 512 bytes.
>
> In the case of a 4Kn device sector_size it is possible to describe a much
> larger DSM Trim than the current fixed default of 512 bytes.
>
> This patch assumes the minimum descriptor is sector_size and fills out
> the descriptor accordingly.
>
> The ACS-2 specification is quite clear that the DSM command payload is
> sized as number of 512 byte transfers so a 4Kn device will operate
> correctly without this patch.
>
> Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
> ---
> v5:
> - Reshuffled descripton.
> - Added support for a sector_size descriptor other than 512 bytes.
>
> drivers/ata/libata-scsi.c | 85 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 57 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index ebf1a04..37f456e 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3283,7 +3283,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim
> * @cmd: SCSI command being translated
> - * @num: Maximum number of entries (nominally 64).
> + * @trmax: Maximum number of entries that will fit in sector_size bytes.
> * @sector: Starting sector
> * @count: Total Range of request in logical sectors
> *
> @@ -3298,63 +3298,80 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> * LBA's should be sorted order and not overlap.
> *
> * NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static unsigned int ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 num,
> - u64 sector, u32 count)
> +static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
> + u64 sector, u32 count)
> {
> - __le64 *buffer;
> - u32 i = 0, used_bytes;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + __le64 *buf;
> + u32 i = 0;
> unsigned long flags;
>
> - BUILD_BUG_ON(512 > ATA_SCSI_RBUF_SIZE);
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
> +
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - buffer = ((void *)ata_scsi_rbuf);
> - while (i < num) {
> + buf = ((void *)ata_scsi_rbuf);
> + memset(buf, 0, len);
> + while (i < trmax) {
> u64 entry = sector |
> ((u64)(count > 0xffff ? 0xffff : count) << 48);
> - buffer[i++] = __cpu_to_le64(entry);
> + buf[i++] = __cpu_to_le64(entry);
> if (count <= 0xffff)
> break;
> count -= 0xffff;
> sector += 0xffff;
> }
> -
> - used_bytes = ALIGN(i * 8, 512);
> - memset(buffer + i, 0, used_bytes - i * 8);
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buffer, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
>
> - return used_bytes;
> + return r;
> }
>
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same
> * @cmd: SCSI command being translated
> * @lba: Starting sector
> - * @num: Number of logical sectors to be zero'd.
> + * @num: Number of sectors to be zero'd.
> *
> - * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted
> + * Rewrite the WRITE SAME payload to be an SCT Write Same formatted
> * descriptor.
> * NOTE: Writes a pattern (0's) in the foreground.
> - * Large write-same requents can timeout.
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> +static size_t ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> {
> - u16 *sctpg;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + u16 *buf;
> unsigned long flags;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - sctpg = ((void *)ata_scsi_rbuf);
> + buf = ((void *)ata_scsi_rbuf);
> +
> + put_unaligned_le16(0x0002, &buf[0]); /* SCT_ACT_WRITE_SAME */
> + put_unaligned_le16(0x0101, &buf[1]); /* WRITE PTRN FG */
> + put_unaligned_le64(lba, &buf[2]);
> + put_unaligned_le64(num, &buf[6]);
> + put_unaligned_le32(0u, &buf[10]); /* pattern */
> +
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
>
> - put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */
> - put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */
> - put_unaligned_le64(lba, &sctpg[2]);
> - put_unaligned_le64(num, &sctpg[6]);
> - put_unaligned_le32(0u, &sctpg[10]);
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
> +
> + return r;
> }
>
> /**
> @@ -3371,11 +3388,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> {
> struct ata_taskfile *tf = &qc->tf;
> struct scsi_cmnd *scmd = qc->scsicmd;
> + struct scsi_device *sdp = scmd->device;
> + size_t len = sdp->sector_size;
> struct ata_device *dev = qc->dev;
> const u8 *cdb = scmd->cmnd;
> u64 block;
> u32 n_block;
> - const u32 trmax = ATA_MAX_TRIM_RNUM;
> + const u32 trmax = len >> 3;
> u32 size;
> u16 fp;
> u8 bp = 0xff;
> @@ -3420,8 +3439,16 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> if (!scsi_sg_count(scmd))
> goto invalid_param_len;
>
> + /*
> + * size must match sector size in bytes
> + * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
> + * is defined as number of 512 byte blocks to be transferred.
> + */
> if (unmap) {
> size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
> +
> if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
> /* Newer devices support queued TRIM commands */
> tf->protocol = ATA_PROT_NCQ;
> @@ -3441,7 +3468,9 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> tf->command = ATA_CMD_DSM;
> }
> } else {
> - ata_format_sct_write_same(scmd, block, n_block);
> + size = ata_format_sct_write_same(scmd, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
>
> tf->hob_feature = 0;
> tf->feature = 0;
> --
> 2.9.3
>
[toc] | [prev] | [next] | [standalone]
| From | Shaun Tancheff <shaun.tancheff@seagate.com> |
|---|---|
| Date | 2016-08-25 10:50 +0200 |
| Subject | Re: [PATCH v6 3/4 RESEND] SCT Write Same / DSM Trim |
| Message-ID | <s9Ywi-75h-43@gated-at.bofh.it> |
| In reply to | #1469889 |
On Thu, Aug 25, 2016 at 2:01 AM, Tom Yan <tom.ty89@gmail.com> wrote: > Really please just drop this patch. There is no rational reason for > you to associate the maximum payload size to the logical sector size. Been over this many, many times now. It has to do with the size of the buffer setup through WRITE SAME in drivers/scsi/sd.c > And please stop using the ATA SCSI Response Buffer (ata_scsi_rbuf) > that is used for response to the SCSI layer for SCSI commands that > won't really interact with the ATA device (i.e. triggers an ATA > command), while ata_format_sct_write_same() and > ata_scsi_write_same_xlat() are used for constructing payload that is > going to be send to the ATA device. Can't you even see that these are > of different direction to different layer? Adding a new global buffer where there is one there already is kind of silly. The buffer already has a perfectly acceptable spinlock and the time spent copying data around is trivially small in comparison to the I/O operation so there is not likely to be any contention over the buffer. It is memory. Why do you think ata_scsi_rbuf is so special?
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-22 10:40 +0200 |
| Message-ID | <s8SVY-3V6-27@gated-at.bofh.it> |
| In reply to | #1467348 |
As mentioned before, as of the latest draft of ACS-4, nothing about a
larger payload size is mentioned. Conservatively speaking, it sort of
means that we are allowing four 512-byte block payload on 4Kn device
regardless of the reported limit in the IDENTIFY DEVICE data. I am
really not sure if it's a good thing to do. Doesn't seem necessary
anyway, especially when our block layer does not support such a large
bio size (well, yet), so each request will end up using a payload of
two 512-byte blocks at max anyway.
Also, it's IMHO better to do it in a seperate patch (series) after the
SCT Write Same support has entered libata's repo too, because this has
nothing to with it but TRIM translation. In case the future ACS
standards has clearer/better instruction on this, it will be easier
for us to revert/follow up too.
And you'll need to fix the Block Limits VPD simulation
(ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write
Same Length dynamically as per the logical sector size, otherwise your
effort will be completely in vain, even if our block layer is
overhauled in the future.
Please be noted that, since your haven't touched ata_scsiop_inq_b0 at
all, the reported Maximum Write Same Length will be:
On device with TRIM support:
- 4194240 LOGICAL sector per request split / command
-- ~=2G on non-4Kn drives
-- ~=16G on non-4Kn drives
On device without TRIM support:
- 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command
-- ~= 32M on non-4Kn drives
-- ~=256M on non-4Kn drives
Even if we ignore the upper limit(s) of the block layer, do we want
such inconsistencies?
On 22 August 2016 at 04:23, Shaun Tancheff <shaun@tancheff.com> wrote:
> Correct handling of devices with sector_size other that 512 bytes.
>
> Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
> ---
> In the case of a 4Kn device sector_size it is possible to describe a much
> larger DSM Trim than the current fixed default of 512 bytes.
>
> This patch assumes the minimum descriptor is sector_size and fills out
> the descriptor accordingly.
>
> The ACS-2 specification is quite clear that the DSM command payload is
> sized as number of 512 byte transfers so a 4Kn device will operate
> correctly without this patch.
>
> v5:
> - Added support for a sector_size descriptor other than 512 bytes.
>
> drivers/ata/libata-scsi.c | 85 +++++++++++++++++++++++++++++++----------------
> 1 file changed, 57 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index ebf1a04..37f456e 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3283,7 +3283,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim
> * @cmd: SCSI command being translated
> - * @num: Maximum number of entries (nominally 64).
> + * @trmax: Maximum number of entries that will fit in sector_size bytes.
> * @sector: Starting sector
> * @count: Total Range of request in logical sectors
> *
> @@ -3298,63 +3298,80 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> * LBA's should be sorted order and not overlap.
> *
> * NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static unsigned int ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 num,
> - u64 sector, u32 count)
> +static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax,
> + u64 sector, u32 count)
> {
> - __le64 *buffer;
> - u32 i = 0, used_bytes;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + __le64 *buf;
> + u32 i = 0;
> unsigned long flags;
>
> - BUILD_BUG_ON(512 > ATA_SCSI_RBUF_SIZE);
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
> +
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - buffer = ((void *)ata_scsi_rbuf);
> - while (i < num) {
> + buf = ((void *)ata_scsi_rbuf);
> + memset(buf, 0, len);
> + while (i < trmax) {
> u64 entry = sector |
> ((u64)(count > 0xffff ? 0xffff : count) << 48);
> - buffer[i++] = __cpu_to_le64(entry);
> + buf[i++] = __cpu_to_le64(entry);
> if (count <= 0xffff)
> break;
> count -= 0xffff;
> sector += 0xffff;
> }
> -
> - used_bytes = ALIGN(i * 8, 512);
> - memset(buffer + i, 0, used_bytes - i * 8);
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buffer, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
>
> - return used_bytes;
> + return r;
> }
>
> /**
> * ata_format_dsm_trim_descr() - SATL Write Same to ATA SCT Write Same
> * @cmd: SCSI command being translated
> * @lba: Starting sector
> - * @num: Number of logical sectors to be zero'd.
> + * @num: Number of sectors to be zero'd.
> *
> - * Rewrite the WRITE SAME descriptor to be an SCT Write Same formatted
> + * Rewrite the WRITE SAME payload to be an SCT Write Same formatted
> * descriptor.
> * NOTE: Writes a pattern (0's) in the foreground.
> - * Large write-same requents can timeout.
> + *
> + * Return: Number of bytes copied into sglist.
> */
> -static void ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> +static size_t ata_format_sct_write_same(struct scsi_cmnd *cmd, u64 lba, u64 num)
> {
> - u16 *sctpg;
> + struct scsi_device *sdp = cmd->device;
> + size_t len = sdp->sector_size;
> + size_t r;
> + u16 *buf;
> unsigned long flags;
>
> spin_lock_irqsave(&ata_scsi_rbuf_lock, flags);
> - sctpg = ((void *)ata_scsi_rbuf);
> + buf = ((void *)ata_scsi_rbuf);
> +
> + put_unaligned_le16(0x0002, &buf[0]); /* SCT_ACT_WRITE_SAME */
> + put_unaligned_le16(0x0101, &buf[1]); /* WRITE PTRN FG */
> + put_unaligned_le64(lba, &buf[2]);
> + put_unaligned_le64(num, &buf[6]);
> + put_unaligned_le32(0u, &buf[10]); /* pattern */
> +
> + WARN_ON(len > ATA_SCSI_RBUF_SIZE);
>
> - put_unaligned_le16(0x0002, &sctpg[0]); /* SCT_ACT_WRITE_SAME */
> - put_unaligned_le16(0x0101, &sctpg[1]); /* WRITE PTRN FG */
> - put_unaligned_le64(lba, &sctpg[2]);
> - put_unaligned_le64(num, &sctpg[6]);
> - put_unaligned_le32(0u, &sctpg[10]);
> + if (len > ATA_SCSI_RBUF_SIZE)
> + len = ATA_SCSI_RBUF_SIZE;
>
> - sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), sctpg, 512);
> + r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len);
> spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags);
> +
> + return r;
> }
>
> /**
> @@ -3371,11 +3388,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> {
> struct ata_taskfile *tf = &qc->tf;
> struct scsi_cmnd *scmd = qc->scsicmd;
> + struct scsi_device *sdp = scmd->device;
> + size_t len = sdp->sector_size;
> struct ata_device *dev = qc->dev;
> const u8 *cdb = scmd->cmnd;
> u64 block;
> u32 n_block;
> - const u32 trmax = ATA_MAX_TRIM_RNUM;
> + const u32 trmax = len >> 3;
> u32 size;
> u16 fp;
> u8 bp = 0xff;
> @@ -3420,8 +3439,16 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> if (!scsi_sg_count(scmd))
> goto invalid_param_len;
>
> + /*
> + * size must match sector size in bytes
> + * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count)
> + * is defined as number of 512 byte blocks to be transferred.
> + */
> if (unmap) {
> size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
> +
> if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) {
> /* Newer devices support queued TRIM commands */
> tf->protocol = ATA_PROT_NCQ;
> @@ -3441,7 +3468,9 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc)
> tf->command = ATA_CMD_DSM;
> }
> } else {
> - ata_format_sct_write_same(scmd, block, n_block);
> + size = ata_format_sct_write_same(scmd, block, n_block);
> + if (size != len)
> + goto invalid_param_len;
>
> tf->hob_feature = 0;
> tf->feature = 0;
> --
> 2.9.3
>
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-22 10:40 +0200 |
| Message-ID | <s8SVY-3V6-33@gated-at.bofh.it> |
| In reply to | #1467465 |
On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: > As mentioned before, as of the latest draft of ACS-4, nothing about a > larger payload size is mentioned. Conservatively speaking, it sort of *payload block size > means that we are allowing four 512-byte block payload on 4Kn device *eight 512-byte-block payload > regardless of the reported limit in the IDENTIFY DEVICE data. I am > really not sure if it's a good thing to do. Doesn't seem necessary > anyway, especially when our block layer does not support such a large > bio size (well, yet), so each request will end up using a payload of > two 512-byte blocks at max anyway. > > Also, it's IMHO better to do it in a seperate patch (series) after the > SCT Write Same support has entered libata's repo too, because this has > nothing to with it but TRIM translation. In case the future ACS > standards has clearer/better instruction on this, it will be easier > for us to revert/follow up too. > > And you'll need to fix the Block Limits VPD simulation > (ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write > Same Length dynamically as per the logical sector size, otherwise your > effort will be completely in vain, even if our block layer is > overhauled in the future. > > Please be noted that, since your haven't touched ata_scsiop_inq_b0 at > all, the reported Maximum Write Same Length will be: > > On device with TRIM support: > - 4194240 LOGICAL sector per request split / command > -- ~=2G on non-4Kn drives > -- ~=16G on non-4Kn drives > > On device without TRIM support: > - 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command > -- ~= 32M on non-4Kn drives > -- ~=256M on non-4Kn drives > > Even if we ignore the upper limit(s) of the block layer, do we want > such inconsistencies? >
[toc] | [prev] | [next] | [standalone]
| From | Shaun Tancheff <shaun.tancheff@seagate.com> |
|---|---|
| Date | 2016-08-22 17:10 +0200 |
| Message-ID | <s8Z1o-7TZ-19@gated-at.bofh.it> |
| In reply to | #1467466 |
On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: > On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: >> As mentioned before, as of the latest draft of ACS-4, nothing about a >> larger payload size is mentioned. Conservatively speaking, it sort of > > *payload block size > >> means that we are allowing four 512-byte block payload on 4Kn device > > *eight 512-byte-block payload > >> regardless of the reported limit in the IDENTIFY DEVICE data. I am >> really not sure if it's a good thing to do. Doesn't seem necessary >> anyway, especially when our block layer does not support such a large >> bio size (well, yet), so each request will end up using a payload of >> two 512-byte blocks at max anyway. >> >> Also, it's IMHO better to do it in a seperate patch (series) after the >> SCT Write Same support has entered libata's repo too, because this has >> nothing to with it but TRIM translation. In case the future ACS >> standards has clearer/better instruction on this, it will be easier >> for us to revert/follow up too. I am certainly fine with dropping this patch as it is not critical to the reset of the series. Nothing will break if we stick with the 512 byte fixed limit. This is at most a prep patch for handling increased limits should they be reported. All it really is doing is acknowledging that any write same must have a payload of sector_size which can be something larger than 512 bytes. >> And you'll need to fix the Block Limits VPD simulation >> (ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write >> Same Length dynamically as per the logical sector size, otherwise your >> effort will be completely in vain, even if our block layer is >> overhauled in the future. Martin had earlier suggested that I leave the write same defaults as is due to concerns with misbehaving hardware. I think your patch adjusting the reported limits is reasonable enough. It seems to me we should have the hardware report it's actual limits, for example, report what the spec allows. Of course there are lots of reasons to limit the absolute maximums. So in this case we are just enabling the limit to be increased but not changing the current black-listing that distrusts DSM Trim. Once we have 4Kn devices to test then we can start white-listing and see if there is an overall increase in performance. >> Please be noted that, since your haven't touched ata_scsiop_inq_b0 at >> all, the reported Maximum Write Same Length will be: >> >> On device with TRIM support: >> - 4194240 LOGICAL sector per request split / command >> -- ~=2G on non-4Kn drives >> -- ~=16G on non-4Kn drives >> >> On device without TRIM support: >> - 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command >> -- ~= 32M on non-4Kn drives >> -- ~=256M on non-4Kn drives >> >> Even if we ignore the upper limit(s) of the block layer, do we want >> such inconsistencies? Hmm. Overall I think it is still okay if a bit confusing. It is possible that for devices which support SCT Write Same and DSM TRIM will still Trim faster than they can Write Same, However the internal implementation is opaque so I can't say if Write Same is often implemented in terms of TRIM or not. I mean that's how _I_ do it [Write 1 block and map N blocks to it], But not every FTL will have come to the same conclusion. I also suspect that given the choice for most use casess that TRIM is preferred over WS when TRIM supports returning zeroed blocks. -- Shaun Tancheff
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-22 19:10 +0200 |
| Message-ID | <s90Tv-F4-1@gated-at.bofh.it> |
| In reply to | #1467697 |
On 22 August 2016 at 15:04, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: > On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: >> On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: >>> As mentioned before, as of the latest draft of ACS-4, nothing about a >>> larger payload size is mentioned. Conservatively speaking, it sort of >> >> *payload block size >> >>> means that we are allowing four 512-byte block payload on 4Kn device >> >> *eight 512-byte-block payload >> >>> regardless of the reported limit in the IDENTIFY DEVICE data. I am >>> really not sure if it's a good thing to do. Doesn't seem necessary >>> anyway, especially when our block layer does not support such a large >>> bio size (well, yet), so each request will end up using a payload of >>> two 512-byte blocks at max anyway. >>> >>> Also, it's IMHO better to do it in a seperate patch (series) after the >>> SCT Write Same support has entered libata's repo too, because this has >>> nothing to with it but TRIM translation. In case the future ACS >>> standards has clearer/better instruction on this, it will be easier >>> for us to revert/follow up too. > > I am certainly fine with dropping this patch as it is not critical to > the reset of the series. > > Nothing will break if we stick with the 512 byte fixed limit. This > is at most a prep patch for handling increased limits should > they be reported. > > All it really is doing is acknowledging that any write same > must have a payload of sector_size which can be something > larger than 512 bytes. Actually I am not sure if we should hard code the limit ata_format_dsm_trim_descr() / ata_set_lba_range_entries() at all. The current implementation (with or without your patch) seems redundant and unnecessary to me. All we need to do should be: making sure that the block limits VPD advertises a safe Maximum Write Same Length, and reject Write Same (16) commands that have "number of blocks" that exceeds the limit (which is what I introduced in commit 5c79097a28c2, "libata-scsi: reject WRITE SAME (16) with n_block that exceeds limit"). In that case, we don't need to hard code the limit in the while-condition again; instead we should just make it end with the request size, since the accepted request could never be larger than the limit we advertise. > >>> And you'll need to fix the Block Limits VPD simulation >>> (ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write >>> Same Length dynamically as per the logical sector size, otherwise your >>> effort will be completely in vain, even if our block layer is >>> overhauled in the future. > > Martin had earlier suggested that I leave the write same defaults > as is due to concerns with misbehaving hardware. It doesn't really apply in libata's anyway. SD_MAX_WS10_BLOCKS means nothing to ATA drives, except from coincidentally being the same value as ATA_MAX_SECTORS_LBA48 (which technically should have been 65536 instead). > > I think your patch adjusting the reported limits is reasonable > enough. It seems to me we should have the hardware > report it's actual limits, for example, report what the spec > allows. As you mentioned yourself before, technically SCT Write Same does not have a limit. The only practical limit is the timeout in the SCSI layer, so the actual bytes being (over)written is probably our only concern. For the case of TRIM, devices do report a limit in their IDENTIFY DEVICE data. However, as Martin always said, it is not an always-safe piece of data for us to refer to, that's why we have been statically allowing only 1-block payload. Therefore, it seems convenient (and consistent) that we make SCT Write Same always use the same limit as TRIM, no matter if it is supported on a certain device. And to make sure the actual bytes being written / time required per command does not increase enormously as per the sector size, we decrease the limit accordingly. Certainly that's not necessary if 16G per command is fine on most devices. Also, does SCT Write Same commands that write 32M/256M per command make any sense? I mean would we benefit from such small SCT Write Same commands at all? > > Of course there are lots of reasons to limit the absolute > maximums. > > So in this case we are just enabling the limit to be > increased but not changing the current black-listing > that distrusts DSM Trim. Once we have 4Kn devices > to test then we can start white-listing and see if there > is an overall increase in performance. > >>> Please be noted that, since your haven't touched ata_scsiop_inq_b0 at >>> all, the reported Maximum Write Same Length will be: >>> >>> On device with TRIM support: >>> - 4194240 LOGICAL sector per request split / command >>> -- ~=2G on non-4Kn drives >>> -- ~=16G on non-4Kn drives >>> >>> On device without TRIM support: >>> - 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command >>> -- ~= 32M on non-4Kn drives >>> -- ~=256M on non-4Kn drives >>> >>> Even if we ignore the upper limit(s) of the block layer, do we want >>> such inconsistencies? > > Hmm. Overall I think it is still okay if a bit confusing. > It is possible that for devices which support SCT Write Same > and DSM TRIM will still Trim faster than they can Write Same, > However the internal implementation is opaque so I can't > say if Write Same is often implemented in terms of TRIM > or not. I mean that's how _I_ do it [Write 1 block and map > N blocks to it], But not every FTL will have come to the > same conclusion. Why would SCT Write Same be implemented in terms of TRIM? Neither would we need to care about that anyway. Considering we will unlikely allow multi-block payload TRIM, and we probably have no reason to touch the SCSI Write Same timeout, the only thing we need to consider is whether we want to decrease the advertised limit base on the typical SCT Write Same speed on traditional HDDs and the timeout, especially in the 4Kn case. Since I have no experience with SCT Write Same at all, and neither do I own any spinning HDD at all, I cannot firmly suggest what to do. All I can suggest is: should we decrease it per sector size? Or would 2G per command still be too large to avoid timeout? > > I also suspect that given the choice for most use casess that > TRIM is preferred over WS when TRIM supports returning > zeroed blocks. Well, for devices with discard_zeroes_data = 1, the block layer will not issue write same requests (see blkdev_issue_zeroout in block/blk-lib.c). However, libata only consider the RZAT support bit from a white list of devices (see ata_scsiop_read_cap in libata-scsi and the white list in libata-core). > > -- > Shaun Tancheff
[toc] | [prev] | [next] | [standalone]
| From | Shaun Tancheff <shaun.tancheff@seagate.com> |
|---|---|
| Date | 2016-08-22 20:10 +0200 |
| Message-ID | <s91Pz-1fk-21@gated-at.bofh.it> |
| In reply to | #1467826 |
On Mon, Aug 22, 2016 at 12:02 PM, Tom Yan <tom.ty89@gmail.com> wrote: > On 22 August 2016 at 15:04, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: >> On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: >>> On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: > Since I have no experience with SCT Write Same at all, and neither do > I own any spinning HDD at all, I cannot firmly suggest what to do. All > I can suggest is: should we decrease it per sector size? Or would 2G > per command still be too large to avoid timeout? Timeout for WS is 120 seconds so we should be fine there. The number to look for is the: Max. Sustained Transfer Rate OD (MB/s): 190 8TB (180 5TB) Which means the above drives should complete a 2G write in about 10 to 11 seconds. If these were 4Kn drives and we allowed a 16G max then it would be 80-90 seconds, assuming the write speed didn't get any better. So holding the maximum to around 2G is probably the best overall, in my opinion. -- Shaun Tancheff On Mon, Aug 22, 2016 at 12:02 PM, Tom Yan <tom.ty89@gmail.com> wrote: > On 22 August 2016 at 15:04, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: >> On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: >>> On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: >>>> As mentioned before, as of the latest draft of ACS-4, nothing about a >>>> larger payload size is mentioned. Conservatively speaking, it sort of >>> >>> *payload block size >>> >>>> means that we are allowing four 512-byte block payload on 4Kn device >>> >>> *eight 512-byte-block payload >>> >>>> regardless of the reported limit in the IDENTIFY DEVICE data. I am >>>> really not sure if it's a good thing to do. Doesn't seem necessary >>>> anyway, especially when our block layer does not support such a large >>>> bio size (well, yet), so each request will end up using a payload of >>>> two 512-byte blocks at max anyway. >>>> >>>> Also, it's IMHO better to do it in a seperate patch (series) after the >>>> SCT Write Same support has entered libata's repo too, because this has >>>> nothing to with it but TRIM translation. In case the future ACS >>>> standards has clearer/better instruction on this, it will be easier >>>> for us to revert/follow up too. >> >> I am certainly fine with dropping this patch as it is not critical to >> the reset of the series. >> >> Nothing will break if we stick with the 512 byte fixed limit. This >> is at most a prep patch for handling increased limits should >> they be reported. >> >> All it really is doing is acknowledging that any write same >> must have a payload of sector_size which can be something >> larger than 512 bytes. > > Actually I am not sure if we should hard code the limit > ata_format_dsm_trim_descr() / ata_set_lba_range_entries() at all. The > current implementation (with or without your patch) seems redundant > and unnecessary to me. > > All we need to do should be: making sure that the block limits VPD > advertises a safe Maximum Write Same Length, and reject Write Same > (16) commands that have "number of blocks" that exceeds the limit > (which is what I introduced in commit 5c79097a28c2, "libata-scsi: > reject WRITE SAME (16) with n_block that exceeds limit"). > > In that case, we don't need to hard code the limit in the > while-condition again; instead we should just make it end with the > request size, since the accepted request could never be larger than > the limit we advertise. > >> >>>> And you'll need to fix the Block Limits VPD simulation >>>> (ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write >>>> Same Length dynamically as per the logical sector size, otherwise your >>>> effort will be completely in vain, even if our block layer is >>>> overhauled in the future. >> >> Martin had earlier suggested that I leave the write same defaults >> as is due to concerns with misbehaving hardware. > > It doesn't really apply in libata's anyway. SD_MAX_WS10_BLOCKS means > nothing to ATA drives, except from coincidentally being the same value > as ATA_MAX_SECTORS_LBA48 (which technically should have been 65536 > instead). > >> >> I think your patch adjusting the reported limits is reasonable >> enough. It seems to me we should have the hardware >> report it's actual limits, for example, report what the spec >> allows. > > As you mentioned yourself before, technically SCT Write Same does not > have a limit. The only practical limit is the timeout in the SCSI > layer, so the actual bytes being (over)written is probably our only > concern. > > For the case of TRIM, devices do report a limit in their IDENTIFY > DEVICE data. However, as Martin always said, it is not an always-safe > piece of data for us to refer to, that's why we have been statically > allowing only 1-block payload. > > Therefore, it seems convenient (and consistent) that we make SCT Write > Same always use the same limit as TRIM, no matter if it is supported > on a certain device. And to make sure the actual bytes being written / > time required per command does not increase enormously as per the > sector size, we decrease the limit accordingly. Certainly that's not > necessary if 16G per command is fine on most devices. > > Also, does SCT Write Same commands that write 32M/256M per command > make any sense? I mean would we benefit from such small SCT Write Same > commands at all? > >> >> Of course there are lots of reasons to limit the absolute >> maximums. >> >> So in this case we are just enabling the limit to be >> increased but not changing the current black-listing >> that distrusts DSM Trim. Once we have 4Kn devices >> to test then we can start white-listing and see if there >> is an overall increase in performance. >> >>>> Please be noted that, since your haven't touched ata_scsiop_inq_b0 at >>>> all, the reported Maximum Write Same Length will be: >>>> >>>> On device with TRIM support: >>>> - 4194240 LOGICAL sector per request split / command >>>> -- ~=2G on non-4Kn drives >>>> -- ~=16G on non-4Kn drives >>>> >>>> On device without TRIM support: >>>> - 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command >>>> -- ~= 32M on non-4Kn drives >>>> -- ~=256M on non-4Kn drives >>>> >>>> Even if we ignore the upper limit(s) of the block layer, do we want >>>> such inconsistencies? >> >> Hmm. Overall I think it is still okay if a bit confusing. >> It is possible that for devices which support SCT Write Same >> and DSM TRIM will still Trim faster than they can Write Same, >> However the internal implementation is opaque so I can't >> say if Write Same is often implemented in terms of TRIM >> or not. I mean that's how _I_ do it [Write 1 block and map >> N blocks to it], But not every FTL will have come to the >> same conclusion. > > Why would SCT Write Same be implemented in terms of TRIM? Neither > would we need to care about that anyway. Considering we will unlikely > allow multi-block payload TRIM, and we probably have no reason to > touch the SCSI Write Same timeout, the only thing we need to consider > is whether we want to decrease the advertised limit base on the > typical SCT Write Same speed on traditional HDDs and the timeout, > especially in the 4Kn case. > > Since I have no experience with SCT Write Same at all, and neither do > I own any spinning HDD at all, I cannot firmly suggest what to do. All > I can suggest is: should we decrease it per sector size? Or would 2G > per command still be too large to avoid timeout? > >> >> I also suspect that given the choice for most use casess that >> TRIM is preferred over WS when TRIM supports returning >> zeroed blocks. > > Well, for devices with discard_zeroes_data = 1, the block layer will > not issue write same requests (see blkdev_issue_zeroout in > block/blk-lib.c). However, libata only consider the RZAT support bit > from a white list of devices (see ata_scsiop_read_cap in libata-scsi > and the white list in libata-core). > >> >> -- >> Shaun Tancheff -- Shaun Tancheff
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-22 21:00 +0200 |
| Message-ID | <s92BX-1yy-13@gated-at.bofh.it> |
| In reply to | #1467873 |
In that case I see no reason that my suggestion should not be adopted. Currently speaking (as I mentioned in the commit message) it is reasonable to decrease it per logical sector size in the TRIM-only sense as well because of the block layer / bio size limit. FWIW, as of ACS-4, RANGE LENGTH field in DSM(XL)/TRIM range entry should be "number of logical sectors". Therefore, if there will be any 4Kn SSDs, _bytes_ TRIM'd per command is expected to be increased with the sector size as well, just like SCT Write Same. For the "payload block size" that is "always" 512-byte as per the same spec, I don't think we need to concern about it. I think it only matters if we want to enable multi-block TRIM payload according to the reported limit in IDENTIFY DEVICE data. Probably it merely means that the "each of the blocks" in the reported limit will always mean 64 TRIM entries, even on 4Kn drives, instead of 512. On 23 August 2016 at 02:00, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: > On Mon, Aug 22, 2016 at 12:02 PM, Tom Yan <tom.ty89@gmail.com> wrote: >> On 22 August 2016 at 15:04, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: >>> On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: >>>> On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: > >> Since I have no experience with SCT Write Same at all, and neither do >> I own any spinning HDD at all, I cannot firmly suggest what to do. All >> I can suggest is: should we decrease it per sector size? Or would 2G >> per command still be too large to avoid timeout? > > Timeout for WS is 120 seconds so we should be fine there. > > The number to look for is the: > Max. Sustained Transfer Rate OD (MB/s): 190 8TB (180 5TB) > > Which means the above drives should complete a 2G write in > about 10 to 11 seconds. > > If these were 4Kn drives and we allowed a 16G max then it > would be 80-90 seconds, assuming the write speed didn't > get any better. > > So holding the maximum to around 2G is probably the best > overall, in my opinion. > > -- > Shaun Tancheff > > On Mon, Aug 22, 2016 at 12:02 PM, Tom Yan <tom.ty89@gmail.com> wrote: >> On 22 August 2016 at 15:04, Shaun Tancheff <shaun.tancheff@seagate.com> wrote: >>> On Mon, Aug 22, 2016 at 3:33 AM, Tom Yan <tom.ty89@gmail.com> wrote: >>>> On 22 August 2016 at 08:31, Tom Yan <tom.ty89@gmail.com> wrote: >>>>> As mentioned before, as of the latest draft of ACS-4, nothing about a >>>>> larger payload size is mentioned. Conservatively speaking, it sort of >>>> >>>> *payload block size >>>> >>>>> means that we are allowing four 512-byte block payload on 4Kn device >>>> >>>> *eight 512-byte-block payload >>>> >>>>> regardless of the reported limit in the IDENTIFY DEVICE data. I am >>>>> really not sure if it's a good thing to do. Doesn't seem necessary >>>>> anyway, especially when our block layer does not support such a large >>>>> bio size (well, yet), so each request will end up using a payload of >>>>> two 512-byte blocks at max anyway. >>>>> >>>>> Also, it's IMHO better to do it in a seperate patch (series) after the >>>>> SCT Write Same support has entered libata's repo too, because this has >>>>> nothing to with it but TRIM translation. In case the future ACS >>>>> standards has clearer/better instruction on this, it will be easier >>>>> for us to revert/follow up too. >>> >>> I am certainly fine with dropping this patch as it is not critical to >>> the reset of the series. >>> >>> Nothing will break if we stick with the 512 byte fixed limit. This >>> is at most a prep patch for handling increased limits should >>> they be reported. >>> >>> All it really is doing is acknowledging that any write same >>> must have a payload of sector_size which can be something >>> larger than 512 bytes. >> >> Actually I am not sure if we should hard code the limit >> ata_format_dsm_trim_descr() / ata_set_lba_range_entries() at all. The >> current implementation (with or without your patch) seems redundant >> and unnecessary to me. >> >> All we need to do should be: making sure that the block limits VPD >> advertises a safe Maximum Write Same Length, and reject Write Same >> (16) commands that have "number of blocks" that exceeds the limit >> (which is what I introduced in commit 5c79097a28c2, "libata-scsi: >> reject WRITE SAME (16) with n_block that exceeds limit"). >> >> In that case, we don't need to hard code the limit in the >> while-condition again; instead we should just make it end with the >> request size, since the accepted request could never be larger than >> the limit we advertise. >> >>> >>>>> And you'll need to fix the Block Limits VPD simulation >>>>> (ata_scsiop_inq_b0) too, so that it will advertise the Maximum Write >>>>> Same Length dynamically as per the logical sector size, otherwise your >>>>> effort will be completely in vain, even if our block layer is >>>>> overhauled in the future. >>> >>> Martin had earlier suggested that I leave the write same defaults >>> as is due to concerns with misbehaving hardware. >> >> It doesn't really apply in libata's anyway. SD_MAX_WS10_BLOCKS means >> nothing to ATA drives, except from coincidentally being the same value >> as ATA_MAX_SECTORS_LBA48 (which technically should have been 65536 >> instead). >> >>> >>> I think your patch adjusting the reported limits is reasonable >>> enough. It seems to me we should have the hardware >>> report it's actual limits, for example, report what the spec >>> allows. >> >> As you mentioned yourself before, technically SCT Write Same does not >> have a limit. The only practical limit is the timeout in the SCSI >> layer, so the actual bytes being (over)written is probably our only >> concern. >> >> For the case of TRIM, devices do report a limit in their IDENTIFY >> DEVICE data. However, as Martin always said, it is not an always-safe >> piece of data for us to refer to, that's why we have been statically >> allowing only 1-block payload. >> >> Therefore, it seems convenient (and consistent) that we make SCT Write >> Same always use the same limit as TRIM, no matter if it is supported >> on a certain device. And to make sure the actual bytes being written / >> time required per command does not increase enormously as per the >> sector size, we decrease the limit accordingly. Certainly that's not >> necessary if 16G per command is fine on most devices. >> >> Also, does SCT Write Same commands that write 32M/256M per command >> make any sense? I mean would we benefit from such small SCT Write Same >> commands at all? >> >>> >>> Of course there are lots of reasons to limit the absolute >>> maximums. >>> >>> So in this case we are just enabling the limit to be >>> increased but not changing the current black-listing >>> that distrusts DSM Trim. Once we have 4Kn devices >>> to test then we can start white-listing and see if there >>> is an overall increase in performance. >>> >>>>> Please be noted that, since your haven't touched ata_scsiop_inq_b0 at >>>>> all, the reported Maximum Write Same Length will be: >>>>> >>>>> On device with TRIM support: >>>>> - 4194240 LOGICAL sector per request split / command >>>>> -- ~=2G on non-4Kn drives >>>>> -- ~=16G on non-4Kn drives >>>>> >>>>> On device without TRIM support: >>>>> - 0 --> SD_MAX_WS10_BLOCKS (65535) per request split / command >>>>> -- ~= 32M on non-4Kn drives >>>>> -- ~=256M on non-4Kn drives >>>>> >>>>> Even if we ignore the upper limit(s) of the block layer, do we want >>>>> such inconsistencies? >>> >>> Hmm. Overall I think it is still okay if a bit confusing. >>> It is possible that for devices which support SCT Write Same >>> and DSM TRIM will still Trim faster than they can Write Same, >>> However the internal implementation is opaque so I can't >>> say if Write Same is often implemented in terms of TRIM >>> or not. I mean that's how _I_ do it [Write 1 block and map >>> N blocks to it], But not every FTL will have come to the >>> same conclusion. >> >> Why would SCT Write Same be implemented in terms of TRIM? Neither >> would we need to care about that anyway. Considering we will unlikely >> allow multi-block payload TRIM, and we probably have no reason to >> touch the SCSI Write Same timeout, the only thing we need to consider >> is whether we want to decrease the advertised limit base on the >> typical SCT Write Same speed on traditional HDDs and the timeout, >> especially in the 4Kn case. >> >> Since I have no experience with SCT Write Same at all, and neither do >> I own any spinning HDD at all, I cannot firmly suggest what to do. All >> I can suggest is: should we decrease it per sector size? Or would 2G >> per command still be too large to avoid timeout? >> >>> >>> I also suspect that given the choice for most use casess that >>> TRIM is preferred over WS when TRIM supports returning >>> zeroed blocks. >> >> Well, for devices with discard_zeroes_data = 1, the block layer will >> not issue write same requests (see blkdev_issue_zeroout in >> block/blk-lib.c). However, libata only consider the RZAT support bit >> from a white list of devices (see ata_scsiop_read_cap in libata-scsi >> and the white list in libata-core). >> >>> >>> -- >>> Shaun Tancheff > > > > -- > Shaun Tancheff
[toc] | [prev] | [next] | [standalone]
| From | Tom Yan <tom.ty89@gmail.com> |
|---|---|
| Date | 2016-08-22 23:00 +0200 |
| Message-ID | <s94u6-2Ol-35@gated-at.bofh.it> |
| In reply to | #1467952 |
On 22 August 2016 at 18:52, Tom Yan <tom.ty89@gmail.com> wrote:
>
> For the "payload block size" that is "always" 512-byte as per the same
> spec, I don't think we need to concern about it. I think it only
> matters if we want to enable multi-block TRIM payload according to the
> reported limit in IDENTIFY DEVICE data. Probably it merely means that
> the "each of the blocks" in the reported limit will always mean 64
> TRIM entries, even on 4Kn drives, instead of 512.
>
Actually that's what we assumed in our current code that forms the DSM
command as well. See how (hob_)feature for queued TRIM and how
(hob_)nsect for non-queued TRIM are set in ata_scsi_write_same_xlat in
libata-scsi ('size / 512').
So if you are going to increase the payload block size per logical
sector size (in other word, you assume that the payload block size is
_expected_ to be the logical block size, in spite of what ACS told,
you'll need to adjust how the aforementioned fields in the ATA
taskfile are set as well.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web