HAMMER - Implement experimental volume removal
[dragonfly.git] / sys / vfs / hammer / hammer_blockmap.c
index afac580..bff567f 100644 (file)
@@ -164,6 +164,17 @@ again:
         */
        layer1_offset = freemap->phys_offset +
                        HAMMER_BLOCKMAP_LAYER1_OFFSET(next_offset);
+
+       /*
+        * Skip this block if it is belonging to a volume that we are
+         * currently trying to remove from the file-system.
+        */
+       if ((int)HAMMER_VOL_DECODE(layer1_offset) == hmp->volume_to_remove) {
+               next_offset = (next_offset + HAMMER_BLOCKMAP_LAYER2) &
+                             ~HAMMER_BLOCKMAP_LAYER2_MASK;
+               goto again;
+       }
+
        layer1 = hammer_bread(hmp, layer1_offset, errorp, &buffer1);
        if (*errorp) {
                result_offset = 0;
@@ -1077,7 +1088,7 @@ failed:
        hammer_rel_volume(root_volume, 0);
        if (hammer_debug_general & 0x0800) {
                kprintf("hammer_blockmap_getfree: %016llx -> %d\n",
-                       zone_offset, bytes);
+                       (long long)zone_offset, bytes);
        }
        return(bytes);
 }
@@ -1177,7 +1188,7 @@ failed:
        hammer_rel_volume(root_volume, 0);
        if (hammer_debug_general & 0x0800) {
                kprintf("hammer_blockmap_lookup: %016llx -> %016llx\n",
-                       zone_offset, result_offset);
+                       (long long)zone_offset, (long long)result_offset);
        }
        return(result_offset);
 }
@@ -1187,7 +1198,7 @@ failed:
  * Check space availability
  */
 int
-hammer_checkspace(hammer_mount_t hmp, int slop)
+_hammer_checkspace(hammer_mount_t hmp, int slop, int64_t *resp)
 {
        const int in_size = sizeof(struct hammer_inode_data) +
                            sizeof(union hammer_btree_elm);
@@ -1202,6 +1213,8 @@ hammer_checkspace(hammer_mount_t hmp, int slop)
                    (slop << HAMMER_LARGEBLOCK_BITS);
 
        hammer_count_extra_space_used = usedbytes;      /* debugging */
+       if (resp)
+               *resp = usedbytes;
 
        if (hmp->copy_stat_freebigblocks >=
            (usedbytes >> HAMMER_LARGEBLOCK_BITS)) {