[JFFS2] Deletion dirents should be REF_NORMAL, not REF_PRISTINE.
[safe/jmp/linux-2.6] / fs / jffs2 / write.c
index 6717679..bc61859 100644 (file)
@@ -1,14 +1,12 @@
 /*
  * JFFS2 -- Journalling Flash File System, Version 2.
  *
- * Copyright (C) 2001-2003 Red Hat, Inc.
+ * Copyright © 2001-2007 Red Hat, Inc.
  *
  * Created by David Woodhouse <dwmw2@infradead.org>
  *
  * For licensing information, see the file 'LICENCE' in this directory.
  *
- * $Id: write.c,v 1.97 2005/11/07 11:14:42 gleixner Exp $
- *
  */
 
 #include <linux/kernel.h>
@@ -175,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;
@@ -292,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);
@@ -507,8 +518,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
        uint32_t alloclen;
        int ret;
 
-       if (1 /* alternative branch needs testing */ ||
-           !jffs2_can_mark_obsolete(c)) {
+       if (!jffs2_can_mark_obsolete(c)) {
                /* We can't mark stuff obsolete on the medium. We need to write a deletion dirent */
 
                rd = jffs2_alloc_raw_dirent();