Artem B. Bityutskiy | 730554d | 2005-07-17 07:56:26 +0100 | [diff] [blame] | 1 | /* |
| 2 | * JFFS2 -- Journalling Flash File System, Version 2. |
| 3 | * |
| 4 | * Copyright (C) 2001-2003 Red Hat, Inc. |
| 5 | * |
| 6 | * Created by David Woodhouse <dwmw2@infradead.org> |
| 7 | * |
| 8 | * For licensing information, see the file 'LICENCE' in this directory. |
| 9 | * |
| 10 | * $Id: debug.h,v 1.1 2005/07/17 06:56:20 dedekind Exp $ |
| 11 | * |
| 12 | */ |
| 13 | #ifndef _JFFS2_DEBUG_H_ |
| 14 | #define _JFFS2_DEBUG_H_ |
| 15 | |
| 16 | #include <linux/config.h> |
| 17 | |
| 18 | #ifndef CONFIG_JFFS2_FS_DEBUG |
| 19 | #define CONFIG_JFFS2_FS_DEBUG 1 |
| 20 | #endif |
| 21 | |
| 22 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
| 23 | #define JFFS2_DBG_PARANOIA_CHECKS |
| 24 | #define D1(x) x |
| 25 | #else |
| 26 | #define D1(x) |
| 27 | #endif |
| 28 | |
| 29 | #if CONFIG_JFFS2_FS_DEBUG > 1 |
| 30 | #define D2(x) x |
| 31 | #else |
| 32 | #define D2(x) |
| 33 | #endif |
| 34 | |
| 35 | /* Enable JFFS2 sanity checks */ |
| 36 | #define JFFS2_DBG_SANITY_CHECKS |
| 37 | |
| 38 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
| 39 | void |
| 40 | jffs2_dbg_dump_block_lists(struct jffs2_sb_info *c); |
| 41 | |
| 42 | void |
| 43 | jffs2_dbg_dump_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb); |
| 44 | |
| 45 | void |
| 46 | jffs2_dbg_dump_fragtree(struct jffs2_inode_info *f); |
| 47 | |
| 48 | void |
| 49 | jffs2_dbg_dump_buffer(char *buf, int len, uint32_t offs); |
| 50 | #endif |
| 51 | |
| 52 | #ifdef JFFS2_DBG_PARANOIA_CHECKS |
| 53 | void |
| 54 | jffs2_dbg_fragtree_paranoia_check(struct jffs2_inode_info *f); |
| 55 | |
| 56 | void |
| 57 | jffs2_dbg_acct_paranoia_check(struct jffs2_sb_info *c, |
| 58 | struct jffs2_eraseblock *jeb); |
| 59 | |
| 60 | void |
| 61 | jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, |
| 62 | uint32_t ofs, int len); |
| 63 | #else |
| 64 | #define jffs2_dbg_fragtree_paranoia_check(f) |
| 65 | #define jffs2_dbg_acct_paranoia_check(c, jeb) |
| 66 | #define jffs2_dbg_prewrite_paranoia_check(c, ofs, len) |
| 67 | #endif /* !JFFS2_PARANOIA_CHECKS */ |
| 68 | |
| 69 | #ifdef JFFS2_DBG_SANITY_CHECKS |
| 70 | /* |
| 71 | * Check the space accounting of the file system and of |
| 72 | * the JFFS3 erasable block 'jeb'. |
| 73 | */ |
| 74 | static inline void |
| 75 | jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, |
| 76 | struct jffs2_eraseblock *jeb) |
| 77 | { |
| 78 | if (unlikely(jeb && jeb->used_size + jeb->dirty_size + |
| 79 | jeb->free_size + jeb->wasted_size + |
| 80 | jeb->unchecked_size != c->sector_size)) { |
| 81 | printk(KERN_ERR "Eeep. Space accounting for block at 0x%08x is screwed\n", jeb->offset); |
| 82 | printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + wasted %#08x + unchecked " |
| 83 | "%#08x != total %#08x\n", jeb->free_size, jeb->dirty_size, jeb->used_size, |
| 84 | jeb->wasted_size, jeb->unchecked_size, c->sector_size); |
| 85 | BUG(); |
| 86 | } |
| 87 | |
| 88 | if (unlikely(c->used_size + c->dirty_size + c->free_size + c->erasing_size + c->bad_size |
| 89 | + c->wasted_size + c->unchecked_size != c->flash_size)) { |
| 90 | printk(KERN_ERR "Eeep. Space accounting superblock info is screwed\n"); |
| 91 | printk(KERN_ERR "free %#08x + dirty %#08x + used %#08x + erasing %#08x + bad %#08x + " |
| 92 | "wasted %#08x + unchecked %#08x != total %#08x\n", |
| 93 | c->free_size, c->dirty_size, c->used_size, c->erasing_size, c->bad_size, |
| 94 | c->wasted_size, c->unchecked_size, c->flash_size); |
| 95 | BUG(); |
| 96 | } |
| 97 | } |
| 98 | #else |
| 99 | static inline void |
| 100 | jffs2_dbg_acct_sanity_check(struct jffs2_sb_info *c, |
| 101 | struct jffs2_eraseblock *jeb); |
| 102 | #endif /* !JFFS2_DBG_SANITY_CHECKS */ |
| 103 | |
| 104 | #endif /* _JFFS2_DEBUG_H_ */ |