Merge branch 'futexes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / fs / jffs2 / build.c
index 0ca2fff..c5e1450 100644 (file)
@@ -46,7 +46,7 @@ next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c)
 
 
 static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
-                                       struct jffs2_inode_cache *ic)
+                                   struct jffs2_inode_cache *ic)
 {
        struct jffs2_full_dirent *fd;
 
@@ -68,11 +68,17 @@ static void jffs2_build_inode_pass1(struct jffs2_sb_info *c,
                        continue;
                }
 
-               if (child_ic->nlink++ && fd->type == DT_DIR) {
-                       JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n",
-                               fd->name, fd->ino, ic->ino);
-                       /* TODO: What do we do about it? */
-               }
+               if (fd->type == DT_DIR) {
+                       if (child_ic->pino_nlink) {
+                               JFFS2_ERROR("child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n",
+                                           fd->name, fd->ino, ic->ino);
+                               /* TODO: What do we do about it? */
+                       } else {
+                               child_ic->pino_nlink = ic->ino;
+                       }
+               } else
+                       child_ic->pino_nlink++;
+
                dbg_fsbuild("increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino);
                /* Can't free scan_dents so far. We might need them in pass 2 */
        }
@@ -125,7 +131,7 @@ static int jffs2_build_filesystem(struct jffs2_sb_info *c)
        dbg_fsbuild("pass 2 starting\n");
 
        for_each_inode(i, c, ic) {
-               if (ic->nlink)
+               if (ic->pino_nlink)
                        continue;
 
                jffs2_build_remove_unlinked_inode(c, ic, &dead_fds);
@@ -232,16 +238,19 @@ static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c,
                        /* Reduce nlink of the child. If it's now zero, stick it on the
                           dead_fds list to be cleaned up later. Else just free the fd */
 
-                       child_ic->nlink--;
+                       if (fd->type == DT_DIR)
+                               child_ic->pino_nlink = 0;
+                       else
+                               child_ic->pino_nlink--;
 
-                       if (!child_ic->nlink) {
-                               dbg_fsbuild("inode #%u (\"%s\") has now got zero nlink, adding to dead_fds list.\n",
+                       if (!child_ic->pino_nlink) {
+                               dbg_fsbuild("inode #%u (\"%s\") now has no links; adding to dead_fds list.\n",
                                          fd->ino, fd->name);
                                fd->next = *dead_fds;
                                *dead_fds = fd;
                        } else {
                                dbg_fsbuild("inode #%u (\"%s\") has now got nlink %d. Ignoring.\n",
-                                         fd->ino, fd->name, child_ic->nlink);
+                                         fd->ino, fd->name, child_ic->pino_nlink);
                                jffs2_free_full_dirent(fd);
                        }
                }
@@ -285,6 +294,14 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c)
           than actually making progress? */
        c->resv_blocks_gcbad = 0;//c->resv_blocks_deletion + 2;
 
+       /* What number of 'very dirty' eraseblocks do we allow before we
+          trigger the GC thread even if we don't _need_ the space. When we
+          can't mark nodes obsolete on the medium, the old dirty nodes cause
+          performance problems because we have to inspect and discard them. */
+       c->vdirty_blocks_gctrigger = c->resv_blocks_gctrigger;
+       if (jffs2_can_mark_obsolete(c))
+               c->vdirty_blocks_gctrigger *= 10;
+
        /* If there's less than this amount of dirty space, don't bother
           trying to GC to make more space. It'll be a fruitless task */
        c->nospc_dirty_size = c->sector_size + (c->flash_size / 100);
@@ -303,6 +320,8 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c)
                  c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024);
        dbg_fsbuild("Amount of dirty space required to GC: %d bytes\n",
                  c->nospc_dirty_size);
+       dbg_fsbuild("Very dirty blocks before GC triggered: %d\n",
+                 c->vdirty_blocks_gctrigger);
 }
 
 int jffs2_do_mount_fs(struct jffs2_sb_info *c)
@@ -335,6 +354,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
        INIT_LIST_HEAD(&c->dirty_list);
        INIT_LIST_HEAD(&c->erasable_list);
        INIT_LIST_HEAD(&c->erasing_list);
+       INIT_LIST_HEAD(&c->erase_checking_list);
        INIT_LIST_HEAD(&c->erase_pending_list);
        INIT_LIST_HEAD(&c->erasable_pending_wbuf_list);
        INIT_LIST_HEAD(&c->erase_complete_list);