Skip to content

Commit

Permalink
UBIFS: get rid of dbg_err
Browse files Browse the repository at this point in the history
This patch removes the 'dbg_err()' macro and we now use 'ubifs_err()' instead.
The idea of 'dbg_err()' was to compile out some error message to make the
binary a bit smaller - but I think it was a bad idea.

Signed-off-by: Artem Bityutskiy <[email protected]>
  • Loading branch information
dedekind committed May 16, 2012
1 parent f70b7e5 commit a6aae4d
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 119 deletions.
4 changes: 2 additions & 2 deletions fs/ubifs/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,13 +716,13 @@ int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot)
return 0;

out_dump:
dbg_err("dumping index node (iip=%d)", i->iip);
ubifs_err("dumping index node (iip=%d)", i->iip);
ubifs_dump_node(c, idx);
list_del(&i->list);
kfree(i);
if (!list_empty(&list)) {
i = list_entry(list.prev, struct idx_node, list);
dbg_err("dumping parent index node");
ubifs_err("dumping parent index node");
ubifs_dump_node(c, &i->idx);
}
out_free:
Expand Down
30 changes: 15 additions & 15 deletions fs/ubifs/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,24 +1285,24 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
err = 1;
key_read(c, &dent1->key, &key);
if (keys_cmp(c, &zbr1->key, &key)) {
dbg_err("1st entry at %d:%d has key %s", zbr1->lnum,
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_snprintf_key(c, &zbr1->key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_err("1st entry at %d:%d has key %s", zbr1->lnum,
zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_err("but it should have key %s according to tnc",
dbg_snprintf_key(c, &zbr1->key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_dump_node(c, dent1);
goto out_free;
}

key_read(c, &dent2->key, &key);
if (keys_cmp(c, &zbr2->key, &key)) {
dbg_err("2nd entry at %d:%d has key %s", zbr1->lnum,
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_snprintf_key(c, &zbr2->key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_err("2nd entry at %d:%d has key %s", zbr1->lnum,
zbr1->offs, dbg_snprintf_key(c, &key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_err("but it should have key %s according to tnc",
dbg_snprintf_key(c, &zbr2->key, key_buf,
DBG_KEY_BUF_LEN));
ubifs_dump_node(c, dent2);
goto out_free;
}
Expand All @@ -1316,10 +1316,10 @@ static int dbg_check_key_order(struct ubifs_info *c, struct ubifs_zbranch *zbr1,
goto out_free;
}
if (cmp == 0 && nlen1 == nlen2)
dbg_err("2 xent/dent nodes with the same name");
ubifs_err("2 xent/dent nodes with the same name");
else
dbg_err("bad order of colliding key %s",
dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));
ubifs_err("bad order of colliding key %s",
dbg_snprintf_key(c, &key, key_buf, DBG_KEY_BUF_LEN));

ubifs_msg("first node at %d:%d\n", zbr1->lnum, zbr1->offs);
ubifs_dump_node(c, dent1);
Expand Down
4 changes: 0 additions & 4 deletions fs/ubifs/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ struct ubifs_global_debug_info {
} \
} while (0)

#define dbg_err(fmt, ...) do { \
ubifs_err(fmt, ##__VA_ARGS__); \
} while (0)

#define ubifs_dbg_msg(type, fmt, ...) \
pr_debug("UBIFS DBG " type ": " fmt "\n", ##__VA_ARGS__)

Expand Down
43 changes: 22 additions & 21 deletions fs/ubifs/lpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2094,8 +2094,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
int i;

if (pnode->num != col) {
dbg_err("pnode num %d expected %d parent num %d iip %d",
pnode->num, col, pnode->parent->num, pnode->iip);
ubifs_err("pnode num %d expected %d parent num %d iip %d",
pnode->num, col, pnode->parent->num, pnode->iip);
return -EINVAL;
}
for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
Expand All @@ -2109,14 +2109,14 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
if (lnum >= c->leb_cnt)
continue;
if (lprops->lnum != lnum) {
dbg_err("bad LEB number %d expected %d",
lprops->lnum, lnum);
ubifs_err("bad LEB number %d expected %d",
lprops->lnum, lnum);
return -EINVAL;
}
if (lprops->flags & LPROPS_TAKEN) {
if (cat != LPROPS_UNCAT) {
dbg_err("LEB %d taken but not uncat %d",
lprops->lnum, cat);
ubifs_err("LEB %d taken but not uncat %d",
lprops->lnum, cat);
return -EINVAL;
}
continue;
Expand All @@ -2128,8 +2128,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
case LPROPS_FRDI_IDX:
break;
default:
dbg_err("LEB %d index but cat %d",
lprops->lnum, cat);
ubifs_err("LEB %d index but cat %d",
lprops->lnum, cat);
return -EINVAL;
}
} else {
Expand All @@ -2141,8 +2141,8 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
case LPROPS_FREEABLE:
break;
default:
dbg_err("LEB %d not index but cat %d",
lprops->lnum, cat);
ubifs_err("LEB %d not index but cat %d",
lprops->lnum, cat);
return -EINVAL;
}
}
Expand Down Expand Up @@ -2182,24 +2182,24 @@ static int dbg_chk_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
break;
}
if (!found) {
dbg_err("LEB %d cat %d not found in cat heap/list",
lprops->lnum, cat);
ubifs_err("LEB %d cat %d not found in cat heap/list",
lprops->lnum, cat);
return -EINVAL;
}
switch (cat) {
case LPROPS_EMPTY:
if (lprops->free != c->leb_size) {
dbg_err("LEB %d cat %d free %d dirty %d",
lprops->lnum, cat, lprops->free,
lprops->dirty);
ubifs_err("LEB %d cat %d free %d dirty %d",
lprops->lnum, cat, lprops->free,
lprops->dirty);
return -EINVAL;
}
case LPROPS_FREEABLE:
case LPROPS_FRDI_IDX:
if (lprops->free + lprops->dirty != c->leb_size) {
dbg_err("LEB %d cat %d free %d dirty %d",
lprops->lnum, cat, lprops->free,
lprops->dirty);
ubifs_err("LEB %d cat %d free %d dirty %d",
lprops->lnum, cat, lprops->free,
lprops->dirty);
return -EINVAL;
}
}
Expand Down Expand Up @@ -2233,9 +2233,10 @@ int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode,
/* cnode is a nnode */
num = calc_nnode_num(row, col);
if (cnode->num != num) {
dbg_err("nnode num %d expected %d "
"parent num %d iip %d", cnode->num, num,
(nnode ? nnode->num : 0), cnode->iip);
ubifs_err("nnode num %d expected %d "
"parent num %d iip %d",
cnode->num, num,
(nnode ? nnode->num : 0), cnode->iip);
return -EINVAL;
}
nn = (struct ubifs_nnode *)cnode;
Expand Down
44 changes: 21 additions & 23 deletions fs/ubifs/lpt_commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,8 @@ static int layout_cnodes(struct ubifs_info *c)
return 0;

no_space:
ubifs_err("LPT out of space");
dbg_err("LPT out of space at LEB %d:%d needing %d, done_ltab %d, "
"done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
ubifs_err("LPT out of space at LEB %d:%d needing %d, done_ltab %d, "
"done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
ubifs_dump_lpt_info(c);
ubifs_dump_lpt_lebs(c);
dump_stack();
Expand Down Expand Up @@ -548,9 +547,8 @@ static int write_cnodes(struct ubifs_info *c)
return 0;

no_space:
ubifs_err("LPT out of space mismatch");
dbg_err("LPT out of space mismatch at LEB %d:%d needing %d, done_ltab "
"%d, done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
ubifs_err("LPT out of space mismatch at LEB %d:%d needing %d, done_ltab "
"%d, done_lsave %d", lnum, offs, len, done_ltab, done_lsave);
ubifs_dump_lpt_info(c);
ubifs_dump_lpt_lebs(c);
dump_stack();
Expand Down Expand Up @@ -1733,7 +1731,7 @@ int dbg_check_ltab(struct ubifs_info *c)
for (lnum = c->lpt_first; lnum <= c->lpt_last; lnum++) {
err = dbg_check_ltab_lnum(c, lnum);
if (err) {
dbg_err("failed at LEB %d", lnum);
ubifs_err("failed at LEB %d", lnum);
return err;
}
}
Expand Down Expand Up @@ -1765,8 +1763,8 @@ int dbg_chk_lpt_free_spc(struct ubifs_info *c)
free += c->leb_size;
}
if (free < c->lpt_sz) {
dbg_err("LPT space error: free %lld lpt_sz %lld",
free, c->lpt_sz);
ubifs_err("LPT space error: free %lld lpt_sz %lld",
free, c->lpt_sz);
ubifs_dump_lpt_info(c);
ubifs_dump_lpt_lebs(c);
dump_stack();
Expand Down Expand Up @@ -1805,13 +1803,13 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
d->chk_lpt_lebs = 0;
d->chk_lpt_wastage = 0;
if (c->dirty_pn_cnt > c->pnode_cnt) {
dbg_err("dirty pnodes %d exceed max %d",
c->dirty_pn_cnt, c->pnode_cnt);
ubifs_err("dirty pnodes %d exceed max %d",
c->dirty_pn_cnt, c->pnode_cnt);
err = -EINVAL;
}
if (c->dirty_nn_cnt > c->nnode_cnt) {
dbg_err("dirty nnodes %d exceed max %d",
c->dirty_nn_cnt, c->nnode_cnt);
ubifs_err("dirty nnodes %d exceed max %d",
c->dirty_nn_cnt, c->nnode_cnt);
err = -EINVAL;
}
return err;
Expand All @@ -1828,23 +1826,23 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
chk_lpt_sz *= d->chk_lpt_lebs;
chk_lpt_sz += len - c->nhead_offs;
if (d->chk_lpt_sz != chk_lpt_sz) {
dbg_err("LPT wrote %lld but space used was %lld",
d->chk_lpt_sz, chk_lpt_sz);
ubifs_err("LPT wrote %lld but space used was %lld",
d->chk_lpt_sz, chk_lpt_sz);
err = -EINVAL;
}
if (d->chk_lpt_sz > c->lpt_sz) {
dbg_err("LPT wrote %lld but lpt_sz is %lld",
d->chk_lpt_sz, c->lpt_sz);
ubifs_err("LPT wrote %lld but lpt_sz is %lld",
d->chk_lpt_sz, c->lpt_sz);
err = -EINVAL;
}
if (d->chk_lpt_sz2 && d->chk_lpt_sz != d->chk_lpt_sz2) {
dbg_err("LPT layout size %lld but wrote %lld",
d->chk_lpt_sz, d->chk_lpt_sz2);
ubifs_err("LPT layout size %lld but wrote %lld",
d->chk_lpt_sz, d->chk_lpt_sz2);
err = -EINVAL;
}
if (d->chk_lpt_sz2 && d->new_nhead_offs != len) {
dbg_err("LPT new nhead offs: expected %d was %d",
d->new_nhead_offs, len);
ubifs_err("LPT new nhead offs: expected %d was %d",
d->new_nhead_offs, len);
err = -EINVAL;
}
lpt_sz = (long long)c->pnode_cnt * c->pnode_sz;
Expand All @@ -1853,8 +1851,8 @@ int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
if (c->big_lpt)
lpt_sz += c->lsave_sz;
if (d->chk_lpt_sz - d->chk_lpt_wastage > lpt_sz) {
dbg_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld",
d->chk_lpt_sz, d->chk_lpt_wastage, lpt_sz);
ubifs_err("LPT chk_lpt_sz %lld + waste %lld exceeds %lld",
d->chk_lpt_sz, d->chk_lpt_wastage, lpt_sz);
err = -EINVAL;
}
if (err) {
Expand Down
4 changes: 2 additions & 2 deletions fs/ubifs/orphan.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int ubifs_add_orphan(struct ubifs_info *c, ino_t inum)
else if (inum > o->inum)
p = &(*p)->rb_right;
else {
dbg_err("orphaned twice");
ubifs_err("orphaned twice");
spin_unlock(&c->orphan_lock);
kfree(orphan);
return 0;
Expand Down Expand Up @@ -154,7 +154,7 @@ void ubifs_delete_orphan(struct ubifs_info *c, ino_t inum)
}
}
spin_unlock(&c->orphan_lock);
dbg_err("missing orphan ino %lu", (unsigned long)inum);
ubifs_err("missing orphan ino %lu", (unsigned long)inum);
dump_stack();
}

Expand Down
22 changes: 11 additions & 11 deletions fs/ubifs/recovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,11 @@ int ubifs_recover_master_node(struct ubifs_info *c)
out_free:
ubifs_err("failed to recover master node");
if (mst1) {
dbg_err("dumping first master node");
ubifs_err("dumping first master node");
ubifs_dump_node(c, mst1);
}
if (mst2) {
dbg_err("dumping second master node");
ubifs_err("dumping second master node");
ubifs_dump_node(c, mst2);
}
vfree(buf2);
Expand Down Expand Up @@ -683,7 +683,7 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
ret, lnum, offs);
break;
} else {
dbg_err("unexpected return value %d", ret);
ubifs_err("unexpected return value %d", ret);
err = -EINVAL;
goto error;
}
Expand Down Expand Up @@ -789,7 +789,7 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,

corrupted_rescan:
/* Re-scan the corrupted data with verbose messages */
dbg_err("corruptio %d", ret);
ubifs_err("corruptio %d", ret);
ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
corrupted:
ubifs_scanned_corruption(c, lnum, offs, buf);
Expand Down Expand Up @@ -827,17 +827,17 @@ static int get_cs_sqnum(struct ubifs_info *c, int lnum, int offs,
goto out_free;
ret = ubifs_scan_a_node(c, cs_node, UBIFS_CS_NODE_SZ, lnum, offs, 0);
if (ret != SCANNED_A_NODE) {
dbg_err("Not a valid node");
ubifs_err("Not a valid node");
goto out_err;
}
if (cs_node->ch.node_type != UBIFS_CS_NODE) {
dbg_err("Node a CS node, type is %d", cs_node->ch.node_type);
ubifs_err("Node a CS node, type is %d", cs_node->ch.node_type);
goto out_err;
}
if (le64_to_cpu(cs_node->cmt_no) != c->cmt_no) {
dbg_err("CS node cmt_no %llu != current cmt_no %llu",
(unsigned long long)le64_to_cpu(cs_node->cmt_no),
c->cmt_no);
ubifs_err("CS node cmt_no %llu != current cmt_no %llu",
(unsigned long long)le64_to_cpu(cs_node->cmt_no),
c->cmt_no);
goto out_err;
}
*cs_sqnum = le64_to_cpu(cs_node->ch.sqnum);
Expand Down Expand Up @@ -1138,7 +1138,7 @@ static int grab_empty_leb(struct ubifs_info *c)
*/
lnum = ubifs_find_free_leb_for_idx(c);
if (lnum < 0) {
dbg_err("could not find an empty LEB");
ubifs_err("could not find an empty LEB");
ubifs_dump_lprops(c);
ubifs_dump_budg(c, &c->bi);
return lnum;
Expand Down Expand Up @@ -1218,7 +1218,7 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c)
}
mutex_unlock(&wbuf->io_mutex);
if (err < 0) {
dbg_err("GC failed, error %d", err);
ubifs_err("GC failed, error %d", err);
if (err == -EAGAIN)
err = -EINVAL;
return err;
Expand Down
Loading

0 comments on commit a6aae4d

Please sign in to comment.