User: Password:
|
|
Subscribe / Log in / New account

The second half of the 2.6.37 merge window

The second half of the 2.6.37 merge window

Posted Nov 1, 2010 21:22 UTC (Mon) by slothrop (guest, #69834)
Parent article: The second half of the 2.6.37 merge window

BTW a nice userspace program for the (ext4) FITRIM ioctl() command
can be found here:
http://www.spinics.net/lists/xfs/msg01837.html
It's called fstrim and works nicely on my Vertex SSD.
Compile and run as root (e.g.): fstrim -v /
(There is no visible feedback, you have to wait a few minutes
(depending on the size and state of the SSD) before it finishes.)


(Log in to post comments)

The second half of the 2.6.37 merge window

Posted Nov 1, 2010 21:31 UTC (Mon) by slothrop (guest, #69834) [Link]

It now can also be found on sourceforge:
http://sourceforge.net/projects/fstrim/

The second half of the 2.6.37 merge window

Posted Nov 1, 2010 23:16 UTC (Mon) by tardyp (subscriber, #58715) [Link]

Do you think this could be used to reduce the size of virtualbox'es variable size virtual disks?

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 4:51 UTC (Tue) by slothrop (guest, #69834) [Link]

No. This is not about reducing sizes, its about telling
your SSD which blocks are not used by the filesystem currently,
so that they could be added to the internal list of available
blocks. This hopefully makes the SSD snappier and faster.

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 6:39 UTC (Tue) by bronson (subscriber, #4806) [Link]

Right. And if you tell virtualbox which blocks on the virtual disk are no longer used, the backing file can be made more sparse.

In theory, trim could be just as useful to loopback-mounted filesystems as it is to SSDs, no?

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 7:24 UTC (Tue) by slothrop (guest, #69834) [Link]

That's an interesting idea, but it needs to be implemented
in virtualbox or qemu. Then you could issue the FITRIM
ioctl from the running guest and it would be intercepted
by these programs and acted upon accordingly.

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 14:05 UTC (Tue) by tardyp (subscriber, #58715) [Link]

Seems one of the dev of vbox was answering on this topic a while ago.
http://forums.virtualbox.org/viewtopic.php?f=9&t=1822...
"""
VD images files are typically mapped onto physical rotating media. These have high burst bandwidth but poor seek times (compared to SSD). The VDI format uses 2Mb pages for performance reasons. Dropping this to 4K to align it to the SDD driver technology would have a disastrous impact on real I/O performance (up to a factor of 10 slowdown say). Sorry, but this is a dumb idea.
"""
This was not wrong 1 year ago.. now, I'm doing desktop virtualization on ssd laptop. I dont want my virtualdisk to grow undefinitively. I dont want spinning disk optimizations.

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 16:51 UTC (Tue) by butlerm (guest, #13312) [Link]

Nothing stops clients from trimming free 2MB blocks using 4K block trim operations...

The second half of the 2.6.37 merge window

Posted Nov 3, 2010 16:49 UTC (Wed) by nix (subscriber, #2304) [Link]

You'd also need a holepunch operation in the overlying filesystem, to be able to insert holes in the middle of an existing file.

The second half of the 2.6.37 merge window

Posted Nov 2, 2010 7:37 UTC (Tue) by mokki (subscriber, #33200) [Link]

I think so. When the virtual block device run by virtualbox/kvm detects the trim command it could punch a hole to the disk image, freeing disk space.

The xfs has an ioctl for punching holes to files. unfortunately a fallocate flag for deallocating space from 2007 has not been included in mainline.

The second half of the 2.6.37 merge window

Posted Nov 3, 2010 15:18 UTC (Wed) by nye (guest, #51576) [Link]

>BTW a nice userspace program for the (ext4) FITRIM ioctl() command can be found here:

In what circumstances would you want to use this rather than just mounting with the 'discard' option?

I'm curious because I've just bought my first SSD and I'm wondering how best to maintain performance. At first I was thinking of reserving some unpartitioned space, but then it occurred to me that it would probably be better just to use an ext4 partition. That way I can use the space if I really need it at some point, but it can be 'reclaimed' by the SSD for its own purposes when there's nothing stored there. Is that not correct?

The second half of the 2.6.37 merge window

Posted Nov 3, 2010 15:31 UTC (Wed) by slothrop (guest, #69834) [Link]

I have performance problems with my first generation
Vertex SSD if I use the ext4 discard option. So in
this case it is better to run fstrim as a cron job every
night. But if you have a good SSD with a fast ATA trim
implementation, the discard mount option is just fine.

The second half of the 2.6.37 merge window

Posted Nov 3, 2010 16:45 UTC (Wed) by nye (guest, #51576) [Link]

Ah, that makes sense - thanks.

The second half of the 2.6.37 merge window

Posted Nov 6, 2010 4:13 UTC (Sat) by Lope (guest, #65656) [Link]

The question of how often do you want to run fstrim on the whole filesystem is a little tricky, because it depends on what type of workload you are running. If you are able to fill up you disk within one day you probably should reclaim the space (discard) at least one time a day, but on regular desktop I very much doubt that.

So, what you probably want to do (if you want to be exact) is to watch the amount of data written to the filesystem (you can do that through /sys/fs/ext4/<device>/lifetime_write_kbytes assuming that on <device> is ext4 fs) and when it is going to reach some threshold (like 80% of device size) you would need to start doing the discard (note that FITRIM on ext4 will return amount of reclaimed space). But all of this may be an awful overkill for simple desktop:). And aside of that there are some very bad devices out there which are showing significant performance regression even at 50% fs saturation. And of course if you have more partitions on the same device ... it gets even more complicated :)

All that said, if you are ok with doing it once a day (and you are not even noticing it) it is good thing to do. But if it disturbs you, you probably would not want to do it so often, or at least do it per partes (which you can do with a little scripting) through a longer period of time.

The second half of the 2.6.37 merge window

Posted Nov 6, 2010 18:08 UTC (Sat) by slothrop (guest, #69834) [Link]

Good points,
I write ~30GB per week to my 30GB SSD (just one partition).
So I changed cron from running fstrim daily to twice a week.

The second half of the 2.6.37 merge window

Posted Nov 6, 2010 4:27 UTC (Sat) by Lope (guest, #65656) [Link]

If you do want to benchmark discard performance of you SSD you can use this tool :

http://sourceforge.net/projects/test-discard/

BUT, there are some very bad devices which might be corrupted by sending lots of small TRIM's so better be careful (Or blame your vendor for doing bad job!).


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds