aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/jffs/jffs_fm.c3
-rw-r--r--fs/jffs2/debug.c4
-rw-r--r--fs/jffs2/debug.h1
-rw-r--r--fs/jffs2/fs.c3
-rw-r--r--fs/jffs2/gc.c2
-rw-r--r--fs/jffs2/nodelist.h10
-rw-r--r--fs/jffs2/readinode.c3
-rw-r--r--fs/jffs2/scan.c6
-rw-r--r--fs/jffs2/summary.c6
-rw-r--r--fs/jffs2/super.c7
-rw-r--r--fs/jffs2/symlink.c2
-rw-r--r--fs/jffs2/wbuf.c21
-rw-r--r--fs/jffs2/xattr.c5
13 files changed, 36 insertions, 37 deletions
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 077258b2103e..5a95fbdd6fdb 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/err.h>
20#include <linux/blkdev.h> 21#include <linux/blkdev.h>
21#include <linux/jffs.h> 22#include <linux/jffs.h>
22#include "jffs_fm.h" 23#include "jffs_fm.h"
@@ -104,7 +105,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
104 105
105 mtd = get_mtd_device(NULL, unit); 106 mtd = get_mtd_device(NULL, unit);
106 107
107 if (!mtd) { 108 if (IS_ERR(mtd)) {
108 kfree(fmc); 109 kfree(fmc);
109 DJM(no_jffs_fmcontrol--); 110 DJM(no_jffs_fmcontrol--);
110 return NULL; 111 return NULL;
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 72b4fc13a106..4189e4a36050 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -178,8 +178,8 @@ __jffs2_dbg_acct_paranoia_check_nolock(struct jffs2_sb_info *c,
178 while (ref2) { 178 while (ref2) {
179 uint32_t totlen = ref_totlen(c, jeb, ref2); 179 uint32_t totlen = ref_totlen(c, jeb, ref2);
180 180
181 if (ref2->flash_offset < jeb->offset || 181 if (ref_offset(ref2) < jeb->offset ||
182 ref2->flash_offset > jeb->offset + c->sector_size) { 182 ref_offset(ref2) > jeb->offset + c->sector_size) {
183 JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n", 183 JFFS2_ERROR("node_ref %#08x shouldn't be in block at %#08x.\n",
184 ref_offset(ref2), jeb->offset); 184 ref_offset(ref2), jeb->offset);
185 goto error; 185 goto error;
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h
index 3daf3bca0376..f89c85d5a3f8 100644
--- a/fs/jffs2/debug.h
+++ b/fs/jffs2/debug.h
@@ -13,6 +13,7 @@
13#ifndef _JFFS2_DEBUG_H_ 13#ifndef _JFFS2_DEBUG_H_
14#define _JFFS2_DEBUG_H_ 14#define _JFFS2_DEBUG_H_
15 15
16#include <linux/sched.h>
16 17
17#ifndef CONFIG_JFFS2_FS_DEBUG 18#ifndef CONFIG_JFFS2_FS_DEBUG
18#define CONFIG_JFFS2_FS_DEBUG 0 19#define CONFIG_JFFS2_FS_DEBUG 0
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 7bc1a4201c0c..abb90c0c09cc 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -502,12 +502,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
502 if (ret) 502 if (ret)
503 return ret; 503 return ret;
504 504
505 c->inocache_list = kmalloc(INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *), GFP_KERNEL); 505 c->inocache_list = kcalloc(INOCACHE_HASHSIZE, sizeof(struct jffs2_inode_cache *), GFP_KERNEL);
506 if (!c->inocache_list) { 506 if (!c->inocache_list) {
507 ret = -ENOMEM; 507 ret = -ENOMEM;
508 goto out_wbuf; 508 goto out_wbuf;
509 } 509 }
510 memset(c->inocache_list, 0, INOCACHE_HASHSIZE * sizeof(struct jffs2_inode_cache *));
511 510
512 jffs2_init_xattr_subsystem(c); 511 jffs2_init_xattr_subsystem(c);
513 512
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c
index daff3341ff92..3a3cf225981f 100644
--- a/fs/jffs2/gc.c
+++ b/fs/jffs2/gc.c
@@ -838,6 +838,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
838 838
839 for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) { 839 for (raw = f->inocache->nodes; raw != (void *)f->inocache; raw = raw->next_in_ino) {
840 840
841 cond_resched();
842
841 /* We only care about obsolete ones */ 843 /* We only care about obsolete ones */
842 if (!(ref_obsolete(raw))) 844 if (!(ref_obsolete(raw)))
843 continue; 845 continue;
diff --git a/fs/jffs2/nodelist.h b/fs/jffs2/nodelist.h
index 0ddfd70307fb..4178b4b55948 100644
--- a/fs/jffs2/nodelist.h
+++ b/fs/jffs2/nodelist.h
@@ -294,23 +294,21 @@ static inline int jffs2_encode_dev(union jffs2_device_node *jdev, dev_t rdev)
294 294
295static inline struct jffs2_node_frag *frag_first(struct rb_root *root) 295static inline struct jffs2_node_frag *frag_first(struct rb_root *root)
296{ 296{
297 struct rb_node *node = root->rb_node; 297 struct rb_node *node = rb_first(root);
298 298
299 if (!node) 299 if (!node)
300 return NULL; 300 return NULL;
301 while(node->rb_left) 301
302 node = node->rb_left;
303 return rb_entry(node, struct jffs2_node_frag, rb); 302 return rb_entry(node, struct jffs2_node_frag, rb);
304} 303}
305 304
306static inline struct jffs2_node_frag *frag_last(struct rb_root *root) 305static inline struct jffs2_node_frag *frag_last(struct rb_root *root)
307{ 306{
308 struct rb_node *node = root->rb_node; 307 struct rb_node *node = rb_last(root);
309 308
310 if (!node) 309 if (!node)
311 return NULL; 310 return NULL;
312 while(node->rb_right) 311
313 node = node->rb_right;
314 return rb_entry(node, struct jffs2_node_frag, rb); 312 return rb_entry(node, struct jffs2_node_frag, rb);
315} 313}
316 314
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 266423b2709d..58a0b912e9d0 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -944,13 +944,12 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
944int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) 944int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic)
945{ 945{
946 struct jffs2_raw_inode n; 946 struct jffs2_raw_inode n;
947 struct jffs2_inode_info *f = kmalloc(sizeof(*f), GFP_KERNEL); 947 struct jffs2_inode_info *f = kzalloc(sizeof(*f), GFP_KERNEL);
948 int ret; 948 int ret;
949 949
950 if (!f) 950 if (!f)
951 return -ENOMEM; 951 return -ENOMEM;
952 952
953 memset(f, 0, sizeof(*f));
954 init_MUTEX_LOCKED(&f->sem); 953 init_MUTEX_LOCKED(&f->sem);
955 f->inocache = ic; 954 f->inocache = ic;
956 955
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index e2413466ddd5..3af746eaff0e 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -128,17 +128,19 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
128 } 128 }
129 129
130 if (jffs2_sum_active()) { 130 if (jffs2_sum_active()) {
131 s = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); 131 s = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
132 if (!s) { 132 if (!s) {
133 kfree(flashbuf);
133 JFFS2_WARNING("Can't allocate memory for summary\n"); 134 JFFS2_WARNING("Can't allocate memory for summary\n");
134 return -ENOMEM; 135 return -ENOMEM;
135 } 136 }
136 memset(s, 0, sizeof(struct jffs2_summary));
137 } 137 }
138 138
139 for (i=0; i<c->nr_blocks; i++) { 139 for (i=0; i<c->nr_blocks; i++) {
140 struct jffs2_eraseblock *jeb = &c->blocks[i]; 140 struct jffs2_eraseblock *jeb = &c->blocks[i];
141 141
142 cond_resched();
143
142 /* reset summary info for next eraseblock scan */ 144 /* reset summary info for next eraseblock scan */
143 jffs2_sum_reset_collected(s); 145 jffs2_sum_reset_collected(s);
144 146
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c
index e52cef526d90..25265965bdc1 100644
--- a/fs/jffs2/summary.c
+++ b/fs/jffs2/summary.c
@@ -26,15 +26,13 @@
26 26
27int jffs2_sum_init(struct jffs2_sb_info *c) 27int jffs2_sum_init(struct jffs2_sb_info *c)
28{ 28{
29 c->summary = kmalloc(sizeof(struct jffs2_summary), GFP_KERNEL); 29 c->summary = kzalloc(sizeof(struct jffs2_summary), GFP_KERNEL);
30 30
31 if (!c->summary) { 31 if (!c->summary) {
32 JFFS2_WARNING("Can't allocate memory for summary information!\n"); 32 JFFS2_WARNING("Can't allocate memory for summary information!\n");
33 return -ENOMEM; 33 return -ENOMEM;
34 } 34 }
35 35
36 memset(c->summary, 0, sizeof(struct jffs2_summary));
37
38 c->summary->sum_buf = vmalloc(c->sector_size); 36 c->summary->sum_buf = vmalloc(c->sector_size);
39 37
40 if (!c->summary->sum_buf) { 38 if (!c->summary->sum_buf) {
@@ -398,6 +396,8 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras
398 for (i=0; i<je32_to_cpu(summary->sum_num); i++) { 396 for (i=0; i<je32_to_cpu(summary->sum_num); i++) {
399 dbg_summary("processing summary index %d\n", i); 397 dbg_summary("processing summary index %d\n", i);
400 398
399 cond_resched();
400
401 /* Make sure there's a spare ref for dirty space */ 401 /* Make sure there's a spare ref for dirty space */
402 err = jffs2_prealloc_raw_node_refs(c, jeb, 2); 402 err = jffs2_prealloc_raw_node_refs(c, jeb, 2);
403 if (err) 403 if (err)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 7deb78254021..08a0e6c49e61 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/fs.h> 19#include <linux/fs.h>
20#include <linux/err.h>
20#include <linux/mount.h> 21#include <linux/mount.h>
21#include <linux/jffs2.h> 22#include <linux/jffs2.h>
22#include <linux/pagemap.h> 23#include <linux/pagemap.h>
@@ -184,9 +185,9 @@ static int jffs2_get_sb_mtdnr(struct file_system_type *fs_type,
184 struct mtd_info *mtd; 185 struct mtd_info *mtd;
185 186
186 mtd = get_mtd_device(NULL, mtdnr); 187 mtd = get_mtd_device(NULL, mtdnr);
187 if (!mtd) { 188 if (IS_ERR(mtd)) {
188 D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr)); 189 D1(printk(KERN_DEBUG "jffs2: MTD device #%u doesn't appear to exist\n", mtdnr));
189 return -EINVAL; 190 return PTR_ERR(mtd);
190 } 191 }
191 192
192 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); 193 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);
@@ -221,7 +222,7 @@ static int jffs2_get_sb(struct file_system_type *fs_type,
221 D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4)); 222 D1(printk(KERN_DEBUG "jffs2_get_sb(): mtd:%%s, name \"%s\"\n", dev_name+4));
222 for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) { 223 for (mtdnr = 0; mtdnr < MAX_MTD_DEVICES; mtdnr++) {
223 mtd = get_mtd_device(NULL, mtdnr); 224 mtd = get_mtd_device(NULL, mtdnr);
224 if (mtd) { 225 if (!IS_ERR(mtd)) {
225 if (!strcmp(mtd->name, dev_name+4)) 226 if (!strcmp(mtd->name, dev_name+4))
226 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt); 227 return jffs2_get_sb_mtd(fs_type, flags, dev_name, data, mtd, mnt);
227 put_mtd_device(mtd); 228 put_mtd_device(mtd);
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c
index fc211b6e9b03..b90d5aa3d969 100644
--- a/fs/jffs2/symlink.c
+++ b/fs/jffs2/symlink.c
@@ -51,7 +51,7 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd)
51 */ 51 */
52 52
53 if (!p) { 53 if (!p) {
54 printk(KERN_ERR "jffs2_follow_link(): can't find symlink taerget\n"); 54 printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n");
55 p = ERR_PTR(-EIO); 55 p = ERR_PTR(-EIO);
56 } 56 }
57 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); 57 D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target));
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
index 70707309dfa1..9c99859f5edd 100644
--- a/fs/jffs2/wbuf.c
+++ b/fs/jffs2/wbuf.c
@@ -969,8 +969,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
969 int oobsize = c->mtd->oobsize; 969 int oobsize = c->mtd->oobsize;
970 struct mtd_oob_ops ops; 970 struct mtd_oob_ops ops;
971 971
972 ops.len = NR_OOB_SCAN_PAGES * oobsize; 972 ops.ooblen = NR_OOB_SCAN_PAGES * oobsize;
973 ops.ooblen = oobsize;
974 ops.oobbuf = c->oobbuf; 973 ops.oobbuf = c->oobbuf;
975 ops.ooboffs = 0; 974 ops.ooboffs = 0;
976 ops.datbuf = NULL; 975 ops.datbuf = NULL;
@@ -983,10 +982,10 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
983 return ret; 982 return ret;
984 } 983 }
985 984
986 if (ops.retlen < ops.len) { 985 if (ops.oobretlen < ops.ooblen) {
987 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB " 986 D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB "
988 "returned short read (%zd bytes not %d) for block " 987 "returned short read (%zd bytes not %d) for block "
989 "at %08x\n", ops.retlen, ops.len, jeb->offset)); 988 "at %08x\n", ops.oobretlen, ops.ooblen, jeb->offset));
990 return -EIO; 989 return -EIO;
991 } 990 }
992 991
@@ -1005,7 +1004,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c,
1005 } 1004 }
1006 1005
1007 /* we know, we are aligned :) */ 1006 /* we know, we are aligned :) */
1008 for (page = oobsize; page < ops.len; page += sizeof(long)) { 1007 for (page = oobsize; page < ops.ooblen; page += sizeof(long)) {
1009 long dat = *(long *)(&ops.oobbuf[page]); 1008 long dat = *(long *)(&ops.oobbuf[page]);
1010 if(dat != -1) 1009 if(dat != -1)
1011 return 1; 1010 return 1;
@@ -1033,7 +1032,6 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1033 return 2; 1032 return 2;
1034 } 1033 }
1035 1034
1036 ops.len = oobsize;
1037 ops.ooblen = oobsize; 1035 ops.ooblen = oobsize;
1038 ops.oobbuf = c->oobbuf; 1036 ops.oobbuf = c->oobbuf;
1039 ops.ooboffs = 0; 1037 ops.ooboffs = 0;
@@ -1048,10 +1046,10 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c,
1048 return ret; 1046 return ret;
1049 } 1047 }
1050 1048
1051 if (ops.retlen < ops.len) { 1049 if (ops.oobretlen < ops.ooblen) {
1052 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): " 1050 D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): "
1053 "Read OOB return short read (%zd bytes not %d) " 1051 "Read OOB return short read (%zd bytes not %d) "
1054 "for block at %08x\n", ops.retlen, ops.len, 1052 "for block at %08x\n", ops.oobretlen, ops.ooblen,
1055 jeb->offset)); 1053 jeb->offset));
1056 return -EIO; 1054 return -EIO;
1057 } 1055 }
@@ -1090,8 +1088,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1090 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); 1088 n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
1091 n.totlen = cpu_to_je32(8); 1089 n.totlen = cpu_to_je32(8);
1092 1090
1093 ops.len = c->fsdata_len; 1091 ops.ooblen = c->fsdata_len;
1094 ops.ooblen = c->fsdata_len;;
1095 ops.oobbuf = (uint8_t *)&n; 1092 ops.oobbuf = (uint8_t *)&n;
1096 ops.ooboffs = c->fsdata_pos; 1093 ops.ooboffs = c->fsdata_pos;
1097 ops.datbuf = NULL; 1094 ops.datbuf = NULL;
@@ -1105,10 +1102,10 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c,
1105 jeb->offset, ret)); 1102 jeb->offset, ret));
1106 return ret; 1103 return ret;
1107 } 1104 }
1108 if (ops.retlen != ops.len) { 1105 if (ops.oobretlen != ops.ooblen) {
1109 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): " 1106 D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): "
1110 "Short write for block at %08x: %zd not %d\n", 1107 "Short write for block at %08x: %zd not %d\n",
1111 jeb->offset, ops.retlen, ops.len)); 1108 jeb->offset, ops.oobretlen, ops.ooblen));
1112 return -EIO; 1109 return -EIO;
1113 } 1110 }
1114 return 0; 1111 return 0;
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index 4da09ce1d1f5..4bb3f1897330 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -399,8 +399,6 @@ static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datu
399{ 399{
400 /* must be called under down_write(xattr_sem) */ 400 /* must be called under down_write(xattr_sem) */
401 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) { 401 if (atomic_dec_and_lock(&xd->refcnt, &c->erase_completion_lock)) {
402 uint32_t xid = xd->xid, version = xd->version;
403
404 unload_xattr_datum(c, xd); 402 unload_xattr_datum(c, xd);
405 xd->flags |= JFFS2_XFLAGS_DEAD; 403 xd->flags |= JFFS2_XFLAGS_DEAD;
406 if (xd->node == (void *)xd) { 404 if (xd->node == (void *)xd) {
@@ -411,7 +409,8 @@ static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datu
411 } 409 }
412 spin_unlock(&c->erase_completion_lock); 410 spin_unlock(&c->erase_completion_lock);
413 411
414 dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n", xid, version); 412 dbg_xattr("xdatum(xid=%u, version=%u) was removed.\n",
413 xd->xid, xd->version);
415 } 414 }
416} 415}
417 416