Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 8th April 2012, 03:58 AM
marko's Avatar
marko Offline
Registered User
 
Join Date: Jun 2004
Location: Laurel, MD USA
Posts: 5,448
linuxfirefox
fstrim shows discardable blocks even after using discard option

I expected only the first usage of the fstrim command after my installation of Fedora 16 on a SSD to actually have blocks to trim. I then set the discard option on the mounts to the SSD and rebooted. I then used the system for a while and for the hell of it ran the fstrim -v command and was surprised there were still SSD blocks reported for being discarded.

Doesn't using discard on ext4 on a SSD mean that all "fstrim -v" usages on the SSD would then not find any blocks to discard?

Another thing that's odd is that the number of trimmed bytes reported is huge, like 116GB on my 128GB SSD. If I immediately re-run 'fstrim -v / ' I get 0 bytes trimmed like I'd expect.
Reply With Quote
  #2  
Old 8th April 2012, 05:54 AM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,300
linuxfirefox
Re: fstrim shows discardable blocks even after using discard option

fstrim makes a single syscall withthe open mountpoint.
This call falls to the kernel filesystem code (ext4, btrfs, whatever) which then walks the file system data structures to find all unused blocks in the block device that have not been discarded since the mount. Since the kernel has no idea which blocks have already been discarded - it discards ALL unused blocks of the filesystem (except maybe ones that if KNOWS have been discadred already since mount. Then it discards all of these.

When you run fstrim a second time on an mounted FS, then for ext4 at least it KNOWS all the blocks have been trim'ed already- so the it reports 0 trimmed.

For btrfs it discards ALL unused blocks on every use of 'fstrim. IOW btrfs isn't smart enough to keep

If you reboot or umount and mount the same FS - then it will report the big number - essentially the number of unused blocks.



Example for a btrfs fs
Quote:
[root@crucibulum /]# mount /dev/sda5 /tmp/mp -o discard,ssd
[root@crucibulum /]# fstrim -v /tmp/mp
/tmp/mp: 2566369280 bytes were trimmed
[root@crucibulum /]# fstrim -v /tmp/mp
/tmp/mp: 2566369280 bytes were trimmed
this is for an ext4 fs
Quote:
[root@crucibulum ~]# mount -t ext4 -o discard /dev/sda5 /tmp/mp
[root@crucibulum ~]# fstrim -v /tmp/mp
/tmp/mp: 31813779456 bytes were trimmed
[root@crucibulum ~]# fstrim -v /tmp/mp
/tmp/mp: 0 bytes were trimmed
[root@crucibulum ~]# umount /tmp/mp
[root@crucibulum ~]# mount -t ext4 -o discard /dev/sda5 /tmp/mp
[root@crucibulum ~]# fstrim -v /tmp/mp
/tmp/mp: 31813779456 bytes were trimmed
So ext4 KEEPs the trim info between fstrim calls, while btrfs does not.
Neither can keep the keep the info between mounts or boots.
__________________
None are more hopelessly enslaved than those who falsely believe they are free.
Johann Wolfgang von Goethe

Last edited by stevea; 8th April 2012 at 06:03 AM.
Reply With Quote
Reply

Tags
blocks, discard, discardable, fstrim, option, shows

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
F17 and Discard (TRIM) support on LUKS/dm-crypt devices Japplo F17 Development Forum 19 30th May 2012 06:17 AM
Fc15 Firefox shows, Seamonkey shows not; e.g. google.maps, picasa Basilicum Using Fedora 0 19th September 2011 08:07 PM
Fedora 16 and Discard (TRIM) support on LUKS/dm-crypt devices NoHumanBeing F16 Development 9 19th September 2011 07:52 PM
Bad Blocks CrystalCowboy Using Fedora 3 11th September 2005 10:46 PM


Current GMT-time: 04:55 (Tuesday, 21-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat