Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SSD HDD] TRIM not working
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
canis_lupus
l33t
l33t


Joined: 22 Dec 2005
Posts: 773
Location: Kraków

PostPosted: Fri Nov 09, 2012 7:16 pm    Post subject: [SSD HDD] TRIM not working Reply with quote

I have a Vertex 3 OCZ SSD hard drive and ext4 filesystem mounted with discard option:
Code:
pingwiniarnia lupus # mount
rootfs on / type rootfs (rw)
/dev/root on / type ext4 (rw,noatime,discard,barrier=0,commit=0)


My SATA controller working in AHCI mode:

Code:
pingwiniarnia lupus # dmesg |grep ahci
ahci 0000:00:11.0: version 3.0
ahci 0000:00:11.0: AHCI 0001.0200 32 slots 6 ports 6 Gbps 0x3f impl SATA mode
ahci 0000:00:11.0: flags: 64bit ncq sntf ilck pm led clo pmp pio slum part


My HDD support TRIM:

Code:
pingwiniarnia lupus # hdparm -I /dev/sda | grep TRIM
           *    Data Set Management TRIM supported (limit 1 block)
           *    Deterministic read data after TRIM


I updated firmware yesterday but when i tested TRIM witch any script, i get the TRIM is still not working. Where is the bug?
_________________
"I love you cię" Różyczko...
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Sun Nov 11, 2012 12:27 am    Post subject: Reply with quote

What script are you using?
Also I hear that some SSD's unused blocks have indeterministic behavior, which will confuse the results of some TRIM checker scripts. I did recall seeing OCZ being one of them. The typical TRIM script that I found works as expected on my Crucial M4. I have yet to try my Intel 520-series.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
canis_lupus
l33t
l33t


Joined: 22 Dec 2005
Posts: 773
Location: Kraków

PostPosted: Mon Nov 12, 2012 9:20 am    Post subject: Reply with quote

eccerr0r wrote:
What script are you using?


Code:
#!/bin/bash
#
# Test if TRIM is working on your SSD. Tested only with EXT4 filesystems
# in Ubuntu 11.10 and Fedora 16. This script is simply an automation of
# the procedures described by Nicolay Doytchev here:
#
# https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking
#
# Author: Dorian Bolivar <dbolivar@gmail.com>
# Date: 20120129
#

if [ $# -ne 3 ]; then
        echo
        echo "Usage: $0 <filename> <size> <device>"
        echo
        echo "<filename> is a temporary file for the test"
        echo "<size> is the file size in MB"
        echo "<device> is the device being tested, e.g. /dev/sda"
        echo
        echo "Example: $0 tempfile 5 /dev/sda"
        echo
        echo "This would run the test for /dev/sda creating a"
        echo "temporary file named \"tempfile\" with 5 MB"
        echo
        exit 1
fi

FILE="$1"
SIZE=$2
DEVICE="$3"

# Create the temporary file
dd if=/dev/urandom of="$FILE" count=1 bs=${SIZE}M oflag=direct                                                                                                                                                                     
sync                                                                                                                                                                                                                               
                                                                                                                                                                                                                                   
# Get the address of the first sector                                                                                                                                                                                               
hdparm --fibmap "$FILE"                                                                                                                                                                                                             
SECTOR=`hdparm --fibmap "$FILE" | tail -n1 | awk '{ print $2; }'`                                                                                                                                                                   
                                                                                                                                                                                                                                   
# Read the first sector prior to deletion                                                                                                                                                                                           
hdparm --read-sector $SECTOR "$DEVICE"                                                                                                                                                                                             
echo                                                                                                                                                                                                                               
echo "This is a sector of the file. It should have been successfully read"                                                                                                                                                         
echo "and show a bunch of random data."                                                                                                                                                                                             
echo                                                                                                                                                                                                                               
read -n 1 -p "Press any key to continue..."                                                                                                                                                                                         
                                                                                                                                                                                                                                   
# Delete the file and re-read the sector                                                                                                                                                                                           
rm -f $FILE                                                                                                                                                                                                                         
sync                                                                                                                                                                                                                               
echo                                                                                                                                                                                                                               
echo "File deleted. Sleeping for 30 seconds before re-reading the sector."                                                                                                                                                         
echo "If TRIM is working, you should see all 0s now."                                                                                                                                                                               
sleep 30                                                                                                                                                                                                                           
hdparm --read-sector $SECTOR "$DEVICE"                                                                                                                                                                                             
echo                                                                                                                                                                                                                               
echo "If the sector isn't filled with 0s, something is wrong with your"                                                                                                                                                             
echo "configuration. Try googling for \"TRIM SSD Linux\"."                                                                                                                                                                         
echo                                                                                                                                                                                                                               
                                                                                                                                                                                                                                   
exit 0

_________________
"I love you cię" Różyczko...
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Mon Nov 12, 2012 3:56 pm    Post subject: Reply with quote

I saw this post...

http://www.ocztechnologyforum.com/forum/showthread.php?100001-Vertex3-linux-ext4-trim-test-fault

If this is the case I don't know if you'll find an answer.

And edited: I just tested on my Sandforce based Intel SSD520 series - and the trim test works...
I do find it really odd that only OCZ disks don't work?
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Jean-Paul
Guru
Guru


Joined: 13 Apr 2009
Posts: 306

PostPosted: Fri Nov 16, 2012 10:31 am    Post subject: Reply with quote

I use the same SSD with the same filesystem.
Quote:
dmesg | grep OCZ
[ 1.262975] ata7.00: ATA-8: OCZ-VERTEX3, 2.11, max UDMA/133


mount
Quote:
mount
/dev/root on / type ext4 (rw,noatime,discard,data=ordered)


I run the script and it seems to work.
Quote:
tempfile:
filesystem blocksize 4096, begins at LBA 25577472; assuming 512 byte sectors.
byte_offset begin_LBA end_LBA sectors
0 25880576 25890815 10240

/dev/sda:
reading sector 25880576: succeeded
8969 d7e2 02bd d7b6 8c65 9ee7 a42e defc
3797 770d 3e52 7cc0 3c22 2be3 d753 4697
d060 e4ae 52c4 913d ffc1 5600 51c9 0093
7b1c 87e5 e541 bb24 8f8f 7170 0c00 99fd
6b23 a786 5b09 20f4 fa55 3f26 aedc 42e7
9cf6 abe7 69c8 8e08 f30c d242 1111 c948
7247 ad06 9c14 d477 9e71 e3c3 0ba3 fa7b
a749 31ff f7dc 90dc b4eb 19c3 9bd7 9ed5
a91e 4107 ae36 a839 b854 087e 5cce 3947
5978 bdf2 871a a1f7 dd5c d166 307c e77a
9921 9bb4 b869 2460 8fb0 13af 3ec8 5100
977f 06c1 226a 9d2e c202 7954 b6dc 751c
ec46 214e ece3 58e7 ddea 4415 19e3 b62a
71fa b19d 8848 163c 2b44 6e3c 4535 c397
323a b137 03fc d97c 362a c7a6 5bbc 53b6
f539 e768 c33c cdcf eb50 f36c 0a59 4754
3bbc c105 8d50 f5cf 3583 687a 88f2 97c0
4f1e bd55 ace7 1af9 533b 8803 ac30 55f3
53a4 433c e72f 9018 d35d 062e 1648 062b
369f 773c c547 1c62 3c1a efb4 f8de 815e
48fb a4e2 7d9b 2137 ab00 c081 6098 6984
e3ff 46a4 24de e157 87cc 13e4 b361 fd0b
23ab 26a1 cafc fd5b fdc3 3243 2890 dcb3
c467 4ef9 74ec a8be 53e1 a91c 9cb1 fc7a
d1ba a651 6f2b d099 3f77 1e9d f09a 7d5c
6f14 ccca d200 2410 e2e4 4ad3 7f16 42da
dc0b 1741 571d e243 a723 3e07 17fc e03c
4811 9fb7 0677 e34c 595b cd8f 6bdd c271
aa31 5269 cde4 3297 7c06 a94d d15d 801f
e8ca f473 d214 bf1f ce51 cb62 7fdb bd5e
5fb1 5ac9 4b4c f4b5 6b0e 8391 8c2d 184f
1e2e 4b20 70bc 308d 1486 6bc4 a234 2cf9

This is a sector of the file. It should have been successfully read
and show a bunch of random data.

Press any key to continue...
File deleted. Sleeping for 30 seconds before re-reading the sector.
If TRIM is working, you should see all 0s now.

/dev/sda:
reading sector 25880576: succeeded
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000

If the sector isn't filled with 0s, something is wrong with your
configuration. Try googling for "TRIM SSD Linux".


Jean-Paul
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Fri Nov 16, 2012 3:36 pm    Post subject: Reply with quote

That is true, if TRIM is working then eventually it should zero out regardless, but it's not clear when it should...

Hmm... should buy another TRIM capable SSD to play with...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
ryao
Retired Dev
Retired Dev


Joined: 27 Feb 2012
Posts: 132

PostPosted: Fri Nov 16, 2012 8:49 pm    Post subject: Re: [SSD HDD] TRIM not working Reply with quote

canis_lupus wrote:
I have a Vertex 3 OCZ SSD hard drive and ext4 filesystem mounted with discard option:
Code:
pingwiniarnia lupus # mount
rootfs on / type rootfs (rw)
/dev/root on / type ext4 (rw,noatime,discard,barrier=0,commit=0)


My SATA controller working in AHCI mode:

Code:
pingwiniarnia lupus # dmesg |grep ahci
ahci 0000:00:11.0: version 3.0
ahci 0000:00:11.0: AHCI 0001.0200 32 slots 6 ports 6 Gbps 0x3f impl SATA mode
ahci 0000:00:11.0: flags: 64bit ncq sntf ilck pm led clo pmp pio slum part


My HDD support TRIM:

Code:
pingwiniarnia lupus # hdparm -I /dev/sda | grep TRIM
           *    Data Set Management TRIM supported (limit 1 block)
           *    Deterministic read data after TRIM


I updated firmware yesterday but when i tested TRIM witch any script, i get the TRIM is still not working. Where is the bug?


Until SATA 3.1, TRIM is a non-queued command such that it needs to be done in batches to avoid significant penalties in IO throughput.

With that said, a far better way to test the kernel discard implementation is to use a ZFS zvol, which lets you measure space utilization.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum