From: Matthew Dillon Date: Wed, 10 Nov 2010 20:12:45 +0000 (-0800) Subject: HAMMER utility - Handle pruning when only snapshot meta-data present X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/63948e839781ff95b7f762aa2bc8a7f14970a48c HAMMER utility - Handle pruning when only snapshot meta-data present * If only snapshot meta-data is present and no snapshot softlinks are found hammer prune (and hammer cleanup) previous exited with an error. This case can occur when creating manual snapshot softlinks and/or trying to prune a slave PFS. * In fact this is incorrect. If meta-data is present we can prune based on that. --- diff --git a/sbin/hammer/cmd_softprune.c b/sbin/hammer/cmd_softprune.c index 4e63f583d2..7335cc2073 100644 --- a/sbin/hammer/cmd_softprune.c +++ b/sbin/hammer/cmd_softprune.c @@ -120,6 +120,15 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt) scan->prune.head.flags |= HAMMER_IOC_PRUNE_ALL; } else { hammer_softprune_scandir(&base, &template, *av); + if (base == NULL) { + const char *dummylink = ""; + scan = hammer_softprune_addentry(&base, &template, + *av, NULL, NULL, + dummylink, dummylink); + if (scan == NULL) + softprune_usage(1); + scan->prune.nelms = 0; + } ++av; --ac; } @@ -127,10 +136,6 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt) /* * XXX future (need to store separate cycles for each filesystem) */ - if (base == NULL) { - fprintf(stderr, "No snapshot softlinks found\n"); - exit(1); - } if (base->next) { fprintf(stderr, "Currently only one HAMMER filesystem may " "be specified in the softlink scan\n"); @@ -185,6 +190,7 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt) } if (scan->prune.nelms == 0 && (scan->prune.head.flags & HAMMER_IOC_PRUNE_ALL) == 0) { + fprintf(stderr, "No snapshots found\n"); continue; } diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8 index ed007b2e56..7f4949a0cf 100644 --- a/sbin/hammer/hammer.8 +++ b/sbin/hammer/hammer.8 @@ -494,11 +494,15 @@ directive has a period of 0 and a retention time of 0 then snapshot generation is disabled, removal of old snapshots are disabled, and prunes will use .Cm prune-everything . +.Pp If the .Cm snapshots directive has a period of 0 but a non-zero retention time then this command will not create any new snapshots but will remove old -snapshots it finds based on the retention time. +snapshots it finds based on the retention time. This form should be +used on PFS masters where you are generating your own snapshot softlinks +manually and on PFS slaves when all you wish to do is prune away existing +snapshots inherited via the mirroring stream. .Pp By default only snapshots in the form .Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM