aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs/gc.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-07 03:06:11 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-08-30 03:19:09 -0400
commit3bb66b47a4268a4419594b4c4aec58dbeb6b58d2 (patch)
tree42e4e7b28adc166573ffef4c23dc03492fd981b4 /fs/ubifs/gc.c
parent1a9476a77083354005750c9df45ba9d71ad12c8c (diff)
UBIFS: introduce list sorting debugging checks
The UBIFS bug in the GC list sorting comparison functions inspired me to write internal debugging check functions which verify that the list of nodes is sorted properly. So, this patch implements 2 new debugging functions: o 'dbg_check_data_nodes_order()' - check order of data nodes list o 'dbg_check_nondata_nodes_order()' - check order of non-data nodes list The debugging functions are executed only if general UBIFS debugging checks are enabled. And they are compiled out if UBIFS debugging is disabled. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/gc.c')
-rw-r--r--fs/ubifs/gc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 4fc31ca0e3b1..396f24a30af9 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -242,14 +242,13 @@ int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
242static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb, 242static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
243 struct list_head *nondata, int *min) 243 struct list_head *nondata, int *min)
244{ 244{
245 int err;
245 struct ubifs_scan_node *snod, *tmp; 246 struct ubifs_scan_node *snod, *tmp;
246 247
247 *min = INT_MAX; 248 *min = INT_MAX;
248 249
249 /* Separate data nodes and non-data nodes */ 250 /* Separate data nodes and non-data nodes */
250 list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) { 251 list_for_each_entry_safe(snod, tmp, &sleb->nodes, list) {
251 int err;
252
253 ubifs_assert(snod->type == UBIFS_INO_NODE || 252 ubifs_assert(snod->type == UBIFS_INO_NODE ||
254 snod->type == UBIFS_DATA_NODE || 253 snod->type == UBIFS_DATA_NODE ||
255 snod->type == UBIFS_DENT_NODE || 254 snod->type == UBIFS_DENT_NODE ||
@@ -293,6 +292,13 @@ static int sort_nodes(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
293 /* Sort data and non-data nodes */ 292 /* Sort data and non-data nodes */
294 list_sort(c, &sleb->nodes, &data_nodes_cmp); 293 list_sort(c, &sleb->nodes, &data_nodes_cmp);
295 list_sort(c, nondata, &nondata_nodes_cmp); 294 list_sort(c, nondata, &nondata_nodes_cmp);
295
296 err = dbg_check_data_nodes_order(c, &sleb->nodes);
297 if (err)
298 return err;
299 err = dbg_check_nondata_nodes_order(c, nondata);
300 if (err)
301 return err;
296 return 0; 302 return 0;
297} 303}
298 304