*
* For licensing information, see the file 'LICENCE' in this directory.
*
- * $Id: nodelist.c,v 1.111 2005/08/17 14:57:39 dedekind Exp $
+ * $Id: nodelist.c,v 1.115 2005/11/07 11:14:40 gleixner Exp $
*
*/
void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list)
{
struct jffs2_full_dirent **prev = list;
-
- JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino);
+
+ dbg_dentlist("add dirent \"%s\", ino #%u\n", new->name, new->ino);
while ((*prev) && (*prev)->nhash <= new->nhash) {
if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
/* Duplicate. Free one */
if (new->version < (*prev)->version) {
- JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
+ dbg_dentlist("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
(*prev)->name, (*prev)->ino);
jffs2_mark_node_obsolete(c, new->raw);
jffs2_free_full_dirent(new);
} else {
- JFFS2_DBG_DENTLIST("marking old dirent \"%s\", ino #%u bsolete\n",
+ dbg_dentlist("marking old dirent \"%s\", ino #%u bsolete\n",
(*prev)->name, (*prev)->ino);
new->next = (*prev)->next;
jffs2_mark_node_obsolete(c, ((*prev)->raw));
{
struct jffs2_node_frag *frag = jffs2_lookup_node_frag(list, size);
- JFFS2_DBG_FRAGTREE("truncating fragtree to 0x%08x bytes\n", size);
+ dbg_fragtree("truncating fragtree to 0x%08x bytes\n", size);
/* We know frag->ofs <= size. That's what lookup does for us */
if (frag && frag->ofs != size) {
if (size == 0)
return;
- /*
+ /*
* If the last fragment starts at the RAM page boundary, it is
* REF_PRISTINE irrespective of its size.
*/
frag = frag_last(list);
- if ((frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {
- JFFS2_DBG_FRAGTREE2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",
- frag->ofs, frag->ofs + frag->size);
+ if (frag->node && (frag->ofs & (PAGE_CACHE_SIZE - 1)) == 0) {
+ dbg_fragtree2("marking the last fragment 0x%08x-0x%08x REF_PRISTINE.\n",
+ frag->ofs, frag->ofs + frag->size);
frag->node->raw->flash_offset = ref_offset(frag->node->raw) | REF_PRISTINE;
}
}
this->node->frags--;
if (!this->node->frags) {
/* The node has no valid frags left. It's totally obsoleted */
- JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
+ dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size);
jffs2_mark_node_obsolete(c, this->node->raw);
jffs2_free_full_dnode(this->node);
} else {
- JFFS2_DBG_FRAGTREE2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n",
+ dbg_fragtree2("marking old node @0x%08x (0x%04x-0x%04x) REF_NORMAL. frags is %d\n",
ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size, this->node->frags);
mark_ref_normal(this->node->raw);
}
-
+
}
jffs2_free_node_frag(this);
}
struct rb_node *parent = &base->rb;
struct rb_node **link = &parent;
- JFFS2_DBG_FRAGTREE2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size);
+ dbg_fragtree2("insert frag (0x%04x-0x%04x)\n", newfrag->ofs, newfrag->ofs + newfrag->size);
while (*link) {
parent = *link;
base = rb_entry(parent, struct jffs2_node_frag, rb);
-
+
if (newfrag->ofs > base->ofs)
link = &base->rb.rb_right;
else if (newfrag->ofs < base->ofs)
static inline struct jffs2_node_frag * new_fragment(struct jffs2_full_dnode *fn, uint32_t ofs, uint32_t size)
{
struct jffs2_node_frag *newfrag;
-
+
newfrag = jffs2_alloc_node_frag();
if (likely(newfrag)) {
newfrag->ofs = ofs;
}
if (this) {
- /* By definition, the 'this' node has no right-hand child,
+ /* By definition, the 'this' node has no right-hand child,
because there are no frags with offset greater than it.
So that's where we want to put the hole */
- JFFS2_DBG_FRAGTREE2("add hole frag %#04x-%#04x on the right of the new frag.\n",
+ dbg_fragtree2("add hole frag %#04x-%#04x on the right of the new frag.\n",
holefrag->ofs, holefrag->ofs + holefrag->size);
rb_link_node(&holefrag->rb, &this->rb, &this->rb.rb_right);
} else {
- JFFS2_DBG_FRAGTREE2("Add hole frag %#04x-%#04x to the root of the tree.\n",
+ dbg_fragtree2("Add hole frag %#04x-%#04x to the root of the tree.\n",
holefrag->ofs, holefrag->ofs + holefrag->size);
rb_link_node(&holefrag->rb, NULL, &root->rb_node);
}
rb_insert_color(&holefrag->rb, root);
this = holefrag;
}
-
+
if (this) {
- /* By definition, the 'this' node has no right-hand child,
+ /* By definition, the 'this' node has no right-hand child,
because there are no frags with offset greater than it.
So that's where we want to put new fragment */
- JFFS2_DBG_FRAGTREE2("add the new node at the right\n");
- rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
+ dbg_fragtree2("add the new node at the right\n");
+ rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
} else {
- JFFS2_DBG_FRAGTREE2("insert the new node at the root of the tree\n");
+ dbg_fragtree2("insert the new node at the root of the tree\n");
rb_link_node(&newfrag->rb, NULL, &root->rb_node);
}
rb_insert_color(&newfrag->rb, root);
this = jffs2_lookup_node_frag(root, newfrag->node->ofs);
if (this) {
- JFFS2_DBG_FRAGTREE2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
+ dbg_fragtree2("lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
this->ofs, this->ofs+this->size, this->node?(ref_offset(this->node->raw)):0xffffffff, this);
lastend = this->ofs + this->size;
} else {
- JFFS2_DBG_FRAGTREE2("lookup gave no frag\n");
+ dbg_fragtree2("lookup gave no frag\n");
lastend = 0;
}
-
+
/* See if we ran off the end of the fragtree */
if (lastend <= newfrag->ofs) {
/* We did */
}
if (this->node)
- JFFS2_DBG_FRAGTREE2("dealing with frag %u-%u, phys %#08x(%d).\n",
+ dbg_fragtree2("dealing with frag %u-%u, phys %#08x(%d).\n",
this->ofs, this->ofs + this->size,
ref_offset(this->node->raw), ref_flags(this->node->raw));
else
- JFFS2_DBG_FRAGTREE2("dealing with hole frag %u-%u.\n",
+ dbg_fragtree2("dealing with hole frag %u-%u.\n",
this->ofs, this->ofs + this->size);
/* OK. 'this' is pointing at the first frag that newfrag->ofs at least partially obsoletes,
- * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs
+ * - i.e. newfrag->ofs < this->ofs+this->size && newfrag->ofs >= this->ofs
*/
if (newfrag->ofs > this->ofs) {
/* This node isn't completely obsoleted. The start of it remains valid */
struct jffs2_node_frag *newfrag2;
if (this->node)
- JFFS2_DBG_FRAGTREE2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",
+ dbg_fragtree2("split old frag 0x%04x-0x%04x, phys 0x%08x\n",
this->ofs, this->ofs+this->size, ref_offset(this->node->raw));
- else
- JFFS2_DBG_FRAGTREE2("split old hole frag 0x%04x-0x%04x\n",
+ else
+ dbg_fragtree2("split old hole frag 0x%04x-0x%04x\n",
this->ofs, this->ofs+this->size);
-
+
/* New second frag pointing to this's node */
newfrag2 = new_fragment(this->node, newfrag->ofs + newfrag->size,
this->ofs + this->size - newfrag->ofs - newfrag->size);
from newfrag to insert newfrag2. */
jffs2_fragtree_insert(newfrag, this);
rb_insert_color(&newfrag->rb, root);
-
+
jffs2_fragtree_insert(newfrag2, newfrag);
rb_insert_color(&newfrag2->rb, root);
-
+
return 0;
}
/* New node just reduces 'this' frag in size, doesn't split it */
jffs2_fragtree_insert(newfrag, this);
rb_insert_color(&newfrag->rb, root);
} else {
- /* New frag starts at the same point as 'this' used to. Replace
+ /* New frag starts at the same point as 'this' used to. Replace
it in the tree without doing a delete and insertion */
- JFFS2_DBG_FRAGTREE2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",
+ dbg_fragtree2("inserting newfrag (*%p),%d-%d in before 'this' (*%p),%d-%d\n",
newfrag, newfrag->ofs, newfrag->ofs+newfrag->size, this, this->ofs, this->ofs+this->size);
-
+
rb_replace_node(&this->rb, &newfrag->rb, root);
-
+
if (newfrag->ofs + newfrag->size >= this->ofs+this->size) {
- JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);
+ dbg_fragtree2("obsoleting node frag %p (%x-%x)\n", this, this->ofs, this->ofs+this->size);
jffs2_obsolete_node_frag(c, this);
} else {
this->ofs += newfrag->size;
}
}
/* OK, now we have newfrag added in the correct place in the tree, but
- frag_next(newfrag) may be a fragment which is overlapped by it
+ frag_next(newfrag) may be a fragment which is overlapped by it
*/
while ((this = frag_next(newfrag)) && newfrag->ofs + newfrag->size >= this->ofs + this->size) {
/* 'this' frag is obsoleted completely. */
- JFFS2_DBG_FRAGTREE2("obsoleting node frag %p (%x-%x) and removing from tree\n",
+ dbg_fragtree2("obsoleting node frag %p (%x-%x) and removing from tree\n",
this, this->ofs, this->ofs+this->size);
rb_erase(&this->rb, root);
jffs2_obsolete_node_frag(c, this);
}
- /* Now we're pointing at the first frag which isn't totally obsoleted by
+ /* Now we're pointing at the first frag which isn't totally obsoleted by
the new frag */
if (!this || newfrag->ofs + newfrag->size == this->ofs)
return 0;
}
-/*
+/*
* Given an inode, probably with existing tree of fragments, add the new node
* to the fragment tree.
*/
return -ENOMEM;
newfrag->node->frags = 1;
- JFFS2_DBG_FRAGTREE("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",
+ dbg_fragtree("adding node %#04x-%#04x @0x%08x on flash, newfrag *%p\n",
fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag);
-
+
ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);
if (unlikely(ret))
return ret;
struct jffs2_node_frag *prev = frag_prev(newfrag);
mark_ref_normal(fn->raw);
- /* If we don't start at zero there's _always_ a previous */
+ /* If we don't start at zero there's _always_ a previous */
if (prev->node)
mark_ref_normal(prev->node->raw);
}
if ((newfrag->ofs+newfrag->size) & (PAGE_CACHE_SIZE-1)) {
struct jffs2_node_frag *next = frag_next(newfrag);
-
+
if (next) {
mark_ref_normal(fn->raw);
if (next->node)
BUG_ON(tn->csize == 0);
+ if (!jffs2_is_writebuffered(c))
+ goto adj_acc;
+
/* Calculate how many bytes were already checked */
ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
- len = ofs & (c->wbuf_pagesize - 1);
+ len = ofs % c->wbuf_pagesize;
if (likely(len))
len = c->wbuf_pagesize - len;
if (len >= tn->csize) {
- JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
+ dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
ref_offset(ref), tn->csize, ofs);
goto adj_acc;
}
-
+
ofs += len;
len = tn->csize - len;
-
- JFFS2_DBG_READINODE("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",
+
+ dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n",
ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len);
-
+
#ifndef __ECOS
/* TODO: instead, incapsulate point() stuff to jffs2_flash_read(),
* adding and jffs2_flash_read_end() interface. */
pointed = 1; /* succefully pointed to device */
}
#endif
-
+
if (!pointed) {
buffer = kmalloc(len, GFP_KERNEL);
if (unlikely(!buffer))
return -ENOMEM;
-
+
/* TODO: this is very frequent pattern, make it a separate
* routine */
err = jffs2_flash_read(c, ofs, len, &retlen, buffer);
JFFS2_ERROR("can not read %d bytes from 0x%08x, error code: %d.\n", len, ofs, err);
goto free_out;
}
-
+
if (retlen != len) {
JFFS2_ERROR("short read at %#08x: %d instead of %d.\n", ofs, retlen, len);
err = -EIO;
jeb = &c->blocks[ref->flash_offset / c->sector_size];
len = ref_totlen(c, jeb, ref);
- /*
+ /*
* Mark the node as having been checked and fix the
* accounting accordingly.
*/
static inline int check_node(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_tmp_dnode_info *tn)
{
int ret;
-
+
BUG_ON(ref_obsolete(tn->fn->raw));
/* We only check the data CRC of unchecked nodes */
if (ref_flags(tn->fn->raw) != REF_UNCHECKED)
return 0;
-
- JFFS2_DBG_FRAGTREE2("check node %#04x-%#04x, phys offs %#08x.\n",
+
+ dbg_fragtree2("check node %#04x-%#04x, phys offs %#08x.\n",
tn->fn->ofs, tn->fn->ofs + tn->fn->size, ref_offset(tn->fn->raw));
ret = check_node_data(c, tn);
JFFS2_ERROR("check_node_data() returned error: %d.\n",
ret);
} else if (unlikely(ret > 0)) {
- JFFS2_DBG_FRAGTREE2("CRC error, mark it obsolete.\n");
+ dbg_fragtree2("CRC error, mark it obsolete.\n");
jffs2_mark_node_obsolete(c, tn->fn->raw);
}
return ret;
}
-/*
+/*
* Helper function for jffs2_add_older_frag_to_fragtree().
*
* Called when the new fragment that is being inserted
static int split_hole(struct jffs2_sb_info *c, struct rb_root *root,
struct jffs2_node_frag *newfrag, struct jffs2_node_frag *hole)
{
- JFFS2_DBG_FRAGTREE2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n",
+ dbg_fragtree2("fragment %#04x-%#04x splits the hole %#04x-%#04x\n",
newfrag->ofs, newfrag->ofs + newfrag->size, hole->ofs, hole->ofs + hole->size);
if (hole->ofs == newfrag->ofs) {
- /*
+ /*
* Well, the new fragment actually starts at the same offset as
* the hole.
*/
if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) {
- /*
+ /*
* We replace the overlapped left part of the hole by
* the new node.
*/
-
- JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and cut the left part of the hole\n",
+
+ dbg_fragtree2("insert fragment %#04x-%#04x and cut the left part of the hole\n",
newfrag->ofs, newfrag->ofs + newfrag->size);
rb_replace_node(&hole->rb, &newfrag->rb, root);
-
+
hole->ofs += newfrag->size;
hole->size -= newfrag->size;
-
- /*
+
+ /*
* We know that 'hole' should be the right hand
* fragment.
*/
jffs2_fragtree_insert(hole, newfrag);
rb_insert_color(&hole->rb, root);
} else {
- /*
+ /*
* Ah, the new fragment is of the same size as the hole.
* Relace the hole by it.
*/
- JFFS2_DBG_FRAGTREE2("insert fragment %#04x-%#04x and overwrite hole\n",
+ dbg_fragtree2("insert fragment %#04x-%#04x and overwrite hole\n",
newfrag->ofs, newfrag->ofs + newfrag->size);
rb_replace_node(&hole->rb, &newfrag->rb, root);
jffs2_free_node_frag(hole);
}
} else {
/* The new fragment lefts some hole space at the left */
-
+
struct jffs2_node_frag * newfrag2 = NULL;
if (hole->ofs + hole->size > newfrag->ofs + newfrag->size) {
}
hole->size = newfrag->ofs - hole->ofs;
- JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n",
+ dbg_fragtree2("left the hole %#04x-%#04x at the left and inserd fragment %#04x-%#04x\n",
hole->ofs, hole->ofs + hole->size, newfrag->ofs, newfrag->ofs + newfrag->size);
jffs2_fragtree_insert(newfrag, hole);
rb_insert_color(&newfrag->rb, root);
-
+
if (newfrag2) {
- JFFS2_DBG_FRAGTREE2("left the hole %#04x-%#04x at the right\n",
+ dbg_fragtree2("left the hole %#04x-%#04x at the right\n",
newfrag2->ofs, newfrag2->ofs + newfrag2->size);
jffs2_fragtree_insert(newfrag2, newfrag);
rb_insert_color(&newfrag2->rb, root);
int err, checked = 0;
int ref_flag;
- JFFS2_DBG_FRAGTREE("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version);
+ dbg_fragtree("insert fragment %#04x-%#04x, ver %u\n", fn_ofs, fn_ofs + fn_size, tn->version);
/* Skip all the nodes which are completed before this one starts */
this = jffs2_lookup_node_frag(root, fn_ofs);
if (this)
- JFFS2_DBG_FRAGTREE2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole");
+ dbg_fragtree2("'this' found %#04x-%#04x (%s)\n", this->ofs, this->ofs + this->size, this->node ? "data" : "hole");
if (this)
lastend = this->ofs + this->size;
else
lastend = 0;
-
+
/* Detect the preliminary type of node */
if (fn->size >= PAGE_CACHE_SIZE)
ref_flag = REF_PRISTINE;
else
ref_flag = REF_NORMAL;
-
+
/* See if we ran off the end of the root */
if (lastend <= fn_ofs) {
/* We did */
-
- /*
+
+ /*
* We are going to insert the new node into the
* fragment tree, so check it.
*/
fn->frags = 0;
while (1) {
- /*
+ /*
* Here we have:
* fn_ofs < this->ofs + this->size && fn_ofs >= this->ofs.
- *
+ *
* Remember, 'this' has higher version, any non-hole node
* which is already in the fragtree is newer then the newly
* inserted.
*/
if (!this->node) {
- /*
+ /*
* 'this' is the hole fragment, so at least the
* beginning of the new fragment is valid.
*/
-
- /*
+
+ /*
* We are going to insert the new node into the
* fragment tree, so check it.
*/
return err;
checked = 1;
}
-
+
if (this->ofs + this->size >= fn_ofs + fn_size) {
/* We split the hole on two parts */
goto out_ok;
}
- /*
+ /*
* The beginning of the new fragment is valid since it
* overlaps the hole node.
*/
this->ofs + this->size - fn_ofs);
if (unlikely(!newfrag))
return -ENOMEM;
-
+
if (fn_ofs == this->ofs) {
- /*
+ /*
* The new node starts at the same offset as
* the hole and supersieds the hole.
*/
- JFFS2_DBG_FRAGTREE2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n",
+ dbg_fragtree2("add the new fragment instead of hole %#04x-%#04x, refcnt %d\n",
fn_ofs, fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
rb_replace_node(&this->rb, &newfrag->rb, root);
jffs2_free_node_frag(this);
} else {
- /*
+ /*
* The hole becomes shorter as its right part
* is supersieded by the new fragment.
*/
- JFFS2_DBG_FRAGTREE2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",
+ dbg_fragtree2("reduce size of hole %#04x-%#04x to %#04x-%#04x\n",
this->ofs, this->ofs + this->size, this->ofs, this->ofs + this->size - newfrag->size);
-
- JFFS2_DBG_FRAGTREE2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,
+
+ dbg_fragtree2("add new fragment %#04x-%#04x, refcnt %d\n", fn_ofs,
fn_ofs + this->ofs + this->size - fn_ofs, fn->frags);
-
+
this->size -= newfrag->size;
jffs2_fragtree_insert(newfrag, this);
rb_insert_color(&newfrag->rb, root);
}
-
+
fn_ofs += newfrag->size;
fn_size -= newfrag->size;
this = rb_entry(rb_next(&newfrag->rb),
struct jffs2_node_frag, rb);
- JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
+ dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
}
- /*
+ /*
* 'This' node is not the hole so it obsoletes the new fragment
* either fully or partially.
*/
if (this->ofs + this->size >= fn_ofs + fn_size) {
/* The new node is obsolete, drop it */
if (fn->frags == 0) {
- JFFS2_DBG_FRAGTREE2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size);
+ dbg_fragtree2("%#04x-%#04x is obsolete, mark it obsolete\n", fn_ofs, fn_ofs + fn_size);
ref_flag = REF_OBSOLETE;
}
goto out_ok;
} else {
struct jffs2_node_frag *new_this;
-
+
/* 'This' node obsoletes the beginning of the new node */
- JFFS2_DBG_FRAGTREE2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);
+ dbg_fragtree2("the beginning %#04x-%#04x is obsolete\n", fn_ofs, this->ofs + this->size);
ref_flag = REF_NORMAL;
-
+
fn_size -= this->ofs + this->size - fn_ofs;
fn_ofs = this->ofs + this->size;
- JFFS2_DBG_FRAGTREE2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);
-
+ dbg_fragtree2("now considering %#04x-%#04x\n", fn_ofs, fn_ofs + fn_size);
+
new_this = rb_entry(rb_next(&this->rb), struct jffs2_node_frag, rb);
if (!new_this) {
- /*
+ /*
* There is no next fragment. Add the rest of
* the new node as the right-hand child.
*/
return err;
checked = 1;
}
-
+
fn->frags += 1;
newfrag = new_fragment(fn, fn_ofs, fn_size);
if (unlikely(!newfrag))
return -ENOMEM;
- JFFS2_DBG_FRAGTREE2("there are no more fragments, insert %#04x-%#04x\n",
+ dbg_fragtree2("there are no more fragments, insert %#04x-%#04x\n",
newfrag->ofs, newfrag->ofs + newfrag->size);
- rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
+ rb_link_node(&newfrag->rb, &this->rb, &this->rb.rb_right);
rb_insert_color(&newfrag->rb, root);
goto out_ok;
} else {
this = new_this;
- JFFS2_DBG_FRAGTREE2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
+ dbg_fragtree2("switch to the next 'this' fragment: %#04x-%#04x %s\n",
this->ofs, this->ofs + this->size, this->node ? "(data)" : "(hole)");
}
}
BUG_ON(fn->size < PAGE_CACHE_SIZE && ref_flag == REF_PRISTINE);
if (ref_flag == REF_OBSOLETE) {
- JFFS2_DBG_FRAGTREE2("the node is obsolete now\n");
+ dbg_fragtree2("the node is obsolete now\n");
/* jffs2_mark_node_obsolete() will adjust space accounting */
jffs2_mark_node_obsolete(c, fn->raw);
return 1;
}
- JFFS2_DBG_FRAGTREE2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE");
+ dbg_fragtree2("the node is \"%s\" now\n", ref_flag == REF_NORMAL ? "REF_NORMAL" : "REF_PRISTINE");
/* Space accounting was adjusted at check_node_data() */
spin_lock(&c->erase_completion_lock);
/* During mount, this needs no locking. During normal operation, its
callers want to do other stuff while still holding the inocache_lock.
- Rather than introducing special case get_ino_cache functions or
+ Rather than introducing special case get_ino_cache functions or
callbacks, we just let the caller do the locking itself. */
-
+
struct jffs2_inode_cache *jffs2_get_ino_cache(struct jffs2_sb_info *c, uint32_t ino)
{
struct jffs2_inode_cache *ret;
while (ret && ret->ino < ino) {
ret = ret->next;
}
-
+
if (ret && ret->ino != ino)
ret = NULL;
if (!new->ino)
new->ino = ++c->highest_ino;
- JFFS2_DBG_INOCACHE("add %p (ino #%u)\n", new, new->ino);
+ dbg_inocache("add %p (ino #%u)\n", new, new->ino);
prev = &c->inocache_list[new->ino % INOCACHE_HASHSIZE];
{
struct jffs2_inode_cache **prev;
- JFFS2_DBG_INOCACHE("del %p (ino #%u)\n", old, old->ino);
+ dbg_inocache("del %p (ino #%u)\n", old, old->ino);
spin_lock(&c->inocache_lock);
-
+
prev = &c->inocache_list[old->ino % INOCACHE_HASHSIZE];
-
+
while ((*prev) && (*prev)->ino < old->ino) {
prev = &(*prev)->next;
}
/* Free it now unless it's in READING or CLEARING state, which
are the transitions upon read_inode() and clear_inode(). The
- rest of the time we know nobody else is looking at it, and
+ rest of the time we know nobody else is looking at it, and
if it's held by read_inode() or clear_inode() they'll free it
for themselves. */
if (old->state != INO_STATE_READING && old->state != INO_STATE_CLEARING)
{
int i;
struct jffs2_inode_cache *this, *next;
-
+
for (i=0; i<INOCACHE_HASHSIZE; i++) {
this = c->inocache_list[i];
while (this) {
c->blocks[i].first_node = c->blocks[i].last_node = NULL;
}
}
-
+
struct jffs2_node_frag *jffs2_lookup_node_frag(struct rb_root *fragtree, uint32_t offset)
{
- /* The common case in lookup is that there will be a node
+ /* The common case in lookup is that there will be a node
which precisely matches. So we go looking for that first */
struct rb_node *next;
struct jffs2_node_frag *prev = NULL;
struct jffs2_node_frag *frag = NULL;
- JFFS2_DBG_FRAGTREE2("root %p, offset %d\n", fragtree, offset);
+ dbg_fragtree2("root %p, offset %d\n", fragtree, offset);
next = fragtree->rb_node;
and return the closest smaller one */
if (prev)
- JFFS2_DBG_FRAGTREE2("no match. Returning frag %#04x-%#04x, closest previous\n",
+ dbg_fragtree2("no match. Returning frag %#04x-%#04x, closest previous\n",
prev->ofs, prev->ofs+prev->size);
- else
- JFFS2_DBG_FRAGTREE2("returning NULL, empty fragtree\n");
-
+ else
+ dbg_fragtree2("returning NULL, empty fragtree\n");
+
return prev;
}
if (!root->rb_node)
return;
- JFFS2_DBG_FRAGTREE("killing\n");
-
+ dbg_fragtree("killing\n");
+
frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
while(frag) {
if (frag->rb.rb_left) {
}
if (frag->node && !(--frag->node->frags)) {
- /* Not a hole, and it's the final remaining frag
+ /* Not a hole, and it's the final remaining frag
of this node. Free the node */
if (c)
jffs2_mark_node_obsolete(c, frag->node->raw);
-
+
jffs2_free_full_dnode(frag->node);
}
parent = frag_parent(frag);
if (parent) {
if (frag_left(parent) == frag)
parent->rb.rb_left = NULL;
- else
+ else
parent->rb.rb_right = NULL;
}