Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 116197
b: refs/heads/master
c: 2242c68
h: refs/heads/master
i:
  116195: 2ca1983
v: v3
  • Loading branch information
Adrian Hunter authored and Artem Bityutskiy committed Sep 30, 2008
1 parent 09df246 commit 9fa320c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 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: 2953e73f1ce4b3284b409aefb9d46bbde6515c37
refs/heads/master: 2242c689ecc390fb4719f595751351d1ecc5c409
54 changes: 33 additions & 21 deletions trunk/fs/ubifs/tnc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
{
struct ubifs_znode *zn, *zi, *zp;
int i, keep, move, appending = 0;
union ubifs_key *key = &zbr->key;
union ubifs_key *key = &zbr->key, *key1;

ubifs_assert(n >= 0 && n <= c->fanout);

Expand Down Expand Up @@ -2003,20 +2003,33 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
zn->level = znode->level;

/* Decide where to split */
if (znode->level == 0 && n == c->fanout &&
key_type(c, key) == UBIFS_DATA_KEY) {
union ubifs_key *key1;

/*
* If this is an inode which is being appended - do not split
* it because no other zbranches can be inserted between
* zbranches of consecutive data nodes anyway.
*/
key1 = &znode->zbranch[n - 1].key;
if (key_inum(c, key1) == key_inum(c, key) &&
key_type(c, key1) == UBIFS_DATA_KEY &&
key_block(c, key1) == key_block(c, key) - 1)
appending = 1;
if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) {
/* Try not to split consecutive data keys */
if (n == c->fanout) {
key1 = &znode->zbranch[n - 1].key;
if (key_inum(c, key1) == key_inum(c, key) &&
key_type(c, key1) == UBIFS_DATA_KEY)
appending = 1;
} else
goto check_split;
} else if (appending && n != c->fanout) {
/* Try not to split consecutive data keys */
appending = 0;
check_split:
if (n >= (c->fanout + 1) / 2) {
key1 = &znode->zbranch[0].key;
if (key_inum(c, key1) == key_inum(c, key) &&
key_type(c, key1) == UBIFS_DATA_KEY) {
key1 = &znode->zbranch[n].key;
if (key_inum(c, key1) != key_inum(c, key) ||
key_type(c, key1) != UBIFS_DATA_KEY) {
keep = n;
move = c->fanout - keep;
zi = znode;
goto do_split;
}
}
}
}

if (appending) {
Expand Down Expand Up @@ -2046,6 +2059,8 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
zbr->znode->parent = zn;
}

do_split:

__set_bit(DIRTY_ZNODE, &zn->flags);
atomic_long_inc(&c->dirty_zn_cnt);

Expand All @@ -2072,14 +2087,11 @@ static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,

/* Insert new znode (produced by spitting) into the parent */
if (zp) {
i = n;
if (n == 0 && zi == znode && znode->iip == 0)
correct_parent_keys(c, znode);

/* Locate insertion point */
n = znode->iip + 1;
if (appending && n != c->fanout)
appending = 0;

if (i == 0 && zi == znode && znode->iip == 0)
correct_parent_keys(c, znode);

/* Tail recursion */
zbr->key = zn->zbranch[0].key;
Expand Down

0 comments on commit 9fa320c

Please sign in to comment.