hammer2 - Add 'snapshot-debug' directive
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 16 Nov 2018 06:32:56 +0000 (22:32 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Wed, 5 Dec 2018 18:28:39 +0000 (10:28 -0800)
* Add the 'snapshot-debug' directive which takes a snapshot without
  first sync'ing the filesystem.  The idea is that the snapshot will
  be taken relative to the most recent filesystem sync (automatic or
  manual), and should still represent a fully consistent filesystem.

sbin/hammer2/cmd_snapshot.c
sbin/hammer2/hammer2.h
sbin/hammer2/main.c

index 4b13f1b..9e91d31 100644 (file)
@@ -52,7 +52,8 @@
  */
 
 int
-cmd_pfs_snapshot(const char *sel_path, const char *path, const char *label)
+cmd_pfs_snapshot(const char *sel_path, const char *path, const char *label,
+                uint32_t pfs_flags)
 {
        hammer2_ioc_pfs_t pfs;
        int ecode = 0;
@@ -93,6 +94,7 @@ cmd_pfs_snapshot(const char *sel_path, const char *path, const char *label)
 
        bzero(&pfs, sizeof(pfs));
        snprintf(pfs.name, sizeof(pfs.name), "%s", label);
+       pfs.pfs_flags = pfs_flags;
 
        if (ioctl(fd, HAMMER2IOC_PFS_SNAPSHOT, &pfs) < 0) {
                perror("ioctl");
index 2b882aa..42b2715 100644 (file)
@@ -134,7 +134,8 @@ int cmd_pfs_list(int ac, const char **av);
 int cmd_pfs_create(const char *sel_path, const char *name,
                        uint8_t pfs_type, const char *uuid_str);
 int cmd_pfs_delete(const char *sel_path, const char *name);
-int cmd_pfs_snapshot(const char *sel_path, const char *name, const char *label);
+int cmd_pfs_snapshot(const char *sel_path, const char *name, const char *label,
+                       uint32_t pfs_flags);
 
 int cmd_service(void);
 int cmd_hash(int ac, const char **av);
index fa44860..0a1ccbb 100644 (file)
@@ -277,24 +277,30 @@ main(int ac, char **av)
                        usage(1);
                }
                ecode = cmd_pfs_delete(sel_path, av[1]);
-       } else if (strcmp(av[0], "snapshot") == 0) {
+       } else if (strcmp(av[0], "snapshot") == 0 ||
+                  strcmp(av[0], "snapshot-debug") == 0) {
                /*
                 * Create snapshot with optional pfs-type and optional
                 * label override.
                 */
+               uint32_t flags = 0;
+
+               if (strcmp(av[0], "snapshot-debug") == 0)
+                       flags = HAMMER2_PFSFLAGS_NOSYNC;
+
                if (ac > 3) {
                        fprintf(stderr, "pfs-snapshot: too many arguments\n");
                        usage(1);
                }
                switch(ac) {
                case 1:
-                       ecode = cmd_pfs_snapshot(sel_path, NULL, NULL);
+                       ecode = cmd_pfs_snapshot(sel_path, NULL, NULL, flags);
                        break;
                case 2:
-                       ecode = cmd_pfs_snapshot(sel_path, av[1], NULL);
+                       ecode = cmd_pfs_snapshot(sel_path, av[1], NULL, flags);
                        break;
                case 3:
-                       ecode = cmd_pfs_snapshot(sel_path, av[1], av[2]);
+                       ecode = cmd_pfs_snapshot(sel_path, av[1], av[2], flags);
                        break;
                }
        } else if (strcmp(av[0], "service") == 0) {
@@ -538,6 +544,8 @@ usage(int code)
                        "Destroy a PFS\n"
                "    snapshot <path> [<label>]    "
                        "Snapshot a PFS or directory\n"
+               "    snapshot-debug <path> [<label>]    "
+                       "Snapshot without filesystem sync\n"
                "    service                      "
                        "Start service daemon\n"
                "    stat [<path>]                "