From: Kai Krakow <hurikhan77+btrfs@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: Possible to wait for snapshot deletion?
Date: Fri, 14 Feb 2014 01:25:57 +0100 [thread overview]
Message-ID: <ld40ta-gl3.ln1@hurikhan77.spdns.de> (raw)
In-Reply-To: 52FD1D1B.7080306@swiftspirit.co.za
Brendan Hide <brendan@swiftspirit.co.za> schrieb:
>> Is it technically possible to wait for a snapshot completely purged from
>> disk? I imagine an option like "--wait" for btrfs delete subvolume.
>>
>> This would fit some purposes I'm planning to implement:
>>
>> * In a backup scenario
>
> I have a similar use-case for this also involving backups. In my case I
> have a script that uses a btrfs filesystem for the backup store using
> snapshots. At the end of each run, if diskspace usage is below a
> predefined threshold, it will delete old snapshots until the diskspace
> usage is below that threshold again.
Yeah, I thought of that approach first, too... But:
> Of course, the first time I added the automatic deletion, it deleted far
> more than was necessary due to the fact that the actual freeing of
> diskspace is asynchronous from the command completion. I ended up
> setting a small delay (of about 60 seconds) between each iteration and
> also set it to monitor system load. If load is not low enough after the
> delay then it waits another 60 seconds.
Due to btrfs' behavior that cannot reliably work as you also figured out. It
will need quirky work-arounds totally dependent on system load.
> This complicated (frankly broken) workaround would be completely
> unnecessary with a --wait switch.
That's why I had the idea. ;-)
> Alternatively, perhaps a knob where we can see if a subvolume deletion
> is in progress could help.
Like "btrfs scrub status"...
If you're feeling curious, here's what I've implemented yet (snapshot
deletion still on the todo list):
https://gist.github.com/kakra/5520370
My idea is to fork-off a background process which constantly removes old
snapshots (within sane bounds yet to be defined) and then exits. Some
mechanism has to be found to not run into a deadlock situation here. Then,
at the end issue a bash "wait" to join the processes again and run a final
sync. However, I don't like to issue explicit syncs from within the
subprocess as the filesystem is busy with rsync at the same time.
PS: Yes, I know there's btrfs send/receive - but it doesn't seem ready for
the big show yet because it still has many strange quirks and should not be
run unattended yet.
--
Replies to list only preferred.
next prev parent reply other threads:[~2014-02-14 0:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 19:02 Possible to wait for snapshot deletion? Kai Krakow
2014-02-13 19:29 ` Brendan Hide
2014-02-14 0:25 ` Kai Krakow [this message]
2014-02-13 19:57 ` Hugo Mills
2014-02-13 20:45 ` Garry T. Williams
2014-02-14 0:12 ` Kai Krakow
2014-02-14 16:05 ` David Sterba
2014-02-13 21:42 ` Holger Hoffstätte
2014-02-14 0:15 ` Kai Krakow
2014-02-14 16:15 ` David Sterba
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=ld40ta-gl3.ln1@hurikhan77.spdns.de \
--to=hurikhan77+btrfs@gmail.com \
--cc=linux-btrfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).