mtd/fs/jffs2 nodelist.c,1.67,1.68
David Woodhouse
dwmw2 at infradead.org
Fri Jan 10 10:59:48 EST 2003
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv18185
Modified Files:
nodelist.c
Log Message:
Fix lack of locking when updating accounting info after checking
crc32 on data nodes. Mark some REF_PRISTINE too.
Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- nodelist.c 9 Jan 2003 17:16:49 -0000 1.67
+++ nodelist.c 10 Jan 2003 15:59:46 -0000 1.68
@@ -19,6 +19,7 @@
#include <linux/rbtree.h>
#include <linux/crc32.h>
#include <linux/slab.h>
+#include <linux/pagemap.h>
#include "nodelist.h"
void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new, struct jffs2_full_dirent **list)
@@ -298,13 +299,30 @@
}
/* Mark the node as having been checked and fix the accounting accordingly */
+ spin_lock_bh(&c->erase_completion_lock);
jeb = &c->blocks[ref->flash_offset / c->sector_size];
jeb->used_size += ref->totlen;
jeb->unchecked_size -= ref->totlen;
c->used_size += ref->totlen;
c->unchecked_size -= ref->totlen;
- mark_ref_normal(ref);
+ /* If node covers at least a whole page, or if it starts at the
+ beginning of a page and runs to the end of the file, or if
+ it's a hole node, mark it REF_PRISTINE, else REF_NORMAL.
+
+ If it's actually overlapped, it'll get made NORMAL (or OBSOLETE)
+ when the overlapping node(s) get added to the tree anyway.
+ */
+ if ((je32_to_cpu(node.i.dsize) >= PAGE_CACHE_SIZE) ||
+ ( ((je32_to_cpu(node.i.offset)&(PAGE_CACHE_SIZE-1))==0) &&
+ (je32_to_cpu(node.i.dsize)+je32_to_cpu(node.i.offset) == je32_to_cpu(node.i.isize)))) {
+ D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_PRISTINE\n", ref_offset(ref)));
+ ref->flash_offset = ref_offset(ref) | REF_PRISTINE;
+ } else {
+ D1(printk(KERN_DEBUG "Marking node at 0x%08x REF_NORMAL\n", ref_offset(ref)));
+ ref->flash_offset = ref_offset(ref) | REF_NORMAL;
+ }
+ spin_unlock_bh(&c->erase_completion_lock);
}
tn = jffs2_alloc_tmp_dnode_info();
More information about the linux-mtd-cvs
mailing list