HAMMER VFS - return shorter-form softlinks "@@-1:%05d" when appropriate.
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 12 Mar 2009 16:03:08 +0000 (09:03 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 12 Mar 2009 16:03:08 +0000 (09:03 -0700)
The HAMMER VFS supports a short "@@-1:%05d" for master PFSs.  Adjust the
HAMMER VFS to return softlinks in that form and adjust the hammer cleanup
code to recognize softlinks in that form.

Note that PFS softlinks are created as "@@PFS%05d", but the HAMMER VFS
presents them in an expanded form which allows the HAMMER VFS to reflect
the latest synchronized transaction id on slave PFSs.  This also prevents
slave PFSs from confusing DragonFly's namecache as each snapshot will appear
to be an entirely different path.

Unfortunately this does mean that cpdup/cp/tar will pickup a translated
softlink and not the actual one.  It's just something else to remember
about these 'weird' PFS mount points.

Suggested-by: YONETANI Tomokazu <qhwt+dfly@les.ath.cx>
sbin/hammer/cmd_cleanup.c
sys/vfs/hammer/hammer_vnops.c

index ea84eeb..b6361a6 100644 (file)
@@ -115,7 +115,8 @@ hammer_cmd_cleanup(char **av, int ac)
                                continue;
                        if ((strncmp(ptr, "(hammer,", 8) == 0) ||
                            ((strncmp(ptr, "(null,", 6) == 0) &&
-                            (strstr(fs, "/@@0x") != NULL))) {
+                            (strstr(fs, "/@@0x") != NULL ||
+                             strstr(fs, "/@@-1") != NULL))) {
                                do_cleanup(path);
                        }
                }
index c26e4f7..c2abe5f 100644 (file)
@@ -716,13 +716,17 @@ hammer_vop_getattr(struct vop_getattr_args *ap)
        /*
         * Special case for @@PFS softlinks.  The actual size of the
         * expanded softlink is "@@0x%016llx:%05d" == 26 bytes.
+        * or for MAX_TID is    "@@-1:%05d" == 10 bytes.
         */
        if (ip->ino_data.obj_type == HAMMER_OBJTYPE_SOFTLINK &&
            ip->ino_data.size == 10 &&
            ip->obj_asof == HAMMER_MAX_TID &&
            ip->obj_localization == 0 &&
            strncmp(ip->ino_data.ext.symlink, "@@PFS", 5) == 0) {
-                   vap->va_size = 26;
+                   if (ip->pfsm->pfsd.mirror_flags & HAMMER_PFSD_SLAVE)
+                           vap->va_size = 26;
+                   else
+                           vap->va_size = 10;
        }
 
        /*
@@ -1447,15 +1451,22 @@ hammer_vop_readlink(struct vop_readlink_args *ap)
                        if (error == 0) {
                                if (pfsm->pfsd.mirror_flags &
                                    HAMMER_PFSD_SLAVE) {
+                                       /* vap->va_size == 26 */
                                        ksnprintf(buf, sizeof(buf),
                                                  "@@0x%016llx:%05d",
                                                  pfsm->pfsd.sync_end_tid,
                                                  localization >> 16);
                                } else {
+                                       /* vap->va_size == 10 */
+                                       ksnprintf(buf, sizeof(buf),
+                                                 "@@-1:%05d",
+                                                 localization >> 16);
+#if 0
                                        ksnprintf(buf, sizeof(buf),
                                                  "@@0x%016llx:%05d",
                                                  HAMMER_MAX_TID,
                                                  localization >> 16);
+#endif
                                }
                                ptr = buf;
                                bytes = strlen(buf);