sys/vfs/hammer: Add HAMMER_ZONE_LAYER1_NEXT_OFFSET()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 9 Nov 2016 12:52:21 +0000 (21:52 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 9 Nov 2016 14:10:35 +0000 (23:10 +0900)
Note that this is different from HAMMER_BLOCKMAP_LAYER1_OFFSET().
HAMMER_BLOCKMAP_LAYER1_OFFSET() is an offset of layer1 entry within
a big-block for layer1, but not zone offset itself.

sys/vfs/hammer/hammer_blockmap.c
sys/vfs/hammer/hammer_disk.h

index 1cab394..595aae6 100644 (file)
@@ -192,8 +192,7 @@ again:
         * layer2, skip to the next layer1 entry.
         */
        if (offset == 0 && layer1->blocks_free == 0) {
-               next_offset = (next_offset + HAMMER_BLOCKMAP_LAYER2) &
-                             ~HAMMER_BLOCKMAP_LAYER2_MASK;
+               next_offset = HAMMER_ZONE_LAYER1_NEXT_OFFSET(next_offset);
                if (hammer_check_volume(hmp, &next_offset)) {
                        result_offset = 0;
                        goto failed;
@@ -508,8 +507,7 @@ again:
         */
        if ((next_offset & HAMMER_BIGBLOCK_MASK) == 0 &&
            layer1->blocks_free == 0) {
-               next_offset = (next_offset + HAMMER_BLOCKMAP_LAYER2) &
-                             ~HAMMER_BLOCKMAP_LAYER2_MASK;
+               next_offset = HAMMER_ZONE_LAYER1_NEXT_OFFSET(next_offset);
                if (hammer_check_volume(hmp, &next_offset))
                        goto failed;
                goto again;
index d88ae28..9d9a754 100644 (file)
@@ -493,6 +493,12 @@ typedef struct hammer_blockmap_layer2 {
        (HAMMER_BLOCKMAP_LAYER2_INDEX(zone2_offset) *           \
         sizeof(struct hammer_blockmap_layer2))
 
+/*
+ * Move on to offset 0 of the next layer1 or layer2.
+ */
+#define HAMMER_ZONE_LAYER1_NEXT_OFFSET(offset)                 \
+       (((offset) + HAMMER_BLOCKMAP_LAYER2) & ~HAMMER_BLOCKMAP_LAYER2_MASK)
+
 /*
  * HAMMER UNDO parameters.  The UNDO fifo is mapped directly in the volume
  * header with an array of zone-2 offsets.  A maximum of (128x8MB) = 1GB,