[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#603735: libata: SSD Discard/Trim functionality does not seems to work correctly



Package: linux-image-2.6.32-5-amd64
Version: 2.6.32-27

According to the linux-2.6 package changelogs ATA trim functionality were 
added with version 2.6.32-12:

linux-2.6  (2.6.32-12) unstable; urgency=low 
* The "Microwave Background" release
	...
	[ maximilian attems]
	...
	* Add libata TRIM support.
	...

It seems that the TRIM patch does not works properly with my SSD an OCZ Vertex 
2 Extended 60GB (OCZSSD2-2VTXE60G).

Generally the Trim functionality could be tested with the following commands:

dd if=/dev/urandom of=tempfile count=100 bs=512k oflag=direct
hdparm --fibmap tempfile
hdparm --read-sector [ADDRESS] /dev/sdX
rm tempfile
sync
hdparm --read-sector [ADDRESS] /dev/sdX

After the last command the output should be only zero values, but I get non 
zero values:

hdparm --read-sector 26854400 /dev/sda

/dev/sda:
reading sector 26854400: succeeded
4442 4465 6cd6 5bc4 42bc f78b 9258 bf66
a024 ebca 5a8f e3f2 4886 9dea 9b50 2b45
...

I'd tried the same commands with a manually compiled 2.6.36 kernel. With this 
kernel I got zero values. It seems that there were changes in 2.6.3[3-6] 
kernels which had fixed the issue.

Furthermore
/sys/block/sda/queue/discard_zeroes_data,
/sys/block/sda/queue/discard_max_entry and
/sys/block/sda/queue/discard_granularity
are not present with 2.6.32-27, but with 2.6.36.

The discard zero indication feature were added with following commit (2.6.33 
kernel series): http://kerneltrap.org/mailarchive/git-commits-
head/2009/12/8/16006

[Max entry and granularity were annotated here: 
http://www.spinics.net/lists/linux-scsi/msg40360.html and 
http://www.spinics.net/lists/dm-devel/msg12155.html 
(http://android.git.kernel.org/?p=kernel/common.git;a=commitdiff;h=86b37281411cf1e9bc0a6b5406c45edb7bd9ea5d)]

Available should be all three attributes in 2.6.33.

Maybe this could explain the difference between 2.6.32-27 and generic kernel 
2.6.36. Eventually SandForce devices did not return zero blocks after discard 
and the ATA Trim works properly with my drive...


mount:
/dev/sda1 on / type ext4 (rw,noatime,nodiratime,errors=remount-ro,discard)
...

SSD capabilities:
hdparm -I /dev/sda
...
           *    Data Set Management TRIM supported
           *    Deterministic read data after TRIM
...

sysfs queue directory:
ls -la /sys/block/sda/queue/
insgesamt 0
drwxr-xr-x 3 root root    0 16. Nov 19:55 .
drwxr-xr-x 9 root root    0 16. Nov 19:55 ..
-r--r--r-- 1 root root 4096 16. Nov 20:49 hw_sector_size
drwxr-xr-x 2 root root    0 16. Nov 20:49 iosched
-rw-r--r-- 1 root root 4096 16. Nov 20:49 iostats
-r--r--r-- 1 root root 4096 16. Nov 20:49 logical_block_size
-r--r--r-- 1 root root 4096 16. Nov 20:49 max_hw_sectors_kb
-rw-r--r-- 1 root root 4096 16. Nov 20:49 max_sectors_kb
-r--r--r-- 1 root root 4096 16. Nov 20:49 minimum_io_size
-rw-r--r-- 1 root root 4096 16. Nov 20:49 nomerges
-rw-r--r-- 1 root root 4096 16. Nov 20:49 nr_requests
-r--r--r-- 1 root root 4096 16. Nov 20:49 optimal_io_size
-r--r--r-- 1 root root 4096 16. Nov 20:49 physical_block_size
-rw-r--r-- 1 root root 4096 16. Nov 20:49 read_ahead_kb
-rw-r--r-- 1 root root 4096 16. Nov 20:49 rotational
-rw-r--r-- 1 root root 4096 16. Nov 20:49 rq_affinity
-rw-r--r-- 1 root root 4096 16. Nov 19:55 scheduler



Reply to: