Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanoid #912: sanoid --prune-snapshots performance boost by making --f… #913

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ For more full details on sanoid.conf settings see [Wiki page](https://github.com

This will process your sanoid.conf file, it will NOT create snapshots, but it will purge expired ones.

+ --no-force-prune

Double-check that no send/recv is in progress before pruning a snapshot. This restores the behavoir that was default up to version 2.2.0. May slow down by a second for pruned snapshot. Normally, this should not be needed, because zfs does not drop busy snapshots anyway.

+ --force-prune

Purges expired snapshots even if a send/recv is in progress
Expand Down
9 changes: 5 additions & 4 deletions sanoid
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ my %args = (
GetOptions(\%args, "verbose", "debug", "cron", "readonly", "quiet",
"configdir=s", "cache-dir=s", "run-dir=s",
"monitor-health", "force-update",
"monitor-snapshots", "take-snapshots", "prune-snapshots", "force-prune",
"monitor-snapshots", "take-snapshots", "prune-snapshots",
"no-force-prune",
"monitor-capacity"
) or pod2usage(2);

Expand All @@ -40,7 +41,7 @@ my $cacheTTL = 900; # 15 minutes

# Allow a much older snapshot cache file than default if _only_ "--monitor-*" action commands are given
# (ignore "--verbose", "--configdir" etc)
if (($args{'monitor-snapshots'} || $args{'monitor-health'} || $args{'monitor-capacity'}) && ! ($args{'cron'} || $args{'force-update'} || $args{'take-snapshots'} || $args{'prune-snapshots'} || $args{'force-prune'})) {
if (($args{'monitor-snapshots'} || $args{'monitor-health'} || $args{'monitor-capacity'}) && ! ($args{'cron'} || $args{'force-update'} || $args{'take-snapshots'} || $args{'prune-snapshots'} || $args{'no-force-prune'})) {
# The command combination above must not assert true for any command that takes or prunes snapshots
$cacheTTL = 18000; # 5 hours
if ($args{'debug'}) { print "DEBUG: command combo means that the cache file (provided it exists) will be allowed to be older than default.\n"; }
Expand Down Expand Up @@ -349,7 +350,7 @@ sub prune_snapshots {
}

if ($args{'verbose'}) { print "INFO: pruning $snap ... \n"; }
if (!$args{'force-prune'} && iszfsbusy($path)) {
if ($args{'no-force-prune'} && iszfsbusy($path)) {
if ($args{'verbose'}) { print "INFO: deferring pruning of $snap - $path is currently in zfs send or receive.\n"; }
} else {
if (! $args{'readonly'}) {
Expand Down Expand Up @@ -1752,7 +1753,7 @@ Options:
--monitor-snapshots Reports on snapshot "health", in a Nagios compatible format
--take-snapshots Creates snapshots as specified in sanoid.conf
--prune-snapshots Purges expired snapshots as specified in sanoid.conf
--force-prune Purges expired snapshots even if a send/recv is in progress
--no-force-prune Double-check that no send/recv is in progress before pruning

--help Prints this helptext
--version Prints the version number
Expand Down