sys/vfs/hammer: Add HAMMER_ZONE_LAYER2_NEXT_OFFSET()
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 9 Nov 2016 13:06:18 +0000 (22:06 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 9 Nov 2016 14:10:40 +0000 (23:10 +0900)
Note that this is different from HAMMER_BLOCKMAP_LAYER2_OFFSET().
HAMMER_BLOCKMAP_LAYER2_OFFSET() is an offset of layer2 entry within
a big-block for layer2, but not zone offset itself.

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

index 6096394..6ee3d9a 100644 (file)
@@ -184,8 +184,8 @@ again:
                assert(layer2->append_off == 0);
        }
        if (layer2->zone != zone) {
-               blockmap->next_offset = (blockmap->next_offset + HAMMER_BIGBLOCK_SIZE) &
-                                       ~HAMMER_BIGBLOCK_MASK64;
+               blockmap->next_offset =
+                       HAMMER_ZONE_LAYER2_NEXT_OFFSET(blockmap->next_offset);
                goto again;
        }
 
index 595aae6..a07385f 100644 (file)
@@ -293,8 +293,7 @@ again:
        if (resv) {
                if (resv->zone != zone) {
                        hammer_unlock(&hmp->blkmap_lock);
-                       next_offset = (next_offset + HAMMER_BIGBLOCK_SIZE) &
-                                     ~HAMMER_BIGBLOCK_MASK64;
+                       next_offset = HAMMER_ZONE_LAYER2_NEXT_OFFSET(next_offset);
                        goto again;
                }
                if (offset < resv->append_off) {
@@ -572,8 +571,7 @@ again:
        if (resv) {
                if (resv->zone != zone) {
                        hammer_unlock(&hmp->blkmap_lock);
-                       next_offset = (next_offset + HAMMER_BIGBLOCK_SIZE) &
-                                     ~HAMMER_BIGBLOCK_MASK64;
+                       next_offset = HAMMER_ZONE_LAYER2_NEXT_OFFSET(next_offset);
                        goto again;
                }
                if (offset < resv->append_off) {
index 9d9a754..1159f1d 100644 (file)
@@ -499,6 +499,9 @@ typedef struct hammer_blockmap_layer2 {
 #define HAMMER_ZONE_LAYER1_NEXT_OFFSET(offset)                 \
        (((offset) + HAMMER_BLOCKMAP_LAYER2) & ~HAMMER_BLOCKMAP_LAYER2_MASK)
 
+#define HAMMER_ZONE_LAYER2_NEXT_OFFSET(offset)                 \
+       (((offset) + HAMMER_BIGBLOCK_SIZE) & ~HAMMER_BIGBLOCK_MASK64)
+
 /*
  * 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,