Skip to content

Commit

Permalink
UBIFS: do not use key type in list_sort
Browse files Browse the repository at this point in the history
In comparison function for 'list_sort()' we use key type to distinguish between
node types. However, we have a bit simper way to detect node type -
'snod->type'. This more logical to use, comparing to decoding key types. Also
allows to get rid of 2 local variables.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Aug 30, 2010
1 parent 44ec83b commit ab87118
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions fs/ubifs/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,29 @@ int data_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
*/
int nondata_nodes_cmp(void *priv, struct list_head *a, struct list_head *b)
{
int typea, typeb;
ino_t inuma, inumb;
struct ubifs_info *c = priv;
struct ubifs_scan_node *sa, *sb;

cond_resched();
sa = list_entry(a, struct ubifs_scan_node, list);
sb = list_entry(b, struct ubifs_scan_node, list);
typea = key_type(c, &sa->key);
typeb = key_type(c, &sb->key);
ubifs_assert(typea != UBIFS_DATA_KEY && typeb != UBIFS_DATA_KEY);
ubifs_assert(sa->type != UBIFS_DATA_NODE &&
sb->type != UBIFS_DATA_NODE);

/* Inodes go before directory entries */
if (typea == UBIFS_INO_KEY) {
if (typeb == UBIFS_INO_KEY)
if (sa->type == UBIFS_INO_NODE) {
if (sb->type == UBIFS_INO_NODE)
return sb->len - sa->len;
return -1;
}
if (typeb == UBIFS_INO_KEY)
if (sb->type == UBIFS_INO_NODE)
return 1;

ubifs_assert(typea == UBIFS_DENT_KEY || typea == UBIFS_XENT_KEY);
ubifs_assert(typeb == UBIFS_DENT_KEY || typeb == UBIFS_XENT_KEY);
ubifs_assert(sa->type == UBIFS_DENT_NODE ||
sa->type == UBIFS_XENT_NODE);
ubifs_assert(sb->type == UBIFS_DENT_NODE ||
sb->type == UBIFS_XENT_NODE);
inuma = key_inum(c, &sa->key);
inumb = key_inum(c, &sb->key);

Expand Down

0 comments on commit ab87118

Please sign in to comment.