From: Rich Freeman <rich0@gentoo.org>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] "Amount" of fstrim? (curiosity driven, no paranoia :)
Date: Sun, 26 Apr 2020 15:29:40 -0400 [thread overview]
Message-ID: <CAGfcS_n-dMTd6bHcFMU6M-fqBgiYpTakbRDahbUnStb3TLCyBg@mail.gmail.com> (raw)
In-Reply-To: <20200426161551.fmzwvoepd2tzbrrr@solfire>
On Sun, Apr 26, 2020 at 12:15 PM <tuxic@posteo.de> wrote:
>
> On 04/26 11:20, Rich Freeman wrote:
> > On Sun, Apr 26, 2020 at 10:52 AM <tuxic@posteo.de> wrote:
> > >
> > > Fstrim reports about 200 GiB of trimmed data.
> > >
> >
> > My suggestion would be to run fstrim twice in a row and see how fast
> > it operates and what the results are. If the second one completes
> > very quickly that suggests that the drive is sane. I'd probably just
> > run it daily in that case, but weekly is probably fine especially if
> > the drive isn't very full.
> >
>
> host:/root>fstrim -v /
> /: 3.3 GiB (3578650624 bytes) trimmed
> host:/root>fstrim -v /
> /: 0 B (0 bytes) trimmed
>
> This time the first fstrim reports a small mount of trimmed
> data and second one no fstrimmed data at all.
>
Ok, I became a bit less lazy and started looking at the source.
All fstrim does is send an FITRIM ioctl to the kernel for the device.
This is implemented in a filesystem-dependent manner, and I couldn't
actually find any documentation on it (actual documentation on the
ioctl - not the fstrim manpage/etc). A quick glimpse at the ext4
source suggests that ext4 has a flag that can track whether a group of
blocks has been trimmed yet or not since it was last deallocated. So
ext4 will make repeated fstrim runs a no-op and the drive won't see
these.
At least, that was what I got after about 5-10min of browsing. I
didn't take the time to grok how ext4 tracks free space and so on.
Incidentally, in the other thread the reason that dry-run didn't
report anything to be trimmed is that this is hard-coded:
printf(_("%s: 0 B (dry run) trimmed on %s\n"), path, devname);
https://github.com/karelzak/util-linux/blob/master/sys-utils/fstrim.c#L109
Otherwise the ioctl returns how much space was trimmed, and fstrim outputs this.
--
Rich
next prev parent reply other threads:[~2020-04-26 19:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 14:52 [gentoo-user] "Amount" of fstrim? (curiosity driven, no paranoia :) tuxic
2020-04-26 15:20 ` Rich Freeman
2020-04-26 16:15 ` tuxic
2020-04-26 19:29 ` Rich Freeman [this message]
2020-04-27 1:43 ` tuxic
2020-04-27 1:58 ` Rich Freeman
2020-04-27 3:14 ` tuxic
2020-04-27 8:22 ` William Kenworthy
2020-04-27 10:32 ` Alan Mackenzie
2020-04-27 15:12 ` Kent Fredric
2020-04-27 16:20 ` tuxic
2020-04-27 16:59 ` Rich Freeman
2020-04-27 19:07 ` antlists
2020-04-27 19:17 ` Rich Freeman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAGfcS_n-dMTd6bHcFMU6M-fqBgiYpTakbRDahbUnStb3TLCyBg@mail.gmail.com \
--to=rich0@gentoo.org \
--cc=gentoo-user@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox