]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/jffs2/write.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
[linux-2.6-omap-h63xx.git] / fs / jffs2 / write.c
index c9fe0ab3a3296d782c9eb47a03f6eba88a4d09f3..664c164aa67c19bef7583ce6fa7014cc715ffef5 100644 (file)
@@ -173,6 +173,12 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
                flash_ofs |= REF_NORMAL;
        }
        fn->raw = jffs2_add_physical_node_ref(c, flash_ofs, PAD(sizeof(*ri)+datalen), f->inocache);
+       if (IS_ERR(fn->raw)) {
+               void *hold_err = fn->raw;
+               /* Release the full_dnode which is now useless, and return */
+               jffs2_free_full_dnode(fn);
+               return ERR_PTR(PTR_ERR(hold_err));
+       }
        fn->ofs = je32_to_cpu(ri->offset);
        fn->size = je32_to_cpu(ri->dsize);
        fn->frags = 0;
@@ -290,7 +296,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
                return ERR_PTR(ret?ret:-EIO);
        }
        /* Mark the space used */
-       fd->raw = jffs2_add_physical_node_ref(c, flash_ofs | REF_PRISTINE, PAD(sizeof(*rd)+namelen), f->inocache);
+       fd->raw = jffs2_add_physical_node_ref(c, flash_ofs | dirent_node_state(rd),
+                                             PAD(sizeof(*rd)+namelen), f->inocache);
+       if (IS_ERR(fd->raw)) {
+               void *hold_err = fd->raw;
+               /* Release the full_dirent which is now useless, and return */
+               jffs2_free_full_dirent(fd);
+               return ERR_PTR(PTR_ERR(hold_err));
+       }
 
        if (retried) {
                jffs2_dbg_acct_sanity_check(c,NULL);
@@ -553,6 +566,9 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
                struct jffs2_full_dirent **prev = &dir_f->dents;
                uint32_t nhash = full_name_hash(name, namelen);
 
+               /* We don't actually want to reserve any space, but we do
+                  want to be holding the alloc_sem when we write to flash */
+               down(&c->alloc_sem);
                down(&dir_f->sem);
 
                while ((*prev) && (*prev)->nhash <= nhash) {