Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 213004
b: refs/heads/master
c: ba2f48f
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Aug 30, 2010
1 parent be5172c commit 6f0cfcb
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5b7a3a2e1b0cbc7d5410a8da60dac266a3e19268
refs/heads/master: ba2f48f70efcf4d82deafb2be327ed64b1f043a5
14 changes: 14 additions & 0 deletions trunk/fs/ubifs/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@ static inline void trun_key_init(const struct ubifs_info *c,
key->u32[1] = UBIFS_TRUN_KEY << UBIFS_S_KEY_BLOCK_BITS;
}

/**
* invalid_key_init - initialize invalid node key.
* @c: UBIFS file-system description object
* @key: key to initialize
*
* This is a helper function which marks a @key object as invalid.
*/
static inline void invalid_key_init(const struct ubifs_info *c,
union ubifs_key *key)
{
key->u32[0] = 0xDEADBEAF;
key->u32[1] = UBIFS_INVALID_KEY;
}

/**
* key_type - get key type.
* @c: UBIFS file-system description object
Expand Down
5 changes: 4 additions & 1 deletion trunk/fs/ubifs/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
struct ubifs_ino_node *ino = buf;
struct ubifs_scan_node *snod;

snod = kzalloc(sizeof(struct ubifs_scan_node), GFP_NOFS);
snod = kmalloc(sizeof(struct ubifs_scan_node), GFP_NOFS);
if (!snod)
return -ENOMEM;

Expand All @@ -218,6 +218,9 @@ int ubifs_add_snod(const struct ubifs_info *c, struct ubifs_scan_leb *sleb,
*/
key_read(c, &ino->key, &snod->key);
break;
default:
invalid_key_init(c, &snod->key);
break;
}
list_add_tail(&snod->list, &sleb->nodes);
sleb->nodes_cnt += 1;
Expand Down
5 changes: 4 additions & 1 deletion trunk/fs/ubifs/tnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ int ubifs_lookup_level0(struct ubifs_info *c, const union ubifs_key *key,
unsigned long time = get_seconds();

dbg_tnc("search key %s", DBGKEY(key));
ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);

znode = c->zroot.znode;
if (unlikely(!znode)) {
Expand Down Expand Up @@ -2966,7 +2967,7 @@ static struct ubifs_znode *right_znode(struct ubifs_info *c,
*
* This function searches an indexing node by its first key @key and its
* address @lnum:@offs. It looks up the indexing tree by pulling all indexing
* nodes it traverses to TNC. This function is called fro indexing nodes which
* nodes it traverses to TNC. This function is called for indexing nodes which
* were found on the media by scanning, for example when garbage-collecting or
* when doing in-the-gaps commit. This means that the indexing node which is
* looked for does not have to have exactly the same leftmost key @key, because
Expand All @@ -2988,6 +2989,8 @@ static struct ubifs_znode *lookup_znode(struct ubifs_info *c,
struct ubifs_znode *znode, *zn;
int n, nn;

ubifs_assert(key_type(c, key) < UBIFS_INVALID_KEY);

/*
* The arguments have probably been read off flash, so don't assume
* they are valid.
Expand Down
6 changes: 5 additions & 1 deletion trunk/fs/ubifs/ubifs.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@
* in TNC. However, when replaying, it is handy to introduce fake "truncation"
* keys for truncation nodes because the code becomes simpler. So we define
* %UBIFS_TRUN_KEY type.
*
* But otherwise, out of the journal reply scope, the truncation keys are
* invalid.
*/
#define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT
#define UBIFS_TRUN_KEY UBIFS_KEY_TYPES_CNT
#define UBIFS_INVALID_KEY UBIFS_KEY_TYPES_CNT

/*
* How much a directory entry/extended attribute entry adds to the parent/host
Expand Down

0 comments on commit 6f0cfcb

Please sign in to comment.