From 92ed14a37d1dd6414a6bacb80f63bffedca3ff45 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 14 Oct 2009 18:19:15 -0700 Subject: [PATCH] HAMMER - Add additional warnings for v2/v3 upgrades, fix bug in snaprm * Add warnings related to backup scripts when upgrading from V2 to V3. The synctid directive does not generate a snapshot. You should generate a real snapshot to properly track them. Also, removing a snapshot softlink does not remove the meta-data and thus the pruning code will continue to prune around that snapshot. The snaprm directive should be used when removing snapshot softlinks to also remove the meta-data. * Snaprm now uses the current directory when removing a transaction id and no target directory was specified. * Snaprm now makes it clear that a failure to remove meta-data when removing a softlink is just a warning, not a fatal error. --- sbin/hammer/cmd_snapshot.c | 14 ++++++++++++-- sbin/hammer/hammer.8 | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/sbin/hammer/cmd_snapshot.c b/sbin/hammer/cmd_snapshot.c index cfc113ba46..1ae270aa8f 100644 --- a/sbin/hammer/cmd_snapshot.c +++ b/sbin/hammer/cmd_snapshot.c @@ -210,6 +210,8 @@ hammer_cmd_snaprm(char **av, int ac) av[i]); /* not reached */ } + if (fsfd < 0) + fsfd = open(".", O_RDONLY); snapshot_del(fsfd, tid); } else if (S_ISDIR(st.st_mode)) { if (fsfd >= 0) @@ -503,10 +505,18 @@ snapshot_del(int fsfd, hammer_tid_t tid) snapshot.count = 1; snapshot.snaps[0].tid = tid; + /* + * Do not abort if we are unable to remove the meta-data. + */ if (ioctl(fsfd, HAMMERIOC_DEL_SNAPSHOT, &snapshot) < 0) { - err(2, "hammer snaprm 0x%016jx", (uintmax_t)tid); + err(2, "hammer snaprm 0x%016jx", + (uintmax_t)tid); + } else if (snapshot.head.error == ENOENT) { + fprintf(stderr, "Warning: hammer snaprm 0x%016jx: " + "meta-data not found\n", + (uintmax_t)tid); } else if (snapshot.head.error) { - fprintf(stderr, "hammer snaprm 0x%016jx: %s\n", + fprintf(stderr, "Warning: hammer snaprm 0x%016jx: %s\n", (uintmax_t)tid, strerror(snapshot.head.error)); } } diff --git a/sbin/hammer/hammer.8 b/sbin/hammer/hammer.8 index 77deaa0990..13ed973bc4 100644 --- a/sbin/hammer/hammer.8 +++ b/sbin/hammer/hammer.8 @@ -1099,6 +1099,30 @@ the .Cm snapls directive to get a definitive list from the meta-data and regenerate them from that list. +.Pp +WARNING! If you are using hammer to backup filesystems your scripts +may be using the +.Cm synctid +directive to generate transaction ids. This directive does not create +a snapshot. You will have to modify your scripts to use the +.Cm snapq +directive to generate the linkbuf for the softlink you create, or +use one of the other +.Cm snap* +directives. +The older +.Cm snapshot +directive will continue to work as expected and in V3 it will also +record the snapshot transaction id in meta-data. You may also want +to make use of the new 'note' tag for the meta-data. +.Pp +WARNING! If you used to remove snapshot softlinks with +.Nm rm +you should probably start using the +.Cm snaprm +directive instead to also remove the related meta-data. +The pruning code scans the meta-data so just removing the +softlink is not sufficient. .Sh FILES .Bl -tag -width ".It Pa /var/slaves/" -compact .It Pa /snapshots -- 2.41.0