Skip to content

Commit e4803c3

Browse files
Estelle HammacheThomas Gleixner
authored andcommitted
[JFFS2] Fix write buffer retry case
Correction of retry case to avoid silent failure of rmdir when jffs2_wbuf_recover GCs the previous entry (+ corresponding dnode case). Signed-off-by: Estelle Hammache <estelle.hammache@st.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent ed3786a commit e4803c3

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

‎fs/jffs2/write.c‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* For licensing information, see the file 'LICENCE' in this directory.
99
*
10-
* $Id: write.c,v 1.87 2004/11/16 20:36:12 dwmw2 Exp $
10+
* $Id: write.c,v 1.88 2005/01/24 21:13:39 hammache Exp $
1111
*
1212
*/
1313

@@ -136,6 +136,21 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
136136
raw->__totlen = PAD(sizeof(*ri)+datalen);
137137
raw->next_phys = NULL;
138138

139+
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version))
140+
{
141+
if (! retried)
142+
{
143+
BUG();
144+
}
145+
else
146+
{
147+
D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, highest version %d -> updating dnode\n",
148+
je32_to_cpu(ri->version), f->highest_version));
149+
ri->version = cpu_to_je32(++f->highest_version);
150+
ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8));
151+
}
152+
}
153+
139154
ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen,
140155
(alloc_mode==ALLOC_GC)?0:f->inocache->ino);
141156

@@ -280,6 +295,22 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
280295
raw->__totlen = PAD(sizeof(*rd)+namelen);
281296
raw->next_phys = NULL;
282297

298+
if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version))
299+
{
300+
if (! retried)
301+
{
302+
BUG();
303+
}
304+
else
305+
{
306+
D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, highest version %d -> updating dirent\n",
307+
je32_to_cpu(rd->version), f->highest_version));
308+
rd->version = cpu_to_je32(++f->highest_version);
309+
fd->version = je32_to_cpu(rd->version);
310+
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
311+
}
312+
}
313+
283314
ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen,
284315
(alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino));
285316
if (ret || (retlen != sizeof(*rd) + namelen)) {

0 commit comments

Comments
 (0)