mtd/fs/jffs2 readinode.c,1.99,1.100
David Woodhouse
dwmw2 at infradead.org
Sat Jan 18 16:10:16 EST 2003
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv2895
Modified Files:
readinode.c
Log Message:
Change jffs2_add_full_dnode_to_fragtree() to jffs2_add_frag_to_fragtree().
Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- readinode.c 18 Jan 2003 20:12:19 -0000 1.99
+++ readinode.c 18 Jan 2003 21:10:14 -0000 1.100
@@ -21,9 +21,10 @@
#include <linux/compiler.h>
#include "nodelist.h"
-static int jffs2_add_full_dnode_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_full_dnode *fn);
+static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag);
-D1(static void jffs2_print_fragtree(struct rb_root *list, int permitbug)
+#if CONFIG_JFFS2_FS_DEBUG >= 1
+static void jffs2_print_fragtree(struct rb_root *list, int permitbug)
{
struct jffs2_node_frag *this = frag_first(list);
uint32_t lastofs = 0;
@@ -46,31 +47,17 @@
printk(KERN_CRIT "Frag tree got a hole in it\n");
BUG();
}
-})
+}
-D1(void jffs2_print_frag_list(struct jffs2_inode_info *f)
+void jffs2_print_frag_list(struct jffs2_inode_info *f)
{
jffs2_print_fragtree(&f->fragtree, 0);
if (f->metadata) {
printk(KERN_DEBUG "metadata at 0x%08x\n", ref_offset(f->metadata->raw));
}
-})
-
-
-/* Given an inode, probably with existing list of fragments, add the new node
- * to the fragment list.
- */
-int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn)
-{
- int ret;
- D1(printk(KERN_DEBUG "jffs2_add_full_dnode_to_inode(ino #%u, f %p, fn %p)\n", f->inocache->ino, f, fn));
-
- ret = jffs2_add_full_dnode_to_fragtree(c, &f->fragtree, fn);
-
- D2(jffs2_print_frag_list(f));
- return ret;
}
+#endif /* D1 */
static void jffs2_obsolete_node_frag(struct jffs2_sb_info *c, struct jffs2_node_frag *this)
{
@@ -93,26 +80,24 @@
jffs2_free_node_frag(this);
}
-/* Doesn't set inode->i_size */
-static int jffs2_add_full_dnode_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_full_dnode *fn)
+/* Given an inode, probably with existing list of fragments, add the new node
+ * to the fragment list.
+ */
+int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, struct jffs2_full_dnode *fn)
{
- struct jffs2_node_frag *this;
+ int ret;
struct jffs2_node_frag *newfrag;
- uint32_t lastend;
+
+ D1(printk(KERN_DEBUG "jffs2_add_full_dnode_to_inode(ino #%u, f %p, fn %p)\n", f->inocache->ino, f, fn));
newfrag = jffs2_alloc_node_frag();
if (unlikely(!newfrag))
return -ENOMEM;
- if (unlikely(!fn->raw)) {
- printk(KERN_WARNING "dwmw2 is stupid. j_a_f_d_t_f should never happen with ->raw == NULL\n");
- BUG();
- }
-
D2(printk(KERN_DEBUG "adding node %04x-%04x @0x%08x on flash, newfrag *%p\n",
fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag));
- if (!fn->size) {
+ if (unlikely(!fn->size)) {
jffs2_free_node_frag(newfrag);
return 0;
}
@@ -122,8 +107,22 @@
newfrag->node = fn;
newfrag->node->frags = 1;
+ ret = jffs2_add_frag_to_fragtree(c, &f->fragtree, newfrag);
+ if (ret)
+ return ret;
+
+ D2(jffs2_print_frag_list(f));
+ return 0;
+}
+
+/* Doesn't set inode->i_size */
+static int jffs2_add_frag_to_fragtree(struct jffs2_sb_info *c, struct rb_root *list, struct jffs2_node_frag *newfrag)
+{
+ struct jffs2_node_frag *this;
+ uint32_t lastend;
+
/* Skip all the nodes which are completed before this one starts */
- this = jffs2_lookup_node_frag(list, fn->ofs);
+ this = jffs2_lookup_node_frag(list, newfrag->node->ofs);
if (this) {
D2(printk(KERN_DEBUG "j_a_f_d_t_f: Lookup gave frag 0x%04x-0x%04x; phys 0x%08x (*%p)\n",
@@ -145,16 +144,16 @@
if ((lastend-1) >> PAGE_CACHE_SHIFT == newfrag->ofs >> PAGE_CACHE_SHIFT) {
if (this->node)
mark_ref_normal(this->node->raw);
- mark_ref_normal(fn->raw);
+ mark_ref_normal(newfrag->node->raw);
}
- if (lastend < fn->ofs) {
+ if (lastend < newfrag->node->ofs) {
/* ... and we need to put a hole in before the new node */
struct jffs2_node_frag *holefrag = jffs2_alloc_node_frag();
if (!holefrag)
return -ENOMEM;
holefrag->ofs = lastend;
- holefrag->size = fn->ofs - lastend;
+ holefrag->size = newfrag->node->ofs - lastend;
holefrag->node = NULL;
if (this) {
/* By definition, the 'this' node has no right-hand child,
@@ -192,9 +191,9 @@
if (newfrag->ofs > this->ofs) {
/* This node isn't completely obsoleted. The start of it remains valid */
- /* Mark the new node and the partially covered node REF_NORMAL -- let
+ /* Mark the new node and the partially covered node REF_NORMAL -- let
the GC take a look at them */
- mark_ref_normal(fn->raw);
+ mark_ref_normal(newfrag->node->raw);
if (this->node)
mark_ref_normal(this->node->raw);
@@ -285,7 +284,7 @@
/* And mark them REF_NORMAL so the GC takes a look at them */
if (this->node)
mark_ref_normal(this->node->raw);
- mark_ref_normal(fn->raw);
+ mark_ref_normal(newfrag->node->raw);
return 0;
}
@@ -330,7 +329,7 @@
D2(printk(KERN_DEBUG "jffs2_do_read_inode(): getting inocache\n"));
-retry_inocache:
+ retry_inocache:
spin_lock(&c->inocache_lock);
f->inocache = jffs2_get_ino_cache(c, ino);
More information about the linux-mtd-cvs
mailing list