Blame view
fs/reiserfs/prints.c
21.4 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 |
/* * Copyright 2000 by Hans Reiser, licensing governed by reiserfs/README */ |
1da177e4c Linux-2.6.12-rc2 |
4 5 |
#include <linux/time.h> #include <linux/fs.h> |
f466c6fdb move private bits... |
6 |
#include "reiserfs.h" |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 13 14 |
#include <linux/string.h> #include <linux/buffer_head.h> #include <stdarg.h> static char error_buf[1024]; static char fmt_buf[1024]; static char off_buf[80]; |
bd4c625c0 reiserfs: run scr... |
15 |
static char *reiserfs_cpu_offset(struct cpu_key *key) |
1da177e4c Linux-2.6.12-rc2 |
16 |
{ |
bd4c625c0 reiserfs: run scr... |
17 |
if (cpu_key_k_type(key) == TYPE_DIRENTRY) |
53872ed07 fs/reiserfs: repl... |
18 |
sprintf(off_buf, "%llu(%llu)", |
bd4c625c0 reiserfs: run scr... |
19 20 21 22 23 24 25 26 |
(unsigned long long) GET_HASH_VALUE(cpu_key_k_offset(key)), (unsigned long long) GET_GENERATION_NUMBER(cpu_key_k_offset(key))); else sprintf(off_buf, "0x%Lx", (unsigned long long)cpu_key_k_offset(key)); return off_buf; |
1da177e4c Linux-2.6.12-rc2 |
27 |
} |
bd4c625c0 reiserfs: run scr... |
28 |
static char *le_offset(struct reiserfs_key *key) |
1da177e4c Linux-2.6.12-rc2 |
29 |
{ |
bd4c625c0 reiserfs: run scr... |
30 |
int version; |
1da177e4c Linux-2.6.12-rc2 |
31 |
|
bd4c625c0 reiserfs: run scr... |
32 33 |
version = le_key_version(key); if (le_key_k_type(version, key) == TYPE_DIRENTRY) |
53872ed07 fs/reiserfs: repl... |
34 |
sprintf(off_buf, "%llu(%llu)", |
bd4c625c0 reiserfs: run scr... |
35 36 37 38 39 40 41 42 |
(unsigned long long) GET_HASH_VALUE(le_key_k_offset(version, key)), (unsigned long long) GET_GENERATION_NUMBER(le_key_k_offset(version, key))); else sprintf(off_buf, "0x%Lx", (unsigned long long)le_key_k_offset(version, key)); return off_buf; |
1da177e4c Linux-2.6.12-rc2 |
43 |
} |
bd4c625c0 reiserfs: run scr... |
44 |
static char *cpu_type(struct cpu_key *key) |
1da177e4c Linux-2.6.12-rc2 |
45 |
{ |
bd4c625c0 reiserfs: run scr... |
46 47 48 49 50 51 52 53 54 |
if (cpu_key_k_type(key) == TYPE_STAT_DATA) return "SD"; if (cpu_key_k_type(key) == TYPE_DIRENTRY) return "DIR"; if (cpu_key_k_type(key) == TYPE_DIRECT) return "DIRECT"; if (cpu_key_k_type(key) == TYPE_INDIRECT) return "IND"; return "UNKNOWN"; |
1da177e4c Linux-2.6.12-rc2 |
55 |
} |
bd4c625c0 reiserfs: run scr... |
56 |
static char *le_type(struct reiserfs_key *key) |
1da177e4c Linux-2.6.12-rc2 |
57 |
{ |
bd4c625c0 reiserfs: run scr... |
58 |
int version; |
1da177e4c Linux-2.6.12-rc2 |
59 |
|
bd4c625c0 reiserfs: run scr... |
60 |
version = le_key_version(key); |
1da177e4c Linux-2.6.12-rc2 |
61 |
|
bd4c625c0 reiserfs: run scr... |
62 63 64 65 66 67 68 69 70 71 |
if (le_key_k_type(version, key) == TYPE_STAT_DATA) return "SD"; if (le_key_k_type(version, key) == TYPE_DIRENTRY) return "DIR"; if (le_key_k_type(version, key) == TYPE_DIRECT) return "DIRECT"; if (le_key_k_type(version, key) == TYPE_INDIRECT) return "IND"; return "UNKNOWN"; } |
1da177e4c Linux-2.6.12-rc2 |
72 73 |
/* %k */ |
fe10e398e reiserfs: fix buf... |
74 |
static int scnprintf_le_key(char *buf, size_t size, struct reiserfs_key *key) |
1da177e4c Linux-2.6.12-rc2 |
75 |
{ |
bd4c625c0 reiserfs: run scr... |
76 |
if (key) |
fe10e398e reiserfs: fix buf... |
77 78 79 80 |
return scnprintf(buf, size, "[%d %d %s %s]", le32_to_cpu(key->k_dir_id), le32_to_cpu(key->k_objectid), le_offset(key), le_type(key)); |
bd4c625c0 reiserfs: run scr... |
81 |
else |
fe10e398e reiserfs: fix buf... |
82 |
return scnprintf(buf, size, "[NULL]"); |
1da177e4c Linux-2.6.12-rc2 |
83 |
} |
1da177e4c Linux-2.6.12-rc2 |
84 |
/* %K */ |
fe10e398e reiserfs: fix buf... |
85 |
static int scnprintf_cpu_key(char *buf, size_t size, struct cpu_key *key) |
1da177e4c Linux-2.6.12-rc2 |
86 |
{ |
bd4c625c0 reiserfs: run scr... |
87 |
if (key) |
fe10e398e reiserfs: fix buf... |
88 89 90 91 |
return scnprintf(buf, size, "[%d %d %s %s]", key->on_disk_key.k_dir_id, key->on_disk_key.k_objectid, reiserfs_cpu_offset(key), cpu_type(key)); |
bd4c625c0 reiserfs: run scr... |
92 |
else |
fe10e398e reiserfs: fix buf... |
93 |
return scnprintf(buf, size, "[NULL]"); |
1da177e4c Linux-2.6.12-rc2 |
94 |
} |
fe10e398e reiserfs: fix buf... |
95 96 |
static int scnprintf_de_head(char *buf, size_t size, struct reiserfs_de_head *deh) |
1da177e4c Linux-2.6.12-rc2 |
97 |
{ |
bd4c625c0 reiserfs: run scr... |
98 |
if (deh) |
fe10e398e reiserfs: fix buf... |
99 100 101 102 103 |
return scnprintf(buf, size, "[offset=%d dir_id=%d objectid=%d location=%d state=%04x]", deh_offset(deh), deh_dir_id(deh), deh_objectid(deh), deh_location(deh), deh_state(deh)); |
bd4c625c0 reiserfs: run scr... |
104 |
else |
fe10e398e reiserfs: fix buf... |
105 |
return scnprintf(buf, size, "[NULL]"); |
1da177e4c Linux-2.6.12-rc2 |
106 107 |
} |
fe10e398e reiserfs: fix buf... |
108 |
static int scnprintf_item_head(char *buf, size_t size, struct item_head *ih) |
1da177e4c Linux-2.6.12-rc2 |
109 |
{ |
bd4c625c0 reiserfs: run scr... |
110 |
if (ih) { |
fe10e398e reiserfs: fix buf... |
111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
char *p = buf; char * const end = buf + size; p += scnprintf(p, end - p, "%s", (ih_version(ih) == KEY_FORMAT_3_6) ? "*3.6* " : "*3.5*"); p += scnprintf_le_key(p, end - p, &ih->ih_key); p += scnprintf(p, end - p, ", item_len %d, item_location %d, free_space(entry_count) %d", ih_item_len(ih), ih_location(ih), ih_free_space(ih)); return p - buf; |
bd4c625c0 reiserfs: run scr... |
125 |
} else |
fe10e398e reiserfs: fix buf... |
126 |
return scnprintf(buf, size, "[NULL]"); |
1da177e4c Linux-2.6.12-rc2 |
127 |
} |
fe10e398e reiserfs: fix buf... |
128 129 |
static int scnprintf_direntry(char *buf, size_t size, struct reiserfs_dir_entry *de) |
1da177e4c Linux-2.6.12-rc2 |
130 |
{ |
bd4c625c0 reiserfs: run scr... |
131 |
char name[20]; |
1da177e4c Linux-2.6.12-rc2 |
132 |
|
bd4c625c0 reiserfs: run scr... |
133 134 |
memcpy(name, de->de_name, de->de_namelen > 19 ? 19 : de->de_namelen); name[de->de_namelen > 19 ? 19 : de->de_namelen] = 0; |
fe10e398e reiserfs: fix buf... |
135 136 |
return scnprintf(buf, size, "\"%s\"==>[%d %d]", name, de->de_dir_id, de->de_objectid); |
1da177e4c Linux-2.6.12-rc2 |
137 |
} |
fe10e398e reiserfs: fix buf... |
138 |
static int scnprintf_block_head(char *buf, size_t size, struct buffer_head *bh) |
1da177e4c Linux-2.6.12-rc2 |
139 |
{ |
fe10e398e reiserfs: fix buf... |
140 141 142 |
return scnprintf(buf, size, "level=%d, nr_items=%d, free_space=%d rdkey ", B_LEVEL(bh), B_NR_ITEMS(bh), B_FREE_SPACE(bh)); |
1da177e4c Linux-2.6.12-rc2 |
143 |
} |
fe10e398e reiserfs: fix buf... |
144 |
static int scnprintf_buffer_head(char *buf, size_t size, struct buffer_head *bh) |
1da177e4c Linux-2.6.12-rc2 |
145 |
{ |
fe10e398e reiserfs: fix buf... |
146 147 148 149 150 151 152 153 154 |
return scnprintf(buf, size, "dev %pg, size %zd, blocknr %llu, count %d, state 0x%lx, page %p, (%s, %s, %s)", bh->b_bdev, bh->b_size, (unsigned long long)bh->b_blocknr, atomic_read(&(bh->b_count)), bh->b_state, bh->b_page, buffer_uptodate(bh) ? "UPTODATE" : "!UPTODATE", buffer_dirty(bh) ? "DIRTY" : "CLEAN", buffer_locked(bh) ? "LOCKED" : "UNLOCKED"); |
1da177e4c Linux-2.6.12-rc2 |
155 |
} |
fe10e398e reiserfs: fix buf... |
156 |
static int scnprintf_disk_child(char *buf, size_t size, struct disk_child *dc) |
1da177e4c Linux-2.6.12-rc2 |
157 |
{ |
fe10e398e reiserfs: fix buf... |
158 159 |
return scnprintf(buf, size, "[dc_number=%d, dc_size=%u]", dc_block_number(dc), dc_size(dc)); |
1da177e4c Linux-2.6.12-rc2 |
160 |
} |
cacbe3d7a reiserfs: prepare... |
161 |
static char *is_there_reiserfs_struct(char *fmt, int *what) |
1da177e4c Linux-2.6.12-rc2 |
162 |
{ |
bd4c625c0 reiserfs: run scr... |
163 |
char *k = fmt; |
1da177e4c Linux-2.6.12-rc2 |
164 |
|
bd4c625c0 reiserfs: run scr... |
165 166 167 168 169 170 |
while ((k = strchr(k, '%')) != NULL) { if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' || k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') { *what = k[1]; break; } |
bd4c625c0 reiserfs: run scr... |
171 172 173 174 |
k++; } return k; } |
1da177e4c Linux-2.6.12-rc2 |
175 |
|
098297b27 reiserfs: cleanup... |
176 177 178 179 180 181 182 183 184 185 186 187 188 |
/* * debugging reiserfs we used to print out a lot of different * variables, like keys, item headers, buffer heads etc. Values of * most fields matter. So it took a long time just to write * appropriative printk. With this reiserfs_warning you can use format * specification for complex structures like you used to do with * printfs for integers, doubles and pointers. For instance, to print * out key structure you have to write just: * reiserfs_warning ("bad key %k", key); * instead of * printk ("bad key %lu %lu %lu %lu", key->k_dir_id, key->k_objectid, * key->k_offset, key->k_uniqueness); */ |
78b6513d2 reiserfs: add loc... |
189 |
static DEFINE_SPINLOCK(error_lock); |
bd4c625c0 reiserfs: run scr... |
190 191 192 193 194 |
static void prepare_error_buf(const char *fmt, va_list args) { char *fmt1 = fmt_buf; char *k; char *p = error_buf; |
fe10e398e reiserfs: fix buf... |
195 |
char * const end = &error_buf[sizeof(error_buf)]; |
cacbe3d7a reiserfs: prepare... |
196 |
int what; |
bd4c625c0 reiserfs: run scr... |
197 |
|
78b6513d2 reiserfs: add loc... |
198 |
spin_lock(&error_lock); |
fe10e398e reiserfs: fix buf... |
199 200 201 202 |
if (WARN_ON(strscpy(fmt_buf, fmt, sizeof(fmt_buf)) < 0)) { strscpy(error_buf, "format string too long", end - error_buf); goto out_unlock; } |
bd4c625c0 reiserfs: run scr... |
203 |
|
cacbe3d7a reiserfs: prepare... |
204 |
while ((k = is_there_reiserfs_struct(fmt1, &what)) != NULL) { |
bd4c625c0 reiserfs: run scr... |
205 |
*k = 0; |
fe10e398e reiserfs: fix buf... |
206 |
p += vscnprintf(p, end - p, fmt1, args); |
bd4c625c0 reiserfs: run scr... |
207 |
|
bd4c625c0 reiserfs: run scr... |
208 209 |
switch (what) { case 'k': |
fe10e398e reiserfs: fix buf... |
210 211 |
p += scnprintf_le_key(p, end - p, va_arg(args, struct reiserfs_key *)); |
bd4c625c0 reiserfs: run scr... |
212 213 |
break; case 'K': |
fe10e398e reiserfs: fix buf... |
214 215 |
p += scnprintf_cpu_key(p, end - p, va_arg(args, struct cpu_key *)); |
bd4c625c0 reiserfs: run scr... |
216 217 |
break; case 'h': |
fe10e398e reiserfs: fix buf... |
218 219 |
p += scnprintf_item_head(p, end - p, va_arg(args, struct item_head *)); |
bd4c625c0 reiserfs: run scr... |
220 221 |
break; case 't': |
fe10e398e reiserfs: fix buf... |
222 223 |
p += scnprintf_direntry(p, end - p, va_arg(args, struct reiserfs_dir_entry *)); |
bd4c625c0 reiserfs: run scr... |
224 225 |
break; case 'y': |
fe10e398e reiserfs: fix buf... |
226 227 |
p += scnprintf_disk_child(p, end - p, va_arg(args, struct disk_child *)); |
bd4c625c0 reiserfs: run scr... |
228 229 |
break; case 'z': |
fe10e398e reiserfs: fix buf... |
230 231 |
p += scnprintf_block_head(p, end - p, va_arg(args, struct buffer_head *)); |
bd4c625c0 reiserfs: run scr... |
232 233 |
break; case 'b': |
fe10e398e reiserfs: fix buf... |
234 235 |
p += scnprintf_buffer_head(p, end - p, va_arg(args, struct buffer_head *)); |
bd4c625c0 reiserfs: run scr... |
236 237 |
break; case 'a': |
fe10e398e reiserfs: fix buf... |
238 239 |
p += scnprintf_de_head(p, end - p, va_arg(args, struct reiserfs_de_head *)); |
bd4c625c0 reiserfs: run scr... |
240 241 |
break; } |
bd4c625c0 reiserfs: run scr... |
242 243 |
fmt1 = k + 2; } |
fe10e398e reiserfs: fix buf... |
244 245 |
p += vscnprintf(p, end - p, fmt1, args); out_unlock: |
78b6513d2 reiserfs: add loc... |
246 |
spin_unlock(&error_lock); |
1da177e4c Linux-2.6.12-rc2 |
247 248 |
} |
098297b27 reiserfs: cleanup... |
249 250 251 252 253 254 255 256 257 258 |
/* * in addition to usual conversion specifiers this accepts reiserfs * specific conversion specifiers: * %k to print little endian key, * %K to print cpu key, * %h to print item_head, * %t to print directory entry * %z to print block head (arg must be struct buffer_head * * %b to print buffer_head */ |
1da177e4c Linux-2.6.12-rc2 |
259 260 261 262 263 264 265 266 |
#define do_reiserfs_warning(fmt)\ {\ va_list args;\ va_start( args, fmt );\ prepare_error_buf( fmt, args );\ va_end( args );\ } |
45b03d5e8 reiserfs: rework ... |
267 268 |
void __reiserfs_warning(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
269 |
{ |
bd4c625c0 reiserfs: run scr... |
270 271 |
do_reiserfs_warning(fmt); if (sb) |
45b03d5e8 reiserfs: rework ... |
272 273 274 275 |
printk(KERN_WARNING "REISERFS warning (device %s): %s%s%s: " "%s ", sb->s_id, id ? id : "", id ? " " : "", function, error_buf); |
bd4c625c0 reiserfs: run scr... |
276 |
else |
45b03d5e8 reiserfs: rework ... |
277 278 279 |
printk(KERN_WARNING "REISERFS warning: %s%s%s: %s ", id ? id : "", id ? " " : "", function, error_buf); |
1da177e4c Linux-2.6.12-rc2 |
280 281 282 |
} /* No newline.. reiserfs_info calls can be followed by printk's */ |
bd4c625c0 reiserfs: run scr... |
283 |
void reiserfs_info(struct super_block *sb, const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
284 |
{ |
bd4c625c0 reiserfs: run scr... |
285 286 |
do_reiserfs_warning(fmt); if (sb) |
a5437152e reiserfs: use mor... |
287 288 |
printk(KERN_NOTICE "REISERFS (device %s): %s", sb->s_id, error_buf); |
bd4c625c0 reiserfs: run scr... |
289 |
else |
a5437152e reiserfs: use mor... |
290 |
printk(KERN_NOTICE "REISERFS %s:", error_buf); |
1da177e4c Linux-2.6.12-rc2 |
291 292 293 |
} /* No newline.. reiserfs_printk calls can be followed by printk's */ |
bd4c625c0 reiserfs: run scr... |
294 |
static void reiserfs_printk(const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
295 |
{ |
bd4c625c0 reiserfs: run scr... |
296 297 |
do_reiserfs_warning(fmt); printk(error_buf); |
1da177e4c Linux-2.6.12-rc2 |
298 |
} |
bd4c625c0 reiserfs: run scr... |
299 |
void reiserfs_debug(struct super_block *s, int level, const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
300 301 |
{ #ifdef CONFIG_REISERFS_CHECK |
bd4c625c0 reiserfs: run scr... |
302 303 |
do_reiserfs_warning(fmt); if (s) |
a5437152e reiserfs: use mor... |
304 305 306 |
printk(KERN_DEBUG "REISERFS debug (device %s): %s ", s->s_id, error_buf); |
bd4c625c0 reiserfs: run scr... |
307 |
else |
a5437152e reiserfs: use mor... |
308 309 |
printk(KERN_DEBUG "REISERFS debug: %s ", error_buf); |
1da177e4c Linux-2.6.12-rc2 |
310 311 |
#endif } |
098297b27 reiserfs: cleanup... |
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
/* * The format: * * maintainer-errorid: [function-name:] message * * where errorid is unique to the maintainer and function-name is * optional, is recommended, so that anyone can easily find the bug * with a simple grep for the short to type string * maintainer-errorid. Don't bother with reusing errorids, there are * lots of numbers out there. * * Example: * * reiserfs_panic( * p_sb, "reiser-29: reiserfs_new_blocknrs: " * "one of search_start or rn(%d) is equal to MAX_B_NUM," * "which means that we are optimizing location based on the " * "bogus location of a temp buffer (%p).", * rn, bh * ); * * Regular panic()s sometimes clear the screen before the message can * be read, thus the need for the while loop. * * Numbering scheme for panic used by Vladimir and Anatoly( Hans completely * ignores this scheme, and considers it pointless complexity): * * panics in reiserfs_fs.h have numbers from 1000 to 1999 * super.c 2000 to 2999 * preserve.c (unused) 3000 to 3999 * bitmap.c 4000 to 4999 * stree.c 5000 to 5999 * prints.c 6000 to 6999 * namei.c 7000 to 7999 * fix_nodes.c 8000 to 8999 * dir.c 9000 to 9999 * lbalance.c 10000 to 10999 * ibalance.c 11000 to 11999 not ready * do_balan.c 12000 to 12999 * inode.c 13000 to 13999 * file.c 14000 to 14999 * objectid.c 15000 - 15999 * buffer.c 16000 - 16999 * symlink.c 17000 - 17999 * * . */ |
1da177e4c Linux-2.6.12-rc2 |
358 |
|
c3a9c2109 reiserfs: rework ... |
359 360 |
void __reiserfs_panic(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
361 |
{ |
bd4c625c0 reiserfs: run scr... |
362 |
do_reiserfs_warning(fmt); |
1da177e4c Linux-2.6.12-rc2 |
363 |
|
c3a9c2109 reiserfs: rework ... |
364 |
#ifdef CONFIG_REISERFS_CHECK |
8e186e454 reiserfs: dont us... |
365 |
dump_stack(); |
c3a9c2109 reiserfs: rework ... |
366 367 |
#endif if (sb) |
278f6679f reiserfs: locking... |
368 369 |
printk(KERN_WARNING "REISERFS panic (device %s): %s%s%s: %s ", |
c3a9c2109 reiserfs: rework ... |
370 371 372 |
sb->s_id, id ? id : "", id ? " " : "", function, error_buf); else |
278f6679f reiserfs: locking... |
373 374 |
printk(KERN_WARNING "REISERFS panic: %s%s%s: %s ", |
c3a9c2109 reiserfs: rework ... |
375 |
id ? id : "", id ? " " : "", function, error_buf); |
278f6679f reiserfs: locking... |
376 |
BUG(); |
1da177e4c Linux-2.6.12-rc2 |
377 |
} |
1e5e59d43 reiserfs: introdu... |
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
void __reiserfs_error(struct super_block *sb, const char *id, const char *function, const char *fmt, ...) { do_reiserfs_warning(fmt); BUG_ON(sb == NULL); if (reiserfs_error_panic(sb)) __reiserfs_panic(sb, id, function, error_buf); if (id && id[0]) printk(KERN_CRIT "REISERFS error (device %s): %s %s: %s ", sb->s_id, id, function, error_buf); else printk(KERN_CRIT "REISERFS error (device %s): %s: %s ", sb->s_id, function, error_buf); |
bc98a42c1 VFS: Convert sb->... |
396 |
if (sb_rdonly(sb)) |
1e5e59d43 reiserfs: introdu... |
397 398 399 400 |
return; reiserfs_info(sb, "Remounting filesystem read-only "); |
1751e8a6c Rename superblock... |
401 |
sb->s_flags |= SB_RDONLY; |
1e5e59d43 reiserfs: introdu... |
402 403 |
reiserfs_abort_journal(sb, -EIO); } |
bd4c625c0 reiserfs: run scr... |
404 |
void reiserfs_abort(struct super_block *sb, int errno, const char *fmt, ...) |
1da177e4c Linux-2.6.12-rc2 |
405 |
{ |
bd4c625c0 reiserfs: run scr... |
406 |
do_reiserfs_warning(fmt); |
1da177e4c Linux-2.6.12-rc2 |
407 |
|
bd4c625c0 reiserfs: run scr... |
408 |
if (reiserfs_error_panic(sb)) { |
a5437152e reiserfs: use mor... |
409 410 411 |
panic(KERN_CRIT "REISERFS panic (device %s): %s ", sb->s_id, error_buf); |
bd4c625c0 reiserfs: run scr... |
412 |
} |
1da177e4c Linux-2.6.12-rc2 |
413 |
|
a5437152e reiserfs: use mor... |
414 |
if (reiserfs_is_journal_aborted(SB_JOURNAL(sb))) |
bd4c625c0 reiserfs: run scr... |
415 |
return; |
1da177e4c Linux-2.6.12-rc2 |
416 |
|
a5437152e reiserfs: use mor... |
417 418 419 |
printk(KERN_CRIT "REISERFS abort (device %s): %s ", sb->s_id, error_buf); |
1da177e4c Linux-2.6.12-rc2 |
420 |
|
1751e8a6c Rename superblock... |
421 |
sb->s_flags |= SB_RDONLY; |
32e8b1062 reiserfs: rearran... |
422 |
reiserfs_abort_journal(sb, errno); |
1da177e4c Linux-2.6.12-rc2 |
423 |
} |
098297b27 reiserfs: cleanup... |
424 425 426 427 428 |
/* * this prints internal nodes (4 keys/items in line) (dc_number, * dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number, * dc_size)... */ |
bd4c625c0 reiserfs: run scr... |
429 |
static int print_internal(struct buffer_head *bh, int first, int last) |
1da177e4c Linux-2.6.12-rc2 |
430 |
{ |
bd4c625c0 reiserfs: run scr... |
431 432 433 434 |
struct reiserfs_key *key; struct disk_child *dc; int i; int from, to; |
1da177e4c Linux-2.6.12-rc2 |
435 |
|
bd4c625c0 reiserfs: run scr... |
436 437 |
if (!B_IS_KEYS_LEVEL(bh)) return 1; |
1da177e4c Linux-2.6.12-rc2 |
438 |
|
bd4c625c0 reiserfs: run scr... |
439 |
check_internal(bh); |
1da177e4c Linux-2.6.12-rc2 |
440 |
|
bd4c625c0 reiserfs: run scr... |
441 442 443 444 445 446 447 |
if (first == -1) { from = 0; to = B_NR_ITEMS(bh); } else { from = first; to = last < B_NR_ITEMS(bh) ? last : B_NR_ITEMS(bh); } |
1da177e4c Linux-2.6.12-rc2 |
448 |
|
bd4c625c0 reiserfs: run scr... |
449 450 |
reiserfs_printk("INTERNAL NODE (%ld) contains %z ", bh->b_blocknr, bh); |
1da177e4c Linux-2.6.12-rc2 |
451 |
|
bd4c625c0 reiserfs: run scr... |
452 453 |
dc = B_N_CHILD(bh, from); reiserfs_printk("PTR %d: %y ", from, dc); |
1da177e4c Linux-2.6.12-rc2 |
454 |
|
4cf5f7add reiserfs: cleanup... |
455 |
for (i = from, key = internal_key(bh, from), dc++; i < to; |
bd4c625c0 reiserfs: run scr... |
456 457 458 459 460 461 462 463 464 465 |
i++, key++, dc++) { reiserfs_printk("KEY %d: %k PTR %d: %y ", i, key, i + 1, dc); if (i && i % 4 == 0) printk(" "); } printk(" "); return 0; } |
1da177e4c Linux-2.6.12-rc2 |
466 |
|
bd4c625c0 reiserfs: run scr... |
467 468 469 470 471 472 473 |
static int print_leaf(struct buffer_head *bh, int print_mode, int first, int last) { struct block_head *blkh; struct item_head *ih; int i, nr; int from, to; |
1da177e4c Linux-2.6.12-rc2 |
474 |
|
bd4c625c0 reiserfs: run scr... |
475 476 |
if (!B_IS_ITEMS_LEVEL(bh)) return 1; |
1da177e4c Linux-2.6.12-rc2 |
477 |
|
bd4c625c0 reiserfs: run scr... |
478 |
check_leaf(bh); |
1da177e4c Linux-2.6.12-rc2 |
479 |
|
bd4c625c0 reiserfs: run scr... |
480 |
blkh = B_BLK_HEAD(bh); |
4cf5f7add reiserfs: cleanup... |
481 |
ih = item_head(bh, 0); |
bd4c625c0 reiserfs: run scr... |
482 |
nr = blkh_nr_item(blkh); |
1da177e4c Linux-2.6.12-rc2 |
483 |
|
bd4c625c0 reiserfs: run scr... |
484 485 486 487 488 489 |
printk (" =================================================================== "); reiserfs_printk("LEAF NODE (%ld) contains %z ", bh->b_blocknr, bh); |
1da177e4c Linux-2.6.12-rc2 |
490 |
|
bd4c625c0 reiserfs: run scr... |
491 492 493 494 495 496 |
if (!(print_mode & PRINT_LEAF_ITEMS)) { reiserfs_printk("FIRST ITEM_KEY: %k, LAST ITEM KEY: %k ", &(ih->ih_key), &((ih + nr - 1)->ih_key)); return 0; } |
1da177e4c Linux-2.6.12-rc2 |
497 |
|
bd4c625c0 reiserfs: run scr... |
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
if (first < 0 || first > nr - 1) from = 0; else from = first; if (last < 0 || last > nr) to = nr; else to = last; ih += from; printk ("------------------------------------------------------------------------------- "); printk ("|##| type | key | ilen | free_space | version | loc | "); for (i = from; i < to; i++, ih++) { printk ("------------------------------------------------------------------------------- "); reiserfs_printk("|%2d| %h | ", i, ih); if (print_mode & PRINT_LEAF_ITEMS) |
4cf5f7add reiserfs: cleanup... |
522 |
op_print_item(ih, ih_item_body(bh, ih)); |
bd4c625c0 reiserfs: run scr... |
523 |
} |
1da177e4c Linux-2.6.12-rc2 |
524 |
|
bd4c625c0 reiserfs: run scr... |
525 526 527 |
printk ("=================================================================== "); |
1da177e4c Linux-2.6.12-rc2 |
528 |
|
bd4c625c0 reiserfs: run scr... |
529 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
530 |
} |
bd4c625c0 reiserfs: run scr... |
531 |
char *reiserfs_hashname(int code) |
1da177e4c Linux-2.6.12-rc2 |
532 |
{ |
bd4c625c0 reiserfs: run scr... |
533 534 535 536 537 538 |
if (code == YURA_HASH) return "rupasov"; if (code == TEA_HASH) return "tea"; if (code == R5_HASH) return "r5"; |
1da177e4c Linux-2.6.12-rc2 |
539 |
|
bd4c625c0 reiserfs: run scr... |
540 |
return "unknown"; |
1da177e4c Linux-2.6.12-rc2 |
541 542 543 |
} /* return 1 if this is not super block */ |
bd4c625c0 reiserfs: run scr... |
544 545 546 547 548 549 |
static int print_super_block(struct buffer_head *bh) { struct reiserfs_super_block *rs = (struct reiserfs_super_block *)(bh->b_data); int skipped, data_blocks; char *version; |
bd4c625c0 reiserfs: run scr... |
550 551 552 553 554 555 556 557 558 559 560 |
if (is_reiserfs_3_5(rs)) { version = "3.5"; } else if (is_reiserfs_3_6(rs)) { version = "3.6"; } else if (is_reiserfs_jr(rs)) { version = ((sb_version(rs) == REISERFS_VERSION_2) ? "3.6" : "3.5"); } else { return 1; } |
a1c6f0573 fs: use block_dev... |
561 562 |
printk("%pg\'s super block is in block %llu ", bh->b_bdev, |
bd4c625c0 reiserfs: run scr... |
563 564 565 566 567 568 569 570 571 |
(unsigned long long)bh->b_blocknr); printk("Reiserfs version %s ", version); printk("Block count %u ", sb_block_count(rs)); printk("Blocksize %d ", sb_blocksize(rs)); printk("Free blocks %u ", sb_free_blocks(rs)); |
098297b27 reiserfs: cleanup... |
572 573 574 |
/* * FIXME: this would be confusing if * someone stores reiserfs super block in some data block ;) |
1da177e4c Linux-2.6.12-rc2 |
575 |
// skipped = (bh->b_blocknr * bh->b_size) / sb_blocksize(rs); |
098297b27 reiserfs: cleanup... |
576 |
*/ |
bd4c625c0 reiserfs: run scr... |
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
skipped = bh->b_blocknr; data_blocks = sb_block_count(rs) - skipped - 1 - sb_bmap_nr(rs) - (!is_reiserfs_jr(rs) ? sb_jp_journal_size(rs) + 1 : sb_reserved_for_journal(rs)) - sb_free_blocks(rs); printk ("Busy blocks (skipped %d, bitmaps - %d, journal (or reserved) blocks - %d " "1 super block, %d data blocks ", skipped, sb_bmap_nr(rs), (!is_reiserfs_jr(rs) ? (sb_jp_journal_size(rs) + 1) : sb_reserved_for_journal(rs)), data_blocks); printk("Root block %u ", sb_root_block(rs)); printk("Journal block (first) %d ", sb_jp_journal_1st_block(rs)); printk("Journal dev %d ", sb_jp_journal_dev(rs)); printk("Journal orig size %d ", sb_jp_journal_size(rs)); printk("FS state %d ", sb_fs_state(rs)); printk("Hash function \"%s\" ", reiserfs_hashname(sb_hash_function_code(rs))); printk("Tree height %d ", sb_tree_height(rs)); return 0; |
1da177e4c Linux-2.6.12-rc2 |
605 |
} |
bd4c625c0 reiserfs: run scr... |
606 |
static int print_desc_block(struct buffer_head *bh) |
1da177e4c Linux-2.6.12-rc2 |
607 |
{ |
bd4c625c0 reiserfs: run scr... |
608 |
struct reiserfs_journal_desc *desc; |
1da177e4c Linux-2.6.12-rc2 |
609 |
|
bd4c625c0 reiserfs: run scr... |
610 611 |
if (memcmp(get_journal_desc_magic(bh), JOURNAL_DESC_MAGIC, 8)) return 1; |
1da177e4c Linux-2.6.12-rc2 |
612 |
|
bd4c625c0 reiserfs: run scr... |
613 614 615 616 |
desc = (struct reiserfs_journal_desc *)(bh->b_data); printk("Desc block %llu (j_trans_id %d, j_mount_id %d, j_len %d)", (unsigned long long)bh->b_blocknr, get_desc_trans_id(desc), get_desc_mount_id(desc), get_desc_trans_len(desc)); |
1da177e4c Linux-2.6.12-rc2 |
617 |
|
bd4c625c0 reiserfs: run scr... |
618 |
return 0; |
1da177e4c Linux-2.6.12-rc2 |
619 |
} |
098297b27 reiserfs: cleanup... |
620 621 |
/* ..., int print_mode, int first, int last) */ void print_block(struct buffer_head *bh, ...) |
1da177e4c Linux-2.6.12-rc2 |
622 |
{ |
bd4c625c0 reiserfs: run scr... |
623 624 |
va_list args; int mode, first, last; |
1da177e4c Linux-2.6.12-rc2 |
625 |
|
bd4c625c0 reiserfs: run scr... |
626 627 628 629 630 |
if (!bh) { printk("print_block: buffer is NULL "); return; } |
1da177e4c Linux-2.6.12-rc2 |
631 |
|
566538a6c reiserfs: make su... |
632 |
va_start(args, bh); |
bd4c625c0 reiserfs: run scr... |
633 634 635 636 637 638 639 640 641 642 643 |
mode = va_arg(args, int); first = va_arg(args, int); last = va_arg(args, int); if (print_leaf(bh, mode, first, last)) if (print_internal(bh, first, last)) if (print_super_block(bh)) if (print_desc_block(bh)) printk ("Block %llu contains unformatted data ", (unsigned long long)bh->b_blocknr); |
774ed22c2 reiserfs: complem... |
644 645 |
va_end(args); |
1da177e4c Linux-2.6.12-rc2 |
646 |
} |
1da177e4c Linux-2.6.12-rc2 |
647 648 649 |
static char print_tb_buf[2048]; /* this stores initial state of tree balance in the print_tb_buf */ |
bd4c625c0 reiserfs: run scr... |
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
void store_print_tb(struct tree_balance *tb) { int h = 0; int i; struct buffer_head *tbSh, *tbFh; if (!tb) return; sprintf(print_tb_buf, " " "BALANCING %d " "MODE=%c, ITEM_POS=%d POS_IN_ITEM=%d " "===================================================================== " "* h * S * L * R * F * FL * FR * CFL * CFR * ", REISERFS_SB(tb->tb_sb)->s_do_balance, tb->tb_mode, PATH_LAST_POSITION(tb->tb_path), tb->tb_path->pos_in_item); |
e8c96f8c2 [PATCH] fs: Use A... |
672 |
for (h = 0; h < ARRAY_SIZE(tb->insert_size); h++) { |
bd4c625c0 reiserfs: run scr... |
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
if (PATH_H_PATH_OFFSET(tb->tb_path, h) <= tb->tb_path->path_length && PATH_H_PATH_OFFSET(tb->tb_path, h) > ILLEGAL_PATH_ELEMENT_OFFSET) { tbSh = PATH_H_PBUFFER(tb->tb_path, h); tbFh = PATH_H_PPARENT(tb->tb_path, h); } else { tbSh = NULL; tbFh = NULL; } sprintf(print_tb_buf + strlen(print_tb_buf), "* %d * %3lld(%2d) * %3lld(%2d) * %3lld(%2d) * %5lld * %5lld * %5lld * %5lld * %5lld * ", h, (tbSh) ? (long long)(tbSh->b_blocknr) : (-1LL), |
a228bf8f0 reiserfs: cleanup... |
688 |
(tbSh) ? atomic_read(&tbSh->b_count) : -1, |
bd4c625c0 reiserfs: run scr... |
689 |
(tb->L[h]) ? (long long)(tb->L[h]->b_blocknr) : (-1LL), |
a228bf8f0 reiserfs: cleanup... |
690 |
(tb->L[h]) ? atomic_read(&tb->L[h]->b_count) : -1, |
bd4c625c0 reiserfs: run scr... |
691 |
(tb->R[h]) ? (long long)(tb->R[h]->b_blocknr) : (-1LL), |
a228bf8f0 reiserfs: cleanup... |
692 |
(tb->R[h]) ? atomic_read(&tb->R[h]->b_count) : -1, |
bd4c625c0 reiserfs: run scr... |
693 694 695 696 697 698 699 700 701 |
(tbFh) ? (long long)(tbFh->b_blocknr) : (-1LL), (tb->FL[h]) ? (long long)(tb->FL[h]-> b_blocknr) : (-1LL), (tb->FR[h]) ? (long long)(tb->FR[h]-> b_blocknr) : (-1LL), (tb->CFL[h]) ? (long long)(tb->CFL[h]-> b_blocknr) : (-1LL), (tb->CFR[h]) ? (long long)(tb->CFR[h]-> b_blocknr) : (-1LL)); |
1da177e4c Linux-2.6.12-rc2 |
702 |
} |
1da177e4c Linux-2.6.12-rc2 |
703 |
|
bd4c625c0 reiserfs: run scr... |
704 705 706 707 708 709 710 711 |
sprintf(print_tb_buf + strlen(print_tb_buf), "===================================================================== " "* h * size * ln * lb * rn * rb * blkn * s0 * s1 * s1b * s2 * s2b * curb * lk * rk * " "* 0 * %4d * %2d * %2d * %2d * %2d * %4d * %2d * %2d * %3d * %2d * %3d * %4d * %2d * %2d * ", tb->insert_size[0], tb->lnum[0], tb->lbytes, tb->rnum[0], |
b49fb112d reiserfs: balance... |
712 713 714 |
tb->rbytes, tb->blknum[0], tb->s0num, tb->snum[0], tb->sbytes[0], tb->snum[1], tb->sbytes[1], tb->cur_blknum, tb->lkey[0], tb->rkey[0]); |
bd4c625c0 reiserfs: run scr... |
715 716 717 718 719 720 721 722 723 724 725 |
/* this prints balance parameters for non-leaf levels */ h = 0; do { h++; sprintf(print_tb_buf + strlen(print_tb_buf), "* %d * %4d * %2d * * %2d * * %2d * ", h, tb->insert_size[h], tb->lnum[h], tb->rnum[h], tb->blknum[h]); } while (tb->insert_size[h]); |
1da177e4c Linux-2.6.12-rc2 |
726 |
|
bd4c625c0 reiserfs: run scr... |
727 728 729 730 |
sprintf(print_tb_buf + strlen(print_tb_buf), "===================================================================== " "FEB list: "); |
1da177e4c Linux-2.6.12-rc2 |
731 |
|
bd4c625c0 reiserfs: run scr... |
732 733 |
/* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */ h = 0; |
e8c96f8c2 [PATCH] fs: Use A... |
734 |
for (i = 0; i < ARRAY_SIZE(tb->FEB); i++) |
bd4c625c0 reiserfs: run scr... |
735 736 737 738 |
sprintf(print_tb_buf + strlen(print_tb_buf), "%p (%llu %d)%s", tb->FEB[i], tb->FEB[i] ? (unsigned long long)tb->FEB[i]-> b_blocknr : 0ULL, |
a228bf8f0 reiserfs: cleanup... |
739 |
tb->FEB[i] ? atomic_read(&tb->FEB[i]->b_count) : 0, |
e8c96f8c2 [PATCH] fs: Use A... |
740 741 |
(i == ARRAY_SIZE(tb->FEB) - 1) ? " " : ", "); |
1da177e4c Linux-2.6.12-rc2 |
742 |
|
bd4c625c0 reiserfs: run scr... |
743 744 745 |
sprintf(print_tb_buf + strlen(print_tb_buf), "======================== the end ==================================== "); |
1da177e4c Linux-2.6.12-rc2 |
746 |
} |
bd4c625c0 reiserfs: run scr... |
747 748 749 750 751 |
void print_cur_tb(char *mes) { printk("%s %s", mes, print_tb_buf); } |
1da177e4c Linux-2.6.12-rc2 |
752 |
|
bd4c625c0 reiserfs: run scr... |
753 |
static void check_leaf_block_head(struct buffer_head *bh) |
1da177e4c Linux-2.6.12-rc2 |
754 |
{ |
bd4c625c0 reiserfs: run scr... |
755 756 757 758 759 760 |
struct block_head *blkh; int nr; blkh = B_BLK_HEAD(bh); nr = blkh_nr_item(blkh); if (nr > (bh->b_size - BLKH_SIZE) / IH_SIZE) |
c3a9c2109 reiserfs: rework ... |
761 |
reiserfs_panic(NULL, "vs-6010", "invalid item number %z", |
bd4c625c0 reiserfs: run scr... |
762 763 |
bh); if (blkh_free_space(blkh) > bh->b_size - BLKH_SIZE - IH_SIZE * nr) |
c3a9c2109 reiserfs: rework ... |
764 |
reiserfs_panic(NULL, "vs-6020", "invalid free space %z", |
bd4c625c0 reiserfs: run scr... |
765 |
bh); |
1da177e4c Linux-2.6.12-rc2 |
766 |
|
1da177e4c Linux-2.6.12-rc2 |
767 |
} |
bd4c625c0 reiserfs: run scr... |
768 769 |
static void check_internal_block_head(struct buffer_head *bh) { |
bd4c625c0 reiserfs: run scr... |
770 |
if (!(B_LEVEL(bh) > DISK_LEAF_NODE_LEVEL && B_LEVEL(bh) <= MAX_HEIGHT)) |
c3a9c2109 reiserfs: rework ... |
771 |
reiserfs_panic(NULL, "vs-6025", "invalid level %z", bh); |
bd4c625c0 reiserfs: run scr... |
772 773 |
if (B_NR_ITEMS(bh) > (bh->b_size - BLKH_SIZE) / IH_SIZE) |
c3a9c2109 reiserfs: rework ... |
774 |
reiserfs_panic(NULL, "vs-6030", "invalid item number %z", bh); |
bd4c625c0 reiserfs: run scr... |
775 776 777 778 |
if (B_FREE_SPACE(bh) != bh->b_size - BLKH_SIZE - KEY_SIZE * B_NR_ITEMS(bh) - DC_SIZE * (B_NR_ITEMS(bh) + 1)) |
c3a9c2109 reiserfs: rework ... |
779 |
reiserfs_panic(NULL, "vs-6040", "invalid free space %z", bh); |
bd4c625c0 reiserfs: run scr... |
780 781 |
} |
1da177e4c Linux-2.6.12-rc2 |
782 |
|
bd4c625c0 reiserfs: run scr... |
783 |
void check_leaf(struct buffer_head *bh) |
1da177e4c Linux-2.6.12-rc2 |
784 |
{ |
bd4c625c0 reiserfs: run scr... |
785 786 787 788 789 790 |
int i; struct item_head *ih; if (!bh) return; check_leaf_block_head(bh); |
4cf5f7add reiserfs: cleanup... |
791 792 |
for (i = 0, ih = item_head(bh, 0); i < B_NR_ITEMS(bh); i++, ih++) op_check_item(ih, ih_item_body(bh, ih)); |
1da177e4c Linux-2.6.12-rc2 |
793 |
} |
bd4c625c0 reiserfs: run scr... |
794 795 796 797 798 799 |
void check_internal(struct buffer_head *bh) { if (!bh) return; check_internal_block_head(bh); } |
1da177e4c Linux-2.6.12-rc2 |
800 |
|
bd4c625c0 reiserfs: run scr... |
801 |
void print_statistics(struct super_block *s) |
1da177e4c Linux-2.6.12-rc2 |
802 |
{ |
bd4c625c0 reiserfs: run scr... |
803 804 805 806 807 808 809 810 |
/* printk ("reiserfs_put_super: session statistics: balances %d, fix_nodes %d, \ bmap with search %d, without %d, dir2ind %d, ind2dir %d ", REISERFS_SB(s)->s_do_balance, REISERFS_SB(s)->s_fix_nodes, REISERFS_SB(s)->s_bmaps, REISERFS_SB(s)->s_bmaps_without_search, REISERFS_SB(s)->s_direct2indirect, REISERFS_SB(s)->s_indirect2direct); */ |
1da177e4c Linux-2.6.12-rc2 |
811 812 |
} |