NFE - Change default RX ring size from 128 -> 256, Adjust moderation timer.
[dragonfly.git] / sbin / hammer / cmd_blockmap.c
blobe483369fdf98fa35bacf881990e173ada26c05f1
1 /*
2 * Copyright (c) 2008 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * $DragonFly: src/sbin/hammer/cmd_blockmap.c,v 1.4 2008/07/19 18:48:14 dillon Exp $
37 #include "hammer.h"
39 static void dump_blockmap(const char *label, int zone);
41 void
42 hammer_cmd_blockmap(void)
44 dump_blockmap("btree", HAMMER_ZONE_FREEMAP_INDEX);
45 #if 0
46 dump_blockmap("btree", HAMMER_ZONE_BTREE_INDEX);
47 dump_blockmap("meta", HAMMER_ZONE_META_INDEX);
48 dump_blockmap("large-data", HAMMER_ZONE_LARGE_DATA_INDEX);
49 dump_blockmap("small-data", HAMMER_ZONE_SMALL_DATA_INDEX);
50 #endif
53 #if 1
55 static
56 void
57 dump_blockmap(const char *label, int zone)
59 struct volume_info *root_volume;
60 hammer_blockmap_t rootmap;
61 struct hammer_blockmap_layer1 *layer1;
62 struct hammer_blockmap_layer2 *layer2;
63 struct buffer_info *buffer1 = NULL;
64 struct buffer_info *buffer2 = NULL;
65 hammer_off_t layer1_offset;
66 hammer_off_t layer2_offset;
67 hammer_off_t scan1;
68 hammer_off_t scan2;
69 int xerr;
71 assert(RootVolNo >= 0);
72 root_volume = get_volume(RootVolNo);
73 rootmap = &root_volume->ondisk->vol0_blockmap[zone];
74 assert(rootmap->phys_offset != 0);
76 printf("zone %-16s next %016jx alloc %016jx\n",
77 label,
78 (uintmax_t)rootmap->next_offset,
79 (uintmax_t)rootmap->alloc_offset);
81 for (scan1 = HAMMER_ZONE_ENCODE(zone, 0);
82 scan1 < HAMMER_ZONE_ENCODE(zone, HAMMER_OFF_LONG_MASK);
83 scan1 += HAMMER_BLOCKMAP_LAYER2) {
85 * Dive layer 1.
87 layer1_offset = rootmap->phys_offset +
88 HAMMER_BLOCKMAP_LAYER1_OFFSET(scan1);
89 layer1 = get_buffer_data(layer1_offset, &buffer1, 0);
90 xerr = ' ';
91 if (layer1->layer1_crc != crc32(layer1, HAMMER_LAYER1_CRCSIZE))
92 xerr = 'B';
93 if (xerr == ' ' &&
94 layer1->phys_offset == HAMMER_BLOCKMAP_UNAVAIL) {
95 continue;
97 printf("%c layer1 %016jx @%016jx blocks-free %jd\n",
98 xerr,
99 (uintmax_t)scan1,
100 (uintmax_t)layer1->phys_offset,
101 (intmax_t)layer1->blocks_free);
102 if (layer1->phys_offset == HAMMER_BLOCKMAP_FREE)
103 continue;
104 for (scan2 = scan1;
105 scan2 < scan1 + HAMMER_BLOCKMAP_LAYER2;
106 scan2 += HAMMER_LARGEBLOCK_SIZE
109 * Dive layer 2, each entry represents a large-block.
111 layer2_offset = layer1->phys_offset +
112 HAMMER_BLOCKMAP_LAYER2_OFFSET(scan2);
113 layer2 = get_buffer_data(layer2_offset, &buffer2, 0);
114 xerr = ' ';
115 if (layer2->entry_crc != crc32(layer2, HAMMER_LAYER2_CRCSIZE))
116 xerr = 'B';
117 printf("%c %016jx zone=%d app=%-7d free=%-7d\n",
118 xerr,
119 (uintmax_t)scan2,
120 layer2->zone,
121 layer2->append_off,
122 layer2->bytes_free);
125 if (buffer1)
126 rel_buffer(buffer1);
127 if (buffer2)
128 rel_buffer(buffer2);
129 rel_volume(root_volume);
132 #endif