From: Jeff Moyer <jmoyer@redhat.com>
To: "Richard W.M. Jones" <rjones@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, pbonzini@redhat.com
Subject: Re: Making discard/fstrim reliable
Date: Wed, 02 Apr 2014 14:18:40 -0400 [thread overview]
Message-ID: <x49lhvntx1b.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20140326204708.GA29191@redhat.com> (Richard W. M. Jones's message of "Wed, 26 Mar 2014 20:47:08 +0000")
"Richard W.M. Jones" <rjones@redhat.com> writes:
Hi, Richard,
> virt-sparsify is a tool for trimming free space in virtual disk
> images. The new implementation uses vfs/kernel/qemu discard support.
> Essentially it does:
>
Presumably there's a "start guest" step here that's missing?
> for each filesystem:
> mount -o discard $fs /mnt
What is $fs? Do you pass in a list of devices?
Also, you don't need to mount with -o discard in order to use fstrim.
In fact, I'd recommend against doing that.
> sync
Interesting. Have you seen mount dirty inodes or something?
> fstrim /mnt
> umount /mnt
> sync
> # qemu is killed after sync returns
>
> Although typing these commands by hand works fine, when you run them
> from a program the fstrim doesn't happen all the way down the stack
> reliably. Mostly it works, but sometimes it only trims some space
> from the host file.
What is in the stack? Are you using qcow2 images, plain files, device
mapper, anything else? Which file systems are you testing, and are they
used in the host, the guest or both? How are you checking for success?
Do you have a golden image you start with so that your test case is
repeatable?
> It appears that when the host is slow / under load, the problem
> happens more frequently. Also it may happen more frequently on i686
> than on x86-64 (possibly also due to speed of host).
I don't know of any reason that any of the variables you listed would
affect the reliability at all. As far as I can tell, fstrim is a
synchronous ioctl. I believe the only reason space wouldn't be freed is
if the fs is fragmented in such a way as to not meet the minimum trim
granularity of the underlying device. Of course, there may be file
system specific reasons too, I guess. Hopefully others can comment on
that.
Cheers,
Jeff
> The question is: What can I do to make sure the trim happens reliably,
> all the way down the stack, before qemu is killed?
>
> I am testing this using the latest upstream kernel & qemu.
>
> Rich.
next prev parent reply other threads:[~2014-04-02 18:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-26 20:47 Making discard/fstrim reliable Richard W.M. Jones
2014-04-02 18:18 ` Jeff Moyer [this message]
2014-04-02 18:59 ` Richard W.M. Jones
2014-04-02 20:02 ` Jeff Moyer
2014-04-02 20:26 ` Richard W.M. Jones
2014-04-10 15:05 ` Richard W.M. Jones
2014-04-03 17:08 ` Lukáš Czerner
2014-04-03 17:23 ` Richard W.M. Jones
2014-04-03 17:57 ` Paolo Bonzini
2014-04-03 18:08 ` Richard W.M. Jones
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=x49lhvntx1b.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rjones@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).