Commit 94b1984a authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'linux-next' of git://git.infradead.org/ubifs-2.6

* 'linux-next' of git://git.infradead.org/ubifs-2.6:
  UBIFS: fix key printing
  UBIFS: use snprintf instead of sprintf when printing keys
  UBIFS: fix debugging messages
  UBIFS: make debugging messages light again
  UBI: fix debugging messages
  UBI: make vid_hdr non-static
parents 1a52bb0b 515315a1
...@@ -43,7 +43,10 @@ ...@@ -43,7 +43,10 @@
pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__) pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__)
/* Just a debugging messages not related to any specific UBI subsystem */ /* Just a debugging messages not related to any specific UBI subsystem */
#define dbg_msg(fmt, ...) ubi_dbg_msg("msg", fmt, ##__VA_ARGS__) #define dbg_msg(fmt, ...) \
printk(KERN_DEBUG "UBI DBG (pid %d): %s: " fmt "\n", \
current->pid, __func__, ##__VA_ARGS__)
/* General debugging messages */ /* General debugging messages */
#define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__) #define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
/* Messages from the eraseblock association sub-system */ /* Messages from the eraseblock association sub-system */
......
...@@ -306,7 +306,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, ...@@ -306,7 +306,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si,
int copy, void *vtbl) int copy, void *vtbl)
{ {
int err, tries = 0; int err, tries = 0;
static struct ubi_vid_hdr *vid_hdr; struct ubi_vid_hdr *vid_hdr;
struct ubi_scan_leb *new_seb; struct ubi_scan_leb *new_seb;
ubi_msg("create volume table (copy #%d)", copy + 1); ubi_msg("create volume table (copy #%d)", copy + 1);
......
...@@ -38,9 +38,6 @@ ...@@ -38,9 +38,6 @@
DEFINE_SPINLOCK(dbg_lock); DEFINE_SPINLOCK(dbg_lock);
static char dbg_key_buf0[128];
static char dbg_key_buf1[128];
static const char *get_key_fmt(int fmt) static const char *get_key_fmt(int fmt)
{ {
switch (fmt) { switch (fmt) {
...@@ -103,8 +100,8 @@ static const char *get_dent_type(int type) ...@@ -103,8 +100,8 @@ static const char *get_dent_type(int type)
} }
} }
static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key, const char *dbg_snprintf_key(const struct ubifs_info *c,
char *buffer) const union ubifs_key *key, char *buffer, int len)
{ {
char *p = buffer; char *p = buffer;
int type = key_type(c, key); int type = key_type(c, key);
...@@ -112,45 +109,34 @@ static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key, ...@@ -112,45 +109,34 @@ static void sprintf_key(const struct ubifs_info *c, const union ubifs_key *key,
if (c->key_fmt == UBIFS_SIMPLE_KEY_FMT) { if (c->key_fmt == UBIFS_SIMPLE_KEY_FMT) {
switch (type) { switch (type) {
case UBIFS_INO_KEY: case UBIFS_INO_KEY:
sprintf(p, "(%lu, %s)", (unsigned long)key_inum(c, key), len -= snprintf(p, len, "(%lu, %s)",
(unsigned long)key_inum(c, key),
get_key_type(type)); get_key_type(type));
break; break;
case UBIFS_DENT_KEY: case UBIFS_DENT_KEY:
case UBIFS_XENT_KEY: case UBIFS_XENT_KEY:
sprintf(p, "(%lu, %s, %#08x)", len -= snprintf(p, len, "(%lu, %s, %#08x)",
(unsigned long)key_inum(c, key), (unsigned long)key_inum(c, key),
get_key_type(type), key_hash(c, key)); get_key_type(type), key_hash(c, key));
break; break;
case UBIFS_DATA_KEY: case UBIFS_DATA_KEY:
sprintf(p, "(%lu, %s, %u)", len -= snprintf(p, len, "(%lu, %s, %u)",
(unsigned long)key_inum(c, key), (unsigned long)key_inum(c, key),
get_key_type(type), key_block(c, key)); get_key_type(type), key_block(c, key));
break; break;
case UBIFS_TRUN_KEY: case UBIFS_TRUN_KEY:
sprintf(p, "(%lu, %s)", len -= snprintf(p, len, "(%lu, %s)",
(unsigned long)key_inum(c, key), (unsigned long)key_inum(c, key),
get_key_type(type)); get_key_type(type));
break; break;
default: default:
sprintf(p, "(bad key type: %#08x, %#08x)", len -= snprintf(p, len, "(bad key type: %#08x, %#08x)",
key->u32[0], key->u32[1]); key->u32[0], key->u32[1]);
} }
} else } else
sprintf(p, "bad key format %d", c->key_fmt); len -= snprintf(p, len, "bad key format %d", c->key_fmt);
} ubifs_assert(len > 0);
return p;
const char *dbg_key_str0(const struct ubifs_info *c, const union ubifs_key *key)
{
/* dbg_lock must be held */
sprintf_key(c, key, dbg_key_buf0);
return dbg_key_buf0;
}
const char *dbg_key_str1(const struct ubifs_info *c, const union ubifs_key *key)
{
/* dbg_lock must be held */
sprintf_key(c, key, dbg_key_buf1);
return dbg_key_buf1;
} }
const char *dbg_ntype(int type) const char *dbg_ntype(int type)
...@@ -319,6 +305,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) ...@@ -319,6 +305,7 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
int i, n; int i, n;
union ubifs_key key; union ubifs_key key;
const struct ubifs_ch *ch = node; const struct ubifs_ch *ch = node;
char key_buf[DBG_KEY_BUF_LEN];
if (dbg_is_tst_rcvry(c)) if (dbg_is_tst_rcvry(c))
return; return;
...@@ -474,7 +461,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) ...@@ -474,7 +461,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
const struct ubifs_ino_node *ino = node; const struct ubifs_ino_node *ino = node;
key_read(c, &ino->key, &key); key_read(c, &ino->key, &key);
printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); printk(KERN_DEBUG "\tkey %s\n",
dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
printk(KERN_DEBUG "\tcreat_sqnum %llu\n", printk(KERN_DEBUG "\tcreat_sqnum %llu\n",
(unsigned long long)le64_to_cpu(ino->creat_sqnum)); (unsigned long long)le64_to_cpu(ino->creat_sqnum));
printk(KERN_DEBUG "\tsize %llu\n", printk(KERN_DEBUG "\tsize %llu\n",
...@@ -517,7 +505,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) ...@@ -517,7 +505,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
int nlen = le16_to_cpu(dent->nlen); int nlen = le16_to_cpu(dent->nlen);
key_read(c, &dent->key, &key); key_read(c, &dent->key, &key);
printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); printk(KERN_DEBUG "\tkey %s\n",
dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
printk(KERN_DEBUG "\tinum %llu\n", printk(KERN_DEBUG "\tinum %llu\n",
(unsigned long long)le64_to_cpu(dent->inum)); (unsigned long long)le64_to_cpu(dent->inum));
printk(KERN_DEBUG "\ttype %d\n", (int)dent->type); printk(KERN_DEBUG "\ttype %d\n", (int)dent->type);
...@@ -541,7 +530,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) ...@@ -541,7 +530,8 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ; int dlen = le32_to_cpu(ch->len) - UBIFS_DATA_NODE_SZ;
key_read(c, &dn->key, &key); key_read(c, &dn->key, &key);
printk(KERN_DEBUG "\tkey %s\n", DBGKEY(&key)); printk(KERN_DEBUG "\tkey %s\n",
dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
printk(KERN_DEBUG "\tsize %u\n", printk(KERN_DEBUG "\tsize %u\n",
le32_to_cpu(dn->size)); le32_to_cpu(dn->size));
printk(KERN_DEBUG "\tcompr_typ %d\n", printk(KERN_DEBUG "\tcompr_typ %d\n",
...@@ -582,7 +572,9 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node) ...@@ -582,7 +572,9 @@ void dbg_dump_node(const struct ubifs_info *c, const void *node)
key_read(c, &br->key, &key); key_read(c, &br->key, &key);
printk(KERN_DEBUG "\t%d: LEB %d:%d len %d key %s\n", printk(KERN_DEBUG "\t%d: LEB %d:%d len %d key %s\n",
i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs), i, le32_to_cpu(br->lnum), le32_to_cpu(br->offs),
le32_to_cpu(br->len), DBGKEY(&key)); le32_to_cpu(br->len),
dbg_snprintf_key(c, &key, key_buf,
DBG_KEY_BUF_LEN));
} }
break; break;
} }
...@@ -934,6 +926,7 @@ void dbg_dump_znode(const struct ubifs_info *c, ...@@ -934,6 +926,7 @@ void dbg_dump_znode(const struct ubifs_info *c,
{ {
int n; int n;
const struct ubifs_zbranch *zbr; const struct ubifs_zbranch *zbr;
char key_buf[DBG_KEY_BUF_LEN];
spin_lock(&dbg_lock); spin_lock(&dbg_lock);
if (znode->parent) if (znode->parent)
...@@ -958,12 +951,16 @@ void dbg_dump_znode(const struct ubifs_info *c, ...@@ -958,12 +951,16 @@ void dbg_dump_znode(const struct ubifs_info *c,
printk(KERN_DEBUG "\t%d: znode %p LEB %d:%d len %d key " printk(KERN_DEBUG "\t%d: znode %p LEB %d:%d len %d key "
"%s\n", n, zbr->znode, zbr->lnum, "%s\n", n, zbr->znode, zbr->lnum,
zbr->offs, zbr->len, zbr->offs, zbr->len,
DBGKEY(&zbr->key)); dbg_snprintf_key(c, &zbr->key,
key_buf,
DBG_KEY_BUF_LEN));
else else
printk(KERN_DEBUG "\t%d: LNC %p LEB %d:%d len %d key " printk(KERN_DEBUG "\t%d: LNC %p LEB %d:%d len %d key "
"%s\n", n, zbr->znode, zbr->lnum, "%s\n", n, zbr->znode, zbr->lnum,
zbr->offs, zbr->len, zbr->offs, zbr->len,
DBGKEY(&zbr->key)); dbg_snprintf_key(c, &zbr->key,
key_buf,
DBG_KEY_BUF_LEN));
} }
spin_unlock(&dbg_lock); spin_unlock(&dbg_lock);
} }
...@@ -1260,6 +1257,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, ...@@ -1260,6 +1257,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
int err, nlen1, nlen2, cmp; int err, nlen1, nlen2, cmp;
struct ubifs_dent_node *dent1, *dent2; struct ubifs_dent_node *dent1, *dent2;
union ubifs_key key; union ubifs_key key;
char key_buf[DBG_KEY_BUF_LEN];
ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key)); ubifs_assert(!keys_cmp(c, &zbr1->key, &zbr2->key));
dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS); dent1 = kmalloc(UBIFS_MAX_DENT_NODE_SZ, GFP_NOFS);
...@@ -1290,9 +1288,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, ...@@ -1290,9 +1288,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
key_read(c, &dent1->key, &key); key_read(c, &dent1->key, &key);
if (keys_cmp(c, &zbr1->key, &key)) { if (keys_cmp(c, &zbr1->key, &key)) {
dbg_err("1st entry at %d:%d has key %s", zbr1->lnum, dbg_err("1st entry at %d:%d has key %s", zbr1->lnum,
zbr1->offs, DBGKEY(&key)); zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
DBG_KEY_BUF_LEN));
dbg_err("but it should have key %s according to tnc", dbg_err("but it should have key %s according to tnc",
DBGKEY(&zbr1->key)); dbg_snprintf_key(c, &zbr1->key, key_buf,
DBG_KEY_BUF_LEN));
dbg_dump_node(c, dent1); dbg_dump_node(c, dent1);
goto out_free; goto out_free;
} }
...@@ -1300,9 +1300,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, ...@@ -1300,9 +1300,11 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
key_read(c, &dent2->key, &key); key_read(c, &dent2->key, &key);
if (keys_cmp(c, &zbr2->key, &key)) { if (keys_cmp(c, &zbr2->key, &key)) {
dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum, dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum,
zbr1->offs, DBGKEY(&key)); zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
DBG_KEY_BUF_LEN));
dbg_err("but it should have key %s according to tnc", dbg_err("but it should have key %s according to tnc",
DBGKEY(&zbr2->key)); dbg_snprintf_key(c, &zbr2->key, key_buf,
DBG_KEY_BUF_LEN));
dbg_dump_node(c, dent2); dbg_dump_node(c, dent2);
goto out_free; goto out_free;
} }
...@@ -1319,7 +1321,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1, ...@@ -1319,7 +1321,7 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
dbg_err("2 xent/dent nodes with the same name"); dbg_err("2 xent/dent nodes with the same name");
else else
dbg_err("bad order of colliding key %s", dbg_err("bad order of colliding key %s",
DBGKEY(&key)); dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs); ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs);
dbg_dump_node(c, dent1); dbg_dump_node(c, dent1);
......
...@@ -169,40 +169,39 @@ struct ubifs_global_debug_info { ...@@ -169,40 +169,39 @@ struct ubifs_global_debug_info {
spin_unlock(&dbg_lock); \ spin_unlock(&dbg_lock); \
} while (0) } while (0)
const char *dbg_key_str0(const struct ubifs_info *c, #define ubifs_dbg_msg(type, fmt, ...) \
const union ubifs_key *key); pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)
const char *dbg_key_str1(const struct ubifs_info *c,
const union ubifs_key *key); #define DBG_KEY_BUF_LEN 32
#define ubifs_dbg_msg_key(type, key, fmt, ...) do { \
/* char __tmp_key_buf[DBG_KEY_BUF_LEN]; \
* DBGKEY macros require @dbg_lock to be held, which it is in the dbg message pr_debug("UBIFS DBG " type ": " fmt "%s\n", ##__VA_ARGS__, \
* macros. dbg_snprintf_key(c, key, __tmp_key_buf, DBG_KEY_BUF_LEN)); \
*/
#define DBGKEY(key) dbg_key_str0(c, (key))
#define DBGKEY1(key) dbg_key_str1(c, (key))
extern spinlock_t dbg_lock;
#define ubifs_dbg_msg(type, fmt, ...) do { \
spin_lock(&dbg_lock); \
pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__); \
spin_unlock(&dbg_lock); \
} while (0) } while (0)
/* Just a debugging messages not related to any specific UBIFS subsystem */ /* Just a debugging messages not related to any specific UBIFS subsystem */
#define dbg_msg(fmt, ...) ubifs_dbg_msg("msg", fmt, ##__VA_ARGS__) #define dbg_msg(fmt, ...) \
printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n", current->pid, \
__func__, ##__VA_ARGS__)
/* General messages */ /* General messages */
#define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__) #define dbg_gen(fmt, ...) ubifs_dbg_msg("gen", fmt, ##__VA_ARGS__)
/* Additional journal messages */ /* Additional journal messages */
#define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__) #define dbg_jnl(fmt, ...) ubifs_dbg_msg("jnl", fmt, ##__VA_ARGS__)
#define dbg_jnlk(key, fmt, ...) \
ubifs_dbg_msg_key("jnl", key, fmt, ##__VA_ARGS__)
/* Additional TNC messages */ /* Additional TNC messages */
#define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__) #define dbg_tnc(fmt, ...) ubifs_dbg_msg("tnc", fmt, ##__VA_ARGS__)
#define dbg_tnck(key, fmt, ...) \
ubifs_dbg_msg_key("tnc", key, fmt, ##__VA_ARGS__)
/* Additional lprops messages */ /* Additional lprops messages */
#define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__) #define dbg_lp(fmt, ...) ubifs_dbg_msg("lp", fmt, ##__VA_ARGS__)
/* Additional LEB find messages */ /* Additional LEB find messages */
#define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__) #define dbg_find(fmt, ...) ubifs_dbg_msg("find", fmt, ##__VA_ARGS__)
/* Additional mount messages */ /* Additional mount messages */
#define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__) #define dbg_mnt(fmt, ...) ubifs_dbg_msg("mnt", fmt, ##__VA_ARGS__)
#define dbg_mntk(key, fmt, ...) \
ubifs_dbg_msg_key("mnt", key, fmt, ##__VA_ARGS__)
/* Additional I/O messages */ /* Additional I/O messages */
#define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__) #define dbg_io(fmt, ...) ubifs_dbg_msg("io", fmt, ##__VA_ARGS__)
/* Additional commit messages */ /* Additional commit messages */
...@@ -218,6 +217,7 @@ extern spinlock_t dbg_lock; ...@@ -218,6 +217,7 @@ extern spinlock_t dbg_lock;
/* Additional recovery messages */ /* Additional recovery messages */
#define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__) #define dbg_rcvry(fmt, ...) ubifs_dbg_msg("rcvry", fmt, ##__VA_ARGS__)
extern spinlock_t dbg_lock;
extern struct ubifs_global_debug_info ubifs_dbg; extern struct ubifs_global_debug_info ubifs_dbg;
static inline int dbg_is_chk_gen(const struct ubifs_info *c) static inline int dbg_is_chk_gen(const struct ubifs_info *c)
...@@ -258,6 +258,8 @@ const char *dbg_cstate(int cmt_state); ...@@ -258,6 +258,8 @@ const char *dbg_cstate(int cmt_state);
const char *dbg_jhead(int jhead); const char *dbg_jhead(int jhead);
const char *dbg_get_key_dump(const struct ubifs_info *c, const char *dbg_get_key_dump(const struct ubifs_info *c,
const union ubifs_key *key); const union ubifs_key *key);
const char *dbg_snprintf_key(const struct ubifs_info *c,
const union ubifs_key *key, char *buffer, int len);
void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode); void dbg_dump_inode(struct ubifs_info *c, const struct inode *inode);
void dbg_dump_node(const struct ubifs_info *c, const void *node); void dbg_dump_node(const struct ubifs_info *c, const void *node);
void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum, void dbg_dump_lpt_node(const struct ubifs_info *c, void *node, int lnum,
...@@ -368,6 +370,10 @@ static inline const char *dbg_jhead(int jhead) { return ""; } ...@@ -368,6 +370,10 @@ static inline const char *dbg_jhead(int jhead) { return ""; }
static inline const char * static inline const char *
dbg_get_key_dump(const struct ubifs_info *c, dbg_get_key_dump(const struct ubifs_info *c,
const union ubifs_key *key) { return ""; } const union ubifs_key *key) { return ""; }
static inline const char *
dbg_snprintf_key(const struct ubifs_info *c,
const union ubifs_key *key, char *buffer,
int len) { return ""; }
static inline void dbg_dump_inode(struct ubifs_info *c, static inline void dbg_dump_inode(struct ubifs_info *c,
const struct inode *inode) { return; } const struct inode *inode) { return; }
static inline void dbg_dump_node(const struct ubifs_info *c, static inline void dbg_dump_node(const struct ubifs_info *c,
......
...@@ -697,9 +697,8 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode, ...@@ -697,9 +697,8 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1; int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1;
struct ubifs_inode *ui = ubifs_inode(inode); struct ubifs_inode *ui = ubifs_inode(inode);
dbg_jnl("ino %lu, blk %u, len %d, key %s", dbg_jnlk(key, "ino %lu, blk %u, len %d, key ",
(unsigned long)key_inum(c, key), key_block(c, key), len, (unsigned long)key_inum(c, key), key_block(c, key), len);
DBGKEY(key));
ubifs_assert(len <= UBIFS_BLOCK_SIZE); ubifs_assert(len <= UBIFS_BLOCK_SIZE);
data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN); data = kmalloc(dlen, GFP_NOFS | __GFP_NOWARN);
...@@ -1177,7 +1176,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode, ...@@ -1177,7 +1176,7 @@ int ubifs_jnl_truncate(struct ubifs_info *c, const struct inode *inode,
dn = (void *)trun + UBIFS_TRUN_NODE_SZ; dn = (void *)trun + UBIFS_TRUN_NODE_SZ;
blk = new_size >> UBIFS_BLOCK_SHIFT; blk = new_size >> UBIFS_BLOCK_SHIFT;
data_key_init(c, &key, inum, blk); data_key_init(c, &key, inum, blk);
dbg_jnl("last block key %s", DBGKEY(&key)); dbg_jnlk(&key, "last block key ");
err = ubifs_tnc_lookup(c, &key, dn); err = ubifs_tnc_lookup(c, &key, dn);
if (err == -ENOENT) if (err == -ENOENT)
dlen = 0; /* Not found (so it is a hole) */ dlen = 0; /* Not found (so it is a hole) */
......
...@@ -221,8 +221,8 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r) ...@@ -221,8 +221,8 @@ static int apply_replay_entry(struct ubifs_info *c, struct replay_entry *r)
{ {
int err; int err;
dbg_mnt("LEB %d:%d len %d deletion %d sqnum %llu %s", r->lnum, dbg_mntk(&r->key, "LEB %d:%d len %d deletion %d sqnum %llu key ",
r->offs, r->len, r->deletion, r->sqnum, DBGKEY(&r->key)); r->lnum, r->offs, r->len, r->deletion, r->sqnum);
/* Set c->replay_sqnum to help deal with dangling branches. */ /* Set c->replay_sqnum to help deal with dangling branches. */
c->replay_sqnum = r->sqnum; c->replay_sqnum = r->sqnum;
...@@ -361,7 +361,7 @@ static int insert_node(struct ubifs_info *c, int lnum, int offs, int len, ...@@ -361,7 +361,7 @@ static int insert_node(struct ubifs_info *c, int lnum, int offs, int len,
{ {
struct replay_entry *r; struct replay_entry *r;
dbg_mnt("add LEB %d:%d, key %s", lnum, offs, DBGKEY(key)); dbg_mntk(key, "add LEB %d:%d, key ", lnum, offs);
if (key_inum(c, key) >= c->highest_inum) if (key_inum(c, key) >= c->highest_inum)
c->highest_inum = key_inum(c, key); c->highest_inum = key_inum(c, key);
...@@ -409,7 +409,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len, ...@@ -409,7 +409,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
struct replay_entry *r; struct replay_entry *r;
char *nbuf; char *nbuf;
dbg_mnt("add LEB %d:%d, key %s", lnum, offs, DBGKEY(key)); dbg_mntk(key, "add LEB %d:%d, key ", lnum, offs);
if (key_inum(c, key) >= c->highest_inum) if (key_inum(c, key) >= c->highest_inum)
c->highest_inum = key_inum(c, key); c->highest_inum = key_inum(c, key);
......
...@@ -505,7 +505,7 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, ...@@ -505,7 +505,7 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
{ {
int ret; int ret;
dbg_tnc("LEB %d:%d, key %s", zbr->lnum, zbr->offs, DBGKEY(key)); dbg_tnck(key, "LEB %d:%d, key ", zbr->lnum, zbr->offs);
ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum, ret = try_read_node(c, node, key_type(c, key), zbr->len, zbr->lnum,
zbr->offs); zbr->offs);
...@@ -519,8 +519,8 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key, ...@@ -519,8 +519,8 @@ static int fallible_read_node(struct ubifs_info *c, const union ubifs_key *key,
ret = 0; ret = 0;
} }
if (ret == 0 && c->replaying) if (ret == 0 && c->replaying)
dbg_mnt("dangling branch LEB %d:%d len %d, key %s", dbg_mntk(key, "dangling branch LEB %d:%d len %d, key ",
zbr->lnum, zbr->offs, zbr->len, DBGKEY(key)); zbr->lnum, zbr->offs, zbr->len);
return ret; return ret;
} }
...@@ -995,9 +995,9 @@ static int fallible_resolve_collision(struct ubifs_info *c, ...@@ -995,9 +995,9 @@ static int fallible_resolve_collision(struct ubifs_info *c,
if (adding || !o_znode) if (adding || !o_znode)
return 0; return 0;
dbg_mnt("dangling match LEB %d:%d len %d %s", dbg_mntk(key, "dangling match LEB %d:%d len %d key ",
o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs, o_znode->zbranch[o_n].lnum, o_znode->zbranch[o_n].offs,
o_znode->zbranch[o_n].len, DBGKEY(key)); o_znode->zbranch[o_n].len);
*zn = o_znode; *zn = o_znode;
*n = o_n; *n = o_n;
return 1; return 1;
...@@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key, ...@@ -1179,7 +1179,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_znode *znode; struct ubifs_znode *znode;
unsigned long time = get_seconds(); unsigned long time = get_seconds();
dbg_tnc("search key %s", DBGKEY(key)); dbg_tnck(key, "search key ");
ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY); ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);
znode = c->zroot.znode; znode = c->zroot.znode;
...@@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key, ...@@ -1315,7 +1315,7 @@ static int lookup_level0_dirty(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_znode *znode; struct ubifs_znode *znode;
unsigned long time = get_seconds(); unsigned long time = get_seconds();
dbg_tnc("search and dirty key %s", DBGKEY(key)); dbg_tnck(key, "search and dirty key ");
znode = c->zroot.znode; znode = c->zroot.znode;
if (unlikely(!znode)) { if (unlikely(!znode)) {
...@@ -1722,8 +1722,8 @@ static int validate_data_node(struct ubifs_info *c, void *buf, ...@@ -1722,8 +1722,8 @@ static int validate_data_node(struct ubifs_info *c, void *buf,
if (!keys_eq(c, &zbr->key, &key1)) { if (!keys_eq(c, &zbr->key, &key1)) {
ubifs_err("bad key in node at LEB %d:%d", ubifs_err("bad key in node at LEB %d:%d",
zbr->lnum, zbr->offs); zbr->lnum, zbr->offs);
dbg_tnc("looked for key %s found node's key %s", dbg_tnck(&zbr->key, "looked for key ");
DBGKEY(&zbr->key), DBGKEY1(&key1)); dbg_tnck(&key1, "found node's key ");
goto out_err; goto out_err;
} }
...@@ -1776,7 +1776,7 @@ int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu) ...@@ -1776,7 +1776,7 @@ int ubifs_tnc_bulk_read(struct ubifs_info *c, struct bu_info *bu)
ubifs_err("failed to read from LEB %d:%d, error %d", ubifs_err("failed to read from LEB %d:%d, error %d",
lnum, offs, err); lnum, offs, err);
dbg_dump_stack(); dbg_dump_stack();
dbg_tnc("key %s", DBGKEY(&bu->key)); dbg_tnck(&bu->key, "key ");
return err; return err;
} }
...@@ -1811,7 +1811,7 @@ static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key, ...@@ -1811,7 +1811,7 @@ static int do_lookup_nm(struct ubifs_info *c, const union ubifs_key *key,
int found, n, err; int found, n, err;
struct ubifs_znode *znode; struct ubifs_znode *znode;
dbg_tnc("name '%.*s' key %s", nm->len, nm->name, DBGKEY(key)); dbg_tnck(key, "name '%.*s' key ", nm->len, nm->name);
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
found = ubifs_lookup_level0(c, key, &znode, &n); found = ubifs_lookup_level0(c, key, &znode, &n);
if (!found) { if (!found) {
...@@ -1985,8 +1985,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, ...@@ -1985,8 +1985,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
zp = znode->parent; zp = znode->parent;
if (znode->child_cnt < c->fanout) { if (znode->child_cnt < c->fanout) {
ubifs_assert(n != c->fanout); ubifs_assert(n != c->fanout);
dbg_tnc("inserted at %d level %d, key %s", n, znode->level, dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level);
DBGKEY(key));
insert_zbranch(znode, zbr, n); insert_zbranch(znode, zbr, n);
...@@ -2001,7 +2000,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, ...@@ -2001,7 +2000,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
* Unfortunately, @znode does not have more empty slots and we have to * Unfortunately, @znode does not have more empty slots and we have to
* split it. * split it.
*/ */
dbg_tnc("splitting level %d, key %s", znode->level, DBGKEY(key)); dbg_tnck(key, "splitting level %d, key ", znode->level);
if (znode->alt) if (znode->alt)
/* /*
...@@ -2095,7 +2094,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, ...@@ -2095,7 +2094,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
} }
/* Insert new key and branch */ /* Insert new key and branch */
dbg_tnc("inserting at %d level %d, key %s", n, zn->level, DBGKEY(key)); dbg_tnck(key, "inserting at %d level %d, key ", n, zn->level);
insert_zbranch(zi, zbr, n); insert_zbranch(zi, zbr, n);
...@@ -2171,7 +2170,7 @@ int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum, ...@@ -2171,7 +2170,7 @@ int ubifs_tnc_add(struct ubifs_info *c, const union ubifs_key *key, int lnum,
struct ubifs_znode *znode; struct ubifs_znode *znode;
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
dbg_tnc("%d:%d, len %d, key %s", lnum, offs, len, DBGKEY(key)); dbg_tnck(key, "%d:%d, len %d, key ", lnum, offs, len);
found = lookup_level0_dirty(c, key, &znode, &n); found = lookup_level0_dirty(c, key, &znode, &n);
if (!found) { if (!found) {
struct ubifs_zbranch zbr; struct ubifs_zbranch zbr;
...@@ -2220,8 +2219,8 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key, ...@@ -2220,8 +2219,8 @@ int ubifs_tnc_replace(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_znode *znode; struct ubifs_znode *znode;
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
dbg_tnc("old LEB %d:%d, new LEB %d:%d, len %d, key %s", old_lnum, dbg_tnck(key, "old LEB %d:%d, new LEB %d:%d, len %d, key ", old_lnum,
old_offs, lnum, offs, len, DBGKEY(key)); old_offs, lnum, offs, len);
found = lookup_level0_dirty(c, key, &znode, &n); found = lookup_level0_dirty(c, key, &znode, &n);
if (found < 0) { if (found < 0) {
err = found; err = found;
...@@ -2303,8 +2302,8 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key, ...@@ -2303,8 +2302,8 @@ int ubifs_tnc_add_nm(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_znode *znode; struct ubifs_znode *znode;
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
dbg_tnc("LEB %d:%d, name '%.*s', key %s", lnum, offs, nm->len, nm->name, dbg_tnck(key, "LEB %d:%d, name '%.*s', key ",
DBGKEY(key)); lnum, offs, nm->len, nm->name);
found = lookup_level0_dirty(c, key, &znode, &n); found = lookup_level0_dirty(c, key, &znode, &n);
if (found < 0) { if (found < 0) {
err = found; err = found;
...@@ -2397,7 +2396,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) ...@@ -2397,7 +2396,7 @@ static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
/* Delete without merge for now */ /* Delete without merge for now */
ubifs_assert(znode->level == 0); ubifs_assert(znode->level == 0);
ubifs_assert(n >= 0 && n < c->fanout); ubifs_assert(n >= 0 && n < c->fanout);
dbg_tnc("deleting %s", DBGKEY(&znode->zbranch[n].key)); dbg_tnck(&znode->zbranch[n].key, "deleting key ");
zbr = &znode->zbranch[n]; zbr = &znode->zbranch[n];
lnc_free(zbr); lnc_free(zbr);
...@@ -2507,7 +2506,7 @@ int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key) ...@@ -2507,7 +2506,7 @@ int ubifs_tnc_remove(struct ubifs_info *c, const union ubifs_key *key)
struct ubifs_znode *znode; struct ubifs_znode *znode;
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
dbg_tnc("key %s", DBGKEY(key)); dbg_tnck(key, "key ");
found = lookup_level0_dirty(c, key, &znode, &n); found = lookup_level0_dirty(c, key, &znode, &n);
if (found < 0) { if (found < 0) {
err = found; err = found;
...@@ -2538,7 +2537,7 @@ int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key, ...@@ -2538,7 +2537,7 @@ int ubifs_tnc_remove_nm(struct ubifs_info *c, const union ubifs_key *key,
struct ubifs_znode *znode; struct ubifs_znode *znode;
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
dbg_tnc("%.*s, key %s", nm->len, nm->name, DBGKEY(key)); dbg_tnck(key, "%.*s, key ", nm->len, nm->name);
err = lookup_level0_dirty(c, key, &znode, &n); err = lookup_level0_dirty(c, key, &znode, &n);
if (err < 0) if (err < 0)
goto out_unlock; goto out_unlock;
...@@ -2653,7 +2652,7 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key, ...@@ -2653,7 +2652,7 @@ int ubifs_tnc_remove_range(struct ubifs_info *c, union ubifs_key *from_key,
dbg_dump_znode(c, znode); dbg_dump_znode(c, znode);
goto out_unlock; goto out_unlock;
} }
dbg_tnc("removing %s", DBGKEY(key)); dbg_tnck(key, "removing key ");
} }
if (k) { if (k) {
for (i = n + 1 + k; i < znode->child_cnt; i++) for (i = n + 1 + k; i < znode->child_cnt; i++)
...@@ -2773,7 +2772,7 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c, ...@@ -2773,7 +2772,7 @@ struct ubifs_dent_node *ubifs_tnc_next_ent(struct ubifs_info *c,
struct ubifs_zbranch *zbr; struct ubifs_zbranch *zbr;
union ubifs_key *dkey; union ubifs_key *dkey;
dbg_tnc("%s %s", nm->name ? (char *)nm->name : "(lowest)", DBGKEY(key)); dbg_tnck(key, "%s ", nm->name ? (char *)nm->name : "(lowest)");
ubifs_assert(is_hash_key(c, key)); ubifs_assert(is_hash_key(c, key));
mutex_lock(&c->tnc_mutex); mutex_lock(&c->tnc_mutex);
...@@ -3332,9 +3331,9 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode, ...@@ -3332,9 +3331,9 @@ int dbg_check_inode_size(struct ubifs_info *c, const struct inode *inode,
out_dump: out_dump:
block = key_block(c, key); block = key_block(c, key);
ubifs_err("inode %lu has size %lld, but there are data at offset %lld " ubifs_err("inode %lu has size %lld, but there are data at offset %lld",
"(data key %s)", (unsigned long)inode->i_ino, size, (unsigned long)inode->i_ino, size,
((loff_t)block) << UBIFS_BLOCK_SHIFT, DBGKEY(key)); ((loff_t)block) << UBIFS_BLOCK_SHIFT);
mutex_unlock(&c->tnc_mutex); mutex_unlock(&c->tnc_mutex);
dbg_dump_inode(c, inode); dbg_dump_inode(c, inode);
dbg_dump_stack(); dbg_dump_stack();
......
...@@ -328,8 +328,8 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len, ...@@ -328,8 +328,8 @@ static int read_znode(struct ubifs_info *c, int lnum, int offs, int len,
case UBIFS_XENT_KEY: case UBIFS_XENT_KEY:
break; break;
default: default:
dbg_msg("bad key type at slot %d: %s", i, dbg_msg("bad key type at slot %d: %d",
DBGKEY(&zbr->key)); i, key_type(c, &zbr->key));
err = 3; err = 3;
goto out_dump; goto out_dump;
} }
...@@ -475,7 +475,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, ...@@ -475,7 +475,7 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
zbr->offs); zbr->offs);
if (err) { if (err) {
dbg_tnc("key %s", DBGKEY(key)); dbg_tnck(key, "key ");
return err; return err;
} }
...@@ -484,8 +484,8 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr, ...@@ -484,8 +484,8 @@ int ubifs_tnc_read_node(struct ubifs_info *c, struct ubifs_zbranch *zbr,
if (!keys_eq(c, key, &key1)) { if (!keys_eq(c, key, &key1)) {
ubifs_err("bad key in node at LEB %d:%d", ubifs_err("bad key in node at LEB %d:%d",
zbr->lnum, zbr->offs); zbr->lnum, zbr->offs);
dbg_tnc("looked for key %s found node's key %s", dbg_tnck(key, "looked for key ");
DBGKEY(key), DBGKEY1(&key1)); dbg_tnck(&key1, "but found node's key ");
dbg_dump_node(c, node); dbg_dump_node(c, node);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment