From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Mark Lord <kernel@teksavvy.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
jens.axboe@oracle.com, james.bottomley@hansenpartnership.com,
hch@infradead.org, willy@wil.cx, jgarzik@pobox.com,
sandeen@redhat.com, rwheeler@redhat.com,
linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 4/5] libata: Report zeroed read after Trim and max discard size
Date: Thu, 26 Nov 2009 22:46:03 -0500 [thread overview]
Message-ID: <yq18wds3a10.fsf@sermon.lab.mkp.net> (raw)
In-Reply-To: <4B0F3186.6000903@teksavvy.com> (Mark Lord's message of "Thu, 26 Nov 2009 20:55:18 -0500")
>>>>> "Mark" == Mark Lord <kernel@teksavvy.com> writes:
Mark> Is that correct, or should it be this:
Mark> if (ata_id_has_trim(id) && (id[ATA_ID_ADDITIONAL_SUPP] &
Mark> 0x4020) == 0x4020)
Good spotting! You are right, I need both bits to be set...
libata: Report zeroed read after Trim and max discard size
Our current Trim payload is a single sector that can accommodate 64 *
65535 blocks being unmapped. Report this value in the Block Limits
Maximum Unmap LBA count field.
If a storage device supports Trim and the DRAT and RZAT bits are set,
report TPRZ=1 in Read Capacity(16).
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e0995c4..08d4ab7 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2116,8 +2116,10 @@ static unsigned int ata_scsiop_inq_b0(struct ata_scsi_args *args, u8 *rbuf)
* that we support some form of unmap - in thise case via WRITE SAME
* with the unmap bit set.
*/
- if (ata_id_has_trim(args->id))
+ if (ata_id_has_trim(args->id)) {
+ put_unaligned_be32(65535 * 512 / 8, &rbuf[20]);
put_unaligned_be32(1, &rbuf[28]);
+ }
return 0;
}
@@ -2412,8 +2414,12 @@ static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf)
rbuf[14] = (lowest_aligned >> 8) & 0x3f;
rbuf[15] = lowest_aligned;
- if (ata_id_has_trim(args->id))
- rbuf[14] |= 0x80;
+ if (ata_id_has_trim(args->id)) {
+ rbuf[14] |= 0x80; /* TPE */
+
+ if (ata_id_has_zero_after_trim(args->id))
+ rbuf[14] |= 0x40; /* TPRZ */
+ }
}
return 0;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index e2595e8..dfa2298 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -75,6 +75,7 @@ enum {
ATA_ID_EIDE_DMA_TIME = 66,
ATA_ID_EIDE_PIO = 67,
ATA_ID_EIDE_PIO_IORDY = 68,
+ ATA_ID_ADDITIONAL_SUPP = 69,
ATA_ID_QUEUE_DEPTH = 75,
ATA_ID_MAJOR_VER = 80,
ATA_ID_COMMAND_SET_1 = 82,
@@ -816,6 +817,16 @@ static inline int ata_id_has_trim(const u16 *id)
return 0;
}
+static inline int ata_id_has_zero_after_trim(const u16 *id)
+{
+ /* DSM supported, deterministic read, and read zero after trim set */
+ if (ata_id_has_trim(id) &&
+ (id[ATA_ID_ADDITIONAL_SUPP] & 0x4020) == 0x4020)
+ return 1;
+
+ return 0;
+}
+
static inline int ata_id_current_chs_valid(const u16 *id)
{
/* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
next prev parent reply other threads:[~2009-11-27 3:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-26 17:00 Thin provisioning fixes (take 3) Martin K. Petersen
2009-11-26 17:00 ` [PATCH 1/5] block: Allow devices to indicate whether discarded blocks are zeroed Martin K. Petersen
2009-11-26 17:00 ` [PATCH 2/5] sd: WRITE SAME(16) / UNMAP support Martin K. Petersen
2009-11-26 17:00 ` [PATCH 3/5] scsi: Correctly handle thin provisioning write error Martin K. Petersen
2009-11-26 17:00 ` [PATCH 4/5] libata: Report zeroed read after Trim and max discard size Martin K. Petersen
2009-11-27 1:55 ` Mark Lord
2009-11-27 3:46 ` Martin K. Petersen [this message]
2009-12-03 7:57 ` Jeff Garzik
2009-12-03 23:02 ` Jeff Garzik
2009-11-26 17:00 ` [PATCH 5/5] libata: Clarify ata_set_lba_range_entries function Martin K. Petersen
2009-12-03 23:02 ` Jeff Garzik
2009-11-26 17:09 ` Thin provisioning fixes (take 3) James Bottomley
2009-11-26 17:27 ` Martin K. Petersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=yq18wds3a10.fsf@sermon.lab.mkp.net \
--to=martin.petersen@oracle.com \
--cc=hch@infradead.org \
--cc=james.bottomley@hansenpartnership.com \
--cc=jens.axboe@oracle.com \
--cc=jgarzik@pobox.com \
--cc=kernel@teksavvy.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=rwheeler@redhat.com \
--cc=sandeen@redhat.com \
--cc=willy@wil.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).