Mercurial > ecos
annotate packages/fs/jffs2/current/src/build.c @ 3292:7f8e529b4d82 default tip
Fix FREESCALE_EDMA_NBYTES_MLOFFYES_MLOFF() so it works with negative offsets.
| author | vae |
|---|---|
| date | Wed, 29 Apr 2015 23:31:48 +0000 |
| parents | 5bcbb50b501e |
| children |
| rev | line source |
|---|---|
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
1 /* |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
2 * JFFS2 -- Journalling Flash File System, Version 2. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
3 * |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
4 * Copyright (C) 2001-2003 Red Hat, Inc. |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
5 * |
| 1881 | 6 * Created by David Woodhouse <dwmw2@infradead.org> |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
7 * |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
8 * For licensing information, see the file 'LICENCE' in this directory. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
9 * |
| 2042 | 10 * $Id: build.c,v 1.75 2005/07/22 10:32:07 dedekind Exp $ |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
11 * |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
12 */ |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
13 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
14 #include <linux/kernel.h> |
| 570 | 15 #include <linux/sched.h> |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
16 #include <linux/slab.h> |
| 1881 | 17 #include <linux/vmalloc.h> |
| 18 #include <linux/mtd/mtd.h> | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
19 #include "nodelist.h" |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
20 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
21 static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *, struct jffs2_inode_cache *, struct jffs2_full_dirent **); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
22 |
| 1118 | 23 static inline struct jffs2_inode_cache * |
| 24 first_inode_chain(int *i, struct jffs2_sb_info *c) | |
| 25 { | |
| 26 for (; *i < INOCACHE_HASHSIZE; (*i)++) { | |
| 27 if (c->inocache_list[*i]) | |
| 28 return c->inocache_list[*i]; | |
| 29 } | |
| 30 return NULL; | |
| 31 } | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
32 |
| 1118 | 33 static inline struct jffs2_inode_cache * |
| 34 next_inode(int *i, struct jffs2_inode_cache *ic, struct jffs2_sb_info *c) | |
| 35 { | |
| 36 /* More in this chain? */ | |
| 37 if (ic->next) | |
| 38 return ic->next; | |
| 39 (*i)++; | |
| 40 return first_inode_chain(i, c); | |
| 41 } | |
| 42 | |
| 43 #define for_each_inode(i, c, ic) \ | |
| 44 for (i = 0, ic = first_inode_chain(&i, (c)); \ | |
| 45 ic; \ | |
| 46 ic = next_inode(&i, ic, (c))) | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
47 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
48 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
49 static inline void jffs2_build_inode_pass1(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
50 { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
51 struct jffs2_full_dirent *fd; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
52 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
53 D1(printk(KERN_DEBUG "jffs2_build_inode building directory inode #%u\n", ic->ino)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
54 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
55 /* For each child, increase nlink */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
56 for(fd = ic->scan_dents; fd; fd = fd->next) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
57 struct jffs2_inode_cache *child_ic; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
58 if (!fd->ino) |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
59 continue; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
60 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
61 /* XXX: Can get high latency here with huge directories */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
62 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
63 child_ic = jffs2_get_ino_cache(c, fd->ino); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
64 if (!child_ic) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
65 printk(KERN_NOTICE "Eep. Child \"%s\" (ino #%u) of dir ino #%u doesn't exist!\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
66 fd->name, fd->ino, ic->ino); |
| 1881 | 67 jffs2_mark_node_obsolete(c, fd->raw); |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
68 continue; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
69 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
70 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
71 if (child_ic->nlink++ && fd->type == DT_DIR) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
72 printk(KERN_NOTICE "Child dir \"%s\" (ino #%u) of dir ino #%u appears to be a hard link\n", fd->name, fd->ino, ic->ino); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
73 if (fd->ino == 1 && ic->ino == 1) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
74 printk(KERN_NOTICE "This is mostly harmless, and probably caused by creating a JFFS2 image\n"); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
75 printk(KERN_NOTICE "using a buggy version of mkfs.jffs2. Use at least v1.17.\n"); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
76 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
77 /* What do we do about it? */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
78 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
79 D1(printk(KERN_DEBUG "Increased nlink for child \"%s\" (ino #%u)\n", fd->name, fd->ino)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
80 /* Can't free them. We might need them in pass 2 */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
81 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
82 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
83 |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
84 /* Scan plan: |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
85 - Scan physical nodes. Build map of inodes/dirents. Allocate inocaches as we go |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
86 - Scan directory tree from top down, setting nlink in inocaches |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
87 - Scan inocaches for inodes with nlink==0 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
88 */ |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
89 static int jffs2_build_filesystem(struct jffs2_sb_info *c) |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
90 { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
91 int ret; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
92 int i; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
93 struct jffs2_inode_cache *ic; |
| 1881 | 94 struct jffs2_full_dirent *fd; |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
95 struct jffs2_full_dirent *dead_fds = NULL; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
96 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
97 /* First, scan the medium and build all the inode caches with |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
98 lists of physical nodes */ |
| 570 | 99 |
| 2042 | 100 c->flags |= JFFS2_SB_FLAG_SCANNING; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
101 ret = jffs2_scan_medium(c); |
| 2042 | 102 c->flags &= ~JFFS2_SB_FLAG_SCANNING; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
103 if (ret) |
| 1881 | 104 goto exit; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
105 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
106 D1(printk(KERN_DEBUG "Scanned flash completely\n")); |
| 2042 | 107 jffs2_dbg_dump_block_lists_nolock(c); |
| 570 | 108 |
| 2042 | 109 c->flags |= JFFS2_SB_FLAG_BUILDING; |
| 570 | 110 /* Now scan the directory tree, increasing nlink according to every dirent found. */ |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
111 for_each_inode(i, c, ic) { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
112 D1(printk(KERN_DEBUG "Pass 1: ino #%u\n", ic->ino)); |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
113 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
114 D1(BUG_ON(ic->ino > c->highest_ino)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
115 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
116 if (ic->scan_dents) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
117 jffs2_build_inode_pass1(c, ic); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
118 cond_resched(); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
119 } |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
120 } |
| 1881 | 121 |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
122 D1(printk(KERN_DEBUG "Pass 1 complete\n")); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
123 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
124 /* Next, scan for inodes with nlink == 0 and remove them. If |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
125 they were directories, then decrement the nlink of their |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
126 children too, and repeat the scan. As that's going to be |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
127 a fairly uncommon occurrence, it's not so evil to do it this |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
128 way. Recursion bad. */ |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
129 D1(printk(KERN_DEBUG "Pass 2 starting\n")); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
130 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
131 for_each_inode(i, c, ic) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
132 D1(printk(KERN_DEBUG "Pass 2: ino #%u, nlink %d, ic %p, nodes %p\n", ic->ino, ic->nlink, ic, ic->nodes)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
133 if (ic->nlink) |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
134 continue; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
135 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
136 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
137 cond_resched(); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
138 } |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
139 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
140 D1(printk(KERN_DEBUG "Pass 2a starting\n")); |
| 570 | 141 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
142 while (dead_fds) { |
| 1881 | 143 fd = dead_fds; |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
144 dead_fds = fd->next; |
| 570 | 145 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
146 ic = jffs2_get_ino_cache(c, fd->ino); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
147 D1(printk(KERN_DEBUG "Removing dead_fd ino #%u (\"%s\"), ic at %p\n", fd->ino, fd->name, ic)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
148 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
149 if (ic) |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
150 jffs2_build_remove_unlinked_inode(c, ic, &dead_fds); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
151 jffs2_free_full_dirent(fd); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
152 } |
| 570 | 153 |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
154 D1(printk(KERN_DEBUG "Pass 2 complete\n")); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
155 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
156 /* Finally, we can scan again and free the dirent structs */ |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
157 for_each_inode(i, c, ic) { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
158 D1(printk(KERN_DEBUG "Pass 3: ino #%u, ic %p, nodes %p\n", ic->ino, ic, ic->nodes)); |
| 570 | 159 |
| 160 while(ic->scan_dents) { | |
| 161 fd = ic->scan_dents; | |
| 162 ic->scan_dents = fd->next; | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
163 jffs2_free_full_dirent(fd); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
164 } |
| 570 | 165 ic->scan_dents = NULL; |
| 166 cond_resched(); | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
167 } |
| 2042 | 168 c->flags &= ~JFFS2_SB_FLAG_BUILDING; |
| 169 | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
170 D1(printk(KERN_DEBUG "Pass 3 complete\n")); |
| 2042 | 171 jffs2_dbg_dump_block_lists_nolock(c); |
| 570 | 172 |
| 173 /* Rotate the lists by some number to ensure wear levelling */ | |
| 174 jffs2_rotate_lists(c); | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
175 |
| 1881 | 176 ret = 0; |
| 177 | |
| 178 exit: | |
| 179 if (ret) { | |
| 180 for_each_inode(i, c, ic) { | |
| 181 while(ic->scan_dents) { | |
| 182 fd = ic->scan_dents; | |
| 183 ic->scan_dents = fd->next; | |
| 184 jffs2_free_full_dirent(fd); | |
| 185 } | |
| 186 } | |
| 187 } | |
| 188 | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
189 return ret; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
190 } |
| 570 | 191 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
192 static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic, struct jffs2_full_dirent **dead_fds) |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
193 { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
194 struct jffs2_raw_node_ref *raw; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
195 struct jffs2_full_dirent *fd; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
196 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
197 D1(printk(KERN_DEBUG "JFFS2: Removing ino #%u with nlink == zero.\n", ic->ino)); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
198 |
| 1881 | 199 raw = ic->nodes; |
| 200 while (raw != (void *)ic) { | |
| 201 struct jffs2_raw_node_ref *next = raw->next_in_ino; | |
| 570 | 202 D1(printk(KERN_DEBUG "obsoleting node at 0x%08x\n", ref_offset(raw))); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
203 jffs2_mark_node_obsolete(c, raw); |
| 1881 | 204 raw = next; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
205 } |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
206 |
| 570 | 207 if (ic->scan_dents) { |
| 208 int whinged = 0; | |
| 209 D1(printk(KERN_DEBUG "Inode #%u was a directory which may have children...\n", ic->ino)); | |
| 210 | |
| 211 while(ic->scan_dents) { | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
212 struct jffs2_inode_cache *child_ic; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
213 |
| 570 | 214 fd = ic->scan_dents; |
| 215 ic->scan_dents = fd->next; | |
| 216 | |
| 217 if (!fd->ino) { | |
| 218 /* It's a deletion dirent. Ignore it */ | |
| 219 D1(printk(KERN_DEBUG "Child \"%s\" is a deletion dirent, skipping...\n", fd->name)); | |
| 220 jffs2_free_full_dirent(fd); | |
| 221 continue; | |
| 222 } | |
| 223 if (!whinged) { | |
| 224 whinged = 1; | |
| 225 printk(KERN_NOTICE "Inode #%u was a directory with children - removing those too...\n", ic->ino); | |
| 226 } | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
227 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
228 D1(printk(KERN_DEBUG "Removing child \"%s\", ino #%u\n", |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
229 fd->name, fd->ino)); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
230 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
231 child_ic = jffs2_get_ino_cache(c, fd->ino); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
232 if (!child_ic) { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
233 printk(KERN_NOTICE "Cannot remove child \"%s\", ino #%u, because it doesn't exist\n", fd->name, fd->ino); |
| 570 | 234 jffs2_free_full_dirent(fd); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
235 continue; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
236 } |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
237 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
238 /* Reduce nlink of the child. If it's now zero, stick it on the |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
239 dead_fds list to be cleaned up later. Else just free the fd */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
240 |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
241 child_ic->nlink--; |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
242 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
243 if (!child_ic->nlink) { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
244 D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got zero nlink. Adding to dead_fds list.\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
245 fd->ino, fd->name)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
246 fd->next = *dead_fds; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
247 *dead_fds = fd; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
248 } else { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
249 D1(printk(KERN_DEBUG "Inode #%u (\"%s\") has now got nlink %d. Ignoring.\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
250 fd->ino, fd->name, child_ic->nlink)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
251 jffs2_free_full_dirent(fd); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
252 } |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
253 } |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
254 } |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
255 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
256 /* |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
257 We don't delete the inocache from the hash list and free it yet. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
258 The erase code will do that, when all the nodes are completely gone. |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
259 */ |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
260 } |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
261 |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
262 static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
263 { |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
264 uint32_t size; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
265 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
266 /* Deletion should almost _always_ be allowed. We're fairly |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
267 buggered once we stop allowing people to delete stuff |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
268 because there's not enough free space... */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
269 c->resv_blocks_deletion = 2; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
270 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
271 /* Be conservative about how much space we need before we allow writes. |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
272 On top of that which is required for deletia, require an extra 2% |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
273 of the medium to be available, for overhead caused by nodes being |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
274 split across blocks, etc. */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
275 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
276 size = c->flash_size / 50; /* 2% of flash size */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
277 size += c->nr_blocks * 100; /* And 100 bytes per eraseblock */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
278 size += c->sector_size - 1; /* ... and round up */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
279 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
280 c->resv_blocks_write = c->resv_blocks_deletion + (size / c->sector_size); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
281 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
282 /* When do we let the GC thread run in the background */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
283 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
284 c->resv_blocks_gctrigger = c->resv_blocks_write + 1; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
285 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
286 /* When do we allow garbage collection to merge nodes to make |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
287 long-term progress at the expense of short-term space exhaustion? */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
288 c->resv_blocks_gcmerge = c->resv_blocks_deletion + 1; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
289 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
290 /* When do we allow garbage collection to eat from bad blocks rather |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
291 than actually making progress? */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
292 c->resv_blocks_gcbad = 0;//c->resv_blocks_deletion + 2; |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
293 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
294 /* If there's less than this amount of dirty space, don't bother |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
295 trying to GC to make more space. It'll be a fruitless task */ |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
296 c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
297 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
298 D1(printk(KERN_DEBUG "JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
299 c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
300 D1(printk(KERN_DEBUG "Blocks required to allow deletion: %d (%d KiB)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
301 c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
302 D1(printk(KERN_DEBUG "Blocks required to allow writes: %d (%d KiB)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
303 c->resv_blocks_write, c->resv_blocks_write*c->sector_size/1024)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
304 D1(printk(KERN_DEBUG "Blocks required to quiesce GC thread: %d (%d KiB)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
305 c->resv_blocks_gctrigger, c->resv_blocks_gctrigger*c->sector_size/1024)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
306 D1(printk(KERN_DEBUG "Blocks required to allow GC merges: %d (%d KiB)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
307 c->resv_blocks_gcmerge, c->resv_blocks_gcmerge*c->sector_size/1024)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
308 D1(printk(KERN_DEBUG "Blocks required to GC bad blocks: %d (%d KiB)\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
309 c->resv_blocks_gcbad, c->resv_blocks_gcbad*c->sector_size/1024)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
310 D1(printk(KERN_DEBUG "Amount of dirty space required to GC: %d bytes\n", |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
311 c->nospc_dirty_size)); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
312 } |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
313 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
314 int jffs2_do_mount_fs(struct jffs2_sb_info *c) |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
315 { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
316 int i; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
317 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
318 c->free_size = c->flash_size; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
319 c->nr_blocks = c->flash_size / c->sector_size; |
| 1881 | 320 #ifndef __ECOS |
| 321 if (c->mtd->flags & MTD_NO_VIRTBLOCKS) | |
| 322 c->blocks = vmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks); | |
| 323 else | |
| 324 #endif | |
| 325 c->blocks = kmalloc(sizeof(struct jffs2_eraseblock) * c->nr_blocks, GFP_KERNEL); | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
326 if (!c->blocks) |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
327 return -ENOMEM; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
328 for (i=0; i<c->nr_blocks; i++) { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
329 INIT_LIST_HEAD(&c->blocks[i].list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
330 c->blocks[i].offset = i * c->sector_size; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
331 c->blocks[i].free_size = c->sector_size; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
332 c->blocks[i].dirty_size = 0; |
| 570 | 333 c->blocks[i].wasted_size = 0; |
| 334 c->blocks[i].unchecked_size = 0; | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
335 c->blocks[i].used_size = 0; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
336 c->blocks[i].first_node = NULL; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
337 c->blocks[i].last_node = NULL; |
| 1881 | 338 c->blocks[i].bad_count = 0; |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
339 } |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
340 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
341 INIT_LIST_HEAD(&c->clean_list); |
| 570 | 342 INIT_LIST_HEAD(&c->very_dirty_list); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
343 INIT_LIST_HEAD(&c->dirty_list); |
| 570 | 344 INIT_LIST_HEAD(&c->erasable_list); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
345 INIT_LIST_HEAD(&c->erasing_list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
346 INIT_LIST_HEAD(&c->erase_pending_list); |
| 570 | 347 INIT_LIST_HEAD(&c->erasable_pending_wbuf_list); |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
348 INIT_LIST_HEAD(&c->erase_complete_list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
349 INIT_LIST_HEAD(&c->free_list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
350 INIT_LIST_HEAD(&c->bad_list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
351 INIT_LIST_HEAD(&c->bad_used_list); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
352 c->highest_ino = 1; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
353 |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
354 if (jffs2_build_filesystem(c)) { |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
355 D1(printk(KERN_DEBUG "build_fs failed\n")); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
356 jffs2_free_ino_caches(c); |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
357 jffs2_free_raw_node_refs(c); |
| 1881 | 358 #ifndef __ECOS |
| 359 if (c->mtd->flags & MTD_NO_VIRTBLOCKS) | |
| 360 vfree(c->blocks); | |
| 361 else | |
| 362 #endif | |
| 363 kfree(c->blocks); | |
| 364 | |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
365 return -EIO; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
366 } |
|
1372
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
367 |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
368 jffs2_calc_trigger_levels(c); |
|
121121d3d18f
Merge changes from David Woodhouse (bring up to date with MTD project)
gthomas
parents:
1118
diff
changeset
|
369 |
|
208
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
370 return 0; |
|
e0c0827131d1
Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents:
diff
changeset
|
371 } |
