HAMMER - Add hammer dedup filesystem version dump
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 7 Nov 2010 17:43:08 +0000 (09:43 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 18 Nov 2010 17:42:43 +0000 (09:42 -0800)
* Require a version 5 filesystem for dedup operation.  Upgrading can be done
  in-place.  All this does is make the layer2 bytes_free field a signed
  value instead of unsigned, allowing it to go negative.

  This allows dedup to use the field to account for multiple references to
  the same block of data, causing the field to (likely) go negative.

sys/vfs/hammer/hammer_dedup.c
sys/vfs/hammer/hammer_disk.h
sys/vfs/hammer/hammer_ioctl.c

index 7c724cd..0bb74b5 100644 (file)
@@ -44,6 +44,15 @@ hammer_ioc_dedup(hammer_transaction_t trans, hammer_inode_t ip,
        int error;
 
        /*
+        * Enforce hammer filesystem version requirements
+        */
+       if (trans->hmp->version < HAMMER_VOL_VERSION_FIVE) {
+               kprintf("hammer: Filesystem must be upgraded to v5 "
+                       "before you can run dedup\n");
+               return (EOPNOTSUPP);
+       }
+
+       /*
         * Cursor1, return an error -> candidate goes to pass2 list
         */
        error = hammer_init_cursor(trans, &cursor1, NULL, NULL);
index b889b1a..0ed2615 100644 (file)
@@ -396,6 +396,11 @@ typedef struct hammer_blockmap_layer2 *hammer_blockmap_layer2_t;
  * (3) Data overwrite for nohistory operations covered by REDO records
  *     can be supported (instead of rolling a new block allocation),
  *     by rolling UNDO for the prior contents of the data.
+ *
+ *                             HAMMER VERSION 5 CHANGES
+ *
+ * Hammer version 5 contains a minor adjustment making layer2's bytes_free
+ * field signed, allowing dedup to push it into the negative domain.
  */
 #define HAMMER_HEAD_ONDISK_SIZE                32
 #define HAMMER_HEAD_ALIGN              8
@@ -641,13 +646,14 @@ typedef struct hammer_volume_ondisk *hammer_volume_ondisk_t;
 
 #define HAMMER_VOL_VERSION_MIN         1       /* minimum supported version */
 #define HAMMER_VOL_VERSION_DEFAULT     4       /* newfs default version */
-#define HAMMER_VOL_VERSION_WIP         5       /* version >= this is WIP */
-#define HAMMER_VOL_VERSION_MAX         4       /* maximum supported version */
+#define HAMMER_VOL_VERSION_WIP         6       /* version >= this is WIP */
+#define HAMMER_VOL_VERSION_MAX         5       /* maximum supported version */
 
 #define HAMMER_VOL_VERSION_ONE         1
 #define HAMMER_VOL_VERSION_TWO         2       /* new dirent layout (2.3+) */
 #define HAMMER_VOL_VERSION_THREE       3       /* new snapshot layout (2.5+) */
 #define HAMMER_VOL_VERSION_FOUR                4       /* new undo/flush (2.5+) */
+#define HAMMER_VOL_VERSION_FIVE                5       /* dedup (2.9+) */
 
 /*
  * Record types are fairly straightforward.  The B-Tree includes the record
index 7d8653d..dbe7e7f 100644 (file)
@@ -538,6 +538,10 @@ hammer_ioc_get_version(hammer_transaction_t trans, hammer_inode_t ip,
                ksnprintf(ver->description, sizeof(ver->description),
                         "New undo/flush, faster flush/sync (DragonFly 2.5+)");
                break;
+       case 5:
+               ksnprintf(ver->description, sizeof(ver->description),
+                        "Adjustments for dedup support (DragonFly 2.9+)");
+               break;
        default:
                ksnprintf(ver->description, sizeof(ver->description),
                         "Unknown");