Commit 34bdc3e2 authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBIFS: simplify lprops debugging check

Now we return all errors from 'scan_check_cb()' directly, so we do not need
'struct scan_check_data' any more, and this patch removes it.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent dcc50c8e
...@@ -1006,22 +1006,12 @@ void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, ...@@ -1006,22 +1006,12 @@ void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat,
} }
} }
/**
* struct scan_check_data - data provided to scan callback function.
* @lst: LEB properties statistics
* @err: error code
*/
struct scan_check_data {
struct ubifs_lp_stats lst;
int err;
};
/** /**
* scan_check_cb - scan callback. * scan_check_cb - scan callback.
* @c: the UBIFS file-system description object * @c: the UBIFS file-system description object
* @lp: LEB properties to scan * @lp: LEB properties to scan
* @in_tree: whether the LEB properties are in main memory * @in_tree: whether the LEB properties are in main memory
* @data: information passed to and from the caller of the scan * @lst: lprops statistics to update
* *
* This function returns a code that indicates whether the scan should continue * This function returns a code that indicates whether the scan should continue
* (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
...@@ -1030,11 +1020,10 @@ struct scan_check_data { ...@@ -1030,11 +1020,10 @@ struct scan_check_data {
*/ */
static int scan_check_cb(struct ubifs_info *c, static int scan_check_cb(struct ubifs_info *c,
const struct ubifs_lprops *lp, int in_tree, const struct ubifs_lprops *lp, int in_tree,
struct scan_check_data *data) struct ubifs_lp_stats *lst)
{ {
struct ubifs_scan_leb *sleb; struct ubifs_scan_leb *sleb;
struct ubifs_scan_node *snod; struct ubifs_scan_node *snod;
struct ubifs_lp_stats *lst = &data->lst;
int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret; int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret;
void *buf = NULL; void *buf = NULL;
...@@ -1267,8 +1256,7 @@ static int scan_check_cb(struct ubifs_info *c, ...@@ -1267,8 +1256,7 @@ static int scan_check_cb(struct ubifs_info *c,
int dbg_check_lprops(struct ubifs_info *c) int dbg_check_lprops(struct ubifs_info *c)
{ {
int i, err; int i, err;
struct scan_check_data data; struct ubifs_lp_stats lst;
struct ubifs_lp_stats *lst = &data.lst;
if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS))
return 0; return 0;
...@@ -1283,29 +1271,23 @@ int dbg_check_lprops(struct ubifs_info *c) ...@@ -1283,29 +1271,23 @@ int dbg_check_lprops(struct ubifs_info *c)
return err; return err;
} }
memset(lst, 0, sizeof(struct ubifs_lp_stats)); memset(&lst, 0, sizeof(struct ubifs_lp_stats));
data.err = 0;
err = ubifs_lpt_scan_nolock(c, c->main_first, c->leb_cnt - 1, err = ubifs_lpt_scan_nolock(c, c->main_first, c->leb_cnt - 1,
(ubifs_lpt_scan_callback)scan_check_cb, (ubifs_lpt_scan_callback)scan_check_cb,
&data); &lst);
if (err && err != -ENOSPC) if (err && err != -ENOSPC)
goto out; goto out;
if (data.err) {
err = data.err;
goto out;
}
if (lst->empty_lebs != c->lst.empty_lebs || if (lst.empty_lebs != c->lst.empty_lebs ||
lst->idx_lebs != c->lst.idx_lebs || lst.idx_lebs != c->lst.idx_lebs ||
lst->total_free != c->lst.total_free || lst.total_free != c->lst.total_free ||
lst->total_dirty != c->lst.total_dirty || lst.total_dirty != c->lst.total_dirty ||
lst->total_used != c->lst.total_used) { lst.total_used != c->lst.total_used) {
ubifs_err("bad overall accounting"); ubifs_err("bad overall accounting");
ubifs_err("calculated: empty_lebs %d, idx_lebs %d, " ubifs_err("calculated: empty_lebs %d, idx_lebs %d, "
"total_free %lld, total_dirty %lld, total_used %lld", "total_free %lld, total_dirty %lld, total_used %lld",
lst->empty_lebs, lst->idx_lebs, lst->total_free, lst.empty_lebs, lst.idx_lebs, lst.total_free,
lst->total_dirty, lst->total_used); lst.total_dirty, lst.total_used);
ubifs_err("read from lprops: empty_lebs %d, idx_lebs %d, " ubifs_err("read from lprops: empty_lebs %d, idx_lebs %d, "
"total_free %lld, total_dirty %lld, total_used %lld", "total_free %lld, total_dirty %lld, total_used %lld",
c->lst.empty_lebs, c->lst.idx_lebs, c->lst.total_free, c->lst.empty_lebs, c->lst.idx_lebs, c->lst.total_free,
...@@ -1314,11 +1296,11 @@ int dbg_check_lprops(struct ubifs_info *c) ...@@ -1314,11 +1296,11 @@ int dbg_check_lprops(struct ubifs_info *c)
goto out; goto out;
} }
if (lst->total_dead != c->lst.total_dead || if (lst.total_dead != c->lst.total_dead ||
lst->total_dark != c->lst.total_dark) { lst.total_dark != c->lst.total_dark) {
ubifs_err("bad dead/dark space accounting"); ubifs_err("bad dead/dark space accounting");
ubifs_err("calculated: total_dead %lld, total_dark %lld", ubifs_err("calculated: total_dead %lld, total_dark %lld",
lst->total_dead, lst->total_dark); lst.total_dead, lst.total_dark);
ubifs_err("read from lprops: total_dead %lld, total_dark %lld", ubifs_err("read from lprops: total_dead %lld, total_dark %lld",
c->lst.total_dead, c->lst.total_dark); c->lst.total_dead, c->lst.total_dark);
err = -EINVAL; err = -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