diff options
Diffstat (limited to 'fs/jffs2/write.c')
-rw-r--r-- | fs/jffs2/write.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 80a5db542629..69100615d9ae 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: write.c,v 1.87 2004/11/16 20:36:12 dwmw2 Exp $ | 10 | * $Id: write.c,v 1.92 2005/04/13 13:22:35 dwmw2 Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
@@ -35,13 +35,12 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, uint | |||
35 | f->inocache = ic; | 35 | f->inocache = ic; |
36 | f->inocache->nlink = 1; | 36 | f->inocache->nlink = 1; |
37 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; | 37 | f->inocache->nodes = (struct jffs2_raw_node_ref *)f->inocache; |
38 | f->inocache->ino = ++c->highest_ino; | ||
39 | f->inocache->state = INO_STATE_PRESENT; | 38 | f->inocache->state = INO_STATE_PRESENT; |
40 | 39 | ||
41 | ri->ino = cpu_to_je32(f->inocache->ino); | ||
42 | 40 | ||
43 | D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); | ||
44 | jffs2_add_ino_cache(c, f->inocache); | 41 | jffs2_add_ino_cache(c, f->inocache); |
42 | D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); | ||
43 | ri->ino = cpu_to_je32(f->inocache->ino); | ||
45 | 44 | ||
46 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 45 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
47 | ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); | 46 | ri->nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE); |
@@ -136,6 +135,15 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
136 | raw->__totlen = PAD(sizeof(*ri)+datalen); | 135 | raw->__totlen = PAD(sizeof(*ri)+datalen); |
137 | raw->next_phys = NULL; | 136 | raw->next_phys = NULL; |
138 | 137 | ||
138 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { | ||
139 | BUG_ON(!retried); | ||
140 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " | ||
141 | "highest version %d -> updating dnode\n", | ||
142 | je32_to_cpu(ri->version), f->highest_version)); | ||
143 | ri->version = cpu_to_je32(++f->highest_version); | ||
144 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | ||
145 | } | ||
146 | |||
139 | ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen, | 147 | ret = jffs2_flash_writev(c, vecs, cnt, flash_ofs, &retlen, |
140 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); | 148 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); |
141 | 149 | ||
@@ -280,6 +288,16 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
280 | raw->__totlen = PAD(sizeof(*rd)+namelen); | 288 | raw->__totlen = PAD(sizeof(*rd)+namelen); |
281 | raw->next_phys = NULL; | 289 | raw->next_phys = NULL; |
282 | 290 | ||
291 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { | ||
292 | BUG_ON(!retried); | ||
293 | D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " | ||
294 | "highest version %d -> updating dirent\n", | ||
295 | je32_to_cpu(rd->version), f->highest_version)); | ||
296 | rd->version = cpu_to_je32(++f->highest_version); | ||
297 | fd->version = je32_to_cpu(rd->version); | ||
298 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); | ||
299 | } | ||
300 | |||
283 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, | 301 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, |
284 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); | 302 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); |
285 | if (ret || (retlen != sizeof(*rd) + namelen)) { | 303 | if (ret || (retlen != sizeof(*rd) + namelen)) { |
@@ -625,20 +643,23 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
625 | 643 | ||
626 | down(&dead_f->sem); | 644 | down(&dead_f->sem); |
627 | 645 | ||
628 | while (dead_f->dents) { | 646 | if (S_ISDIR(OFNI_EDONI_2SFFJ(dead_f)->i_mode)) { |
629 | /* There can be only deleted ones */ | 647 | while (dead_f->dents) { |
630 | fd = dead_f->dents; | 648 | /* There can be only deleted ones */ |
631 | 649 | fd = dead_f->dents; | |
632 | dead_f->dents = fd->next; | 650 | |
633 | 651 | dead_f->dents = fd->next; | |
634 | if (fd->ino) { | 652 | |
635 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", | 653 | if (fd->ino) { |
636 | dead_f->inocache->ino, fd->name, fd->ino); | 654 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", |
637 | } else { | 655 | dead_f->inocache->ino, fd->name, fd->ino); |
638 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", fd->name, dead_f->inocache->ino)); | 656 | } else { |
657 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", | ||
658 | fd->name, dead_f->inocache->ino)); | ||
659 | } | ||
660 | jffs2_mark_node_obsolete(c, fd->raw); | ||
661 | jffs2_free_full_dirent(fd); | ||
639 | } | 662 | } |
640 | jffs2_mark_node_obsolete(c, fd->raw); | ||
641 | jffs2_free_full_dirent(fd); | ||
642 | } | 663 | } |
643 | 664 | ||
644 | dead_f->inocache->nlink--; | 665 | dead_f->inocache->nlink--; |