aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/lprops.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-05-06 13:58:08 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2011-05-16 03:31:39 -0400
commit34bdc3e2578cae3162e481203a2980d55e184a73 (patch)
treebaeb3a1f175d381fb58e565c6f79b7758e7e5575 /fs/ubifs/lprops.c
parentdcc50c8ee334d570cef84fc956084d567f32a8a3 (diff)
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: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/lprops.c')
-rw-r--r--fs/ubifs/lprops.c48
1 files changed, 15 insertions, 33 deletions
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index ac4521ab2798..77c541be6ffc 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -1007,21 +1007,11 @@ out:
1007} 1007}
1008 1008
1009/** 1009/**
1010 * struct scan_check_data - data provided to scan callback function.
1011 * @lst: LEB properties statistics
1012 * @err: error code
1013 */
1014struct scan_check_data {
1015 struct ubifs_lp_stats lst;
1016 int err;
1017};
1018
1019/**
1020 * scan_check_cb - scan callback. 1010 * scan_check_cb - scan callback.
1021 * @c: the UBIFS file-system description object 1011 * @c: the UBIFS file-system description object
1022 * @lp: LEB properties to scan 1012 * @lp: LEB properties to scan
1023 * @in_tree: whether the LEB properties are in main memory 1013 * @in_tree: whether the LEB properties are in main memory
1024 * @data: information passed to and from the caller of the scan 1014 * @lst: lprops statistics to update
1025 * 1015 *
1026 * This function returns a code that indicates whether the scan should continue 1016 * This function returns a code that indicates whether the scan should continue
1027 * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree 1017 * (%LPT_SCAN_CONTINUE), whether the LEB properties should be added to the tree
@@ -1030,11 +1020,10 @@ struct scan_check_data {
1030 */ 1020 */
1031static int scan_check_cb(struct ubifs_info *c, 1021static int scan_check_cb(struct ubifs_info *c,
1032 const struct ubifs_lprops *lp, int in_tree, 1022 const struct ubifs_lprops *lp, int in_tree,
1033 struct scan_check_data *data) 1023 struct ubifs_lp_stats *lst)
1034{ 1024{
1035 struct ubifs_scan_leb *sleb; 1025 struct ubifs_scan_leb *sleb;
1036 struct ubifs_scan_node *snod; 1026 struct ubifs_scan_node *snod;
1037 struct ubifs_lp_stats *lst = &data->lst;
1038 int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret; 1027 int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret;
1039 void *buf = NULL; 1028 void *buf = NULL;
1040 1029
@@ -1267,8 +1256,7 @@ out:
1267int dbg_check_lprops(struct ubifs_info *c) 1256int dbg_check_lprops(struct ubifs_info *c)
1268{ 1257{
1269 int i, err; 1258 int i, err;
1270 struct scan_check_data data; 1259 struct ubifs_lp_stats lst;
1271 struct ubifs_lp_stats *lst = &data.lst;
1272 1260
1273 if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS)) 1261 if (!(ubifs_chk_flags & UBIFS_CHK_LPROPS))
1274 return 0; 1262 return 0;
@@ -1283,29 +1271,23 @@ int dbg_check_lprops(struct ubifs_info *c)
1283 return err; 1271 return err;
1284 } 1272 }
1285 1273
1286 memset(lst, 0, sizeof(struct ubifs_lp_stats)); 1274 memset(&lst, 0, sizeof(struct ubifs_lp_stats));
1287
1288 data.err = 0;
1289 err = ubifs_lpt_scan_nolock(c, c->main_first, c->leb_cnt - 1, 1275 err = ubifs_lpt_scan_nolock(c, c->main_first, c->leb_cnt - 1,
1290 (ubifs_lpt_scan_callback)scan_check_cb, 1276 (ubifs_lpt_scan_callback)scan_check_cb,
1291 &data); 1277 &lst);
1292 if (err && err != -ENOSPC) 1278 if (err && err != -ENOSPC)
1293 goto out; 1279 goto out;
1294 if (data.err) {
1295 err = data.err;
1296 goto out;
1297 }
1298 1280
1299 if (lst->empty_lebs != c->lst.empty_lebs || 1281 if (lst.empty_lebs != c->lst.empty_lebs ||
1300 lst->idx_lebs != c->lst.idx_lebs || 1282 lst.idx_lebs != c->lst.idx_lebs ||
1301 lst->total_free != c->lst.total_free || 1283 lst.total_free != c->lst.total_free ||
1302 lst->total_dirty != c->lst.total_dirty || 1284 lst.total_dirty != c->lst.total_dirty ||
1303 lst->total_used != c->lst.total_used) { 1285 lst.total_used != c->lst.total_used) {
1304 ubifs_err("bad overall accounting"); 1286 ubifs_err("bad overall accounting");
1305 ubifs_err("calculated: empty_lebs %d, idx_lebs %d, " 1287 ubifs_err("calculated: empty_lebs %d, idx_lebs %d, "
1306 "total_free %lld, total_dirty %lld, total_used %lld", 1288 "total_free %lld, total_dirty %lld, total_used %lld",
1307 lst->empty_lebs, lst->idx_lebs, lst->total_free, 1289 lst.empty_lebs, lst.idx_lebs, lst.total_free,
1308 lst->total_dirty, lst->total_used); 1290 lst.total_dirty, lst.total_used);
1309 ubifs_err("read from lprops: empty_lebs %d, idx_lebs %d, " 1291 ubifs_err("read from lprops: empty_lebs %d, idx_lebs %d, "
1310 "total_free %lld, total_dirty %lld, total_used %lld", 1292 "total_free %lld, total_dirty %lld, total_used %lld",
1311 c->lst.empty_lebs, c->lst.idx_lebs, c->lst.total_free, 1293 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 goto out; 1296 goto out;
1315 } 1297 }
1316 1298
1317 if (lst->total_dead != c->lst.total_dead || 1299 if (lst.total_dead != c->lst.total_dead ||
1318 lst->total_dark != c->lst.total_dark) { 1300 lst.total_dark != c->lst.total_dark) {
1319 ubifs_err("bad dead/dark space accounting"); 1301 ubifs_err("bad dead/dark space accounting");
1320 ubifs_err("calculated: total_dead %lld, total_dark %lld", 1302 ubifs_err("calculated: total_dead %lld, total_dark %lld",
1321 lst->total_dead, lst->total_dark); 1303 lst.total_dead, lst.total_dark);
1322 ubifs_err("read from lprops: total_dead %lld, total_dark %lld", 1304 ubifs_err("read from lprops: total_dead %lld, total_dark %lld",
1323 c->lst.total_dead, c->lst.total_dark); 1305 c->lst.total_dead, c->lst.total_dark);
1324 err = -EINVAL; 1306 err = -EINVAL;