diff options
author | Christoph Hellwig <hch@infradead.org> | 2009-11-17 10:00:47 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2009-12-03 02:46:35 -0500 |
commit | 18f0f97850059303ed73b1f02084f55ca330a80c (patch) | |
tree | 6b3f91f521d3d35f864138bd7e8962eb346a09c4 /include/linux/ata.h | |
parent | 6013efd8860bf15c1f86f365332642cfe557152f (diff) | |
download | linux-stable-18f0f97850059303ed73b1f02084f55ca330a80c.tar.gz linux-stable-18f0f97850059303ed73b1f02084f55ca330a80c.tar.bz2 linux-stable-18f0f97850059303ed73b1f02084f55ca330a80c.zip |
libata: add translation for SCSI WRITE SAME (aka TRIM support)
Add support for the ATA TRIM command in libata. We translate a WRITE SAME 16
command with the unmap bit set into an ATA TRIM command and export enough
information in READ CAPACITY 16 and the block limits EVPD page so that the new
SCSI layer discard support will driver this for us.
Note that I hardcode the WRITE_SAME_16 opcode for now as the patch to introduce
the symbolic is not in 2.6.32 yet but only in the SCSI tree - as soon as it is
merged we can fix it up to properly use the symbolic name.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'include/linux/ata.h')
-rw-r--r-- | include/linux/ata.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/ata.h b/include/linux/ata.h index 4fb357312b3b..e2595e877e44 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -87,6 +87,7 @@ enum { ATA_ID_HW_CONFIG = 93, ATA_ID_SPG = 98, ATA_ID_LBA_CAPACITY_2 = 100, + ATA_ID_SECTOR_SIZE = 106, ATA_ID_LAST_LUN = 126, ATA_ID_DLF = 128, ATA_ID_CSFO = 129, @@ -638,6 +639,18 @@ static inline int ata_id_flush_ext_enabled(const u16 *id) return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; } +static inline int ata_id_has_large_logical_sectors(const u16 *id) +{ + if ((id[ATA_ID_SECTOR_SIZE] & 0xc000) != 0x4000) + return 0; + return id[ATA_ID_SECTOR_SIZE] & (1 << 13); +} + +static inline u8 ata_id_logical_per_physical_sectors(const u16 *id) +{ + return id[ATA_ID_SECTOR_SIZE] & 0xf; +} + static inline int ata_id_has_lba48(const u16 *id) { if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |