mtd/fs/jffs2 gc.c,1.138,1.139 write.c,1.85,1.86
Artem Bityuckiy
dedekind at infradead.org
Sat Nov 13 05:44:29 EST 2004
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv14839
Modified Files:
gc.c write.c
Log Message:
Fix potential race when the newly created node_ref is added to the
node_ref list. When the node is first accessed, the first node_ref in the
list might be obsolete and be located in the block being erased. So, we
need to hold spinlock if we insert the new node_ref to the list.
Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -r1.138 -r1.139
--- gc.c 13 Nov 2004 09:51:12 -0000 1.138
+++ gc.c 13 Nov 2004 10:44:26 -0000 1.139
@@ -639,8 +639,10 @@
state being INO_STATE_GC. Note that if we're doing this
for an inode which is in-core, the 'nraw' pointer is then
going to be fetched from ic->nodes by our caller. */
+ spin_lock(&c->erase_completion_lock);
nraw->next_in_ino = ic->nodes;
ic->nodes = nraw;
+ spin_unlock(&c->erase_completion_lock);
jffs2_mark_node_obsolete(c, raw);
D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw)));
Index: write.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/write.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -r1.85 -r1.86
--- write.c 13 Jul 2004 08:58:25 -0000 1.85
+++ write.c 13 Nov 2004 10:44:26 -0000 1.86
@@ -213,8 +213,10 @@
jffs2_add_physical_node_ref(c, raw);
/* Link into per-inode list */
+ spin_lock(&c->erase_completion_lock);
raw->next_in_ino = f->inocache->nodes;
f->inocache->nodes = raw;
+ spin_unlock(&c->erase_completion_lock);
D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n",
flash_ofs, ref_flags(raw), je32_to_cpu(ri->dsize),
@@ -333,8 +335,10 @@
raw->flash_offset |= REF_PRISTINE;
jffs2_add_physical_node_ref(c, raw);
+ spin_lock(&c->erase_completion_lock);
raw->next_in_ino = f->inocache->nodes;
f->inocache->nodes = raw;
+ spin_unlock(&c->erase_completion_lock);
if (retried) {
ACCT_SANITY_CHECK(c,NULL);
More information about the linux-mtd-cvs
mailing list