aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/dir.c6
-rw-r--r--fs/jffs2/fs.c56
-rw-r--r--fs/jffs2/os-linux.h2
-rw-r--r--fs/jffs2/readinode.c2
-rw-r--r--fs/jffs2/super.c1
-rw-r--r--fs/jffs2/write.c4
6 files changed, 42 insertions, 29 deletions
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 787e392ffd41..f948f7e6ec82 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -101,10 +101,10 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target,
101 ino = fd->ino; 101 ino = fd->ino;
102 up(&dir_f->sem); 102 up(&dir_f->sem);
103 if (ino) { 103 if (ino) {
104 inode = iget(dir_i->i_sb, ino); 104 inode = jffs2_iget(dir_i->i_sb, ino);
105 if (!inode) { 105 if (IS_ERR(inode)) {
106 printk(KERN_WARNING "iget() failed for ino #%u\n", ino); 106 printk(KERN_WARNING "iget() failed for ino #%u\n", ino);
107 return (ERR_PTR(-EIO)); 107 return ERR_CAST(inode);
108 } 108 }
109 } 109 }
110 110
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index ee192af0b8b0..e26ea78c7892 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -226,16 +226,23 @@ void jffs2_clear_inode (struct inode *inode)
226 jffs2_do_clear_inode(c, f); 226 jffs2_do_clear_inode(c, f);
227} 227}
228 228
229void jffs2_read_inode (struct inode *inode) 229struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
230{ 230{
231 struct jffs2_inode_info *f; 231 struct jffs2_inode_info *f;
232 struct jffs2_sb_info *c; 232 struct jffs2_sb_info *c;
233 struct jffs2_raw_inode latest_node; 233 struct jffs2_raw_inode latest_node;
234 union jffs2_device_node jdev; 234 union jffs2_device_node jdev;
235 struct inode *inode;
235 dev_t rdev = 0; 236 dev_t rdev = 0;
236 int ret; 237 int ret;
237 238
238 D1(printk(KERN_DEBUG "jffs2_read_inode(): inode->i_ino == %lu\n", inode->i_ino)); 239 D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino));
240
241 inode = iget_locked(sb, ino);
242 if (!inode)
243 return ERR_PTR(-ENOMEM);
244 if (!(inode->i_state & I_NEW))
245 return inode;
239 246
240 f = JFFS2_INODE_INFO(inode); 247 f = JFFS2_INODE_INFO(inode);
241 c = JFFS2_SB_INFO(inode->i_sb); 248 c = JFFS2_SB_INFO(inode->i_sb);
@@ -246,9 +253,9 @@ void jffs2_read_inode (struct inode *inode)
246 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node); 253 ret = jffs2_do_read_inode(c, f, inode->i_ino, &latest_node);
247 254
248 if (ret) { 255 if (ret) {
249 make_bad_inode(inode);
250 up(&f->sem); 256 up(&f->sem);
251 return; 257 iget_failed(inode);
258 return ERR_PTR(ret);
252 } 259 }
253 inode->i_mode = jemode_to_cpu(latest_node.mode); 260 inode->i_mode = jemode_to_cpu(latest_node.mode);
254 inode->i_uid = je16_to_cpu(latest_node.uid); 261 inode->i_uid = je16_to_cpu(latest_node.uid);
@@ -299,19 +306,14 @@ void jffs2_read_inode (struct inode *inode)
299 if (f->metadata->size != sizeof(jdev.old) && 306 if (f->metadata->size != sizeof(jdev.old) &&
300 f->metadata->size != sizeof(jdev.new)) { 307 f->metadata->size != sizeof(jdev.new)) {
301 printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); 308 printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size);
302 up(&f->sem); 309 goto error_io;
303 jffs2_do_clear_inode(c, f);
304 make_bad_inode(inode);
305 return;
306 } 310 }
307 D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); 311 D1(printk(KERN_DEBUG "Reading device numbers from flash\n"));
308 if (jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size) < 0) { 312 ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size);
313 if (ret < 0) {
309 /* Eep */ 314 /* Eep */
310 printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); 315 printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino);
311 up(&f->sem); 316 goto error;
312 jffs2_do_clear_inode(c, f);
313 make_bad_inode(inode);
314 return;
315 } 317 }
316 if (f->metadata->size == sizeof(jdev.old)) 318 if (f->metadata->size == sizeof(jdev.old))
317 rdev = old_decode_dev(je16_to_cpu(jdev.old)); 319 rdev = old_decode_dev(je16_to_cpu(jdev.old));
@@ -331,6 +333,16 @@ void jffs2_read_inode (struct inode *inode)
331 up(&f->sem); 333 up(&f->sem);
332 334
333 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); 335 D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n"));
336 unlock_new_inode(inode);
337 return inode;
338
339error_io:
340 ret = -EIO;
341error:
342 up(&f->sem);
343 jffs2_do_clear_inode(c, f);
344 iget_failed(inode);
345 return ERR_PTR(ret);
334} 346}
335 347
336void jffs2_dirty_inode(struct inode *inode) 348void jffs2_dirty_inode(struct inode *inode)
@@ -518,15 +530,16 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
518 if ((ret = jffs2_do_mount_fs(c))) 530 if ((ret = jffs2_do_mount_fs(c)))
519 goto out_inohash; 531 goto out_inohash;
520 532
521 ret = -EINVAL;
522
523 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); 533 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n"));
524 root_i = iget(sb, 1); 534 root_i = jffs2_iget(sb, 1);
525 if (is_bad_inode(root_i)) { 535 if (IS_ERR(root_i)) {
526 D1(printk(KERN_WARNING "get root inode failed\n")); 536 D1(printk(KERN_WARNING "get root inode failed\n"));
527 goto out_root_i; 537 ret = PTR_ERR(root_i);
538 goto out_root;
528 } 539 }
529 540
541 ret = -ENOMEM;
542
530 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); 543 D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n"));
531 sb->s_root = d_alloc_root(root_i); 544 sb->s_root = d_alloc_root(root_i);
532 if (!sb->s_root) 545 if (!sb->s_root)
@@ -542,6 +555,7 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
542 555
543 out_root_i: 556 out_root_i:
544 iput(root_i); 557 iput(root_i);
558out_root:
545 jffs2_free_ino_caches(c); 559 jffs2_free_ino_caches(c);
546 jffs2_free_raw_node_refs(c); 560 jffs2_free_raw_node_refs(c);
547 if (jffs2_blocks_use_vmalloc(c)) 561 if (jffs2_blocks_use_vmalloc(c))
@@ -611,9 +625,9 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c,
611 jffs2_do_unlink() would need the alloc_sem and we have it. 625 jffs2_do_unlink() would need the alloc_sem and we have it.
612 Just iget() it, and if read_inode() is necessary that's OK. 626 Just iget() it, and if read_inode() is necessary that's OK.
613 */ 627 */
614 inode = iget(OFNI_BS_2SFFJ(c), inum); 628 inode = jffs2_iget(OFNI_BS_2SFFJ(c), inum);
615 if (!inode) 629 if (IS_ERR(inode))
616 return ERR_PTR(-ENOMEM); 630 return ERR_CAST(inode);
617 } 631 }
618 if (is_bad_inode(inode)) { 632 if (is_bad_inode(inode)) {
619 printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n", 633 printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. nlink %d\n",
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index bf64686cf098..1b10d2594092 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -175,7 +175,7 @@ extern const struct inode_operations jffs2_symlink_inode_operations;
175/* fs.c */ 175/* fs.c */
176int jffs2_setattr (struct dentry *, struct iattr *); 176int jffs2_setattr (struct dentry *, struct iattr *);
177int jffs2_do_setattr (struct inode *, struct iattr *); 177int jffs2_do_setattr (struct inode *, struct iattr *);
178void jffs2_read_inode (struct inode *); 178struct inode *jffs2_iget(struct super_block *, unsigned long);
179void jffs2_clear_inode (struct inode *); 179void jffs2_clear_inode (struct inode *);
180void jffs2_dirty_inode(struct inode *inode); 180void jffs2_dirty_inode(struct inode *inode);
181struct inode *jffs2_new_inode (struct inode *dir_i, int mode, 181struct inode *jffs2_new_inode (struct inode *dir_i, int mode,
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index fb89ab5e1d50..e512a93d6249 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -742,7 +742,7 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
742 * are not obsolete. 742 * are not obsolete.
743 * 743 *
744 * Of course, this optimization only makes sense in case 744 * Of course, this optimization only makes sense in case
745 * of NAND flashes (or other flashes whith 745 * of NAND flashes (or other flashes with
746 * !jffs2_can_mark_obsolete()), since on NOR flashes 746 * !jffs2_can_mark_obsolete()), since on NOR flashes
747 * nodes are marked obsolete physically. 747 * nodes are marked obsolete physically.
748 * 748 *
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index ffa447511e6a..4677355996cc 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -65,7 +65,6 @@ static const struct super_operations jffs2_super_operations =
65{ 65{
66 .alloc_inode = jffs2_alloc_inode, 66 .alloc_inode = jffs2_alloc_inode,
67 .destroy_inode =jffs2_destroy_inode, 67 .destroy_inode =jffs2_destroy_inode,
68 .read_inode = jffs2_read_inode,
69 .put_super = jffs2_put_super, 68 .put_super = jffs2_put_super,
70 .write_super = jffs2_write_super, 69 .write_super = jffs2_write_super,
71 .statfs = jffs2_statfs, 70 .statfs = jffs2_statfs,
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c
index ecdf18d0486f..776f13cbf2b5 100644
--- a/fs/jffs2/write.c
+++ b/fs/jffs2/write.c
@@ -177,7 +177,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2
177 void *hold_err = fn->raw; 177 void *hold_err = fn->raw;
178 /* Release the full_dnode which is now useless, and return */ 178 /* Release the full_dnode which is now useless, and return */
179 jffs2_free_full_dnode(fn); 179 jffs2_free_full_dnode(fn);
180 return ERR_PTR(PTR_ERR(hold_err)); 180 return ERR_CAST(hold_err);
181 } 181 }
182 fn->ofs = je32_to_cpu(ri->offset); 182 fn->ofs = je32_to_cpu(ri->offset);
183 fn->size = je32_to_cpu(ri->dsize); 183 fn->size = je32_to_cpu(ri->dsize);
@@ -313,7 +313,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
313 void *hold_err = fd->raw; 313 void *hold_err = fd->raw;
314 /* Release the full_dirent which is now useless, and return */ 314 /* Release the full_dirent which is now useless, and return */
315 jffs2_free_full_dirent(fd); 315 jffs2_free_full_dirent(fd);
316 return ERR_PTR(PTR_ERR(hold_err)); 316 return ERR_CAST(hold_err);
317 } 317 }
318 318
319 if (retried) { 319 if (retried) {