diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /fs/jffs2 | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'fs/jffs2')
-rw-r--r-- | fs/jffs2/acl.c | 32 | ||||
-rw-r--r-- | fs/jffs2/background.c | 29 | ||||
-rw-r--r-- | fs/jffs2/build.c | 6 | ||||
-rw-r--r-- | fs/jffs2/compr.c | 158 | ||||
-rw-r--r-- | fs/jffs2/compr.h | 2 | ||||
-rw-r--r-- | fs/jffs2/compr_lzo.c | 1 | ||||
-rw-r--r-- | fs/jffs2/compr_rubin.c | 2 | ||||
-rw-r--r-- | fs/jffs2/compr_zlib.c | 45 | ||||
-rw-r--r-- | fs/jffs2/debug.c | 22 | ||||
-rw-r--r-- | fs/jffs2/debug.h | 50 | ||||
-rw-r--r-- | fs/jffs2/dir.c | 75 | ||||
-rw-r--r-- | fs/jffs2/erase.c | 91 | ||||
-rw-r--r-- | fs/jffs2/file.c | 78 | ||||
-rw-r--r-- | fs/jffs2/fs.c | 108 | ||||
-rw-r--r-- | fs/jffs2/gc.c | 324 | ||||
-rw-r--r-- | fs/jffs2/jffs2_fs_sb.h | 17 | ||||
-rw-r--r-- | fs/jffs2/malloc.c | 2 | ||||
-rw-r--r-- | fs/jffs2/nodelist.c | 30 | ||||
-rw-r--r-- | fs/jffs2/nodemgmt.c | 262 | ||||
-rw-r--r-- | fs/jffs2/os-linux.h | 17 | ||||
-rw-r--r-- | fs/jffs2/read.c | 70 | ||||
-rw-r--r-- | fs/jffs2/readinode.c | 56 | ||||
-rw-r--r-- | fs/jffs2/scan.c | 237 | ||||
-rw-r--r-- | fs/jffs2/security.c | 35 | ||||
-rw-r--r-- | fs/jffs2/summary.c | 16 | ||||
-rw-r--r-- | fs/jffs2/super.c | 178 | ||||
-rw-r--r-- | fs/jffs2/symlink.c | 7 | ||||
-rw-r--r-- | fs/jffs2/wbuf.c | 258 | ||||
-rw-r--r-- | fs/jffs2/write.c | 113 | ||||
-rw-r--r-- | fs/jffs2/writev.c | 32 | ||||
-rw-r--r-- | fs/jffs2/xattr.c | 25 | ||||
-rw-r--r-- | fs/jffs2/xattr.h | 2 |
32 files changed, 928 insertions, 1452 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 223283c3011..926d02068a1 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
16 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
@@ -94,23 +92,15 @@ static struct posix_acl *jffs2_acl_from_medium(void *value, size_t size) | |||
94 | case ACL_MASK: | 92 | case ACL_MASK: |
95 | case ACL_OTHER: | 93 | case ACL_OTHER: |
96 | value += sizeof(struct jffs2_acl_entry_short); | 94 | value += sizeof(struct jffs2_acl_entry_short); |
95 | acl->a_entries[i].e_id = ACL_UNDEFINED_ID; | ||
97 | break; | 96 | break; |
98 | 97 | ||
99 | case ACL_USER: | 98 | case ACL_USER: |
100 | value += sizeof(struct jffs2_acl_entry); | ||
101 | if (value > end) | ||
102 | goto fail; | ||
103 | acl->a_entries[i].e_uid = | ||
104 | make_kuid(&init_user_ns, | ||
105 | je32_to_cpu(entry->e_id)); | ||
106 | break; | ||
107 | case ACL_GROUP: | 99 | case ACL_GROUP: |
108 | value += sizeof(struct jffs2_acl_entry); | 100 | value += sizeof(struct jffs2_acl_entry); |
109 | if (value > end) | 101 | if (value > end) |
110 | goto fail; | 102 | goto fail; |
111 | acl->a_entries[i].e_gid = | 103 | acl->a_entries[i].e_id = je32_to_cpu(entry->e_id); |
112 | make_kgid(&init_user_ns, | ||
113 | je32_to_cpu(entry->e_id)); | ||
114 | break; | 104 | break; |
115 | 105 | ||
116 | default: | 106 | default: |
@@ -139,19 +129,13 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) | |||
139 | header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); | 129 | header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); |
140 | e = header + 1; | 130 | e = header + 1; |
141 | for (i=0; i < acl->a_count; i++) { | 131 | for (i=0; i < acl->a_count; i++) { |
142 | const struct posix_acl_entry *acl_e = &acl->a_entries[i]; | ||
143 | entry = e; | 132 | entry = e; |
144 | entry->e_tag = cpu_to_je16(acl_e->e_tag); | 133 | entry->e_tag = cpu_to_je16(acl->a_entries[i].e_tag); |
145 | entry->e_perm = cpu_to_je16(acl_e->e_perm); | 134 | entry->e_perm = cpu_to_je16(acl->a_entries[i].e_perm); |
146 | switch(acl_e->e_tag) { | 135 | switch(acl->a_entries[i].e_tag) { |
147 | case ACL_USER: | 136 | case ACL_USER: |
148 | entry->e_id = cpu_to_je32( | ||
149 | from_kuid(&init_user_ns, acl_e->e_uid)); | ||
150 | e += sizeof(struct jffs2_acl_entry); | ||
151 | break; | ||
152 | case ACL_GROUP: | 137 | case ACL_GROUP: |
153 | entry->e_id = cpu_to_je32( | 138 | entry->e_id = cpu_to_je32(acl->a_entries[i].e_id); |
154 | from_kgid(&init_user_ns, acl_e->e_gid)); | ||
155 | e += sizeof(struct jffs2_acl_entry); | 139 | e += sizeof(struct jffs2_acl_entry); |
156 | break; | 140 | break; |
157 | 141 | ||
@@ -377,7 +361,7 @@ static int jffs2_acl_getxattr(struct dentry *dentry, const char *name, | |||
377 | return PTR_ERR(acl); | 361 | return PTR_ERR(acl); |
378 | if (!acl) | 362 | if (!acl) |
379 | return -ENODATA; | 363 | return -ENODATA; |
380 | rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size); | 364 | rc = posix_acl_to_xattr(acl, buffer, size); |
381 | posix_acl_release(acl); | 365 | posix_acl_release(acl); |
382 | 366 | ||
383 | return rc; | 367 | return rc; |
@@ -395,7 +379,7 @@ static int jffs2_acl_setxattr(struct dentry *dentry, const char *name, | |||
395 | return -EPERM; | 379 | return -EPERM; |
396 | 380 | ||
397 | if (value) { | 381 | if (value) { |
398 | acl = posix_acl_from_xattr(&init_user_ns, value, size); | 382 | acl = posix_acl_from_xattr(value, size); |
399 | if (IS_ERR(acl)) | 383 | if (IS_ERR(acl)) |
400 | return PTR_ERR(acl); | 384 | return PTR_ERR(acl); |
401 | if (acl) { | 385 | if (acl) { |
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 2b60ce1996a..404111b016c 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/jffs2.h> | 14 | #include <linux/jffs2.h> |
17 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
@@ -44,13 +42,12 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c) | |||
44 | 42 | ||
45 | tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index); | 43 | tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index); |
46 | if (IS_ERR(tsk)) { | 44 | if (IS_ERR(tsk)) { |
47 | pr_warn("fork failed for JFFS2 garbage collect thread: %ld\n", | 45 | printk(KERN_WARNING "fork failed for JFFS2 garbage collect thread: %ld\n", -PTR_ERR(tsk)); |
48 | -PTR_ERR(tsk)); | ||
49 | complete(&c->gc_thread_exit); | 46 | complete(&c->gc_thread_exit); |
50 | ret = PTR_ERR(tsk); | 47 | ret = PTR_ERR(tsk); |
51 | } else { | 48 | } else { |
52 | /* Wait for it... */ | 49 | /* Wait for it... */ |
53 | jffs2_dbg(1, "Garbage collect thread is pid %d\n", tsk->pid); | 50 | D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", tsk->pid)); |
54 | wait_for_completion(&c->gc_thread_start); | 51 | wait_for_completion(&c->gc_thread_start); |
55 | ret = tsk->pid; | 52 | ret = tsk->pid; |
56 | } | 53 | } |
@@ -63,7 +60,7 @@ void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) | |||
63 | int wait = 0; | 60 | int wait = 0; |
64 | spin_lock(&c->erase_completion_lock); | 61 | spin_lock(&c->erase_completion_lock); |
65 | if (c->gc_task) { | 62 | if (c->gc_task) { |
66 | jffs2_dbg(1, "Killing GC task %d\n", c->gc_task->pid); | 63 | D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid)); |
67 | send_sig(SIGKILL, c->gc_task, 1); | 64 | send_sig(SIGKILL, c->gc_task, 1); |
68 | wait = 1; | 65 | wait = 1; |
69 | } | 66 | } |
@@ -93,7 +90,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
93 | if (!jffs2_thread_should_wake(c)) { | 90 | if (!jffs2_thread_should_wake(c)) { |
94 | set_current_state (TASK_INTERRUPTIBLE); | 91 | set_current_state (TASK_INTERRUPTIBLE); |
95 | spin_unlock(&c->erase_completion_lock); | 92 | spin_unlock(&c->erase_completion_lock); |
96 | jffs2_dbg(1, "%s(): sleeping...\n", __func__); | 93 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); |
97 | schedule(); | 94 | schedule(); |
98 | } else | 95 | } else |
99 | spin_unlock(&c->erase_completion_lock); | 96 | spin_unlock(&c->erase_completion_lock); |
@@ -112,7 +109,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
112 | schedule_timeout_interruptible(msecs_to_jiffies(50)); | 109 | schedule_timeout_interruptible(msecs_to_jiffies(50)); |
113 | 110 | ||
114 | if (kthread_should_stop()) { | 111 | if (kthread_should_stop()) { |
115 | jffs2_dbg(1, "%s(): kthread_stop() called\n", __func__); | 112 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): kthread_stop() called.\n")); |
116 | goto die; | 113 | goto die; |
117 | } | 114 | } |
118 | 115 | ||
@@ -129,32 +126,28 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
129 | 126 | ||
130 | switch(signr) { | 127 | switch(signr) { |
131 | case SIGSTOP: | 128 | case SIGSTOP: |
132 | jffs2_dbg(1, "%s(): SIGSTOP received\n", | 129 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGSTOP received.\n")); |
133 | __func__); | ||
134 | set_current_state(TASK_STOPPED); | 130 | set_current_state(TASK_STOPPED); |
135 | schedule(); | 131 | schedule(); |
136 | break; | 132 | break; |
137 | 133 | ||
138 | case SIGKILL: | 134 | case SIGKILL: |
139 | jffs2_dbg(1, "%s(): SIGKILL received\n", | 135 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGKILL received.\n")); |
140 | __func__); | ||
141 | goto die; | 136 | goto die; |
142 | 137 | ||
143 | case SIGHUP: | 138 | case SIGHUP: |
144 | jffs2_dbg(1, "%s(): SIGHUP received\n", | 139 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGHUP received.\n")); |
145 | __func__); | ||
146 | break; | 140 | break; |
147 | default: | 141 | default: |
148 | jffs2_dbg(1, "%s(): signal %ld received\n", | 142 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): signal %ld received\n", signr)); |
149 | __func__, signr); | ||
150 | } | 143 | } |
151 | } | 144 | } |
152 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ | 145 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ |
153 | disallow_signal(SIGHUP); | 146 | disallow_signal(SIGHUP); |
154 | 147 | ||
155 | jffs2_dbg(1, "%s(): pass\n", __func__); | 148 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): pass\n")); |
156 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { | 149 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { |
157 | pr_notice("No space for garbage collection. Aborting GC thread\n"); | 150 | printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n"); |
158 | goto die; | 151 | goto die; |
159 | } | 152 | } |
160 | } | 153 | } |
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index a3750f902ad..3005ec4520a 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/sched.h> | 14 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
@@ -309,8 +307,8 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) | |||
309 | trying to GC to make more space. It'll be a fruitless task */ | 307 | trying to GC to make more space. It'll be a fruitless task */ |
310 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); | 308 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); |
311 | 309 | ||
312 | dbg_fsbuild("trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", | 310 | dbg_fsbuild("JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", |
313 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks); | 311 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks); |
314 | dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n", | 312 | dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n", |
315 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024); | 313 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024); |
316 | dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n", | 314 | dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n", |
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c index 4849a4c9a0e..de4247021d2 100644 --- a/fs/jffs2/compr.c +++ b/fs/jffs2/compr.c | |||
@@ -12,8 +12,6 @@ | |||
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
16 | |||
17 | #include "compr.h" | 15 | #include "compr.h" |
18 | 16 | ||
19 | static DEFINE_SPINLOCK(jffs2_compressor_list_lock); | 17 | static DEFINE_SPINLOCK(jffs2_compressor_list_lock); |
@@ -55,78 +53,6 @@ static int jffs2_is_best_compression(struct jffs2_compressor *this, | |||
55 | return 0; | 53 | return 0; |
56 | } | 54 | } |
57 | 55 | ||
58 | /* | ||
59 | * jffs2_selected_compress: | ||
60 | * @compr: Explicit compression type to use (ie, JFFS2_COMPR_ZLIB). | ||
61 | * If 0, just take the first available compression mode. | ||
62 | * @data_in: Pointer to uncompressed data | ||
63 | * @cpage_out: Pointer to returned pointer to buffer for compressed data | ||
64 | * @datalen: On entry, holds the amount of data available for compression. | ||
65 | * On exit, expected to hold the amount of data actually compressed. | ||
66 | * @cdatalen: On entry, holds the amount of space available for compressed | ||
67 | * data. On exit, expected to hold the actual size of the compressed | ||
68 | * data. | ||
69 | * | ||
70 | * Returns: the compression type used. Zero is used to show that the data | ||
71 | * could not be compressed; probably because we couldn't find the requested | ||
72 | * compression mode. | ||
73 | */ | ||
74 | static int jffs2_selected_compress(u8 compr, unsigned char *data_in, | ||
75 | unsigned char **cpage_out, u32 *datalen, u32 *cdatalen) | ||
76 | { | ||
77 | struct jffs2_compressor *this; | ||
78 | int err, ret = JFFS2_COMPR_NONE; | ||
79 | uint32_t orig_slen, orig_dlen; | ||
80 | char *output_buf; | ||
81 | |||
82 | output_buf = kmalloc(*cdatalen, GFP_KERNEL); | ||
83 | if (!output_buf) { | ||
84 | pr_warn("No memory for compressor allocation. Compression failed.\n"); | ||
85 | return ret; | ||
86 | } | ||
87 | orig_slen = *datalen; | ||
88 | orig_dlen = *cdatalen; | ||
89 | spin_lock(&jffs2_compressor_list_lock); | ||
90 | list_for_each_entry(this, &jffs2_compressor_list, list) { | ||
91 | /* Skip decompress-only and disabled modules */ | ||
92 | if (!this->compress || this->disabled) | ||
93 | continue; | ||
94 | |||
95 | /* Skip if not the desired compression type */ | ||
96 | if (compr && (compr != this->compr)) | ||
97 | continue; | ||
98 | |||
99 | /* | ||
100 | * Either compression type was unspecified, or we found our | ||
101 | * compressor; either way, we're good to go. | ||
102 | */ | ||
103 | this->usecount++; | ||
104 | spin_unlock(&jffs2_compressor_list_lock); | ||
105 | |||
106 | *datalen = orig_slen; | ||
107 | *cdatalen = orig_dlen; | ||
108 | err = this->compress(data_in, output_buf, datalen, cdatalen); | ||
109 | |||
110 | spin_lock(&jffs2_compressor_list_lock); | ||
111 | this->usecount--; | ||
112 | if (!err) { | ||
113 | /* Success */ | ||
114 | ret = this->compr; | ||
115 | this->stat_compr_blocks++; | ||
116 | this->stat_compr_orig_size += *datalen; | ||
117 | this->stat_compr_new_size += *cdatalen; | ||
118 | break; | ||
119 | } | ||
120 | } | ||
121 | spin_unlock(&jffs2_compressor_list_lock); | ||
122 | if (ret == JFFS2_COMPR_NONE) | ||
123 | kfree(output_buf); | ||
124 | else | ||
125 | *cpage_out = output_buf; | ||
126 | |||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | /* jffs2_compress: | 56 | /* jffs2_compress: |
131 | * @data_in: Pointer to uncompressed data | 57 | * @data_in: Pointer to uncompressed data |
132 | * @cpage_out: Pointer to returned pointer to buffer for compressed data | 58 | * @cpage_out: Pointer to returned pointer to buffer for compressed data |
@@ -150,23 +76,47 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
150 | uint32_t *datalen, uint32_t *cdatalen) | 76 | uint32_t *datalen, uint32_t *cdatalen) |
151 | { | 77 | { |
152 | int ret = JFFS2_COMPR_NONE; | 78 | int ret = JFFS2_COMPR_NONE; |
153 | int mode, compr_ret; | 79 | int compr_ret; |
154 | struct jffs2_compressor *this, *best=NULL; | 80 | struct jffs2_compressor *this, *best=NULL; |
155 | unsigned char *output_buf = NULL, *tmp_buf; | 81 | unsigned char *output_buf = NULL, *tmp_buf; |
156 | uint32_t orig_slen, orig_dlen; | 82 | uint32_t orig_slen, orig_dlen; |
157 | uint32_t best_slen=0, best_dlen=0; | 83 | uint32_t best_slen=0, best_dlen=0; |
158 | 84 | ||
159 | if (c->mount_opts.override_compr) | 85 | switch (jffs2_compression_mode) { |
160 | mode = c->mount_opts.compr; | ||
161 | else | ||
162 | mode = jffs2_compression_mode; | ||
163 | |||
164 | switch (mode) { | ||
165 | case JFFS2_COMPR_MODE_NONE: | 86 | case JFFS2_COMPR_MODE_NONE: |
166 | break; | 87 | break; |
167 | case JFFS2_COMPR_MODE_PRIORITY: | 88 | case JFFS2_COMPR_MODE_PRIORITY: |
168 | ret = jffs2_selected_compress(0, data_in, cpage_out, datalen, | 89 | output_buf = kmalloc(*cdatalen,GFP_KERNEL); |
169 | cdatalen); | 90 | if (!output_buf) { |
91 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n"); | ||
92 | goto out; | ||
93 | } | ||
94 | orig_slen = *datalen; | ||
95 | orig_dlen = *cdatalen; | ||
96 | spin_lock(&jffs2_compressor_list_lock); | ||
97 | list_for_each_entry(this, &jffs2_compressor_list, list) { | ||
98 | /* Skip decompress-only backwards-compatibility and disabled modules */ | ||
99 | if ((!this->compress)||(this->disabled)) | ||
100 | continue; | ||
101 | |||
102 | this->usecount++; | ||
103 | spin_unlock(&jffs2_compressor_list_lock); | ||
104 | *datalen = orig_slen; | ||
105 | *cdatalen = orig_dlen; | ||
106 | compr_ret = this->compress(data_in, output_buf, datalen, cdatalen); | ||
107 | spin_lock(&jffs2_compressor_list_lock); | ||
108 | this->usecount--; | ||
109 | if (!compr_ret) { | ||
110 | ret = this->compr; | ||
111 | this->stat_compr_blocks++; | ||
112 | this->stat_compr_orig_size += *datalen; | ||
113 | this->stat_compr_new_size += *cdatalen; | ||
114 | break; | ||
115 | } | ||
116 | } | ||
117 | spin_unlock(&jffs2_compressor_list_lock); | ||
118 | if (ret == JFFS2_COMPR_NONE) | ||
119 | kfree(output_buf); | ||
170 | break; | 120 | break; |
171 | case JFFS2_COMPR_MODE_SIZE: | 121 | case JFFS2_COMPR_MODE_SIZE: |
172 | case JFFS2_COMPR_MODE_FAVOURLZO: | 122 | case JFFS2_COMPR_MODE_FAVOURLZO: |
@@ -190,8 +140,7 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
190 | tmp_buf = kmalloc(orig_slen, GFP_KERNEL); | 140 | tmp_buf = kmalloc(orig_slen, GFP_KERNEL); |
191 | spin_lock(&jffs2_compressor_list_lock); | 141 | spin_lock(&jffs2_compressor_list_lock); |
192 | if (!tmp_buf) { | 142 | if (!tmp_buf) { |
193 | pr_warn("No memory for compressor allocation. (%d bytes)\n", | 143 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n", orig_slen); |
194 | orig_slen); | ||
195 | continue; | 144 | continue; |
196 | } | 145 | } |
197 | else { | 146 | else { |
@@ -225,28 +174,22 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
225 | best->stat_compr_orig_size += best_slen; | 174 | best->stat_compr_orig_size += best_slen; |
226 | best->stat_compr_new_size += best_dlen; | 175 | best->stat_compr_new_size += best_dlen; |
227 | ret = best->compr; | 176 | ret = best->compr; |
228 | *cpage_out = output_buf; | ||
229 | } | 177 | } |
230 | spin_unlock(&jffs2_compressor_list_lock); | 178 | spin_unlock(&jffs2_compressor_list_lock); |
231 | break; | 179 | break; |
232 | case JFFS2_COMPR_MODE_FORCELZO: | ||
233 | ret = jffs2_selected_compress(JFFS2_COMPR_LZO, data_in, | ||
234 | cpage_out, datalen, cdatalen); | ||
235 | break; | ||
236 | case JFFS2_COMPR_MODE_FORCEZLIB: | ||
237 | ret = jffs2_selected_compress(JFFS2_COMPR_ZLIB, data_in, | ||
238 | cpage_out, datalen, cdatalen); | ||
239 | break; | ||
240 | default: | 180 | default: |
241 | pr_err("unknown compression mode\n"); | 181 | printk(KERN_ERR "JFFS2: unknown compression mode.\n"); |
242 | } | 182 | } |
243 | 183 | out: | |
244 | if (ret == JFFS2_COMPR_NONE) { | 184 | if (ret == JFFS2_COMPR_NONE) { |
245 | *cpage_out = data_in; | 185 | *cpage_out = data_in; |
246 | *datalen = *cdatalen; | 186 | *datalen = *cdatalen; |
247 | none_stat_compr_blocks++; | 187 | none_stat_compr_blocks++; |
248 | none_stat_compr_size += *datalen; | 188 | none_stat_compr_size += *datalen; |
249 | } | 189 | } |
190 | else { | ||
191 | *cpage_out = output_buf; | ||
192 | } | ||
250 | return ret; | 193 | return ret; |
251 | } | 194 | } |
252 | 195 | ||
@@ -280,8 +223,7 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
280 | ret = this->decompress(cdata_in, data_out, cdatalen, datalen); | 223 | ret = this->decompress(cdata_in, data_out, cdatalen, datalen); |
281 | spin_lock(&jffs2_compressor_list_lock); | 224 | spin_lock(&jffs2_compressor_list_lock); |
282 | if (ret) { | 225 | if (ret) { |
283 | pr_warn("Decompressor \"%s\" returned %d\n", | 226 | printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret); |
284 | this->name, ret); | ||
285 | } | 227 | } |
286 | else { | 228 | else { |
287 | this->stat_decompr_blocks++; | 229 | this->stat_decompr_blocks++; |
@@ -291,7 +233,7 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
291 | return ret; | 233 | return ret; |
292 | } | 234 | } |
293 | } | 235 | } |
294 | pr_warn("compression type 0x%02x not available\n", comprtype); | 236 | printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype); |
295 | spin_unlock(&jffs2_compressor_list_lock); | 237 | spin_unlock(&jffs2_compressor_list_lock); |
296 | return -EIO; | 238 | return -EIO; |
297 | } | 239 | } |
@@ -303,7 +245,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) | |||
303 | struct jffs2_compressor *this; | 245 | struct jffs2_compressor *this; |
304 | 246 | ||
305 | if (!comp->name) { | 247 | if (!comp->name) { |
306 | pr_warn("NULL compressor name at registering JFFS2 compressor. Failed.\n"); | 248 | printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n"); |
307 | return -1; | 249 | return -1; |
308 | } | 250 | } |
309 | comp->compr_buf_size=0; | 251 | comp->compr_buf_size=0; |
@@ -313,7 +255,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) | |||
313 | comp->stat_compr_new_size=0; | 255 | comp->stat_compr_new_size=0; |
314 | comp->stat_compr_blocks=0; | 256 | comp->stat_compr_blocks=0; |
315 | comp->stat_decompr_blocks=0; | 257 | comp->stat_decompr_blocks=0; |
316 | jffs2_dbg(1, "Registering JFFS2 compressor \"%s\"\n", comp->name); | 258 | D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name)); |
317 | 259 | ||
318 | spin_lock(&jffs2_compressor_list_lock); | 260 | spin_lock(&jffs2_compressor_list_lock); |
319 | 261 | ||
@@ -336,15 +278,15 @@ out: | |||
336 | 278 | ||
337 | int jffs2_unregister_compressor(struct jffs2_compressor *comp) | 279 | int jffs2_unregister_compressor(struct jffs2_compressor *comp) |
338 | { | 280 | { |
339 | D2(struct jffs2_compressor *this); | 281 | D2(struct jffs2_compressor *this;) |
340 | 282 | ||
341 | jffs2_dbg(1, "Unregistering JFFS2 compressor \"%s\"\n", comp->name); | 283 | D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); |
342 | 284 | ||
343 | spin_lock(&jffs2_compressor_list_lock); | 285 | spin_lock(&jffs2_compressor_list_lock); |
344 | 286 | ||
345 | if (comp->usecount) { | 287 | if (comp->usecount) { |
346 | spin_unlock(&jffs2_compressor_list_lock); | 288 | spin_unlock(&jffs2_compressor_list_lock); |
347 | pr_warn("Compressor module is in use. Unregister failed.\n"); | 289 | printk(KERN_WARNING "JFFS2: Compressor modul is in use. Unregister failed.\n"); |
348 | return -1; | 290 | return -1; |
349 | } | 291 | } |
350 | list_del(&comp->list); | 292 | list_del(&comp->list); |
@@ -381,17 +323,17 @@ int __init jffs2_compressors_init(void) | |||
381 | /* Setting default compression mode */ | 323 | /* Setting default compression mode */ |
382 | #ifdef CONFIG_JFFS2_CMODE_NONE | 324 | #ifdef CONFIG_JFFS2_CMODE_NONE |
383 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; | 325 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; |
384 | jffs2_dbg(1, "default compression mode: none\n"); | 326 | D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) |
385 | #else | 327 | #else |
386 | #ifdef CONFIG_JFFS2_CMODE_SIZE | 328 | #ifdef CONFIG_JFFS2_CMODE_SIZE |
387 | jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; | 329 | jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; |
388 | jffs2_dbg(1, "default compression mode: size\n"); | 330 | D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) |
389 | #else | 331 | #else |
390 | #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO | 332 | #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO |
391 | jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; | 333 | jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; |
392 | jffs2_dbg(1, "default compression mode: favourlzo\n"); | 334 | D1(printk(KERN_INFO "JFFS2: default compression mode: favourlzo\n");) |
393 | #else | 335 | #else |
394 | jffs2_dbg(1, "default compression mode: priority\n"); | 336 | D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) |
395 | #endif | 337 | #endif |
396 | #endif | 338 | #endif |
397 | #endif | 339 | #endif |
diff --git a/fs/jffs2/compr.h b/fs/jffs2/compr.h index 5e91d578f4e..13bb7597ab3 100644 --- a/fs/jffs2/compr.h +++ b/fs/jffs2/compr.h | |||
@@ -40,8 +40,6 @@ | |||
40 | #define JFFS2_COMPR_MODE_PRIORITY 1 | 40 | #define JFFS2_COMPR_MODE_PRIORITY 1 |
41 | #define JFFS2_COMPR_MODE_SIZE 2 | 41 | #define JFFS2_COMPR_MODE_SIZE 2 |
42 | #define JFFS2_COMPR_MODE_FAVOURLZO 3 | 42 | #define JFFS2_COMPR_MODE_FAVOURLZO 3 |
43 | #define JFFS2_COMPR_MODE_FORCELZO 4 | ||
44 | #define JFFS2_COMPR_MODE_FORCEZLIB 5 | ||
45 | 43 | ||
46 | #define FAVOUR_LZO_PERCENT 80 | 44 | #define FAVOUR_LZO_PERCENT 80 |
47 | 45 | ||
diff --git a/fs/jffs2/compr_lzo.c b/fs/jffs2/compr_lzo.c index c553bd6506d..af186ee674d 100644 --- a/fs/jffs2/compr_lzo.c +++ b/fs/jffs2/compr_lzo.c | |||
@@ -33,6 +33,7 @@ static int __init alloc_workspace(void) | |||
33 | lzo_compress_buf = vmalloc(lzo1x_worst_compress(PAGE_SIZE)); | 33 | lzo_compress_buf = vmalloc(lzo1x_worst_compress(PAGE_SIZE)); |
34 | 34 | ||
35 | if (!lzo_mem || !lzo_compress_buf) { | 35 | if (!lzo_mem || !lzo_compress_buf) { |
36 | printk(KERN_WARNING "Failed to allocate lzo deflate workspace\n"); | ||
36 | free_workspace(); | 37 | free_workspace(); |
37 | return -ENOMEM; | 38 | return -ENOMEM; |
38 | } | 39 | } |
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c index 92e0644bf86..9e7cec808c4 100644 --- a/fs/jffs2/compr_rubin.c +++ b/fs/jffs2/compr_rubin.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/string.h> | 13 | #include <linux/string.h> |
16 | #include <linux/types.h> | 14 | #include <linux/types.h> |
17 | #include <linux/jffs2.h> | 15 | #include <linux/jffs2.h> |
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c index 0b9a1e44e83..5a001020c54 100644 --- a/fs/jffs2/compr_zlib.c +++ b/fs/jffs2/compr_zlib.c | |||
@@ -14,8 +14,6 @@ | |||
14 | #error "The userspace support got too messy and was removed. Update your mkfs.jffs2" | 14 | #error "The userspace support got too messy and was removed. Update your mkfs.jffs2" |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
18 | |||
19 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
20 | #include <linux/zlib.h> | 18 | #include <linux/zlib.h> |
21 | #include <linux/zutil.h> | 19 | #include <linux/zutil.h> |
@@ -44,18 +42,18 @@ static int __init alloc_workspaces(void) | |||
44 | { | 42 | { |
45 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize(MAX_WBITS, | 43 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize(MAX_WBITS, |
46 | MAX_MEM_LEVEL)); | 44 | MAX_MEM_LEVEL)); |
47 | if (!def_strm.workspace) | 45 | if (!def_strm.workspace) { |
46 | printk(KERN_WARNING "Failed to allocate %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL)); | ||
48 | return -ENOMEM; | 47 | return -ENOMEM; |
49 | 48 | } | |
50 | jffs2_dbg(1, "Allocated %d bytes for deflate workspace\n", | 49 | D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL))); |
51 | zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL)); | ||
52 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); | 50 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); |
53 | if (!inf_strm.workspace) { | 51 | if (!inf_strm.workspace) { |
52 | printk(KERN_WARNING "Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize()); | ||
54 | vfree(def_strm.workspace); | 53 | vfree(def_strm.workspace); |
55 | return -ENOMEM; | 54 | return -ENOMEM; |
56 | } | 55 | } |
57 | jffs2_dbg(1, "Allocated %d bytes for inflate workspace\n", | 56 | D1(printk(KERN_DEBUG "Allocated %d bytes for inflate workspace\n", zlib_inflate_workspacesize())); |
58 | zlib_inflate_workspacesize()); | ||
59 | return 0; | 57 | return 0; |
60 | } | 58 | } |
61 | 59 | ||
@@ -81,7 +79,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
81 | mutex_lock(&deflate_mutex); | 79 | mutex_lock(&deflate_mutex); |
82 | 80 | ||
83 | if (Z_OK != zlib_deflateInit(&def_strm, 3)) { | 81 | if (Z_OK != zlib_deflateInit(&def_strm, 3)) { |
84 | pr_warn("deflateInit failed\n"); | 82 | printk(KERN_WARNING "deflateInit failed\n"); |
85 | mutex_unlock(&deflate_mutex); | 83 | mutex_unlock(&deflate_mutex); |
86 | return -1; | 84 | return -1; |
87 | } | 85 | } |
@@ -95,14 +93,13 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
95 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { | 93 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { |
96 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); | 94 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); |
97 | def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); | 95 | def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); |
98 | jffs2_dbg(1, "calling deflate with avail_in %d, avail_out %d\n", | 96 | D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", |
99 | def_strm.avail_in, def_strm.avail_out); | 97 | def_strm.avail_in, def_strm.avail_out)); |
100 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); | 98 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); |
101 | jffs2_dbg(1, "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", | 99 | D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", |
102 | def_strm.avail_in, def_strm.avail_out, | 100 | def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); |
103 | def_strm.total_in, def_strm.total_out); | ||
104 | if (ret != Z_OK) { | 101 | if (ret != Z_OK) { |
105 | jffs2_dbg(1, "deflate in loop returned %d\n", ret); | 102 | D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); |
106 | zlib_deflateEnd(&def_strm); | 103 | zlib_deflateEnd(&def_strm); |
107 | mutex_unlock(&deflate_mutex); | 104 | mutex_unlock(&deflate_mutex); |
108 | return -1; | 105 | return -1; |
@@ -114,20 +111,20 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
114 | zlib_deflateEnd(&def_strm); | 111 | zlib_deflateEnd(&def_strm); |
115 | 112 | ||
116 | if (ret != Z_STREAM_END) { | 113 | if (ret != Z_STREAM_END) { |
117 | jffs2_dbg(1, "final deflate returned %d\n", ret); | 114 | D1(printk(KERN_DEBUG "final deflate returned %d\n", ret)); |
118 | ret = -1; | 115 | ret = -1; |
119 | goto out; | 116 | goto out; |
120 | } | 117 | } |
121 | 118 | ||
122 | if (def_strm.total_out >= def_strm.total_in) { | 119 | if (def_strm.total_out >= def_strm.total_in) { |
123 | jffs2_dbg(1, "zlib compressed %ld bytes into %ld; failing\n", | 120 | D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld; failing\n", |
124 | def_strm.total_in, def_strm.total_out); | 121 | def_strm.total_in, def_strm.total_out)); |
125 | ret = -1; | 122 | ret = -1; |
126 | goto out; | 123 | goto out; |
127 | } | 124 | } |
128 | 125 | ||
129 | jffs2_dbg(1, "zlib compressed %ld bytes into %ld\n", | 126 | D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld\n", |
130 | def_strm.total_in, def_strm.total_out); | 127 | def_strm.total_in, def_strm.total_out)); |
131 | 128 | ||
132 | *dstlen = def_strm.total_out; | 129 | *dstlen = def_strm.total_out; |
133 | *sourcelen = def_strm.total_in; | 130 | *sourcelen = def_strm.total_in; |
@@ -160,18 +157,18 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | |||
160 | ((data_in[0] & 0x0f) == Z_DEFLATED) && | 157 | ((data_in[0] & 0x0f) == Z_DEFLATED) && |
161 | !(((data_in[0]<<8) + data_in[1]) % 31)) { | 158 | !(((data_in[0]<<8) + data_in[1]) % 31)) { |
162 | 159 | ||
163 | jffs2_dbg(2, "inflate skipping adler32\n"); | 160 | D2(printk(KERN_DEBUG "inflate skipping adler32\n")); |
164 | wbits = -((data_in[0] >> 4) + 8); | 161 | wbits = -((data_in[0] >> 4) + 8); |
165 | inf_strm.next_in += 2; | 162 | inf_strm.next_in += 2; |
166 | inf_strm.avail_in -= 2; | 163 | inf_strm.avail_in -= 2; |
167 | } else { | 164 | } else { |
168 | /* Let this remain D1 for now -- it should never happen */ | 165 | /* Let this remain D1 for now -- it should never happen */ |
169 | jffs2_dbg(1, "inflate not skipping adler32\n"); | 166 | D1(printk(KERN_DEBUG "inflate not skipping adler32\n")); |
170 | } | 167 | } |
171 | 168 | ||
172 | 169 | ||
173 | if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { | 170 | if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { |
174 | pr_warn("inflateInit failed\n"); | 171 | printk(KERN_WARNING "inflateInit failed\n"); |
175 | mutex_unlock(&inflate_mutex); | 172 | mutex_unlock(&inflate_mutex); |
176 | return 1; | 173 | return 1; |
177 | } | 174 | } |
@@ -179,7 +176,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | |||
179 | while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK) | 176 | while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK) |
180 | ; | 177 | ; |
181 | if (ret != Z_STREAM_END) { | 178 | if (ret != Z_STREAM_END) { |
182 | pr_notice("inflate returned %d\n", ret); | 179 | printk(KERN_NOTICE "inflate returned %d\n", ret); |
183 | } | 180 | } |
184 | zlib_inflateEnd(&inf_strm); | 181 | zlib_inflateEnd(&inf_strm); |
185 | mutex_unlock(&inflate_mutex); | 182 | mutex_unlock(&inflate_mutex); |
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 1090eb64b90..e0b76c87a91 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/types.h> | 14 | #include <linux/types.h> |
17 | #include <linux/pagemap.h> | 15 | #include <linux/pagemap.h> |
@@ -263,15 +261,12 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c) | |||
263 | bad += c->sector_size; | 261 | bad += c->sector_size; |
264 | } | 262 | } |
265 | 263 | ||
266 | #define check(sz) \ | 264 | #define check(sz) \ |
267 | do { \ | 265 | if (sz != c->sz##_size) { \ |
268 | if (sz != c->sz##_size) { \ | 266 | printk(KERN_WARNING #sz "_size mismatch counted 0x%x, c->" #sz "_size 0x%x\n", \ |
269 | pr_warn("%s_size mismatch counted 0x%x, c->%s_size 0x%x\n", \ | 267 | sz, c->sz##_size); \ |
270 | #sz, sz, #sz, c->sz##_size); \ | 268 | dump = 1; \ |
271 | dump = 1; \ | 269 | } |
272 | } \ | ||
273 | } while (0) | ||
274 | |||
275 | check(free); | 270 | check(free); |
276 | check(dirty); | 271 | check(dirty); |
277 | check(used); | 272 | check(used); |
@@ -279,12 +274,11 @@ do { \ | |||
279 | check(unchecked); | 274 | check(unchecked); |
280 | check(bad); | 275 | check(bad); |
281 | check(erasing); | 276 | check(erasing); |
282 | |||
283 | #undef check | 277 | #undef check |
284 | 278 | ||
285 | if (nr_counted != c->nr_blocks) { | 279 | if (nr_counted != c->nr_blocks) { |
286 | pr_warn("%s counted only 0x%x blocks of 0x%x. Where are the others?\n", | 280 | printk(KERN_WARNING "%s counted only 0x%x blocks of 0x%x. Where are the others?\n", |
287 | __func__, nr_counted, c->nr_blocks); | 281 | __func__, nr_counted, c->nr_blocks); |
288 | dump = 1; | 282 | dump = 1; |
289 | } | 283 | } |
290 | 284 | ||
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h index 4fd9be4cbc9..c4f8eef5ca6 100644 --- a/fs/jffs2/debug.h +++ b/fs/jffs2/debug.h | |||
@@ -51,7 +51,6 @@ | |||
51 | * superseded by nicer dbg_xxx() macros... | 51 | * superseded by nicer dbg_xxx() macros... |
52 | */ | 52 | */ |
53 | #if CONFIG_JFFS2_FS_DEBUG > 0 | 53 | #if CONFIG_JFFS2_FS_DEBUG > 0 |
54 | #define DEBUG | ||
55 | #define D1(x) x | 54 | #define D1(x) x |
56 | #else | 55 | #else |
57 | #define D1(x) | 56 | #define D1(x) |
@@ -63,33 +62,50 @@ | |||
63 | #define D2(x) | 62 | #define D2(x) |
64 | #endif | 63 | #endif |
65 | 64 | ||
66 | #define jffs2_dbg(level, fmt, ...) \ | ||
67 | do { \ | ||
68 | if (CONFIG_JFFS2_FS_DEBUG >= level) \ | ||
69 | pr_debug(fmt, ##__VA_ARGS__); \ | ||
70 | } while (0) | ||
71 | |||
72 | /* The prefixes of JFFS2 messages */ | 65 | /* The prefixes of JFFS2 messages */ |
73 | #define JFFS2_DBG KERN_DEBUG | ||
74 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" | 66 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" |
67 | #define JFFS2_ERR_PREFIX "JFFS2 error:" | ||
68 | #define JFFS2_WARN_PREFIX "JFFS2 warning:" | ||
69 | #define JFFS2_NOTICE_PREFIX "JFFS2 notice:" | ||
70 | |||
71 | #define JFFS2_ERR KERN_ERR | ||
72 | #define JFFS2_WARN KERN_WARNING | ||
73 | #define JFFS2_NOT KERN_NOTICE | ||
74 | #define JFFS2_DBG KERN_DEBUG | ||
75 | |||
75 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX | 76 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX |
77 | #define JFFS2_ERR_MSG_PREFIX JFFS2_ERR JFFS2_ERR_PREFIX | ||
78 | #define JFFS2_WARN_MSG_PREFIX JFFS2_WARN JFFS2_WARN_PREFIX | ||
79 | #define JFFS2_NOTICE_MSG_PREFIX JFFS2_NOT JFFS2_NOTICE_PREFIX | ||
76 | 80 | ||
77 | /* JFFS2 message macros */ | 81 | /* JFFS2 message macros */ |
78 | #define JFFS2_ERROR(fmt, ...) \ | 82 | #define JFFS2_ERROR(fmt, ...) \ |
79 | pr_err("error: (%d) %s: " fmt, \ | 83 | do { \ |
80 | task_pid_nr(current), __func__, ##__VA_ARGS__) | 84 | printk(JFFS2_ERR_MSG_PREFIX \ |
85 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
86 | __func__ , ##__VA_ARGS__); \ | ||
87 | } while(0) | ||
81 | 88 | ||
82 | #define JFFS2_WARNING(fmt, ...) \ | 89 | #define JFFS2_WARNING(fmt, ...) \ |
83 | pr_warn("warning: (%d) %s: " fmt, \ | 90 | do { \ |
84 | task_pid_nr(current), __func__, ##__VA_ARGS__) | 91 | printk(JFFS2_WARN_MSG_PREFIX \ |
92 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
93 | __func__ , ##__VA_ARGS__); \ | ||
94 | } while(0) | ||
85 | 95 | ||
86 | #define JFFS2_NOTICE(fmt, ...) \ | 96 | #define JFFS2_NOTICE(fmt, ...) \ |
87 | pr_notice("notice: (%d) %s: " fmt, \ | 97 | do { \ |
88 | task_pid_nr(current), __func__, ##__VA_ARGS__) | 98 | printk(JFFS2_NOTICE_MSG_PREFIX \ |
99 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
100 | __func__ , ##__VA_ARGS__); \ | ||
101 | } while(0) | ||
89 | 102 | ||
90 | #define JFFS2_DEBUG(fmt, ...) \ | 103 | #define JFFS2_DEBUG(fmt, ...) \ |
91 | printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \ | 104 | do { \ |
92 | task_pid_nr(current), __func__, ##__VA_ARGS__) | 105 | printk(JFFS2_DBG_MSG_PREFIX \ |
106 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
107 | __func__ , ##__VA_ARGS__); \ | ||
108 | } while(0) | ||
93 | 109 | ||
94 | /* | 110 | /* |
95 | * We split our debugging messages on several parts, depending on the JFFS2 | 111 | * We split our debugging messages on several parts, depending on the JFFS2 |
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index ad7774d3209..9659b7c0046 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
17 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
@@ -24,16 +22,16 @@ | |||
24 | 22 | ||
25 | static int jffs2_readdir (struct file *, void *, filldir_t); | 23 | static int jffs2_readdir (struct file *, void *, filldir_t); |
26 | 24 | ||
27 | static int jffs2_create (struct inode *,struct dentry *,umode_t, | 25 | static int jffs2_create (struct inode *,struct dentry *,int, |
28 | bool); | 26 | struct nameidata *); |
29 | static struct dentry *jffs2_lookup (struct inode *,struct dentry *, | 27 | static struct dentry *jffs2_lookup (struct inode *,struct dentry *, |
30 | unsigned int); | 28 | struct nameidata *); |
31 | static int jffs2_link (struct dentry *,struct inode *,struct dentry *); | 29 | static int jffs2_link (struct dentry *,struct inode *,struct dentry *); |
32 | static int jffs2_unlink (struct inode *,struct dentry *); | 30 | static int jffs2_unlink (struct inode *,struct dentry *); |
33 | static int jffs2_symlink (struct inode *,struct dentry *,const char *); | 31 | static int jffs2_symlink (struct inode *,struct dentry *,const char *); |
34 | static int jffs2_mkdir (struct inode *,struct dentry *,umode_t); | 32 | static int jffs2_mkdir (struct inode *,struct dentry *,int); |
35 | static int jffs2_rmdir (struct inode *,struct dentry *); | 33 | static int jffs2_rmdir (struct inode *,struct dentry *); |
36 | static int jffs2_mknod (struct inode *,struct dentry *,umode_t,dev_t); | 34 | static int jffs2_mknod (struct inode *,struct dentry *,int,dev_t); |
37 | static int jffs2_rename (struct inode *, struct dentry *, | 35 | static int jffs2_rename (struct inode *, struct dentry *, |
38 | struct inode *, struct dentry *); | 36 | struct inode *, struct dentry *); |
39 | 37 | ||
@@ -74,14 +72,14 @@ const struct inode_operations jffs2_dir_inode_operations = | |||
74 | nice and simple | 72 | nice and simple |
75 | */ | 73 | */ |
76 | static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | 74 | static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, |
77 | unsigned int flags) | 75 | struct nameidata *nd) |
78 | { | 76 | { |
79 | struct jffs2_inode_info *dir_f; | 77 | struct jffs2_inode_info *dir_f; |
80 | struct jffs2_full_dirent *fd = NULL, *fd_list; | 78 | struct jffs2_full_dirent *fd = NULL, *fd_list; |
81 | uint32_t ino = 0; | 79 | uint32_t ino = 0; |
82 | struct inode *inode = NULL; | 80 | struct inode *inode = NULL; |
83 | 81 | ||
84 | jffs2_dbg(1, "jffs2_lookup()\n"); | 82 | D1(printk(KERN_DEBUG "jffs2_lookup()\n")); |
85 | 83 | ||
86 | if (target->d_name.len > JFFS2_MAX_NAME_LEN) | 84 | if (target->d_name.len > JFFS2_MAX_NAME_LEN) |
87 | return ERR_PTR(-ENAMETOOLONG); | 85 | return ERR_PTR(-ENAMETOOLONG); |
@@ -105,7 +103,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
105 | if (ino) { | 103 | if (ino) { |
106 | inode = jffs2_iget(dir_i->i_sb, ino); | 104 | inode = jffs2_iget(dir_i->i_sb, ino); |
107 | if (IS_ERR(inode)) | 105 | if (IS_ERR(inode)) |
108 | pr_warn("iget() failed for ino #%u\n", ino); | 106 | printk(KERN_WARNING "iget() failed for ino #%u\n", ino); |
109 | } | 107 | } |
110 | 108 | ||
111 | return d_splice_alias(inode, target); | 109 | return d_splice_alias(inode, target); |
@@ -121,22 +119,21 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
121 | struct jffs2_full_dirent *fd; | 119 | struct jffs2_full_dirent *fd; |
122 | unsigned long offset, curofs; | 120 | unsigned long offset, curofs; |
123 | 121 | ||
124 | jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", | 122 | D1(printk(KERN_DEBUG "jffs2_readdir() for dir_i #%lu\n", filp->f_path.dentry->d_inode->i_ino)); |
125 | filp->f_path.dentry->d_inode->i_ino); | ||
126 | 123 | ||
127 | f = JFFS2_INODE_INFO(inode); | 124 | f = JFFS2_INODE_INFO(inode); |
128 | 125 | ||
129 | offset = filp->f_pos; | 126 | offset = filp->f_pos; |
130 | 127 | ||
131 | if (offset == 0) { | 128 | if (offset == 0) { |
132 | jffs2_dbg(1, "Dirent 0: \".\", ino #%lu\n", inode->i_ino); | 129 | D1(printk(KERN_DEBUG "Dirent 0: \".\", ino #%lu\n", inode->i_ino)); |
133 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) | 130 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) |
134 | goto out; | 131 | goto out; |
135 | offset++; | 132 | offset++; |
136 | } | 133 | } |
137 | if (offset == 1) { | 134 | if (offset == 1) { |
138 | unsigned long pino = parent_ino(filp->f_path.dentry); | 135 | unsigned long pino = parent_ino(filp->f_path.dentry); |
139 | jffs2_dbg(1, "Dirent 1: \"..\", ino #%lu\n", pino); | 136 | D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", pino)); |
140 | if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) | 137 | if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) |
141 | goto out; | 138 | goto out; |
142 | offset++; | 139 | offset++; |
@@ -149,18 +146,16 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
149 | curofs++; | 146 | curofs++; |
150 | /* First loop: curofs = 2; offset = 2 */ | 147 | /* First loop: curofs = 2; offset = 2 */ |
151 | if (curofs < offset) { | 148 | if (curofs < offset) { |
152 | jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", | 149 | D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", |
153 | fd->name, fd->ino, fd->type, curofs, offset); | 150 | fd->name, fd->ino, fd->type, curofs, offset)); |
154 | continue; | 151 | continue; |
155 | } | 152 | } |
156 | if (!fd->ino) { | 153 | if (!fd->ino) { |
157 | jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n", | 154 | D2(printk(KERN_DEBUG "Skipping deletion dirent \"%s\"\n", fd->name)); |
158 | fd->name); | ||
159 | offset++; | 155 | offset++; |
160 | continue; | 156 | continue; |
161 | } | 157 | } |
162 | jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n", | 158 | D2(printk(KERN_DEBUG "Dirent %ld: \"%s\", ino #%u, type %d\n", offset, fd->name, fd->ino, fd->type)); |
163 | offset, fd->name, fd->ino, fd->type); | ||
164 | if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) | 159 | if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) |
165 | break; | 160 | break; |
166 | offset++; | 161 | offset++; |
@@ -174,8 +169,8 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
174 | /***********************************************************************/ | 169 | /***********************************************************************/ |
175 | 170 | ||
176 | 171 | ||
177 | static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | 172 | static int jffs2_create(struct inode *dir_i, struct dentry *dentry, int mode, |
178 | umode_t mode, bool excl) | 173 | struct nameidata *nd) |
179 | { | 174 | { |
180 | struct jffs2_raw_inode *ri; | 175 | struct jffs2_raw_inode *ri; |
181 | struct jffs2_inode_info *f, *dir_f; | 176 | struct jffs2_inode_info *f, *dir_f; |
@@ -189,12 +184,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | |||
189 | 184 | ||
190 | c = JFFS2_SB_INFO(dir_i->i_sb); | 185 | c = JFFS2_SB_INFO(dir_i->i_sb); |
191 | 186 | ||
192 | jffs2_dbg(1, "%s()\n", __func__); | 187 | D1(printk(KERN_DEBUG "jffs2_create()\n")); |
193 | 188 | ||
194 | inode = jffs2_new_inode(dir_i, mode, ri); | 189 | inode = jffs2_new_inode(dir_i, mode, ri); |
195 | 190 | ||
196 | if (IS_ERR(inode)) { | 191 | if (IS_ERR(inode)) { |
197 | jffs2_dbg(1, "jffs2_new_inode() failed\n"); | 192 | D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); |
198 | jffs2_free_raw_inode(ri); | 193 | jffs2_free_raw_inode(ri); |
199 | return PTR_ERR(inode); | 194 | return PTR_ERR(inode); |
200 | } | 195 | } |
@@ -222,12 +217,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | |||
222 | 217 | ||
223 | jffs2_free_raw_inode(ri); | 218 | jffs2_free_raw_inode(ri); |
224 | 219 | ||
225 | jffs2_dbg(1, "%s(): Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", | 220 | D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", |
226 | __func__, inode->i_ino, inode->i_mode, inode->i_nlink, | 221 | inode->i_ino, inode->i_mode, inode->i_nlink, |
227 | f->inocache->pino_nlink, inode->i_mapping->nrpages); | 222 | f->inocache->pino_nlink, inode->i_mapping->nrpages)); |
228 | 223 | ||
229 | unlock_new_inode(inode); | ||
230 | d_instantiate(dentry, inode); | 224 | d_instantiate(dentry, inode); |
225 | unlock_new_inode(inode); | ||
231 | return 0; | 226 | return 0; |
232 | 227 | ||
233 | fail: | 228 | fail: |
@@ -250,7 +245,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry) | |||
250 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, | 245 | ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, |
251 | dentry->d_name.len, dead_f, now); | 246 | dentry->d_name.len, dead_f, now); |
252 | if (dead_f->inocache) | 247 | if (dead_f->inocache) |
253 | set_nlink(dentry->d_inode, dead_f->inocache->pino_nlink); | 248 | dentry->d_inode->i_nlink = dead_f->inocache->pino_nlink; |
254 | if (!ret) | 249 | if (!ret) |
255 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | 250 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); |
256 | return ret; | 251 | return ret; |
@@ -283,7 +278,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de | |||
283 | 278 | ||
284 | if (!ret) { | 279 | if (!ret) { |
285 | mutex_lock(&f->sem); | 280 | mutex_lock(&f->sem); |
286 | set_nlink(old_dentry->d_inode, ++f->inocache->pino_nlink); | 281 | old_dentry->d_inode->i_nlink = ++f->inocache->pino_nlink; |
287 | mutex_unlock(&f->sem); | 282 | mutex_unlock(&f->sem); |
288 | d_instantiate(dentry, old_dentry->d_inode); | 283 | d_instantiate(dentry, old_dentry->d_inode); |
289 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); | 284 | dir_i->i_mtime = dir_i->i_ctime = ITIME(now); |
@@ -367,15 +362,14 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
367 | /* We use f->target field to store the target path. */ | 362 | /* We use f->target field to store the target path. */ |
368 | f->target = kmemdup(target, targetlen + 1, GFP_KERNEL); | 363 | f->target = kmemdup(target, targetlen + 1, GFP_KERNEL); |
369 | if (!f->target) { | 364 | if (!f->target) { |
370 | pr_warn("Can't allocate %d bytes of memory\n", targetlen + 1); | 365 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); |
371 | mutex_unlock(&f->sem); | 366 | mutex_unlock(&f->sem); |
372 | jffs2_complete_reservation(c); | 367 | jffs2_complete_reservation(c); |
373 | ret = -ENOMEM; | 368 | ret = -ENOMEM; |
374 | goto fail; | 369 | goto fail; |
375 | } | 370 | } |
376 | 371 | ||
377 | jffs2_dbg(1, "%s(): symlink's target '%s' cached\n", | 372 | D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target)); |
378 | __func__, (char *)f->target); | ||
379 | 373 | ||
380 | /* No data here. Only a metadata node, which will be | 374 | /* No data here. Only a metadata node, which will be |
381 | obsoleted by the first data write | 375 | obsoleted by the first data write |
@@ -446,8 +440,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
446 | mutex_unlock(&dir_f->sem); | 440 | mutex_unlock(&dir_f->sem); |
447 | jffs2_complete_reservation(c); | 441 | jffs2_complete_reservation(c); |
448 | 442 | ||
449 | unlock_new_inode(inode); | ||
450 | d_instantiate(dentry, inode); | 443 | d_instantiate(dentry, inode); |
444 | unlock_new_inode(inode); | ||
451 | return 0; | 445 | return 0; |
452 | 446 | ||
453 | fail: | 447 | fail: |
@@ -456,7 +450,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
456 | } | 450 | } |
457 | 451 | ||
458 | 452 | ||
459 | static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode) | 453 | static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, int mode) |
460 | { | 454 | { |
461 | struct jffs2_inode_info *f, *dir_f; | 455 | struct jffs2_inode_info *f, *dir_f; |
462 | struct jffs2_sb_info *c; | 456 | struct jffs2_sb_info *c; |
@@ -503,7 +497,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode | |||
503 | f = JFFS2_INODE_INFO(inode); | 497 | f = JFFS2_INODE_INFO(inode); |
504 | 498 | ||
505 | /* Directories get nlink 2 at start */ | 499 | /* Directories get nlink 2 at start */ |
506 | set_nlink(inode, 2); | 500 | inode->i_nlink = 2; |
507 | /* but ic->pino_nlink is the parent ino# */ | 501 | /* but ic->pino_nlink is the parent ino# */ |
508 | f->inocache->pino_nlink = dir_i->i_ino; | 502 | f->inocache->pino_nlink = dir_i->i_ino; |
509 | 503 | ||
@@ -591,8 +585,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode | |||
591 | mutex_unlock(&dir_f->sem); | 585 | mutex_unlock(&dir_f->sem); |
592 | jffs2_complete_reservation(c); | 586 | jffs2_complete_reservation(c); |
593 | 587 | ||
594 | unlock_new_inode(inode); | ||
595 | d_instantiate(dentry, inode); | 588 | d_instantiate(dentry, inode); |
589 | unlock_new_inode(inode); | ||
596 | return 0; | 590 | return 0; |
597 | 591 | ||
598 | fail: | 592 | fail: |
@@ -624,7 +618,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) | |||
624 | return ret; | 618 | return ret; |
625 | } | 619 | } |
626 | 620 | ||
627 | static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode, dev_t rdev) | 621 | static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, int mode, dev_t rdev) |
628 | { | 622 | { |
629 | struct jffs2_inode_info *f, *dir_f; | 623 | struct jffs2_inode_info *f, *dir_f; |
630 | struct jffs2_sb_info *c; | 624 | struct jffs2_sb_info *c; |
@@ -766,8 +760,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode | |||
766 | mutex_unlock(&dir_f->sem); | 760 | mutex_unlock(&dir_f->sem); |
767 | jffs2_complete_reservation(c); | 761 | jffs2_complete_reservation(c); |
768 | 762 | ||
769 | unlock_new_inode(inode); | ||
770 | d_instantiate(dentry, inode); | 763 | d_instantiate(dentry, inode); |
764 | unlock_new_inode(inode); | ||
771 | return 0; | 765 | return 0; |
772 | 766 | ||
773 | fail: | 767 | fail: |
@@ -862,8 +856,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
862 | f->inocache->pino_nlink++; | 856 | f->inocache->pino_nlink++; |
863 | mutex_unlock(&f->sem); | 857 | mutex_unlock(&f->sem); |
864 | 858 | ||
865 | pr_notice("%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n", | 859 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); |
866 | __func__, ret); | ||
867 | /* Might as well let the VFS know */ | 860 | /* Might as well let the VFS know */ |
868 | d_instantiate(new_dentry, old_dentry->d_inode); | 861 | d_instantiate(new_dentry, old_dentry->d_inode); |
869 | ihold(old_dentry->d_inode); | 862 | ihold(old_dentry->d_inode); |
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index 4a6cf289be2..e513f1913c1 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
17 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
@@ -48,12 +46,11 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
48 | #else /* Linux */ | 46 | #else /* Linux */ |
49 | struct erase_info *instr; | 47 | struct erase_info *instr; |
50 | 48 | ||
51 | jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n", | 49 | D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n", |
52 | __func__, | 50 | jeb->offset, jeb->offset, jeb->offset + c->sector_size)); |
53 | jeb->offset, jeb->offset, jeb->offset + c->sector_size); | ||
54 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); | 51 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); |
55 | if (!instr) { | 52 | if (!instr) { |
56 | pr_warn("kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); | 53 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); |
57 | mutex_lock(&c->erase_free_sem); | 54 | mutex_lock(&c->erase_free_sem); |
58 | spin_lock(&c->erase_completion_lock); | 55 | spin_lock(&c->erase_completion_lock); |
59 | list_move(&jeb->list, &c->erase_pending_list); | 56 | list_move(&jeb->list, &c->erase_pending_list); |
@@ -72,11 +69,12 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
72 | instr->len = c->sector_size; | 69 | instr->len = c->sector_size; |
73 | instr->callback = jffs2_erase_callback; | 70 | instr->callback = jffs2_erase_callback; |
74 | instr->priv = (unsigned long)(&instr[1]); | 71 | instr->priv = (unsigned long)(&instr[1]); |
72 | instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; | ||
75 | 73 | ||
76 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; | 74 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; |
77 | ((struct erase_priv_struct *)instr->priv)->c = c; | 75 | ((struct erase_priv_struct *)instr->priv)->c = c; |
78 | 76 | ||
79 | ret = mtd_erase(c->mtd, instr); | 77 | ret = c->mtd->erase(c->mtd, instr); |
80 | if (!ret) | 78 | if (!ret) |
81 | return; | 79 | return; |
82 | 80 | ||
@@ -86,8 +84,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
86 | 84 | ||
87 | if (ret == -ENOMEM || ret == -EAGAIN) { | 85 | if (ret == -ENOMEM || ret == -EAGAIN) { |
88 | /* Erase failed immediately. Refile it on the list */ | 86 | /* Erase failed immediately. Refile it on the list */ |
89 | jffs2_dbg(1, "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", | 87 | D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret)); |
90 | jeb->offset, ret); | ||
91 | mutex_lock(&c->erase_free_sem); | 88 | mutex_lock(&c->erase_free_sem); |
92 | spin_lock(&c->erase_completion_lock); | 89 | spin_lock(&c->erase_completion_lock); |
93 | list_move(&jeb->list, &c->erase_pending_list); | 90 | list_move(&jeb->list, &c->erase_pending_list); |
@@ -100,11 +97,9 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
100 | } | 97 | } |
101 | 98 | ||
102 | if (ret == -EROFS) | 99 | if (ret == -EROFS) |
103 | pr_warn("Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", | 100 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); |
104 | jeb->offset); | ||
105 | else | 101 | else |
106 | pr_warn("Erase at 0x%08x failed immediately: errno %d\n", | 102 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); |
107 | jeb->offset, ret); | ||
108 | 103 | ||
109 | jffs2_erase_failed(c, jeb, bad_offset); | 104 | jffs2_erase_failed(c, jeb, bad_offset); |
110 | } | 105 | } |
@@ -130,14 +125,13 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
130 | 125 | ||
131 | work_done++; | 126 | work_done++; |
132 | if (!--count) { | 127 | if (!--count) { |
133 | jffs2_dbg(1, "Count reached. jffs2_erase_pending_blocks leaving\n"); | 128 | D1(printk(KERN_DEBUG "Count reached. jffs2_erase_pending_blocks leaving\n")); |
134 | goto done; | 129 | goto done; |
135 | } | 130 | } |
136 | 131 | ||
137 | } else if (!list_empty(&c->erase_pending_list)) { | 132 | } else if (!list_empty(&c->erase_pending_list)) { |
138 | jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); | 133 | jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); |
139 | jffs2_dbg(1, "Starting erase of pending block 0x%08x\n", | 134 | D1(printk(KERN_DEBUG "Starting erase of pending block 0x%08x\n", jeb->offset)); |
140 | jeb->offset); | ||
141 | list_del(&jeb->list); | 135 | list_del(&jeb->list); |
142 | c->erasing_size += c->sector_size; | 136 | c->erasing_size += c->sector_size; |
143 | c->wasted_size -= jeb->wasted_size; | 137 | c->wasted_size -= jeb->wasted_size; |
@@ -165,13 +159,13 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
165 | spin_unlock(&c->erase_completion_lock); | 159 | spin_unlock(&c->erase_completion_lock); |
166 | mutex_unlock(&c->erase_free_sem); | 160 | mutex_unlock(&c->erase_free_sem); |
167 | done: | 161 | done: |
168 | jffs2_dbg(1, "jffs2_erase_pending_blocks completed\n"); | 162 | D1(printk(KERN_DEBUG "jffs2_erase_pending_blocks completed\n")); |
169 | return work_done; | 163 | return work_done; |
170 | } | 164 | } |
171 | 165 | ||
172 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 166 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
173 | { | 167 | { |
174 | jffs2_dbg(1, "Erase completed successfully at 0x%08x\n", jeb->offset); | 168 | D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset)); |
175 | mutex_lock(&c->erase_free_sem); | 169 | mutex_lock(&c->erase_free_sem); |
176 | spin_lock(&c->erase_completion_lock); | 170 | spin_lock(&c->erase_completion_lock); |
177 | list_move_tail(&jeb->list, &c->erase_complete_list); | 171 | list_move_tail(&jeb->list, &c->erase_complete_list); |
@@ -220,7 +214,7 @@ static void jffs2_erase_callback(struct erase_info *instr) | |||
220 | struct erase_priv_struct *priv = (void *)instr->priv; | 214 | struct erase_priv_struct *priv = (void *)instr->priv; |
221 | 215 | ||
222 | if(instr->state != MTD_ERASE_DONE) { | 216 | if(instr->state != MTD_ERASE_DONE) { |
223 | pr_warn("Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n", | 217 | printk(KERN_WARNING "Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n", |
224 | (unsigned long long)instr->addr, instr->state); | 218 | (unsigned long long)instr->addr, instr->state); |
225 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); | 219 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); |
226 | } else { | 220 | } else { |
@@ -275,8 +269,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
275 | return; | 269 | return; |
276 | } | 270 | } |
277 | 271 | ||
278 | jffs2_dbg(1, "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", | 272 | D1(printk(KERN_DEBUG "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", |
279 | jeb->offset, jeb->offset + c->sector_size, ic->ino); | 273 | jeb->offset, jeb->offset + c->sector_size, ic->ino)); |
280 | 274 | ||
281 | D2({ | 275 | D2({ |
282 | int i=0; | 276 | int i=0; |
@@ -287,7 +281,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
287 | 281 | ||
288 | printk(KERN_DEBUG); | 282 | printk(KERN_DEBUG); |
289 | while(this) { | 283 | while(this) { |
290 | pr_cont("0x%08x(%d)->", | 284 | printk(KERN_CONT "0x%08x(%d)->", |
291 | ref_offset(this), ref_flags(this)); | 285 | ref_offset(this), ref_flags(this)); |
292 | if (++i == 5) { | 286 | if (++i == 5) { |
293 | printk(KERN_DEBUG); | 287 | printk(KERN_DEBUG); |
@@ -295,7 +289,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
295 | } | 289 | } |
296 | this = this->next_in_ino; | 290 | this = this->next_in_ino; |
297 | } | 291 | } |
298 | pr_cont("\n"); | 292 | printk(KERN_CONT "\n"); |
299 | }); | 293 | }); |
300 | 294 | ||
301 | switch (ic->class) { | 295 | switch (ic->class) { |
@@ -316,8 +310,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
316 | void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 310 | void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
317 | { | 311 | { |
318 | struct jffs2_raw_node_ref *block, *ref; | 312 | struct jffs2_raw_node_ref *block, *ref; |
319 | jffs2_dbg(1, "Freeing all node refs for eraseblock offset 0x%08x\n", | 313 | D1(printk(KERN_DEBUG "Freeing all node refs for eraseblock offset 0x%08x\n", jeb->offset)); |
320 | jeb->offset); | ||
321 | 314 | ||
322 | block = ref = jeb->first_node; | 315 | block = ref = jeb->first_node; |
323 | 316 | ||
@@ -342,21 +335,21 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
342 | void *ebuf; | 335 | void *ebuf; |
343 | uint32_t ofs; | 336 | uint32_t ofs; |
344 | size_t retlen; | 337 | size_t retlen; |
345 | int ret; | 338 | int ret = -EIO; |
346 | unsigned long *wordebuf; | 339 | |
340 | if (c->mtd->point) { | ||
341 | unsigned long *wordebuf; | ||
347 | 342 | ||
348 | ret = mtd_point(c->mtd, jeb->offset, c->sector_size, &retlen, | 343 | ret = c->mtd->point(c->mtd, jeb->offset, c->sector_size, |
349 | &ebuf, NULL); | 344 | &retlen, &ebuf, NULL); |
350 | if (ret != -EOPNOTSUPP) { | ||
351 | if (ret) { | 345 | if (ret) { |
352 | jffs2_dbg(1, "MTD point failed %d\n", ret); | 346 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); |
353 | goto do_flash_read; | 347 | goto do_flash_read; |
354 | } | 348 | } |
355 | if (retlen < c->sector_size) { | 349 | if (retlen < c->sector_size) { |
356 | /* Don't muck about if it won't let us point to the whole erase sector */ | 350 | /* Don't muck about if it won't let us point to the whole erase sector */ |
357 | jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n", | 351 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); |
358 | retlen); | 352 | c->mtd->unpoint(c->mtd, jeb->offset, retlen); |
359 | mtd_unpoint(c->mtd, jeb->offset, retlen); | ||
360 | goto do_flash_read; | 353 | goto do_flash_read; |
361 | } | 354 | } |
362 | wordebuf = ebuf-sizeof(*wordebuf); | 355 | wordebuf = ebuf-sizeof(*wordebuf); |
@@ -365,12 +358,10 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
365 | if (*++wordebuf != ~0) | 358 | if (*++wordebuf != ~0) |
366 | break; | 359 | break; |
367 | } while(--retlen); | 360 | } while(--retlen); |
368 | mtd_unpoint(c->mtd, jeb->offset, c->sector_size); | 361 | c->mtd->unpoint(c->mtd, jeb->offset, c->sector_size); |
369 | if (retlen) { | 362 | if (retlen) { |
370 | pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n", | 363 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n", |
371 | *wordebuf, | 364 | *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf)); |
372 | jeb->offset + | ||
373 | c->sector_size-retlen * sizeof(*wordebuf)); | ||
374 | return -EIO; | 365 | return -EIO; |
375 | } | 366 | } |
376 | return 0; | 367 | return 0; |
@@ -378,12 +369,11 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
378 | do_flash_read: | 369 | do_flash_read: |
379 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 370 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
380 | if (!ebuf) { | 371 | if (!ebuf) { |
381 | pr_warn("Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", | 372 | printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); |
382 | jeb->offset); | ||
383 | return -EAGAIN; | 373 | return -EAGAIN; |
384 | } | 374 | } |
385 | 375 | ||
386 | jffs2_dbg(1, "Verifying erase at 0x%08x\n", jeb->offset); | 376 | D1(printk(KERN_DEBUG "Verifying erase at 0x%08x\n", jeb->offset)); |
387 | 377 | ||
388 | for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { | 378 | for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { |
389 | uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); | 379 | uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); |
@@ -391,16 +381,14 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
391 | 381 | ||
392 | *bad_offset = ofs; | 382 | *bad_offset = ofs; |
393 | 383 | ||
394 | ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf); | 384 | ret = c->mtd->read(c->mtd, ofs, readlen, &retlen, ebuf); |
395 | if (ret) { | 385 | if (ret) { |
396 | pr_warn("Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", | 386 | printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret); |
397 | ofs, ret); | ||
398 | ret = -EIO; | 387 | ret = -EIO; |
399 | goto fail; | 388 | goto fail; |
400 | } | 389 | } |
401 | if (retlen != readlen) { | 390 | if (retlen != readlen) { |
402 | pr_warn("Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", | 391 | printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen); |
403 | ofs, readlen, retlen); | ||
404 | ret = -EIO; | 392 | ret = -EIO; |
405 | goto fail; | 393 | goto fail; |
406 | } | 394 | } |
@@ -409,8 +397,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
409 | unsigned long *datum = ebuf + i; | 397 | unsigned long *datum = ebuf + i; |
410 | if (*datum + 1) { | 398 | if (*datum + 1) { |
411 | *bad_offset += i; | 399 | *bad_offset += i; |
412 | pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n", | 400 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset); |
413 | *datum, *bad_offset); | ||
414 | ret = -EIO; | 401 | ret = -EIO; |
415 | goto fail; | 402 | goto fail; |
416 | } | 403 | } |
@@ -436,7 +423,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
436 | } | 423 | } |
437 | 424 | ||
438 | /* Write the erase complete marker */ | 425 | /* Write the erase complete marker */ |
439 | jffs2_dbg(1, "Writing erased marker to block at 0x%08x\n", jeb->offset); | 426 | D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); |
440 | bad_offset = jeb->offset; | 427 | bad_offset = jeb->offset; |
441 | 428 | ||
442 | /* Cleanmarker in oob area or no cleanmarker at all ? */ | 429 | /* Cleanmarker in oob area or no cleanmarker at all ? */ |
@@ -465,10 +452,10 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
465 | 452 | ||
466 | if (ret || retlen != sizeof(marker)) { | 453 | if (ret || retlen != sizeof(marker)) { |
467 | if (ret) | 454 | if (ret) |
468 | pr_warn("Write clean marker to block at 0x%08x failed: %d\n", | 455 | printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", |
469 | jeb->offset, ret); | 456 | jeb->offset, ret); |
470 | else | 457 | else |
471 | pr_warn("Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", | 458 | printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", |
472 | jeb->offset, sizeof(marker), retlen); | 459 | jeb->offset, sizeof(marker), retlen); |
473 | 460 | ||
474 | goto filebad; | 461 | goto filebad; |
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 1506673c087..61e6723535b 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
17 | #include <linux/time.h> | 15 | #include <linux/time.h> |
@@ -87,8 +85,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) | |||
87 | unsigned char *pg_buf; | 85 | unsigned char *pg_buf; |
88 | int ret; | 86 | int ret; |
89 | 87 | ||
90 | jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n", | 88 | D2(printk(KERN_DEBUG "jffs2_do_readpage_nolock(): ino #%lu, page at offset 0x%lx\n", inode->i_ino, pg->index << PAGE_CACHE_SHIFT)); |
91 | __func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT); | ||
92 | 89 | ||
93 | BUG_ON(!PageLocked(pg)); | 90 | BUG_ON(!PageLocked(pg)); |
94 | 91 | ||
@@ -108,7 +105,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) | |||
108 | flush_dcache_page(pg); | 105 | flush_dcache_page(pg); |
109 | kunmap(pg); | 106 | kunmap(pg); |
110 | 107 | ||
111 | jffs2_dbg(2, "readpage finished\n"); | 108 | D2(printk(KERN_DEBUG "readpage finished\n")); |
112 | return ret; | 109 | return ret; |
113 | } | 110 | } |
114 | 111 | ||
@@ -138,39 +135,33 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
138 | struct page *pg; | 135 | struct page *pg; |
139 | struct inode *inode = mapping->host; | 136 | struct inode *inode = mapping->host; |
140 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 137 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
141 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | ||
142 | struct jffs2_raw_inode ri; | ||
143 | uint32_t alloc_len = 0; | ||
144 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | 138 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
145 | uint32_t pageofs = index << PAGE_CACHE_SHIFT; | 139 | uint32_t pageofs = index << PAGE_CACHE_SHIFT; |
146 | int ret = 0; | 140 | int ret = 0; |
147 | 141 | ||
148 | jffs2_dbg(1, "%s()\n", __func__); | ||
149 | |||
150 | if (pageofs > inode->i_size) { | ||
151 | ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, | ||
152 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
153 | if (ret) | ||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | mutex_lock(&f->sem); | ||
158 | pg = grab_cache_page_write_begin(mapping, index, flags); | 142 | pg = grab_cache_page_write_begin(mapping, index, flags); |
159 | if (!pg) { | 143 | if (!pg) |
160 | if (alloc_len) | ||
161 | jffs2_complete_reservation(c); | ||
162 | mutex_unlock(&f->sem); | ||
163 | return -ENOMEM; | 144 | return -ENOMEM; |
164 | } | ||
165 | *pagep = pg; | 145 | *pagep = pg; |
166 | 146 | ||
167 | if (alloc_len) { | 147 | D1(printk(KERN_DEBUG "jffs2_write_begin()\n")); |
148 | |||
149 | if (pageofs > inode->i_size) { | ||
168 | /* Make new hole frag from old EOF to new page */ | 150 | /* Make new hole frag from old EOF to new page */ |
151 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | ||
152 | struct jffs2_raw_inode ri; | ||
169 | struct jffs2_full_dnode *fn; | 153 | struct jffs2_full_dnode *fn; |
154 | uint32_t alloc_len; | ||
170 | 155 | ||
171 | jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", | 156 | D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", |
172 | (unsigned int)inode->i_size, pageofs); | 157 | (unsigned int)inode->i_size, pageofs)); |
158 | |||
159 | ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, | ||
160 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | ||
161 | if (ret) | ||
162 | goto out_page; | ||
173 | 163 | ||
164 | mutex_lock(&f->sem); | ||
174 | memset(&ri, 0, sizeof(ri)); | 165 | memset(&ri, 0, sizeof(ri)); |
175 | 166 | ||
176 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 167 | ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -181,8 +172,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
181 | ri.ino = cpu_to_je32(f->inocache->ino); | 172 | ri.ino = cpu_to_je32(f->inocache->ino); |
182 | ri.version = cpu_to_je32(++f->highest_version); | 173 | ri.version = cpu_to_je32(++f->highest_version); |
183 | ri.mode = cpu_to_jemode(inode->i_mode); | 174 | ri.mode = cpu_to_jemode(inode->i_mode); |
184 | ri.uid = cpu_to_je16(i_uid_read(inode)); | 175 | ri.uid = cpu_to_je16(inode->i_uid); |
185 | ri.gid = cpu_to_je16(i_gid_read(inode)); | 176 | ri.gid = cpu_to_je16(inode->i_gid); |
186 | ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs)); | 177 | ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs)); |
187 | ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds()); | 178 | ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds()); |
188 | ri.offset = cpu_to_je32(inode->i_size); | 179 | ri.offset = cpu_to_je32(inode->i_size); |
@@ -197,6 +188,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
197 | if (IS_ERR(fn)) { | 188 | if (IS_ERR(fn)) { |
198 | ret = PTR_ERR(fn); | 189 | ret = PTR_ERR(fn); |
199 | jffs2_complete_reservation(c); | 190 | jffs2_complete_reservation(c); |
191 | mutex_unlock(&f->sem); | ||
200 | goto out_page; | 192 | goto out_page; |
201 | } | 193 | } |
202 | ret = jffs2_add_full_dnode_to_inode(c, f, fn); | 194 | ret = jffs2_add_full_dnode_to_inode(c, f, fn); |
@@ -206,15 +198,16 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
206 | f->metadata = NULL; | 198 | f->metadata = NULL; |
207 | } | 199 | } |
208 | if (ret) { | 200 | if (ret) { |
209 | jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n", | 201 | D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n", ret)); |
210 | ret); | ||
211 | jffs2_mark_node_obsolete(c, fn->raw); | 202 | jffs2_mark_node_obsolete(c, fn->raw); |
212 | jffs2_free_full_dnode(fn); | 203 | jffs2_free_full_dnode(fn); |
213 | jffs2_complete_reservation(c); | 204 | jffs2_complete_reservation(c); |
205 | mutex_unlock(&f->sem); | ||
214 | goto out_page; | 206 | goto out_page; |
215 | } | 207 | } |
216 | jffs2_complete_reservation(c); | 208 | jffs2_complete_reservation(c); |
217 | inode->i_size = pageofs; | 209 | inode->i_size = pageofs; |
210 | mutex_unlock(&f->sem); | ||
218 | } | 211 | } |
219 | 212 | ||
220 | /* | 213 | /* |
@@ -223,18 +216,18 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
223 | * case of a short-copy. | 216 | * case of a short-copy. |
224 | */ | 217 | */ |
225 | if (!PageUptodate(pg)) { | 218 | if (!PageUptodate(pg)) { |
219 | mutex_lock(&f->sem); | ||
226 | ret = jffs2_do_readpage_nolock(inode, pg); | 220 | ret = jffs2_do_readpage_nolock(inode, pg); |
221 | mutex_unlock(&f->sem); | ||
227 | if (ret) | 222 | if (ret) |
228 | goto out_page; | 223 | goto out_page; |
229 | } | 224 | } |
230 | mutex_unlock(&f->sem); | 225 | D1(printk(KERN_DEBUG "end write_begin(). pg->flags %lx\n", pg->flags)); |
231 | jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags); | ||
232 | return ret; | 226 | return ret; |
233 | 227 | ||
234 | out_page: | 228 | out_page: |
235 | unlock_page(pg); | 229 | unlock_page(pg); |
236 | page_cache_release(pg); | 230 | page_cache_release(pg); |
237 | mutex_unlock(&f->sem); | ||
238 | return ret; | 231 | return ret; |
239 | } | 232 | } |
240 | 233 | ||
@@ -255,9 +248,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
255 | int ret = 0; | 248 | int ret = 0; |
256 | uint32_t writtenlen = 0; | 249 | uint32_t writtenlen = 0; |
257 | 250 | ||
258 | jffs2_dbg(1, "%s(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n", | 251 | D1(printk(KERN_DEBUG "jffs2_write_end(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n", |
259 | __func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT, | 252 | inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end, pg->flags)); |
260 | start, end, pg->flags); | ||
261 | 253 | ||
262 | /* We need to avoid deadlock with page_cache_read() in | 254 | /* We need to avoid deadlock with page_cache_read() in |
263 | jffs2_garbage_collect_pass(). So the page must be | 255 | jffs2_garbage_collect_pass(). So the page must be |
@@ -276,8 +268,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
276 | ri = jffs2_alloc_raw_inode(); | 268 | ri = jffs2_alloc_raw_inode(); |
277 | 269 | ||
278 | if (!ri) { | 270 | if (!ri) { |
279 | jffs2_dbg(1, "%s(): Allocation of raw inode failed\n", | 271 | D1(printk(KERN_DEBUG "jffs2_write_end(): Allocation of raw inode failed\n")); |
280 | __func__); | ||
281 | unlock_page(pg); | 272 | unlock_page(pg); |
282 | page_cache_release(pg); | 273 | page_cache_release(pg); |
283 | return -ENOMEM; | 274 | return -ENOMEM; |
@@ -286,8 +277,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
286 | /* Set the fields that the generic jffs2_write_inode_range() code can't find */ | 277 | /* Set the fields that the generic jffs2_write_inode_range() code can't find */ |
287 | ri->ino = cpu_to_je32(inode->i_ino); | 278 | ri->ino = cpu_to_je32(inode->i_ino); |
288 | ri->mode = cpu_to_jemode(inode->i_mode); | 279 | ri->mode = cpu_to_jemode(inode->i_mode); |
289 | ri->uid = cpu_to_je16(i_uid_read(inode)); | 280 | ri->uid = cpu_to_je16(inode->i_uid); |
290 | ri->gid = cpu_to_je16(i_gid_read(inode)); | 281 | ri->gid = cpu_to_je16(inode->i_gid); |
291 | ri->isize = cpu_to_je32((uint32_t)inode->i_size); | 282 | ri->isize = cpu_to_je32((uint32_t)inode->i_size); |
292 | ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds()); | 283 | ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds()); |
293 | 284 | ||
@@ -324,14 +315,13 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
324 | /* generic_file_write has written more to the page cache than we've | 315 | /* generic_file_write has written more to the page cache than we've |
325 | actually written to the medium. Mark the page !Uptodate so that | 316 | actually written to the medium. Mark the page !Uptodate so that |
326 | it gets reread */ | 317 | it gets reread */ |
327 | jffs2_dbg(1, "%s(): Not all bytes written. Marking page !uptodate\n", | 318 | D1(printk(KERN_DEBUG "jffs2_write_end(): Not all bytes written. Marking page !uptodate\n")); |
328 | __func__); | ||
329 | SetPageError(pg); | 319 | SetPageError(pg); |
330 | ClearPageUptodate(pg); | 320 | ClearPageUptodate(pg); |
331 | } | 321 | } |
332 | 322 | ||
333 | jffs2_dbg(1, "%s() returning %d\n", | 323 | D1(printk(KERN_DEBUG "jffs2_write_end() returning %d\n", |
334 | __func__, writtenlen > 0 ? writtenlen : ret); | 324 | writtenlen > 0 ? writtenlen : ret)); |
335 | unlock_page(pg); | 325 | unlock_page(pg); |
336 | page_cache_release(pg); | 326 | page_cache_release(pg); |
337 | return writtenlen > 0 ? writtenlen : ret; | 327 | return writtenlen > 0 ? writtenlen : ret; |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index fe3c0527545..bbcb9755dd2 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/capability.h> | 13 | #include <linux/capability.h> |
16 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
17 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
@@ -41,7 +39,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
41 | int ret; | 39 | int ret; |
42 | int alloc_type = ALLOC_NORMAL; | 40 | int alloc_type = ALLOC_NORMAL; |
43 | 41 | ||
44 | jffs2_dbg(1, "%s(): ino #%lu\n", __func__, inode->i_ino); | 42 | D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); |
45 | 43 | ||
46 | /* Special cases - we don't want more than one data node | 44 | /* Special cases - we don't want more than one data node |
47 | for these types on the medium at any time. So setattr | 45 | for these types on the medium at any time. So setattr |
@@ -52,8 +50,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
52 | /* For these, we don't actually need to read the old node */ | 50 | /* For these, we don't actually need to read the old node */ |
53 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); | 51 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); |
54 | mdata = (char *)&dev; | 52 | mdata = (char *)&dev; |
55 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", | 53 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); |
56 | __func__, mdatalen); | ||
57 | } else if (S_ISLNK(inode->i_mode)) { | 54 | } else if (S_ISLNK(inode->i_mode)) { |
58 | mutex_lock(&f->sem); | 55 | mutex_lock(&f->sem); |
59 | mdatalen = f->metadata->size; | 56 | mdatalen = f->metadata->size; |
@@ -69,8 +66,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
69 | return ret; | 66 | return ret; |
70 | } | 67 | } |
71 | mutex_unlock(&f->sem); | 68 | mutex_unlock(&f->sem); |
72 | jffs2_dbg(1, "%s(): Writing %d bytes of symlink target\n", | 69 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); |
73 | __func__, mdatalen); | ||
74 | } | 70 | } |
75 | 71 | ||
76 | ri = jffs2_alloc_raw_inode(); | 72 | ri = jffs2_alloc_raw_inode(); |
@@ -99,10 +95,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
99 | ri->ino = cpu_to_je32(inode->i_ino); | 95 | ri->ino = cpu_to_je32(inode->i_ino); |
100 | ri->version = cpu_to_je32(++f->highest_version); | 96 | ri->version = cpu_to_je32(++f->highest_version); |
101 | 97 | ||
102 | ri->uid = cpu_to_je16((ivalid & ATTR_UID)? | 98 | ri->uid = cpu_to_je16((ivalid & ATTR_UID)?iattr->ia_uid:inode->i_uid); |
103 | from_kuid(&init_user_ns, iattr->ia_uid):i_uid_read(inode)); | 99 | ri->gid = cpu_to_je16((ivalid & ATTR_GID)?iattr->ia_gid:inode->i_gid); |
104 | ri->gid = cpu_to_je16((ivalid & ATTR_GID)? | ||
105 | from_kgid(&init_user_ns, iattr->ia_gid):i_gid_read(inode)); | ||
106 | 100 | ||
107 | if (ivalid & ATTR_MODE) | 101 | if (ivalid & ATTR_MODE) |
108 | ri->mode = cpu_to_jemode(iattr->ia_mode); | 102 | ri->mode = cpu_to_jemode(iattr->ia_mode); |
@@ -149,8 +143,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
149 | inode->i_ctime = ITIME(je32_to_cpu(ri->ctime)); | 143 | inode->i_ctime = ITIME(je32_to_cpu(ri->ctime)); |
150 | inode->i_mtime = ITIME(je32_to_cpu(ri->mtime)); | 144 | inode->i_mtime = ITIME(je32_to_cpu(ri->mtime)); |
151 | inode->i_mode = jemode_to_cpu(ri->mode); | 145 | inode->i_mode = jemode_to_cpu(ri->mode); |
152 | i_uid_write(inode, je16_to_cpu(ri->uid)); | 146 | inode->i_uid = je16_to_cpu(ri->uid); |
153 | i_gid_write(inode, je16_to_cpu(ri->gid)); | 147 | inode->i_gid = je16_to_cpu(ri->gid); |
154 | 148 | ||
155 | 149 | ||
156 | old_metadata = f->metadata; | 150 | old_metadata = f->metadata; |
@@ -239,10 +233,9 @@ void jffs2_evict_inode (struct inode *inode) | |||
239 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | 233 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); |
240 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 234 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
241 | 235 | ||
242 | jffs2_dbg(1, "%s(): ino #%lu mode %o\n", | 236 | D1(printk(KERN_DEBUG "jffs2_evict_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); |
243 | __func__, inode->i_ino, inode->i_mode); | ||
244 | truncate_inode_pages(&inode->i_data, 0); | 237 | truncate_inode_pages(&inode->i_data, 0); |
245 | clear_inode(inode); | 238 | end_writeback(inode); |
246 | jffs2_do_clear_inode(c, f); | 239 | jffs2_do_clear_inode(c, f); |
247 | } | 240 | } |
248 | 241 | ||
@@ -256,7 +249,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
256 | dev_t rdev = 0; | 249 | dev_t rdev = 0; |
257 | int ret; | 250 | int ret; |
258 | 251 | ||
259 | jffs2_dbg(1, "%s(): ino == %lu\n", __func__, ino); | 252 | D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino)); |
260 | 253 | ||
261 | inode = iget_locked(sb, ino); | 254 | inode = iget_locked(sb, ino); |
262 | if (!inode) | 255 | if (!inode) |
@@ -278,14 +271,14 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
278 | return ERR_PTR(ret); | 271 | return ERR_PTR(ret); |
279 | } | 272 | } |
280 | inode->i_mode = jemode_to_cpu(latest_node.mode); | 273 | inode->i_mode = jemode_to_cpu(latest_node.mode); |
281 | i_uid_write(inode, je16_to_cpu(latest_node.uid)); | 274 | inode->i_uid = je16_to_cpu(latest_node.uid); |
282 | i_gid_write(inode, je16_to_cpu(latest_node.gid)); | 275 | inode->i_gid = je16_to_cpu(latest_node.gid); |
283 | inode->i_size = je32_to_cpu(latest_node.isize); | 276 | inode->i_size = je32_to_cpu(latest_node.isize); |
284 | inode->i_atime = ITIME(je32_to_cpu(latest_node.atime)); | 277 | inode->i_atime = ITIME(je32_to_cpu(latest_node.atime)); |
285 | inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); | 278 | inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); |
286 | inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); | 279 | inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); |
287 | 280 | ||
288 | set_nlink(inode, f->inocache->pino_nlink); | 281 | inode->i_nlink = f->inocache->pino_nlink; |
289 | 282 | ||
290 | inode->i_blocks = (inode->i_size + 511) >> 9; | 283 | inode->i_blocks = (inode->i_size + 511) >> 9; |
291 | 284 | ||
@@ -298,7 +291,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
298 | case S_IFDIR: | 291 | case S_IFDIR: |
299 | { | 292 | { |
300 | struct jffs2_full_dirent *fd; | 293 | struct jffs2_full_dirent *fd; |
301 | set_nlink(inode, 2); /* parent and '.' */ | 294 | inode->i_nlink = 2; /* parent and '.' */ |
302 | 295 | ||
303 | for (fd=f->dents; fd; fd = fd->next) { | 296 | for (fd=f->dents; fd; fd = fd->next) { |
304 | if (fd->type == DT_DIR && fd->ino) | 297 | if (fd->type == DT_DIR && fd->ino) |
@@ -324,16 +317,14 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
324 | /* Read the device numbers from the media */ | 317 | /* Read the device numbers from the media */ |
325 | if (f->metadata->size != sizeof(jdev.old_id) && | 318 | if (f->metadata->size != sizeof(jdev.old_id) && |
326 | f->metadata->size != sizeof(jdev.new_id)) { | 319 | f->metadata->size != sizeof(jdev.new_id)) { |
327 | pr_notice("Device node has strange size %d\n", | 320 | printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); |
328 | f->metadata->size); | ||
329 | goto error_io; | 321 | goto error_io; |
330 | } | 322 | } |
331 | jffs2_dbg(1, "Reading device numbers from flash\n"); | 323 | D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); |
332 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); | 324 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); |
333 | if (ret < 0) { | 325 | if (ret < 0) { |
334 | /* Eep */ | 326 | /* Eep */ |
335 | pr_notice("Read device numbers for inode %lu failed\n", | 327 | printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); |
336 | (unsigned long)inode->i_ino); | ||
337 | goto error; | 328 | goto error; |
338 | } | 329 | } |
339 | if (f->metadata->size == sizeof(jdev.old_id)) | 330 | if (f->metadata->size == sizeof(jdev.old_id)) |
@@ -348,13 +339,12 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
348 | break; | 339 | break; |
349 | 340 | ||
350 | default: | 341 | default: |
351 | pr_warn("%s(): Bogus i_mode %o for ino %lu\n", | 342 | printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino); |
352 | __func__, inode->i_mode, (unsigned long)inode->i_ino); | ||
353 | } | 343 | } |
354 | 344 | ||
355 | mutex_unlock(&f->sem); | 345 | mutex_unlock(&f->sem); |
356 | 346 | ||
357 | jffs2_dbg(1, "jffs2_read_inode() returning\n"); | 347 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); |
358 | unlock_new_inode(inode); | 348 | unlock_new_inode(inode); |
359 | return inode; | 349 | return inode; |
360 | 350 | ||
@@ -372,13 +362,11 @@ void jffs2_dirty_inode(struct inode *inode, int flags) | |||
372 | struct iattr iattr; | 362 | struct iattr iattr; |
373 | 363 | ||
374 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { | 364 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { |
375 | jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n", | 365 | D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino)); |
376 | __func__, inode->i_ino); | ||
377 | return; | 366 | return; |
378 | } | 367 | } |
379 | 368 | ||
380 | jffs2_dbg(1, "%s(): calling setattr() for ino #%lu\n", | 369 | D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino)); |
381 | __func__, inode->i_ino); | ||
382 | 370 | ||
383 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; | 371 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; |
384 | iattr.ia_mode = inode->i_mode; | 372 | iattr.ia_mode = inode->i_mode; |
@@ -391,7 +379,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags) | |||
391 | jffs2_do_setattr(inode, &iattr); | 379 | jffs2_do_setattr(inode, &iattr); |
392 | } | 380 | } |
393 | 381 | ||
394 | int jffs2_do_remount_fs(struct super_block *sb, int *flags, char *data) | 382 | int jffs2_remount_fs (struct super_block *sb, int *flags, char *data) |
395 | { | 383 | { |
396 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 384 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
397 | 385 | ||
@@ -426,8 +414,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
426 | struct jffs2_inode_info *f; | 414 | struct jffs2_inode_info *f; |
427 | int ret; | 415 | int ret; |
428 | 416 | ||
429 | jffs2_dbg(1, "%s(): dir_i %ld, mode 0x%x\n", | 417 | D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); |
430 | __func__, dir_i->i_ino, mode); | ||
431 | 418 | ||
432 | c = JFFS2_SB_INFO(sb); | 419 | c = JFFS2_SB_INFO(sb); |
433 | 420 | ||
@@ -442,14 +429,14 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
442 | 429 | ||
443 | memset(ri, 0, sizeof(*ri)); | 430 | memset(ri, 0, sizeof(*ri)); |
444 | /* Set OS-specific defaults for new inodes */ | 431 | /* Set OS-specific defaults for new inodes */ |
445 | ri->uid = cpu_to_je16(from_kuid(&init_user_ns, current_fsuid())); | 432 | ri->uid = cpu_to_je16(current_fsuid()); |
446 | 433 | ||
447 | if (dir_i->i_mode & S_ISGID) { | 434 | if (dir_i->i_mode & S_ISGID) { |
448 | ri->gid = cpu_to_je16(i_gid_read(dir_i)); | 435 | ri->gid = cpu_to_je16(dir_i->i_gid); |
449 | if (S_ISDIR(mode)) | 436 | if (S_ISDIR(mode)) |
450 | mode |= S_ISGID; | 437 | mode |= S_ISGID; |
451 | } else { | 438 | } else { |
452 | ri->gid = cpu_to_je16(from_kgid(&init_user_ns, current_fsgid())); | 439 | ri->gid = cpu_to_je16(current_fsgid()); |
453 | } | 440 | } |
454 | 441 | ||
455 | /* POSIX ACLs have to be processed now, at least partly. | 442 | /* POSIX ACLs have to be processed now, at least partly. |
@@ -466,11 +453,11 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
466 | iput(inode); | 453 | iput(inode); |
467 | return ERR_PTR(ret); | 454 | return ERR_PTR(ret); |
468 | } | 455 | } |
469 | set_nlink(inode, 1); | 456 | inode->i_nlink = 1; |
470 | inode->i_ino = je32_to_cpu(ri->ino); | 457 | inode->i_ino = je32_to_cpu(ri->ino); |
471 | inode->i_mode = jemode_to_cpu(ri->mode); | 458 | inode->i_mode = jemode_to_cpu(ri->mode); |
472 | i_gid_write(inode, je16_to_cpu(ri->gid)); | 459 | inode->i_gid = je16_to_cpu(ri->gid); |
473 | i_uid_write(inode, je16_to_cpu(ri->uid)); | 460 | inode->i_uid = je16_to_cpu(ri->uid); |
474 | inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; | 461 | inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; |
475 | ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime)); | 462 | ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime)); |
476 | 463 | ||
@@ -479,6 +466,7 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
479 | 466 | ||
480 | if (insert_inode_locked(inode) < 0) { | 467 | if (insert_inode_locked(inode) < 0) { |
481 | make_bad_inode(inode); | 468 | make_bad_inode(inode); |
469 | unlock_new_inode(inode); | ||
482 | iput(inode); | 470 | iput(inode); |
483 | return ERR_PTR(-EINVAL); | 471 | return ERR_PTR(-EINVAL); |
484 | } | 472 | } |
@@ -517,11 +505,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
517 | 505 | ||
518 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER | 506 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER |
519 | if (c->mtd->type == MTD_NANDFLASH) { | 507 | if (c->mtd->type == MTD_NANDFLASH) { |
520 | pr_err("Cannot operate on NAND flash unless jffs2 NAND support is compiled in\n"); | 508 | printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n"); |
521 | return -EINVAL; | 509 | return -EINVAL; |
522 | } | 510 | } |
523 | if (c->mtd->type == MTD_DATAFLASH) { | 511 | if (c->mtd->type == MTD_DATAFLASH) { |
524 | pr_err("Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in\n"); | 512 | printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n"); |
525 | return -EINVAL; | 513 | return -EINVAL; |
526 | } | 514 | } |
527 | #endif | 515 | #endif |
@@ -535,13 +523,12 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
535 | */ | 523 | */ |
536 | if ((c->sector_size * blocks) != c->flash_size) { | 524 | if ((c->sector_size * blocks) != c->flash_size) { |
537 | c->flash_size = c->sector_size * blocks; | 525 | c->flash_size = c->sector_size * blocks; |
538 | pr_info("Flash size not aligned to erasesize, reducing to %dKiB\n", | 526 | printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", |
539 | c->flash_size / 1024); | 527 | c->flash_size / 1024); |
540 | } | 528 | } |
541 | 529 | ||
542 | if (c->flash_size < 5*c->sector_size) { | 530 | if (c->flash_size < 5*c->sector_size) { |
543 | pr_err("Too few erase blocks (%d)\n", | 531 | printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size); |
544 | c->flash_size / c->sector_size); | ||
545 | return -EINVAL; | 532 | return -EINVAL; |
546 | } | 533 | } |
547 | 534 | ||
@@ -564,20 +551,20 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
564 | if ((ret = jffs2_do_mount_fs(c))) | 551 | if ((ret = jffs2_do_mount_fs(c))) |
565 | goto out_inohash; | 552 | goto out_inohash; |
566 | 553 | ||
567 | jffs2_dbg(1, "%s(): Getting root inode\n", __func__); | 554 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); |
568 | root_i = jffs2_iget(sb, 1); | 555 | root_i = jffs2_iget(sb, 1); |
569 | if (IS_ERR(root_i)) { | 556 | if (IS_ERR(root_i)) { |
570 | jffs2_dbg(1, "get root inode failed\n"); | 557 | D1(printk(KERN_WARNING "get root inode failed\n")); |
571 | ret = PTR_ERR(root_i); | 558 | ret = PTR_ERR(root_i); |
572 | goto out_root; | 559 | goto out_root; |
573 | } | 560 | } |
574 | 561 | ||
575 | ret = -ENOMEM; | 562 | ret = -ENOMEM; |
576 | 563 | ||
577 | jffs2_dbg(1, "%s(): d_make_root()\n", __func__); | 564 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); |
578 | sb->s_root = d_make_root(root_i); | 565 | sb->s_root = d_alloc_root(root_i); |
579 | if (!sb->s_root) | 566 | if (!sb->s_root) |
580 | goto out_root; | 567 | goto out_root_i; |
581 | 568 | ||
582 | sb->s_maxbytes = 0xFFFFFFFF; | 569 | sb->s_maxbytes = 0xFFFFFFFF; |
583 | sb->s_blocksize = PAGE_CACHE_SIZE; | 570 | sb->s_blocksize = PAGE_CACHE_SIZE; |
@@ -587,6 +574,8 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
587 | jffs2_start_garbage_collect_thread(c); | 574 | jffs2_start_garbage_collect_thread(c); |
588 | return 0; | 575 | return 0; |
589 | 576 | ||
577 | out_root_i: | ||
578 | iput(root_i); | ||
590 | out_root: | 579 | out_root: |
591 | jffs2_free_ino_caches(c); | 580 | jffs2_free_ino_caches(c); |
592 | jffs2_free_raw_node_refs(c); | 581 | jffs2_free_raw_node_refs(c); |
@@ -632,21 +621,20 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
632 | */ | 621 | */ |
633 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); | 622 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); |
634 | if (!inode) { | 623 | if (!inode) { |
635 | jffs2_dbg(1, "ilookup() failed for ino #%u; inode is probably deleted.\n", | 624 | D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n", |
636 | inum); | 625 | inum)); |
637 | 626 | ||
638 | spin_lock(&c->inocache_lock); | 627 | spin_lock(&c->inocache_lock); |
639 | ic = jffs2_get_ino_cache(c, inum); | 628 | ic = jffs2_get_ino_cache(c, inum); |
640 | if (!ic) { | 629 | if (!ic) { |
641 | jffs2_dbg(1, "Inode cache for ino #%u is gone\n", | 630 | D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum)); |
642 | inum); | ||
643 | spin_unlock(&c->inocache_lock); | 631 | spin_unlock(&c->inocache_lock); |
644 | return NULL; | 632 | return NULL; |
645 | } | 633 | } |
646 | if (ic->state != INO_STATE_CHECKEDABSENT) { | 634 | if (ic->state != INO_STATE_CHECKEDABSENT) { |
647 | /* Wait for progress. Don't just loop */ | 635 | /* Wait for progress. Don't just loop */ |
648 | jffs2_dbg(1, "Waiting for ino #%u in state %d\n", | 636 | D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n", |
649 | ic->ino, ic->state); | 637 | ic->ino, ic->state)); |
650 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 638 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
651 | } else { | 639 | } else { |
652 | spin_unlock(&c->inocache_lock); | 640 | spin_unlock(&c->inocache_lock); |
@@ -664,8 +652,8 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
664 | return ERR_CAST(inode); | 652 | return ERR_CAST(inode); |
665 | } | 653 | } |
666 | if (is_bad_inode(inode)) { | 654 | if (is_bad_inode(inode)) { |
667 | pr_notice("Eep. read_inode() failed for ino #%u. unlinked %d\n", | 655 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. unlinked %d\n", |
668 | inum, unlinked); | 656 | inum, unlinked); |
669 | /* NB. This will happen again. We need to do something appropriate here. */ | 657 | /* NB. This will happen again. We need to do something appropriate here. */ |
670 | iput(inode); | 658 | iput(inode); |
671 | return ERR_PTR(-EIO); | 659 | return ERR_PTR(-EIO); |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 5a2dec2b064..31dce611337 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -10,8 +10,6 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
15 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
16 | #include <linux/mtd/mtd.h> | 14 | #include <linux/mtd/mtd.h> |
17 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
@@ -53,44 +51,44 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) | |||
53 | number of free blocks is low. */ | 51 | number of free blocks is low. */ |
54 | again: | 52 | again: |
55 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { | 53 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { |
56 | jffs2_dbg(1, "Picking block from bad_used_list to GC next\n"); | 54 | D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); |
57 | nextlist = &c->bad_used_list; | 55 | nextlist = &c->bad_used_list; |
58 | } else if (n < 50 && !list_empty(&c->erasable_list)) { | 56 | } else if (n < 50 && !list_empty(&c->erasable_list)) { |
59 | /* Note that most of them will have gone directly to be erased. | 57 | /* Note that most of them will have gone directly to be erased. |
60 | So don't favour the erasable_list _too_ much. */ | 58 | So don't favour the erasable_list _too_ much. */ |
61 | jffs2_dbg(1, "Picking block from erasable_list to GC next\n"); | 59 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); |
62 | nextlist = &c->erasable_list; | 60 | nextlist = &c->erasable_list; |
63 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { | 61 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { |
64 | /* Most of the time, pick one off the very_dirty list */ | 62 | /* Most of the time, pick one off the very_dirty list */ |
65 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next\n"); | 63 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next\n")); |
66 | nextlist = &c->very_dirty_list; | 64 | nextlist = &c->very_dirty_list; |
67 | } else if (n < 126 && !list_empty(&c->dirty_list)) { | 65 | } else if (n < 126 && !list_empty(&c->dirty_list)) { |
68 | jffs2_dbg(1, "Picking block from dirty_list to GC next\n"); | 66 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next\n")); |
69 | nextlist = &c->dirty_list; | 67 | nextlist = &c->dirty_list; |
70 | } else if (!list_empty(&c->clean_list)) { | 68 | } else if (!list_empty(&c->clean_list)) { |
71 | jffs2_dbg(1, "Picking block from clean_list to GC next\n"); | 69 | D1(printk(KERN_DEBUG "Picking block from clean_list to GC next\n")); |
72 | nextlist = &c->clean_list; | 70 | nextlist = &c->clean_list; |
73 | } else if (!list_empty(&c->dirty_list)) { | 71 | } else if (!list_empty(&c->dirty_list)) { |
74 | jffs2_dbg(1, "Picking block from dirty_list to GC next (clean_list was empty)\n"); | 72 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next (clean_list was empty)\n")); |
75 | 73 | ||
76 | nextlist = &c->dirty_list; | 74 | nextlist = &c->dirty_list; |
77 | } else if (!list_empty(&c->very_dirty_list)) { | 75 | } else if (!list_empty(&c->very_dirty_list)) { |
78 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n"); | 76 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n")); |
79 | nextlist = &c->very_dirty_list; | 77 | nextlist = &c->very_dirty_list; |
80 | } else if (!list_empty(&c->erasable_list)) { | 78 | } else if (!list_empty(&c->erasable_list)) { |
81 | jffs2_dbg(1, "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n"); | 79 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n")); |
82 | 80 | ||
83 | nextlist = &c->erasable_list; | 81 | nextlist = &c->erasable_list; |
84 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { | 82 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { |
85 | /* There are blocks are wating for the wbuf sync */ | 83 | /* There are blocks are wating for the wbuf sync */ |
86 | jffs2_dbg(1, "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n"); | 84 | D1(printk(KERN_DEBUG "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n")); |
87 | spin_unlock(&c->erase_completion_lock); | 85 | spin_unlock(&c->erase_completion_lock); |
88 | jffs2_flush_wbuf_pad(c); | 86 | jffs2_flush_wbuf_pad(c); |
89 | spin_lock(&c->erase_completion_lock); | 87 | spin_lock(&c->erase_completion_lock); |
90 | goto again; | 88 | goto again; |
91 | } else { | 89 | } else { |
92 | /* Eep. All were empty */ | 90 | /* Eep. All were empty */ |
93 | jffs2_dbg(1, "No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n"); | 91 | D1(printk(KERN_NOTICE "jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n")); |
94 | return NULL; | 92 | return NULL; |
95 | } | 93 | } |
96 | 94 | ||
@@ -99,15 +97,13 @@ again: | |||
99 | c->gcblock = ret; | 97 | c->gcblock = ret; |
100 | ret->gc_node = ret->first_node; | 98 | ret->gc_node = ret->first_node; |
101 | if (!ret->gc_node) { | 99 | if (!ret->gc_node) { |
102 | pr_warn("Eep. ret->gc_node for block at 0x%08x is NULL\n", | 100 | printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); |
103 | ret->offset); | ||
104 | BUG(); | 101 | BUG(); |
105 | } | 102 | } |
106 | 103 | ||
107 | /* Have we accidentally picked a clean block with wasted space ? */ | 104 | /* Have we accidentally picked a clean block with wasted space ? */ |
108 | if (ret->wasted_size) { | 105 | if (ret->wasted_size) { |
109 | jffs2_dbg(1, "Converting wasted_size %08x to dirty_size\n", | 106 | D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); |
110 | ret->wasted_size); | ||
111 | ret->dirty_size += ret->wasted_size; | 107 | ret->dirty_size += ret->wasted_size; |
112 | c->wasted_size -= ret->wasted_size; | 108 | c->wasted_size -= ret->wasted_size; |
113 | c->dirty_size += ret->wasted_size; | 109 | c->dirty_size += ret->wasted_size; |
@@ -144,8 +140,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
144 | 140 | ||
145 | /* checked_ino is protected by the alloc_sem */ | 141 | /* checked_ino is protected by the alloc_sem */ |
146 | if (c->checked_ino > c->highest_ino && xattr) { | 142 | if (c->checked_ino > c->highest_ino && xattr) { |
147 | pr_crit("Checked all inodes but still 0x%x bytes of unchecked space?\n", | 143 | printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", |
148 | c->unchecked_size); | 144 | c->unchecked_size); |
149 | jffs2_dbg_dump_block_lists_nolock(c); | 145 | jffs2_dbg_dump_block_lists_nolock(c); |
150 | spin_unlock(&c->erase_completion_lock); | 146 | spin_unlock(&c->erase_completion_lock); |
151 | mutex_unlock(&c->alloc_sem); | 147 | mutex_unlock(&c->alloc_sem); |
@@ -167,8 +163,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
167 | } | 163 | } |
168 | 164 | ||
169 | if (!ic->pino_nlink) { | 165 | if (!ic->pino_nlink) { |
170 | jffs2_dbg(1, "Skipping check of ino #%d with nlink/pino zero\n", | 166 | D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink/pino zero\n", |
171 | ic->ino); | 167 | ic->ino)); |
172 | spin_unlock(&c->inocache_lock); | 168 | spin_unlock(&c->inocache_lock); |
173 | jffs2_xattr_delete_inode(c, ic); | 169 | jffs2_xattr_delete_inode(c, ic); |
174 | continue; | 170 | continue; |
@@ -176,15 +172,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
176 | switch(ic->state) { | 172 | switch(ic->state) { |
177 | case INO_STATE_CHECKEDABSENT: | 173 | case INO_STATE_CHECKEDABSENT: |
178 | case INO_STATE_PRESENT: | 174 | case INO_STATE_PRESENT: |
179 | jffs2_dbg(1, "Skipping ino #%u already checked\n", | 175 | D1(printk(KERN_DEBUG "Skipping ino #%u already checked\n", ic->ino)); |
180 | ic->ino); | ||
181 | spin_unlock(&c->inocache_lock); | 176 | spin_unlock(&c->inocache_lock); |
182 | continue; | 177 | continue; |
183 | 178 | ||
184 | case INO_STATE_GC: | 179 | case INO_STATE_GC: |
185 | case INO_STATE_CHECKING: | 180 | case INO_STATE_CHECKING: |
186 | pr_warn("Inode #%u is in state %d during CRC check phase!\n", | 181 | printk(KERN_WARNING "Inode #%u is in state %d during CRC check phase!\n", ic->ino, ic->state); |
187 | ic->ino, ic->state); | ||
188 | spin_unlock(&c->inocache_lock); | 182 | spin_unlock(&c->inocache_lock); |
189 | BUG(); | 183 | BUG(); |
190 | 184 | ||
@@ -192,8 +186,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
192 | /* We need to wait for it to finish, lest we move on | 186 | /* We need to wait for it to finish, lest we move on |
193 | and trigger the BUG() above while we haven't yet | 187 | and trigger the BUG() above while we haven't yet |
194 | finished checking all its nodes */ | 188 | finished checking all its nodes */ |
195 | jffs2_dbg(1, "Waiting for ino #%u to finish reading\n", | 189 | D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); |
196 | ic->ino); | ||
197 | /* We need to come back again for the _same_ inode. We've | 190 | /* We need to come back again for the _same_ inode. We've |
198 | made no progress in this case, but that should be OK */ | 191 | made no progress in this case, but that should be OK */ |
199 | c->checked_ino--; | 192 | c->checked_ino--; |
@@ -211,13 +204,11 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
211 | ic->state = INO_STATE_CHECKING; | 204 | ic->state = INO_STATE_CHECKING; |
212 | spin_unlock(&c->inocache_lock); | 205 | spin_unlock(&c->inocache_lock); |
213 | 206 | ||
214 | jffs2_dbg(1, "%s(): triggering inode scan of ino#%u\n", | 207 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino)); |
215 | __func__, ic->ino); | ||
216 | 208 | ||
217 | ret = jffs2_do_crccheck_inode(c, ic); | 209 | ret = jffs2_do_crccheck_inode(c, ic); |
218 | if (ret) | 210 | if (ret) |
219 | pr_warn("Returned error for crccheck of ino #%u. Expect badness...\n", | 211 | printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino); |
220 | ic->ino); | ||
221 | 212 | ||
222 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); | 213 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); |
223 | mutex_unlock(&c->alloc_sem); | 214 | mutex_unlock(&c->alloc_sem); |
@@ -229,13 +220,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
229 | !list_empty(&c->erase_pending_list)) { | 220 | !list_empty(&c->erase_pending_list)) { |
230 | spin_unlock(&c->erase_completion_lock); | 221 | spin_unlock(&c->erase_completion_lock); |
231 | mutex_unlock(&c->alloc_sem); | 222 | mutex_unlock(&c->alloc_sem); |
232 | jffs2_dbg(1, "%s(): erasing pending blocks\n", __func__); | 223 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() erasing pending blocks\n")); |
233 | if (jffs2_erase_pending_blocks(c, 1)) | 224 | if (jffs2_erase_pending_blocks(c, 1)) |
234 | return 0; | 225 | return 0; |
235 | 226 | ||
236 | jffs2_dbg(1, "No progress from erasing block; doing GC anyway\n"); | 227 | D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n")); |
237 | mutex_lock(&c->alloc_sem); | ||
238 | spin_lock(&c->erase_completion_lock); | 228 | spin_lock(&c->erase_completion_lock); |
229 | mutex_lock(&c->alloc_sem); | ||
239 | } | 230 | } |
240 | 231 | ||
241 | /* First, work out which block we're garbage-collecting */ | 232 | /* First, work out which block we're garbage-collecting */ |
@@ -251,14 +242,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
251 | mutex_unlock(&c->alloc_sem); | 242 | mutex_unlock(&c->alloc_sem); |
252 | return -EAGAIN; | 243 | return -EAGAIN; |
253 | } | 244 | } |
254 | jffs2_dbg(1, "Couldn't find erase block to garbage collect!\n"); | 245 | D1(printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); |
255 | spin_unlock(&c->erase_completion_lock); | 246 | spin_unlock(&c->erase_completion_lock); |
256 | mutex_unlock(&c->alloc_sem); | 247 | mutex_unlock(&c->alloc_sem); |
257 | return -EIO; | 248 | return -EIO; |
258 | } | 249 | } |
259 | 250 | ||
260 | jffs2_dbg(1, "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", | 251 | D1(printk(KERN_DEBUG "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size)); |
261 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size); | ||
262 | D1(if (c->nextblock) | 252 | D1(if (c->nextblock) |
263 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); | 253 | printk(KERN_DEBUG "Nextblock at %08x, used_size %08x, dirty_size %08x, wasted_size %08x, free_size %08x\n", c->nextblock->offset, c->nextblock->used_size, c->nextblock->dirty_size, c->nextblock->wasted_size, c->nextblock->free_size)); |
264 | 254 | ||
@@ -271,14 +261,12 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
271 | gcblock_dirty = jeb->dirty_size; | 261 | gcblock_dirty = jeb->dirty_size; |
272 | 262 | ||
273 | while(ref_obsolete(raw)) { | 263 | while(ref_obsolete(raw)) { |
274 | jffs2_dbg(1, "Node at 0x%08x is obsolete... skipping\n", | 264 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); |
275 | ref_offset(raw)); | ||
276 | raw = ref_next(raw); | 265 | raw = ref_next(raw); |
277 | if (unlikely(!raw)) { | 266 | if (unlikely(!raw)) { |
278 | pr_warn("eep. End of raw list while still supposedly nodes to GC\n"); | 267 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); |
279 | pr_warn("erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", | 268 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", |
280 | jeb->offset, jeb->free_size, | 269 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); |
281 | jeb->dirty_size, jeb->used_size); | ||
282 | jeb->gc_node = raw; | 270 | jeb->gc_node = raw; |
283 | spin_unlock(&c->erase_completion_lock); | 271 | spin_unlock(&c->erase_completion_lock); |
284 | mutex_unlock(&c->alloc_sem); | 272 | mutex_unlock(&c->alloc_sem); |
@@ -287,8 +275,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
287 | } | 275 | } |
288 | jeb->gc_node = raw; | 276 | jeb->gc_node = raw; |
289 | 277 | ||
290 | jffs2_dbg(1, "Going to garbage collect node at 0x%08x\n", | 278 | D1(printk(KERN_DEBUG "Going to garbage collect node at 0x%08x\n", ref_offset(raw))); |
291 | ref_offset(raw)); | ||
292 | 279 | ||
293 | if (!raw->next_in_ino) { | 280 | if (!raw->next_in_ino) { |
294 | /* Inode-less node. Clean marker, snapshot or something like that */ | 281 | /* Inode-less node. Clean marker, snapshot or something like that */ |
@@ -329,9 +316,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
329 | 316 | ||
330 | spin_unlock(&c->erase_completion_lock); | 317 | spin_unlock(&c->erase_completion_lock); |
331 | 318 | ||
332 | jffs2_dbg(1, "%s(): collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", | 319 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", jeb->offset, ref_offset(raw), ref_flags(raw), ic->ino)); |
333 | __func__, jeb->offset, ref_offset(raw), ref_flags(raw), | ||
334 | ic->ino); | ||
335 | 320 | ||
336 | /* Three possibilities: | 321 | /* Three possibilities: |
337 | 1. Inode is already in-core. We must iget it and do proper | 322 | 1. Inode is already in-core. We must iget it and do proper |
@@ -351,8 +336,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
351 | if (ref_flags(raw) == REF_PRISTINE) | 336 | if (ref_flags(raw) == REF_PRISTINE) |
352 | ic->state = INO_STATE_GC; | 337 | ic->state = INO_STATE_GC; |
353 | else { | 338 | else { |
354 | jffs2_dbg(1, "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", | 339 | D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", |
355 | ic->ino); | 340 | ic->ino)); |
356 | } | 341 | } |
357 | break; | 342 | break; |
358 | 343 | ||
@@ -368,8 +353,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
368 | we're holding the alloc_sem, no other garbage collection | 353 | we're holding the alloc_sem, no other garbage collection |
369 | can happen. | 354 | can happen. |
370 | */ | 355 | */ |
371 | pr_crit("Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", | 356 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", |
372 | ic->ino, ic->state); | 357 | ic->ino, ic->state); |
373 | mutex_unlock(&c->alloc_sem); | 358 | mutex_unlock(&c->alloc_sem); |
374 | spin_unlock(&c->inocache_lock); | 359 | spin_unlock(&c->inocache_lock); |
375 | BUG(); | 360 | BUG(); |
@@ -382,8 +367,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
382 | drop the alloc_sem before sleeping. */ | 367 | drop the alloc_sem before sleeping. */ |
383 | 368 | ||
384 | mutex_unlock(&c->alloc_sem); | 369 | mutex_unlock(&c->alloc_sem); |
385 | jffs2_dbg(1, "%s(): waiting for ino #%u in state %d\n", | 370 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", |
386 | __func__, ic->ino, ic->state); | 371 | ic->ino, ic->state)); |
387 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 372 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
388 | /* And because we dropped the alloc_sem we must start again from the | 373 | /* And because we dropped the alloc_sem we must start again from the |
389 | beginning. Ponder chance of livelock here -- we're returning success | 374 | beginning. Ponder chance of livelock here -- we're returning success |
@@ -448,8 +433,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
448 | test_gcnode: | 433 | test_gcnode: |
449 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { | 434 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { |
450 | /* Eep. This really should never happen. GC is broken */ | 435 | /* Eep. This really should never happen. GC is broken */ |
451 | pr_err("Error garbage collecting node at %08x!\n", | 436 | printk(KERN_ERR "Error garbage collecting node at %08x!\n", ref_offset(jeb->gc_node)); |
452 | ref_offset(jeb->gc_node)); | ||
453 | ret = -ENOSPC; | 437 | ret = -ENOSPC; |
454 | } | 438 | } |
455 | release_sem: | 439 | release_sem: |
@@ -461,8 +445,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
461 | 445 | ||
462 | eraseit: | 446 | eraseit: |
463 | if (c->gcblock && !c->gcblock->used_size) { | 447 | if (c->gcblock && !c->gcblock->used_size) { |
464 | jffs2_dbg(1, "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", | 448 | D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset)); |
465 | c->gcblock->offset); | ||
466 | /* We're GC'ing an empty block? */ | 449 | /* We're GC'ing an empty block? */ |
467 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); | 450 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); |
468 | c->gcblock = NULL; | 451 | c->gcblock = NULL; |
@@ -492,12 +475,12 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
492 | 475 | ||
493 | if (c->gcblock != jeb) { | 476 | if (c->gcblock != jeb) { |
494 | spin_unlock(&c->erase_completion_lock); | 477 | spin_unlock(&c->erase_completion_lock); |
495 | jffs2_dbg(1, "GC block is no longer gcblock. Restart\n"); | 478 | D1(printk(KERN_DEBUG "GC block is no longer gcblock. Restart\n")); |
496 | goto upnout; | 479 | goto upnout; |
497 | } | 480 | } |
498 | if (ref_obsolete(raw)) { | 481 | if (ref_obsolete(raw)) { |
499 | spin_unlock(&c->erase_completion_lock); | 482 | spin_unlock(&c->erase_completion_lock); |
500 | jffs2_dbg(1, "node to be GC'd was obsoleted in the meantime.\n"); | 483 | D1(printk(KERN_DEBUG "node to be GC'd was obsoleted in the meantime.\n")); |
501 | /* They'll call again */ | 484 | /* They'll call again */ |
502 | goto upnout; | 485 | goto upnout; |
503 | } | 486 | } |
@@ -553,10 +536,10 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
553 | } else if (fd) { | 536 | } else if (fd) { |
554 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); | 537 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); |
555 | } else { | 538 | } else { |
556 | pr_warn("Raw node at 0x%08x wasn't in node lists for ino #%u\n", | 539 | printk(KERN_WARNING "Raw node at 0x%08x wasn't in node lists for ino #%u\n", |
557 | ref_offset(raw), f->inocache->ino); | 540 | ref_offset(raw), f->inocache->ino); |
558 | if (ref_obsolete(raw)) { | 541 | if (ref_obsolete(raw)) { |
559 | pr_warn("But it's obsolete so we don't mind too much\n"); | 542 | printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); |
560 | } else { | 543 | } else { |
561 | jffs2_dbg_dump_node(c, ref_offset(raw)); | 544 | jffs2_dbg_dump_node(c, ref_offset(raw)); |
562 | BUG(); | 545 | BUG(); |
@@ -579,8 +562,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
579 | uint32_t crc, rawlen; | 562 | uint32_t crc, rawlen; |
580 | int retried = 0; | 563 | int retried = 0; |
581 | 564 | ||
582 | jffs2_dbg(1, "Going to GC REF_PRISTINE node at 0x%08x\n", | 565 | D1(printk(KERN_DEBUG "Going to GC REF_PRISTINE node at 0x%08x\n", ref_offset(raw))); |
583 | ref_offset(raw)); | ||
584 | 566 | ||
585 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); | 567 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); |
586 | 568 | ||
@@ -613,8 +595,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
613 | 595 | ||
614 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); | 596 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); |
615 | if (je32_to_cpu(node->u.hdr_crc) != crc) { | 597 | if (je32_to_cpu(node->u.hdr_crc) != crc) { |
616 | pr_warn("Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 598 | printk(KERN_WARNING "Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
617 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); | 599 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); |
618 | goto bail; | 600 | goto bail; |
619 | } | 601 | } |
620 | 602 | ||
@@ -622,18 +604,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
622 | case JFFS2_NODETYPE_INODE: | 604 | case JFFS2_NODETYPE_INODE: |
623 | crc = crc32(0, node, sizeof(node->i)-8); | 605 | crc = crc32(0, node, sizeof(node->i)-8); |
624 | if (je32_to_cpu(node->i.node_crc) != crc) { | 606 | if (je32_to_cpu(node->i.node_crc) != crc) { |
625 | pr_warn("Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 607 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
626 | ref_offset(raw), je32_to_cpu(node->i.node_crc), | 608 | ref_offset(raw), je32_to_cpu(node->i.node_crc), crc); |
627 | crc); | ||
628 | goto bail; | 609 | goto bail; |
629 | } | 610 | } |
630 | 611 | ||
631 | if (je32_to_cpu(node->i.dsize)) { | 612 | if (je32_to_cpu(node->i.dsize)) { |
632 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); | 613 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); |
633 | if (je32_to_cpu(node->i.data_crc) != crc) { | 614 | if (je32_to_cpu(node->i.data_crc) != crc) { |
634 | pr_warn("Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 615 | printk(KERN_WARNING "Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
635 | ref_offset(raw), | 616 | ref_offset(raw), je32_to_cpu(node->i.data_crc), crc); |
636 | je32_to_cpu(node->i.data_crc), crc); | ||
637 | goto bail; | 617 | goto bail; |
638 | } | 618 | } |
639 | } | 619 | } |
@@ -642,24 +622,21 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
642 | case JFFS2_NODETYPE_DIRENT: | 622 | case JFFS2_NODETYPE_DIRENT: |
643 | crc = crc32(0, node, sizeof(node->d)-8); | 623 | crc = crc32(0, node, sizeof(node->d)-8); |
644 | if (je32_to_cpu(node->d.node_crc) != crc) { | 624 | if (je32_to_cpu(node->d.node_crc) != crc) { |
645 | pr_warn("Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 625 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
646 | ref_offset(raw), | 626 | ref_offset(raw), je32_to_cpu(node->d.node_crc), crc); |
647 | je32_to_cpu(node->d.node_crc), crc); | ||
648 | goto bail; | 627 | goto bail; |
649 | } | 628 | } |
650 | 629 | ||
651 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { | 630 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { |
652 | pr_warn("Name in dirent node at 0x%08x contains zeroes\n", | 631 | printk(KERN_WARNING "Name in dirent node at 0x%08x contains zeroes\n", ref_offset(raw)); |
653 | ref_offset(raw)); | ||
654 | goto bail; | 632 | goto bail; |
655 | } | 633 | } |
656 | 634 | ||
657 | if (node->d.nsize) { | 635 | if (node->d.nsize) { |
658 | crc = crc32(0, node->d.name, node->d.nsize); | 636 | crc = crc32(0, node->d.name, node->d.nsize); |
659 | if (je32_to_cpu(node->d.name_crc) != crc) { | 637 | if (je32_to_cpu(node->d.name_crc) != crc) { |
660 | pr_warn("Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 638 | printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
661 | ref_offset(raw), | 639 | ref_offset(raw), je32_to_cpu(node->d.name_crc), crc); |
662 | je32_to_cpu(node->d.name_crc), crc); | ||
663 | goto bail; | 640 | goto bail; |
664 | } | 641 | } |
665 | } | 642 | } |
@@ -667,8 +644,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
667 | default: | 644 | default: |
668 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ | 645 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ |
669 | if (ic) { | 646 | if (ic) { |
670 | pr_warn("Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", | 647 | printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", |
671 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); | 648 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); |
672 | goto bail; | 649 | goto bail; |
673 | } | 650 | } |
674 | } | 651 | } |
@@ -680,13 +657,12 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
680 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); | 657 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); |
681 | 658 | ||
682 | if (ret || (retlen != rawlen)) { | 659 | if (ret || (retlen != rawlen)) { |
683 | pr_notice("Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", | 660 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", |
684 | rawlen, phys_ofs, ret, retlen); | 661 | rawlen, phys_ofs, ret, retlen); |
685 | if (retlen) { | 662 | if (retlen) { |
686 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); | 663 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); |
687 | } else { | 664 | } else { |
688 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", | 665 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", phys_ofs); |
689 | phys_ofs); | ||
690 | } | 666 | } |
691 | if (!retried) { | 667 | if (!retried) { |
692 | /* Try to reallocate space and retry */ | 668 | /* Try to reallocate space and retry */ |
@@ -695,7 +671,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
695 | 671 | ||
696 | retried = 1; | 672 | retried = 1; |
697 | 673 | ||
698 | jffs2_dbg(1, "Retrying failed write of REF_PRISTINE node.\n"); | 674 | D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); |
699 | 675 | ||
700 | jffs2_dbg_acct_sanity_check(c,jeb); | 676 | jffs2_dbg_acct_sanity_check(c,jeb); |
701 | jffs2_dbg_acct_paranoia_check(c, jeb); | 677 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -705,16 +681,14 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
705 | it is only an upper estimation */ | 681 | it is only an upper estimation */ |
706 | 682 | ||
707 | if (!ret) { | 683 | if (!ret) { |
708 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n", | 684 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); |
709 | phys_ofs); | ||
710 | 685 | ||
711 | jffs2_dbg_acct_sanity_check(c,jeb); | 686 | jffs2_dbg_acct_sanity_check(c,jeb); |
712 | jffs2_dbg_acct_paranoia_check(c, jeb); | 687 | jffs2_dbg_acct_paranoia_check(c, jeb); |
713 | 688 | ||
714 | goto retry; | 689 | goto retry; |
715 | } | 690 | } |
716 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", | 691 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); |
717 | ret); | ||
718 | } | 692 | } |
719 | 693 | ||
720 | if (!ret) | 694 | if (!ret) |
@@ -724,8 +698,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
724 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); | 698 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); |
725 | 699 | ||
726 | jffs2_mark_node_obsolete(c, raw); | 700 | jffs2_mark_node_obsolete(c, raw); |
727 | jffs2_dbg(1, "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", | 701 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); |
728 | ref_offset(raw)); | ||
729 | 702 | ||
730 | out_node: | 703 | out_node: |
731 | kfree(node); | 704 | kfree(node); |
@@ -752,32 +725,29 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
752 | /* For these, we don't actually need to read the old node */ | 725 | /* For these, we don't actually need to read the old node */ |
753 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); | 726 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); |
754 | mdata = (char *)&dev; | 727 | mdata = (char *)&dev; |
755 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", | 728 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen)); |
756 | __func__, mdatalen); | ||
757 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { | 729 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { |
758 | mdatalen = fn->size; | 730 | mdatalen = fn->size; |
759 | mdata = kmalloc(fn->size, GFP_KERNEL); | 731 | mdata = kmalloc(fn->size, GFP_KERNEL); |
760 | if (!mdata) { | 732 | if (!mdata) { |
761 | pr_warn("kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); | 733 | printk(KERN_WARNING "kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); |
762 | return -ENOMEM; | 734 | return -ENOMEM; |
763 | } | 735 | } |
764 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); | 736 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); |
765 | if (ret) { | 737 | if (ret) { |
766 | pr_warn("read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", | 738 | printk(KERN_WARNING "read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", ret); |
767 | ret); | ||
768 | kfree(mdata); | 739 | kfree(mdata); |
769 | return ret; | 740 | return ret; |
770 | } | 741 | } |
771 | jffs2_dbg(1, "%s(): Writing %d bites of symlink target\n", | 742 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); |
772 | __func__, mdatalen); | ||
773 | 743 | ||
774 | } | 744 | } |
775 | 745 | ||
776 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, | 746 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, |
777 | JFFS2_SUMMARY_INODE_SIZE); | 747 | JFFS2_SUMMARY_INODE_SIZE); |
778 | if (ret) { | 748 | if (ret) { |
779 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", | 749 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", |
780 | sizeof(ri) + mdatalen, ret); | 750 | sizeof(ri)+ mdatalen, ret); |
781 | goto out; | 751 | goto out; |
782 | } | 752 | } |
783 | 753 | ||
@@ -814,7 +784,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
814 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); | 784 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); |
815 | 785 | ||
816 | if (IS_ERR(new_fn)) { | 786 | if (IS_ERR(new_fn)) { |
817 | pr_warn("Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 787 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); |
818 | ret = PTR_ERR(new_fn); | 788 | ret = PTR_ERR(new_fn); |
819 | goto out; | 789 | goto out; |
820 | } | 790 | } |
@@ -857,15 +827,14 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
857 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, | 827 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, |
858 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); | 828 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); |
859 | if (ret) { | 829 | if (ret) { |
860 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", | 830 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", |
861 | sizeof(rd)+rd.nsize, ret); | 831 | sizeof(rd)+rd.nsize, ret); |
862 | return ret; | 832 | return ret; |
863 | } | 833 | } |
864 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); | 834 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); |
865 | 835 | ||
866 | if (IS_ERR(new_fd)) { | 836 | if (IS_ERR(new_fd)) { |
867 | pr_warn("jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", | 837 | printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); |
868 | PTR_ERR(new_fd)); | ||
869 | return PTR_ERR(new_fd); | 838 | return PTR_ERR(new_fd); |
870 | } | 839 | } |
871 | jffs2_add_fd_to_list(c, new_fd, &f->dents); | 840 | jffs2_add_fd_to_list(c, new_fd, &f->dents); |
@@ -918,22 +887,19 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
918 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) | 887 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) |
919 | continue; | 888 | continue; |
920 | 889 | ||
921 | jffs2_dbg(1, "Check potential deletion dirent at %08x\n", | 890 | D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw))); |
922 | ref_offset(raw)); | ||
923 | 891 | ||
924 | /* This is an obsolete node belonging to the same directory, and it's of the right | 892 | /* This is an obsolete node belonging to the same directory, and it's of the right |
925 | length. We need to take a closer look...*/ | 893 | length. We need to take a closer look...*/ |
926 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); | 894 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); |
927 | if (ret) { | 895 | if (ret) { |
928 | pr_warn("%s(): Read error (%d) reading obsolete node at %08x\n", | 896 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw)); |
929 | __func__, ret, ref_offset(raw)); | ||
930 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ | 897 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ |
931 | continue; | 898 | continue; |
932 | } | 899 | } |
933 | if (retlen != rawlen) { | 900 | if (retlen != rawlen) { |
934 | pr_warn("%s(): Short read (%zd not %u) reading header from obsolete node at %08x\n", | 901 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Short read (%zd not %u) reading header from obsolete node at %08x\n", |
935 | __func__, retlen, rawlen, | 902 | retlen, rawlen, ref_offset(raw)); |
936 | ref_offset(raw)); | ||
937 | continue; | 903 | continue; |
938 | } | 904 | } |
939 | 905 | ||
@@ -957,9 +923,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
957 | a new deletion dirent to replace it */ | 923 | a new deletion dirent to replace it */ |
958 | mutex_unlock(&c->erase_free_sem); | 924 | mutex_unlock(&c->erase_free_sem); |
959 | 925 | ||
960 | jffs2_dbg(1, "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", | 926 | D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", |
961 | ref_offset(fd->raw), fd->name, | 927 | ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino))); |
962 | ref_offset(raw), je32_to_cpu(rd->ino)); | ||
963 | kfree(rd); | 928 | kfree(rd); |
964 | 929 | ||
965 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); | 930 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); |
@@ -982,8 +947,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
982 | fdp = &(*fdp)->next; | 947 | fdp = &(*fdp)->next; |
983 | } | 948 | } |
984 | if (!found) { | 949 | if (!found) { |
985 | pr_warn("Deletion dirent \"%s\" not found in list for ino #%u\n", | 950 | printk(KERN_WARNING "Deletion dirent \"%s\" not found in list for ino #%u\n", fd->name, f->inocache->ino); |
986 | fd->name, f->inocache->ino); | ||
987 | } | 951 | } |
988 | jffs2_mark_node_obsolete(c, fd->raw); | 952 | jffs2_mark_node_obsolete(c, fd->raw); |
989 | jffs2_free_full_dirent(fd); | 953 | jffs2_free_full_dirent(fd); |
@@ -1000,8 +964,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1000 | uint32_t alloclen, ilen; | 964 | uint32_t alloclen, ilen; |
1001 | int ret; | 965 | int ret; |
1002 | 966 | ||
1003 | jffs2_dbg(1, "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", | 967 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", |
1004 | f->inocache->ino, start, end); | 968 | f->inocache->ino, start, end)); |
1005 | 969 | ||
1006 | memset(&ri, 0, sizeof(ri)); | 970 | memset(&ri, 0, sizeof(ri)); |
1007 | 971 | ||
@@ -1012,37 +976,35 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1012 | write it out again with the _same_ version as before */ | 976 | write it out again with the _same_ version as before */ |
1013 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); | 977 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); |
1014 | if (readlen != sizeof(ri) || ret) { | 978 | if (readlen != sizeof(ri) || ret) { |
1015 | pr_warn("Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", | 979 | printk(KERN_WARNING "Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", ret, readlen); |
1016 | ret, readlen); | ||
1017 | goto fill; | 980 | goto fill; |
1018 | } | 981 | } |
1019 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { | 982 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { |
1020 | pr_warn("%s(): Node at 0x%08x had node type 0x%04x instead of JFFS2_NODETYPE_INODE(0x%04x)\n", | 983 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had node type 0x%04x instead of JFFS2_NODETYPE_INODE(0x%04x)\n", |
1021 | __func__, ref_offset(fn->raw), | 984 | ref_offset(fn->raw), |
1022 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); | 985 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); |
1023 | return -EIO; | 986 | return -EIO; |
1024 | } | 987 | } |
1025 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { | 988 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { |
1026 | pr_warn("%s(): Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", | 989 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", |
1027 | __func__, ref_offset(fn->raw), | 990 | ref_offset(fn->raw), |
1028 | je32_to_cpu(ri.totlen), sizeof(ri)); | 991 | je32_to_cpu(ri.totlen), sizeof(ri)); |
1029 | return -EIO; | 992 | return -EIO; |
1030 | } | 993 | } |
1031 | crc = crc32(0, &ri, sizeof(ri)-8); | 994 | crc = crc32(0, &ri, sizeof(ri)-8); |
1032 | if (crc != je32_to_cpu(ri.node_crc)) { | 995 | if (crc != je32_to_cpu(ri.node_crc)) { |
1033 | pr_warn("%s: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", | 996 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", |
1034 | __func__, ref_offset(fn->raw), | 997 | ref_offset(fn->raw), |
1035 | je32_to_cpu(ri.node_crc), crc); | 998 | je32_to_cpu(ri.node_crc), crc); |
1036 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ | 999 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ |
1037 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1000 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1038 | start, end, f->inocache->ino); | 1001 | start, end, f->inocache->ino); |
1039 | goto fill; | 1002 | goto fill; |
1040 | } | 1003 | } |
1041 | if (ri.compr != JFFS2_COMPR_ZERO) { | 1004 | if (ri.compr != JFFS2_COMPR_ZERO) { |
1042 | pr_warn("%s(): Node 0x%08x wasn't a hole node!\n", | 1005 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); |
1043 | __func__, ref_offset(fn->raw)); | 1006 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1044 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1007 | start, end, f->inocache->ino); |
1045 | start, end, f->inocache->ino); | ||
1046 | goto fill; | 1008 | goto fill; |
1047 | } | 1009 | } |
1048 | } else { | 1010 | } else { |
@@ -1081,14 +1043,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1081 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, | 1043 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, |
1082 | JFFS2_SUMMARY_INODE_SIZE); | 1044 | JFFS2_SUMMARY_INODE_SIZE); |
1083 | if (ret) { | 1045 | if (ret) { |
1084 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", | 1046 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", |
1085 | sizeof(ri), ret); | 1047 | sizeof(ri), ret); |
1086 | return ret; | 1048 | return ret; |
1087 | } | 1049 | } |
1088 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); | 1050 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); |
1089 | 1051 | ||
1090 | if (IS_ERR(new_fn)) { | 1052 | if (IS_ERR(new_fn)) { |
1091 | pr_warn("Error writing new hole node: %ld\n", PTR_ERR(new_fn)); | 1053 | printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); |
1092 | return PTR_ERR(new_fn); | 1054 | return PTR_ERR(new_fn); |
1093 | } | 1055 | } |
1094 | if (je32_to_cpu(ri.version) == f->highest_version) { | 1056 | if (je32_to_cpu(ri.version) == f->highest_version) { |
@@ -1108,9 +1070,9 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1108 | * above.) | 1070 | * above.) |
1109 | */ | 1071 | */ |
1110 | D1(if(unlikely(fn->frags <= 1)) { | 1072 | D1(if(unlikely(fn->frags <= 1)) { |
1111 | pr_warn("%s(): Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n", | 1073 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n", |
1112 | __func__, fn->frags, je32_to_cpu(ri.version), | 1074 | fn->frags, je32_to_cpu(ri.version), f->highest_version, |
1113 | f->highest_version, je32_to_cpu(ri.ino)); | 1075 | je32_to_cpu(ri.ino)); |
1114 | }); | 1076 | }); |
1115 | 1077 | ||
1116 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ | 1078 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ |
@@ -1127,11 +1089,11 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1127 | } | 1089 | } |
1128 | } | 1090 | } |
1129 | if (fn->frags) { | 1091 | if (fn->frags) { |
1130 | pr_warn("%s(): Old node still has frags!\n", __func__); | 1092 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Old node still has frags!\n"); |
1131 | BUG(); | 1093 | BUG(); |
1132 | } | 1094 | } |
1133 | if (!new_fn->frags) { | 1095 | if (!new_fn->frags) { |
1134 | pr_warn("%s(): New node has no frags!\n", __func__); | 1096 | printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); |
1135 | BUG(); | 1097 | BUG(); |
1136 | } | 1098 | } |
1137 | 1099 | ||
@@ -1155,8 +1117,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1155 | 1117 | ||
1156 | memset(&ri, 0, sizeof(ri)); | 1118 | memset(&ri, 0, sizeof(ri)); |
1157 | 1119 | ||
1158 | jffs2_dbg(1, "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", | 1120 | D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", |
1159 | f->inocache->ino, start, end); | 1121 | f->inocache->ino, start, end)); |
1160 | 1122 | ||
1161 | orig_end = end; | 1123 | orig_end = end; |
1162 | orig_start = start; | 1124 | orig_start = start; |
@@ -1187,15 +1149,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1187 | /* If the previous frag doesn't even reach the beginning, there's | 1149 | /* If the previous frag doesn't even reach the beginning, there's |
1188 | excessive fragmentation. Just merge. */ | 1150 | excessive fragmentation. Just merge. */ |
1189 | if (frag->ofs > min) { | 1151 | if (frag->ofs > min) { |
1190 | jffs2_dbg(1, "Expanding down to cover partial frag (0x%x-0x%x)\n", | 1152 | D1(printk(KERN_DEBUG "Expanding down to cover partial frag (0x%x-0x%x)\n", |
1191 | frag->ofs, frag->ofs+frag->size); | 1153 | frag->ofs, frag->ofs+frag->size)); |
1192 | start = frag->ofs; | 1154 | start = frag->ofs; |
1193 | continue; | 1155 | continue; |
1194 | } | 1156 | } |
1195 | /* OK. This frag holds the first byte of the page. */ | 1157 | /* OK. This frag holds the first byte of the page. */ |
1196 | if (!frag->node || !frag->node->raw) { | 1158 | if (!frag->node || !frag->node->raw) { |
1197 | jffs2_dbg(1, "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", | 1159 | D1(printk(KERN_DEBUG "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", |
1198 | frag->ofs, frag->ofs+frag->size); | 1160 | frag->ofs, frag->ofs+frag->size)); |
1199 | break; | 1161 | break; |
1200 | } else { | 1162 | } else { |
1201 | 1163 | ||
@@ -1209,25 +1171,19 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1209 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1171 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1210 | 1172 | ||
1211 | if (jeb == c->gcblock) { | 1173 | if (jeb == c->gcblock) { |
1212 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1174 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1213 | frag->ofs, | 1175 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); |
1214 | frag->ofs + frag->size, | ||
1215 | ref_offset(raw)); | ||
1216 | start = frag->ofs; | 1176 | start = frag->ofs; |
1217 | break; | 1177 | break; |
1218 | } | 1178 | } |
1219 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1179 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1220 | jffs2_dbg(1, "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", | 1180 | D1(printk(KERN_DEBUG "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", |
1221 | frag->ofs, | 1181 | frag->ofs, frag->ofs+frag->size, jeb->offset)); |
1222 | frag->ofs + frag->size, | ||
1223 | jeb->offset); | ||
1224 | break; | 1182 | break; |
1225 | } | 1183 | } |
1226 | 1184 | ||
1227 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1185 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1228 | frag->ofs, | 1186 | frag->ofs, frag->ofs+frag->size, jeb->offset)); |
1229 | frag->ofs + frag->size, | ||
1230 | jeb->offset); | ||
1231 | start = frag->ofs; | 1187 | start = frag->ofs; |
1232 | break; | 1188 | break; |
1233 | } | 1189 | } |
@@ -1243,15 +1199,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1243 | /* If the previous frag doesn't even reach the beginning, there's lots | 1199 | /* If the previous frag doesn't even reach the beginning, there's lots |
1244 | of fragmentation. Just merge. */ | 1200 | of fragmentation. Just merge. */ |
1245 | if (frag->ofs+frag->size < max) { | 1201 | if (frag->ofs+frag->size < max) { |
1246 | jffs2_dbg(1, "Expanding up to cover partial frag (0x%x-0x%x)\n", | 1202 | D1(printk(KERN_DEBUG "Expanding up to cover partial frag (0x%x-0x%x)\n", |
1247 | frag->ofs, frag->ofs+frag->size); | 1203 | frag->ofs, frag->ofs+frag->size)); |
1248 | end = frag->ofs + frag->size; | 1204 | end = frag->ofs + frag->size; |
1249 | continue; | 1205 | continue; |
1250 | } | 1206 | } |
1251 | 1207 | ||
1252 | if (!frag->node || !frag->node->raw) { | 1208 | if (!frag->node || !frag->node->raw) { |
1253 | jffs2_dbg(1, "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", | 1209 | D1(printk(KERN_DEBUG "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", |
1254 | frag->ofs, frag->ofs+frag->size); | 1210 | frag->ofs, frag->ofs+frag->size)); |
1255 | break; | 1211 | break; |
1256 | } else { | 1212 | } else { |
1257 | 1213 | ||
@@ -1265,31 +1221,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1265 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1221 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1266 | 1222 | ||
1267 | if (jeb == c->gcblock) { | 1223 | if (jeb == c->gcblock) { |
1268 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1224 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1269 | frag->ofs, | 1225 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); |
1270 | frag->ofs + frag->size, | ||
1271 | ref_offset(raw)); | ||
1272 | end = frag->ofs + frag->size; | 1226 | end = frag->ofs + frag->size; |
1273 | break; | 1227 | break; |
1274 | } | 1228 | } |
1275 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1229 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1276 | jffs2_dbg(1, "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", | 1230 | D1(printk(KERN_DEBUG "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", |
1277 | frag->ofs, | 1231 | frag->ofs, frag->ofs+frag->size, jeb->offset)); |
1278 | frag->ofs + frag->size, | ||
1279 | jeb->offset); | ||
1280 | break; | 1232 | break; |
1281 | } | 1233 | } |
1282 | 1234 | ||
1283 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1235 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1284 | frag->ofs, | 1236 | frag->ofs, frag->ofs+frag->size, jeb->offset)); |
1285 | frag->ofs + frag->size, | ||
1286 | jeb->offset); | ||
1287 | end = frag->ofs + frag->size; | 1237 | end = frag->ofs + frag->size; |
1288 | break; | 1238 | break; |
1289 | } | 1239 | } |
1290 | } | 1240 | } |
1291 | jffs2_dbg(1, "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", | 1241 | D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", |
1292 | orig_start, orig_end, start, end); | 1242 | orig_start, orig_end, start, end)); |
1293 | 1243 | ||
1294 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); | 1244 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); |
1295 | BUG_ON(end < orig_end); | 1245 | BUG_ON(end < orig_end); |
@@ -1306,8 +1256,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1306 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); | 1256 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); |
1307 | 1257 | ||
1308 | if (IS_ERR(pg_ptr)) { | 1258 | if (IS_ERR(pg_ptr)) { |
1309 | pr_warn("read_cache_page() returned error: %ld\n", | 1259 | printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr)); |
1310 | PTR_ERR(pg_ptr)); | ||
1311 | return PTR_ERR(pg_ptr); | 1260 | return PTR_ERR(pg_ptr); |
1312 | } | 1261 | } |
1313 | 1262 | ||
@@ -1321,8 +1270,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1321 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); | 1270 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); |
1322 | 1271 | ||
1323 | if (ret) { | 1272 | if (ret) { |
1324 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", | 1273 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", |
1325 | sizeof(ri) + JFFS2_MIN_DATA_LEN, ret); | 1274 | sizeof(ri)+ JFFS2_MIN_DATA_LEN, ret); |
1326 | break; | 1275 | break; |
1327 | } | 1276 | } |
1328 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); | 1277 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); |
@@ -1359,8 +1308,7 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1359 | jffs2_free_comprbuf(comprbuf, writebuf); | 1308 | jffs2_free_comprbuf(comprbuf, writebuf); |
1360 | 1309 | ||
1361 | if (IS_ERR(new_fn)) { | 1310 | if (IS_ERR(new_fn)) { |
1362 | pr_warn("Error writing new dnode: %ld\n", | 1311 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); |
1363 | PTR_ERR(new_fn)); | ||
1364 | ret = PTR_ERR(new_fn); | 1312 | ret = PTR_ERR(new_fn); |
1365 | break; | 1313 | break; |
1366 | } | 1314 | } |
diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 413ef89c2d1..0bc6a6c80a5 100644 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h | |||
@@ -29,18 +29,6 @@ | |||
29 | 29 | ||
30 | struct jffs2_inodirty; | 30 | struct jffs2_inodirty; |
31 | 31 | ||
32 | struct jffs2_mount_opts { | ||
33 | bool override_compr; | ||
34 | unsigned int compr; | ||
35 | |||
36 | /* The size of the reserved pool. The reserved pool is the JFFS2 flash | ||
37 | * space which may only be used by root cannot be used by the other | ||
38 | * users. This is implemented simply by means of not allowing the | ||
39 | * latter users to write to the file system if the amount if the | ||
40 | * available space is less then 'rp_size'. */ | ||
41 | unsigned int rp_size; | ||
42 | }; | ||
43 | |||
44 | /* A struct for the overall file system control. Pointers to | 32 | /* A struct for the overall file system control. Pointers to |
45 | jffs2_sb_info structs are named `c' in the source code. | 33 | jffs2_sb_info structs are named `c' in the source code. |
46 | Nee jffs_control | 34 | Nee jffs_control |
@@ -133,16 +121,11 @@ struct jffs2_sb_info { | |||
133 | struct jffs2_inodirty *wbuf_inodes; | 121 | struct jffs2_inodirty *wbuf_inodes; |
134 | struct rw_semaphore wbuf_sem; /* Protects the write buffer */ | 122 | struct rw_semaphore wbuf_sem; /* Protects the write buffer */ |
135 | 123 | ||
136 | struct delayed_work wbuf_dwork; /* write-buffer write-out work */ | ||
137 | int wbuf_queued; /* non-zero delayed work is queued */ | ||
138 | spinlock_t wbuf_dwork_lock; /* protects wbuf_dwork and and wbuf_queued */ | ||
139 | |||
140 | unsigned char *oobbuf; | 124 | unsigned char *oobbuf; |
141 | int oobavail; /* How many bytes are available for JFFS2 in OOB */ | 125 | int oobavail; /* How many bytes are available for JFFS2 in OOB */ |
142 | #endif | 126 | #endif |
143 | 127 | ||
144 | struct jffs2_summary *summary; /* Summary information */ | 128 | struct jffs2_summary *summary; /* Summary information */ |
145 | struct jffs2_mount_opts mount_opts; | ||
146 | 129 | ||
147 | #ifdef CONFIG_JFFS2_FS_XATTR | 130 | #ifdef CONFIG_JFFS2_FS_XATTR |
148 | #define XATTRINDEX_HASHSIZE (57) | 131 | #define XATTRINDEX_HASHSIZE (57) |
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c index 4f47aa24b55..c082868910f 100644 --- a/fs/jffs2/malloc.c +++ b/fs/jffs2/malloc.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
16 | #include <linux/init.h> | 14 | #include <linux/init.h> |
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index 975a1f562c1..5e03233c236 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
16 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
@@ -689,8 +687,8 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
689 | if (!size) | 687 | if (!size) |
690 | return 0; | 688 | return 0; |
691 | if (unlikely(size > jeb->free_size)) { | 689 | if (unlikely(size > jeb->free_size)) { |
692 | pr_crit("Dirty space 0x%x larger then free_size 0x%x (wasted 0x%x)\n", | 690 | printk(KERN_CRIT "Dirty space 0x%x larger then free_size 0x%x (wasted 0x%x)\n", |
693 | size, jeb->free_size, jeb->wasted_size); | 691 | size, jeb->free_size, jeb->wasted_size); |
694 | BUG(); | 692 | BUG(); |
695 | } | 693 | } |
696 | /* REF_EMPTY_NODE is !obsolete, so that works OK */ | 694 | /* REF_EMPTY_NODE is !obsolete, so that works OK */ |
@@ -728,10 +726,8 @@ static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | |||
728 | 726 | ||
729 | /* Last node in block. Use free_space */ | 727 | /* Last node in block. Use free_space */ |
730 | if (unlikely(ref != jeb->last_node)) { | 728 | if (unlikely(ref != jeb->last_node)) { |
731 | pr_crit("ref %p @0x%08x is not jeb->last_node (%p @0x%08x)\n", | 729 | printk(KERN_CRIT "ref %p @0x%08x is not jeb->last_node (%p @0x%08x)\n", |
732 | ref, ref_offset(ref), jeb->last_node, | 730 | ref, ref_offset(ref), jeb->last_node, jeb->last_node?ref_offset(jeb->last_node):0); |
733 | jeb->last_node ? | ||
734 | ref_offset(jeb->last_node) : 0); | ||
735 | BUG(); | 731 | BUG(); |
736 | } | 732 | } |
737 | ref_end = jeb->offset + c->sector_size - jeb->free_size; | 733 | ref_end = jeb->offset + c->sector_size - jeb->free_size; |
@@ -751,20 +747,16 @@ uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, struct jffs2_eraseblock *je | |||
751 | if (!jeb) | 747 | if (!jeb) |
752 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 748 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
753 | 749 | ||
754 | pr_crit("Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", | 750 | printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", |
755 | ref, ref_offset(ref), ref_offset(ref) + ref->__totlen, | 751 | ref, ref_offset(ref), ref_offset(ref)+ref->__totlen, |
756 | ret, ref->__totlen); | 752 | ret, ref->__totlen); |
757 | if (ref_next(ref)) { | 753 | if (ref_next(ref)) { |
758 | pr_crit("next %p (0x%08x-0x%08x)\n", | 754 | printk(KERN_CRIT "next %p (0x%08x-0x%08x)\n", ref_next(ref), ref_offset(ref_next(ref)), |
759 | ref_next(ref), ref_offset(ref_next(ref)), | 755 | ref_offset(ref_next(ref))+ref->__totlen); |
760 | ref_offset(ref_next(ref)) + ref->__totlen); | ||
761 | } else | 756 | } else |
762 | pr_crit("No next ref. jeb->last_node is %p\n", | 757 | printk(KERN_CRIT "No next ref. jeb->last_node is %p\n", jeb->last_node); |
763 | jeb->last_node); | ||
764 | 758 | ||
765 | pr_crit("jeb->wasted_size %x, dirty_size %x, used_size %x, free_size %x\n", | 759 | printk(KERN_CRIT "jeb->wasted_size %x, dirty_size %x, used_size %x, free_size %x\n", jeb->wasted_size, jeb->dirty_size, jeb->used_size, jeb->free_size); |
766 | jeb->wasted_size, jeb->dirty_size, jeb->used_size, | ||
767 | jeb->free_size); | ||
768 | 760 | ||
769 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) | 761 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) |
770 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | 762 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 03310721712..694aa5b0350 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/mtd/mtd.h> | 13 | #include <linux/mtd/mtd.h> |
16 | #include <linux/compiler.h> | 14 | #include <linux/compiler.h> |
@@ -18,37 +16,6 @@ | |||
18 | #include "nodelist.h" | 16 | #include "nodelist.h" |
19 | #include "debug.h" | 17 | #include "debug.h" |
20 | 18 | ||
21 | /* | ||
22 | * Check whether the user is allowed to write. | ||
23 | */ | ||
24 | static int jffs2_rp_can_write(struct jffs2_sb_info *c) | ||
25 | { | ||
26 | uint32_t avail; | ||
27 | struct jffs2_mount_opts *opts = &c->mount_opts; | ||
28 | |||
29 | avail = c->dirty_size + c->free_size + c->unchecked_size + | ||
30 | c->erasing_size - c->resv_blocks_write * c->sector_size | ||
31 | - c->nospc_dirty_size; | ||
32 | |||
33 | if (avail < 2 * opts->rp_size) | ||
34 | jffs2_dbg(1, "rpsize %u, dirty_size %u, free_size %u, " | ||
35 | "erasing_size %u, unchecked_size %u, " | ||
36 | "nr_erasing_blocks %u, avail %u, resrv %u\n", | ||
37 | opts->rp_size, c->dirty_size, c->free_size, | ||
38 | c->erasing_size, c->unchecked_size, | ||
39 | c->nr_erasing_blocks, avail, c->nospc_dirty_size); | ||
40 | |||
41 | if (avail > opts->rp_size) | ||
42 | return 1; | ||
43 | |||
44 | /* Always allow root */ | ||
45 | if (capable(CAP_SYS_RESOURCE)) | ||
46 | return 1; | ||
47 | |||
48 | jffs2_dbg(1, "forbid writing\n"); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | /** | 19 | /** |
53 | * jffs2_reserve_space - request physical space to write nodes to flash | 20 | * jffs2_reserve_space - request physical space to write nodes to flash |
54 | * @c: superblock info | 21 | * @c: superblock info |
@@ -79,22 +46,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
79 | /* align it */ | 46 | /* align it */ |
80 | minsize = PAD(minsize); | 47 | minsize = PAD(minsize); |
81 | 48 | ||
82 | jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize); | 49 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); |
83 | mutex_lock(&c->alloc_sem); | 50 | mutex_lock(&c->alloc_sem); |
84 | 51 | ||
85 | jffs2_dbg(1, "%s(): alloc sem got\n", __func__); | 52 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); |
86 | 53 | ||
87 | spin_lock(&c->erase_completion_lock); | 54 | spin_lock(&c->erase_completion_lock); |
88 | 55 | ||
89 | /* | ||
90 | * Check if the free space is greater then size of the reserved pool. | ||
91 | * If not, only allow root to proceed with writing. | ||
92 | */ | ||
93 | if (prio != ALLOC_DELETION && !jffs2_rp_can_write(c)) { | ||
94 | ret = -ENOSPC; | ||
95 | goto out; | ||
96 | } | ||
97 | |||
98 | /* this needs a little more thought (true <tglx> :)) */ | 56 | /* this needs a little more thought (true <tglx> :)) */ |
99 | while(ret == -EAGAIN) { | 57 | while(ret == -EAGAIN) { |
100 | while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) { | 58 | while(c->nr_free_blocks + c->nr_erasing_blocks < blocksneeded) { |
@@ -115,13 +73,11 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
115 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size; | 73 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size; |
116 | if (dirty < c->nospc_dirty_size) { | 74 | if (dirty < c->nospc_dirty_size) { |
117 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { | 75 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { |
118 | jffs2_dbg(1, "%s(): Low on dirty space to GC, but it's a deletion. Allowing...\n", | 76 | D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on dirty space to GC, but it's a deletion. Allowing...\n")); |
119 | __func__); | ||
120 | break; | 77 | break; |
121 | } | 78 | } |
122 | jffs2_dbg(1, "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n", | 79 | D1(printk(KERN_DEBUG "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n", |
123 | dirty, c->unchecked_size, | 80 | dirty, c->unchecked_size, c->sector_size)); |
124 | c->sector_size); | ||
125 | 81 | ||
126 | spin_unlock(&c->erase_completion_lock); | 82 | spin_unlock(&c->erase_completion_lock); |
127 | mutex_unlock(&c->alloc_sem); | 83 | mutex_unlock(&c->alloc_sem); |
@@ -140,13 +96,12 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
140 | avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size; | 96 | avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size; |
141 | if ( (avail / c->sector_size) <= blocksneeded) { | 97 | if ( (avail / c->sector_size) <= blocksneeded) { |
142 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { | 98 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { |
143 | jffs2_dbg(1, "%s(): Low on possibly available space, but it's a deletion. Allowing...\n", | 99 | D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on possibly available space, but it's a deletion. Allowing...\n")); |
144 | __func__); | ||
145 | break; | 100 | break; |
146 | } | 101 | } |
147 | 102 | ||
148 | jffs2_dbg(1, "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", | 103 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", |
149 | avail, blocksneeded * c->sector_size); | 104 | avail, blocksneeded * c->sector_size)); |
150 | spin_unlock(&c->erase_completion_lock); | 105 | spin_unlock(&c->erase_completion_lock); |
151 | mutex_unlock(&c->alloc_sem); | 106 | mutex_unlock(&c->alloc_sem); |
152 | return -ENOSPC; | 107 | return -ENOSPC; |
@@ -154,14 +109,9 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
154 | 109 | ||
155 | mutex_unlock(&c->alloc_sem); | 110 | mutex_unlock(&c->alloc_sem); |
156 | 111 | ||
157 | jffs2_dbg(1, "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", | 112 | D1(printk(KERN_DEBUG "Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n", |
158 | c->nr_free_blocks, c->nr_erasing_blocks, | 113 | c->nr_free_blocks, c->nr_erasing_blocks, c->free_size, c->dirty_size, c->wasted_size, c->used_size, c->erasing_size, c->bad_size, |
159 | c->free_size, c->dirty_size, c->wasted_size, | 114 | c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); |
160 | c->used_size, c->erasing_size, c->bad_size, | ||
161 | c->free_size + c->dirty_size + | ||
162 | c->wasted_size + c->used_size + | ||
163 | c->erasing_size + c->bad_size, | ||
164 | c->flash_size); | ||
165 | spin_unlock(&c->erase_completion_lock); | 115 | spin_unlock(&c->erase_completion_lock); |
166 | 116 | ||
167 | ret = jffs2_garbage_collect_pass(c); | 117 | ret = jffs2_garbage_collect_pass(c); |
@@ -174,8 +124,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
174 | DECLARE_WAITQUEUE(wait, current); | 124 | DECLARE_WAITQUEUE(wait, current); |
175 | set_current_state(TASK_UNINTERRUPTIBLE); | 125 | set_current_state(TASK_UNINTERRUPTIBLE); |
176 | add_wait_queue(&c->erase_wait, &wait); | 126 | add_wait_queue(&c->erase_wait, &wait); |
177 | jffs2_dbg(1, "%s waiting for erase to complete\n", | 127 | D1(printk(KERN_DEBUG "%s waiting for erase to complete\n", __func__)); |
178 | __func__); | ||
179 | spin_unlock(&c->erase_completion_lock); | 128 | spin_unlock(&c->erase_completion_lock); |
180 | 129 | ||
181 | schedule(); | 130 | schedule(); |
@@ -195,11 +144,9 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
195 | 144 | ||
196 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); | 145 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
197 | if (ret) { | 146 | if (ret) { |
198 | jffs2_dbg(1, "%s(): ret is %d\n", __func__, ret); | 147 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); |
199 | } | 148 | } |
200 | } | 149 | } |
201 | |||
202 | out: | ||
203 | spin_unlock(&c->erase_completion_lock); | 150 | spin_unlock(&c->erase_completion_lock); |
204 | if (!ret) | 151 | if (!ret) |
205 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); | 152 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); |
@@ -214,14 +161,13 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, | |||
214 | int ret = -EAGAIN; | 161 | int ret = -EAGAIN; |
215 | minsize = PAD(minsize); | 162 | minsize = PAD(minsize); |
216 | 163 | ||
217 | jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize); | 164 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc(): Requested 0x%x bytes\n", minsize)); |
218 | 165 | ||
219 | spin_lock(&c->erase_completion_lock); | 166 | spin_lock(&c->erase_completion_lock); |
220 | while(ret == -EAGAIN) { | 167 | while(ret == -EAGAIN) { |
221 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); | 168 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
222 | if (ret) { | 169 | if (ret) { |
223 | jffs2_dbg(1, "%s(): looping, ret is %d\n", | 170 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); |
224 | __func__, ret); | ||
225 | } | 171 | } |
226 | } | 172 | } |
227 | spin_unlock(&c->erase_completion_lock); | 173 | spin_unlock(&c->erase_completion_lock); |
@@ -238,8 +184,8 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
238 | { | 184 | { |
239 | 185 | ||
240 | if (c->nextblock == NULL) { | 186 | if (c->nextblock == NULL) { |
241 | jffs2_dbg(1, "%s(): Erase block at 0x%08x has already been placed in a list\n", | 187 | D1(printk(KERN_DEBUG "jffs2_close_nextblock: Erase block at 0x%08x has already been placed in a list\n", |
242 | __func__, jeb->offset); | 188 | jeb->offset)); |
243 | return; | 189 | return; |
244 | } | 190 | } |
245 | /* Check, if we have a dirty block now, or if it was dirty already */ | 191 | /* Check, if we have a dirty block now, or if it was dirty already */ |
@@ -249,20 +195,17 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
249 | jeb->dirty_size += jeb->wasted_size; | 195 | jeb->dirty_size += jeb->wasted_size; |
250 | jeb->wasted_size = 0; | 196 | jeb->wasted_size = 0; |
251 | if (VERYDIRTY(c, jeb->dirty_size)) { | 197 | if (VERYDIRTY(c, jeb->dirty_size)) { |
252 | jffs2_dbg(1, "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | 198 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
253 | jeb->offset, jeb->free_size, jeb->dirty_size, | 199 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
254 | jeb->used_size); | ||
255 | list_add_tail(&jeb->list, &c->very_dirty_list); | 200 | list_add_tail(&jeb->list, &c->very_dirty_list); |
256 | } else { | 201 | } else { |
257 | jffs2_dbg(1, "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | 202 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
258 | jeb->offset, jeb->free_size, jeb->dirty_size, | 203 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
259 | jeb->used_size); | ||
260 | list_add_tail(&jeb->list, &c->dirty_list); | 204 | list_add_tail(&jeb->list, &c->dirty_list); |
261 | } | 205 | } |
262 | } else { | 206 | } else { |
263 | jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | 207 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
264 | jeb->offset, jeb->free_size, jeb->dirty_size, | 208 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
265 | jeb->used_size); | ||
266 | list_add_tail(&jeb->list, &c->clean_list); | 209 | list_add_tail(&jeb->list, &c->clean_list); |
267 | } | 210 | } |
268 | c->nextblock = NULL; | 211 | c->nextblock = NULL; |
@@ -287,14 +230,13 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
287 | list_move_tail(&ejeb->list, &c->erase_pending_list); | 230 | list_move_tail(&ejeb->list, &c->erase_pending_list); |
288 | c->nr_erasing_blocks++; | 231 | c->nr_erasing_blocks++; |
289 | jffs2_garbage_collect_trigger(c); | 232 | jffs2_garbage_collect_trigger(c); |
290 | jffs2_dbg(1, "%s(): Triggering erase of erasable block at 0x%08x\n", | 233 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n", |
291 | __func__, ejeb->offset); | 234 | ejeb->offset)); |
292 | } | 235 | } |
293 | 236 | ||
294 | if (!c->nr_erasing_blocks && | 237 | if (!c->nr_erasing_blocks && |
295 | !list_empty(&c->erasable_pending_wbuf_list)) { | 238 | !list_empty(&c->erasable_pending_wbuf_list)) { |
296 | jffs2_dbg(1, "%s(): Flushing write buffer\n", | 239 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Flushing write buffer\n")); |
297 | __func__); | ||
298 | /* c->nextblock is NULL, no update to c->nextblock allowed */ | 240 | /* c->nextblock is NULL, no update to c->nextblock allowed */ |
299 | spin_unlock(&c->erase_completion_lock); | 241 | spin_unlock(&c->erase_completion_lock); |
300 | jffs2_flush_wbuf_pad(c); | 242 | jffs2_flush_wbuf_pad(c); |
@@ -306,11 +248,9 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
306 | if (!c->nr_erasing_blocks) { | 248 | if (!c->nr_erasing_blocks) { |
307 | /* Ouch. We're in GC, or we wouldn't have got here. | 249 | /* Ouch. We're in GC, or we wouldn't have got here. |
308 | And there's no space left. At all. */ | 250 | And there's no space left. At all. */ |
309 | pr_crit("Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", | 251 | printk(KERN_CRIT "Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n", |
310 | c->nr_erasing_blocks, c->nr_free_blocks, | 252 | c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", |
311 | list_empty(&c->erasable_list) ? "yes" : "no", | 253 | list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no"); |
312 | list_empty(&c->erasing_list) ? "yes" : "no", | ||
313 | list_empty(&c->erase_pending_list) ? "yes" : "no"); | ||
314 | return -ENOSPC; | 254 | return -ENOSPC; |
315 | } | 255 | } |
316 | 256 | ||
@@ -338,8 +278,7 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
338 | c->wbuf_ofs = 0xffffffff; | 278 | c->wbuf_ofs = 0xffffffff; |
339 | #endif | 279 | #endif |
340 | 280 | ||
341 | jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n", | 281 | D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); |
342 | __func__, c->nextblock->offset); | ||
343 | 282 | ||
344 | return 0; | 283 | return 0; |
345 | } | 284 | } |
@@ -406,8 +345,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
406 | 345 | ||
407 | if (jffs2_wbuf_dirty(c)) { | 346 | if (jffs2_wbuf_dirty(c)) { |
408 | spin_unlock(&c->erase_completion_lock); | 347 | spin_unlock(&c->erase_completion_lock); |
409 | jffs2_dbg(1, "%s(): Flushing write buffer\n", | 348 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); |
410 | __func__); | ||
411 | jffs2_flush_wbuf_pad(c); | 349 | jffs2_flush_wbuf_pad(c); |
412 | spin_lock(&c->erase_completion_lock); | 350 | spin_lock(&c->erase_completion_lock); |
413 | jeb = c->nextblock; | 351 | jeb = c->nextblock; |
@@ -417,16 +355,14 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
417 | spin_unlock(&c->erase_completion_lock); | 355 | spin_unlock(&c->erase_completion_lock); |
418 | 356 | ||
419 | ret = jffs2_prealloc_raw_node_refs(c, jeb, 1); | 357 | ret = jffs2_prealloc_raw_node_refs(c, jeb, 1); |
420 | 358 | if (ret) | |
359 | return ret; | ||
421 | /* Just lock it again and continue. Nothing much can change because | 360 | /* Just lock it again and continue. Nothing much can change because |
422 | we hold c->alloc_sem anyway. In fact, it's not entirely clear why | 361 | we hold c->alloc_sem anyway. In fact, it's not entirely clear why |
423 | we hold c->erase_completion_lock in the majority of this function... | 362 | we hold c->erase_completion_lock in the majority of this function... |
424 | but that's a question for another (more caffeine-rich) day. */ | 363 | but that's a question for another (more caffeine-rich) day. */ |
425 | spin_lock(&c->erase_completion_lock); | 364 | spin_lock(&c->erase_completion_lock); |
426 | 365 | ||
427 | if (ret) | ||
428 | return ret; | ||
429 | |||
430 | waste = jeb->free_size; | 366 | waste = jeb->free_size; |
431 | jffs2_link_node_ref(c, jeb, | 367 | jffs2_link_node_ref(c, jeb, |
432 | (jeb->offset + c->sector_size - waste) | REF_OBSOLETE, | 368 | (jeb->offset + c->sector_size - waste) | REF_OBSOLETE, |
@@ -451,8 +387,7 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
451 | jeb = c->nextblock; | 387 | jeb = c->nextblock; |
452 | 388 | ||
453 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { | 389 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { |
454 | pr_warn("Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", | 390 | printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size); |
455 | jeb->offset, jeb->free_size); | ||
456 | goto restart; | 391 | goto restart; |
457 | } | 392 | } |
458 | } | 393 | } |
@@ -473,9 +408,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
473 | spin_lock(&c->erase_completion_lock); | 408 | spin_lock(&c->erase_completion_lock); |
474 | } | 409 | } |
475 | 410 | ||
476 | jffs2_dbg(1, "%s(): Giving 0x%x bytes at 0x%x\n", | 411 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", |
477 | __func__, | 412 | *len, jeb->offset + (c->sector_size - jeb->free_size))); |
478 | *len, jeb->offset + (c->sector_size - jeb->free_size)); | ||
479 | return 0; | 413 | return 0; |
480 | } | 414 | } |
481 | 415 | ||
@@ -500,22 +434,20 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
500 | 434 | ||
501 | jeb = &c->blocks[ofs / c->sector_size]; | 435 | jeb = &c->blocks[ofs / c->sector_size]; |
502 | 436 | ||
503 | jffs2_dbg(1, "%s(): Node at 0x%x(%d), size 0x%x\n", | 437 | D1(printk(KERN_DEBUG "jffs2_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", |
504 | __func__, ofs & ~3, ofs & 3, len); | 438 | ofs & ~3, ofs & 3, len)); |
505 | #if 1 | 439 | #if 1 |
506 | /* Allow non-obsolete nodes only to be added at the end of c->nextblock, | 440 | /* Allow non-obsolete nodes only to be added at the end of c->nextblock, |
507 | if c->nextblock is set. Note that wbuf.c will file obsolete nodes | 441 | if c->nextblock is set. Note that wbuf.c will file obsolete nodes |
508 | even after refiling c->nextblock */ | 442 | even after refiling c->nextblock */ |
509 | if ((c->nextblock || ((ofs & 3) != REF_OBSOLETE)) | 443 | if ((c->nextblock || ((ofs & 3) != REF_OBSOLETE)) |
510 | && (jeb != c->nextblock || (ofs & ~3) != jeb->offset + (c->sector_size - jeb->free_size))) { | 444 | && (jeb != c->nextblock || (ofs & ~3) != jeb->offset + (c->sector_size - jeb->free_size))) { |
511 | pr_warn("argh. node added in wrong place at 0x%08x(%d)\n", | 445 | printk(KERN_WARNING "argh. node added in wrong place at 0x%08x(%d)\n", ofs & ~3, ofs & 3); |
512 | ofs & ~3, ofs & 3); | ||
513 | if (c->nextblock) | 446 | if (c->nextblock) |
514 | pr_warn("nextblock 0x%08x", c->nextblock->offset); | 447 | printk(KERN_WARNING "nextblock 0x%08x", c->nextblock->offset); |
515 | else | 448 | else |
516 | pr_warn("No nextblock"); | 449 | printk(KERN_WARNING "No nextblock"); |
517 | pr_cont(", expected at %08x\n", | 450 | printk(", expected at %08x\n", jeb->offset + (c->sector_size - jeb->free_size)); |
518 | jeb->offset + (c->sector_size - jeb->free_size)); | ||
519 | return ERR_PTR(-EINVAL); | 451 | return ERR_PTR(-EINVAL); |
520 | } | 452 | } |
521 | #endif | 453 | #endif |
@@ -525,9 +457,8 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
525 | 457 | ||
526 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { | 458 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { |
527 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ | 459 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ |
528 | jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", | 460 | D1(printk(KERN_DEBUG "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
529 | jeb->offset, jeb->free_size, jeb->dirty_size, | 461 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
530 | jeb->used_size); | ||
531 | if (jffs2_wbuf_dirty(c)) { | 462 | if (jffs2_wbuf_dirty(c)) { |
532 | /* Flush the last write in the block if it's outstanding */ | 463 | /* Flush the last write in the block if it's outstanding */ |
533 | spin_unlock(&c->erase_completion_lock); | 464 | spin_unlock(&c->erase_completion_lock); |
@@ -549,7 +480,7 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
549 | 480 | ||
550 | void jffs2_complete_reservation(struct jffs2_sb_info *c) | 481 | void jffs2_complete_reservation(struct jffs2_sb_info *c) |
551 | { | 482 | { |
552 | jffs2_dbg(1, "jffs2_complete_reservation()\n"); | 483 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); |
553 | spin_lock(&c->erase_completion_lock); | 484 | spin_lock(&c->erase_completion_lock); |
554 | jffs2_garbage_collect_trigger(c); | 485 | jffs2_garbage_collect_trigger(c); |
555 | spin_unlock(&c->erase_completion_lock); | 486 | spin_unlock(&c->erase_completion_lock); |
@@ -562,7 +493,7 @@ static inline int on_list(struct list_head *obj, struct list_head *head) | |||
562 | 493 | ||
563 | list_for_each(this, head) { | 494 | list_for_each(this, head) { |
564 | if (this == obj) { | 495 | if (this == obj) { |
565 | jffs2_dbg(1, "%p is on list at %p\n", obj, head); | 496 | D1(printk("%p is on list at %p\n", obj, head)); |
566 | return 1; | 497 | return 1; |
567 | 498 | ||
568 | } | 499 | } |
@@ -580,18 +511,16 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
580 | uint32_t freed_len; | 511 | uint32_t freed_len; |
581 | 512 | ||
582 | if(unlikely(!ref)) { | 513 | if(unlikely(!ref)) { |
583 | pr_notice("EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); | 514 | printk(KERN_NOTICE "EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); |
584 | return; | 515 | return; |
585 | } | 516 | } |
586 | if (ref_obsolete(ref)) { | 517 | if (ref_obsolete(ref)) { |
587 | jffs2_dbg(1, "%s(): called with already obsolete node at 0x%08x\n", | 518 | D1(printk(KERN_DEBUG "jffs2_mark_node_obsolete called with already obsolete node at 0x%08x\n", ref_offset(ref))); |
588 | __func__, ref_offset(ref)); | ||
589 | return; | 519 | return; |
590 | } | 520 | } |
591 | blocknr = ref->flash_offset / c->sector_size; | 521 | blocknr = ref->flash_offset / c->sector_size; |
592 | if (blocknr >= c->nr_blocks) { | 522 | if (blocknr >= c->nr_blocks) { |
593 | pr_notice("raw node at 0x%08x is off the end of device!\n", | 523 | printk(KERN_NOTICE "raw node at 0x%08x is off the end of device!\n", ref->flash_offset); |
594 | ref->flash_offset); | ||
595 | BUG(); | 524 | BUG(); |
596 | } | 525 | } |
597 | jeb = &c->blocks[blocknr]; | 526 | jeb = &c->blocks[blocknr]; |
@@ -613,31 +542,27 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
613 | 542 | ||
614 | if (ref_flags(ref) == REF_UNCHECKED) { | 543 | if (ref_flags(ref) == REF_UNCHECKED) { |
615 | D1(if (unlikely(jeb->unchecked_size < freed_len)) { | 544 | D1(if (unlikely(jeb->unchecked_size < freed_len)) { |
616 | pr_notice("raw unchecked node of size 0x%08x freed from erase block %d at 0x%08x, but unchecked_size was already 0x%08x\n", | 545 | printk(KERN_NOTICE "raw unchecked node of size 0x%08x freed from erase block %d at 0x%08x, but unchecked_size was already 0x%08x\n", |
617 | freed_len, blocknr, | 546 | freed_len, blocknr, ref->flash_offset, jeb->used_size); |
618 | ref->flash_offset, jeb->used_size); | ||
619 | BUG(); | 547 | BUG(); |
620 | }) | 548 | }) |
621 | jffs2_dbg(1, "Obsoleting previously unchecked node at 0x%08x of len %x\n", | 549 | D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), freed_len)); |
622 | ref_offset(ref), freed_len); | ||
623 | jeb->unchecked_size -= freed_len; | 550 | jeb->unchecked_size -= freed_len; |
624 | c->unchecked_size -= freed_len; | 551 | c->unchecked_size -= freed_len; |
625 | } else { | 552 | } else { |
626 | D1(if (unlikely(jeb->used_size < freed_len)) { | 553 | D1(if (unlikely(jeb->used_size < freed_len)) { |
627 | pr_notice("raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n", | 554 | printk(KERN_NOTICE "raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n", |
628 | freed_len, blocknr, | 555 | freed_len, blocknr, ref->flash_offset, jeb->used_size); |
629 | ref->flash_offset, jeb->used_size); | ||
630 | BUG(); | 556 | BUG(); |
631 | }) | 557 | }) |
632 | jffs2_dbg(1, "Obsoleting node at 0x%08x of len %#x: ", | 558 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), freed_len)); |
633 | ref_offset(ref), freed_len); | ||
634 | jeb->used_size -= freed_len; | 559 | jeb->used_size -= freed_len; |
635 | c->used_size -= freed_len; | 560 | c->used_size -= freed_len; |
636 | } | 561 | } |
637 | 562 | ||
638 | // Take care, that wasted size is taken into concern | 563 | // Take care, that wasted size is taken into concern |
639 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { | 564 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { |
640 | jffs2_dbg(1, "Dirtying\n"); | 565 | D1(printk("Dirtying\n")); |
641 | addedsize = freed_len; | 566 | addedsize = freed_len; |
642 | jeb->dirty_size += freed_len; | 567 | jeb->dirty_size += freed_len; |
643 | c->dirty_size += freed_len; | 568 | c->dirty_size += freed_len; |
@@ -645,12 +570,12 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
645 | /* Convert wasted space to dirty, if not a bad block */ | 570 | /* Convert wasted space to dirty, if not a bad block */ |
646 | if (jeb->wasted_size) { | 571 | if (jeb->wasted_size) { |
647 | if (on_list(&jeb->list, &c->bad_used_list)) { | 572 | if (on_list(&jeb->list, &c->bad_used_list)) { |
648 | jffs2_dbg(1, "Leaving block at %08x on the bad_used_list\n", | 573 | D1(printk(KERN_DEBUG "Leaving block at %08x on the bad_used_list\n", |
649 | jeb->offset); | 574 | jeb->offset)); |
650 | addedsize = 0; /* To fool the refiling code later */ | 575 | addedsize = 0; /* To fool the refiling code later */ |
651 | } else { | 576 | } else { |
652 | jffs2_dbg(1, "Converting %d bytes of wasted space to dirty in block at %08x\n", | 577 | D1(printk(KERN_DEBUG "Converting %d bytes of wasted space to dirty in block at %08x\n", |
653 | jeb->wasted_size, jeb->offset); | 578 | jeb->wasted_size, jeb->offset)); |
654 | addedsize += jeb->wasted_size; | 579 | addedsize += jeb->wasted_size; |
655 | jeb->dirty_size += jeb->wasted_size; | 580 | jeb->dirty_size += jeb->wasted_size; |
656 | c->dirty_size += jeb->wasted_size; | 581 | c->dirty_size += jeb->wasted_size; |
@@ -659,7 +584,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
659 | } | 584 | } |
660 | } | 585 | } |
661 | } else { | 586 | } else { |
662 | jffs2_dbg(1, "Wasting\n"); | 587 | D1(printk("Wasting\n")); |
663 | addedsize = 0; | 588 | addedsize = 0; |
664 | jeb->wasted_size += freed_len; | 589 | jeb->wasted_size += freed_len; |
665 | c->wasted_size += freed_len; | 590 | c->wasted_size += freed_len; |
@@ -681,57 +606,50 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
681 | } | 606 | } |
682 | 607 | ||
683 | if (jeb == c->nextblock) { | 608 | if (jeb == c->nextblock) { |
684 | jffs2_dbg(2, "Not moving nextblock 0x%08x to dirty/erase_pending list\n", | 609 | D2(printk(KERN_DEBUG "Not moving nextblock 0x%08x to dirty/erase_pending list\n", jeb->offset)); |
685 | jeb->offset); | ||
686 | } else if (!jeb->used_size && !jeb->unchecked_size) { | 610 | } else if (!jeb->used_size && !jeb->unchecked_size) { |
687 | if (jeb == c->gcblock) { | 611 | if (jeb == c->gcblock) { |
688 | jffs2_dbg(1, "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", | 612 | D1(printk(KERN_DEBUG "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", jeb->offset)); |
689 | jeb->offset); | ||
690 | c->gcblock = NULL; | 613 | c->gcblock = NULL; |
691 | } else { | 614 | } else { |
692 | jffs2_dbg(1, "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", | 615 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", jeb->offset)); |
693 | jeb->offset); | ||
694 | list_del(&jeb->list); | 616 | list_del(&jeb->list); |
695 | } | 617 | } |
696 | if (jffs2_wbuf_dirty(c)) { | 618 | if (jffs2_wbuf_dirty(c)) { |
697 | jffs2_dbg(1, "...and adding to erasable_pending_wbuf_list\n"); | 619 | D1(printk(KERN_DEBUG "...and adding to erasable_pending_wbuf_list\n")); |
698 | list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list); | 620 | list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list); |
699 | } else { | 621 | } else { |
700 | if (jiffies & 127) { | 622 | if (jiffies & 127) { |
701 | /* Most of the time, we just erase it immediately. Otherwise we | 623 | /* Most of the time, we just erase it immediately. Otherwise we |
702 | spend ages scanning it on mount, etc. */ | 624 | spend ages scanning it on mount, etc. */ |
703 | jffs2_dbg(1, "...and adding to erase_pending_list\n"); | 625 | D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); |
704 | list_add_tail(&jeb->list, &c->erase_pending_list); | 626 | list_add_tail(&jeb->list, &c->erase_pending_list); |
705 | c->nr_erasing_blocks++; | 627 | c->nr_erasing_blocks++; |
706 | jffs2_garbage_collect_trigger(c); | 628 | jffs2_garbage_collect_trigger(c); |
707 | } else { | 629 | } else { |
708 | /* Sometimes, however, we leave it elsewhere so it doesn't get | 630 | /* Sometimes, however, we leave it elsewhere so it doesn't get |
709 | immediately reused, and we spread the load a bit. */ | 631 | immediately reused, and we spread the load a bit. */ |
710 | jffs2_dbg(1, "...and adding to erasable_list\n"); | 632 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); |
711 | list_add_tail(&jeb->list, &c->erasable_list); | 633 | list_add_tail(&jeb->list, &c->erasable_list); |
712 | } | 634 | } |
713 | } | 635 | } |
714 | jffs2_dbg(1, "Done OK\n"); | 636 | D1(printk(KERN_DEBUG "Done OK\n")); |
715 | } else if (jeb == c->gcblock) { | 637 | } else if (jeb == c->gcblock) { |
716 | jffs2_dbg(2, "Not moving gcblock 0x%08x to dirty_list\n", | 638 | D2(printk(KERN_DEBUG "Not moving gcblock 0x%08x to dirty_list\n", jeb->offset)); |
717 | jeb->offset); | ||
718 | } else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) { | 639 | } else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) { |
719 | jffs2_dbg(1, "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", | 640 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", jeb->offset)); |
720 | jeb->offset); | ||
721 | list_del(&jeb->list); | 641 | list_del(&jeb->list); |
722 | jffs2_dbg(1, "...and adding to dirty_list\n"); | 642 | D1(printk(KERN_DEBUG "...and adding to dirty_list\n")); |
723 | list_add_tail(&jeb->list, &c->dirty_list); | 643 | list_add_tail(&jeb->list, &c->dirty_list); |
724 | } else if (VERYDIRTY(c, jeb->dirty_size) && | 644 | } else if (VERYDIRTY(c, jeb->dirty_size) && |
725 | !VERYDIRTY(c, jeb->dirty_size - addedsize)) { | 645 | !VERYDIRTY(c, jeb->dirty_size - addedsize)) { |
726 | jffs2_dbg(1, "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", | 646 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", jeb->offset)); |
727 | jeb->offset); | ||
728 | list_del(&jeb->list); | 647 | list_del(&jeb->list); |
729 | jffs2_dbg(1, "...and adding to very_dirty_list\n"); | 648 | D1(printk(KERN_DEBUG "...and adding to very_dirty_list\n")); |
730 | list_add_tail(&jeb->list, &c->very_dirty_list); | 649 | list_add_tail(&jeb->list, &c->very_dirty_list); |
731 | } else { | 650 | } else { |
732 | jffs2_dbg(1, "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", | 651 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", |
733 | jeb->offset, jeb->free_size, jeb->dirty_size, | 652 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); |
734 | jeb->used_size); | ||
735 | } | 653 | } |
736 | 654 | ||
737 | spin_unlock(&c->erase_completion_lock); | 655 | spin_unlock(&c->erase_completion_lock); |
@@ -747,40 +665,33 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
747 | the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet | 665 | the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet |
748 | by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */ | 666 | by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */ |
749 | 667 | ||
750 | jffs2_dbg(1, "obliterating obsoleted node at 0x%08x\n", | 668 | D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref))); |
751 | ref_offset(ref)); | ||
752 | ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); | 669 | ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); |
753 | if (ret) { | 670 | if (ret) { |
754 | pr_warn("Read error reading from obsoleted node at 0x%08x: %d\n", | 671 | printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret); |
755 | ref_offset(ref), ret); | ||
756 | goto out_erase_sem; | 672 | goto out_erase_sem; |
757 | } | 673 | } |
758 | if (retlen != sizeof(n)) { | 674 | if (retlen != sizeof(n)) { |
759 | pr_warn("Short read from obsoleted node at 0x%08x: %zd\n", | 675 | printk(KERN_WARNING "Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); |
760 | ref_offset(ref), retlen); | ||
761 | goto out_erase_sem; | 676 | goto out_erase_sem; |
762 | } | 677 | } |
763 | if (PAD(je32_to_cpu(n.totlen)) != PAD(freed_len)) { | 678 | if (PAD(je32_to_cpu(n.totlen)) != PAD(freed_len)) { |
764 | pr_warn("Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", | 679 | printk(KERN_WARNING "Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", je32_to_cpu(n.totlen), freed_len); |
765 | je32_to_cpu(n.totlen), freed_len); | ||
766 | goto out_erase_sem; | 680 | goto out_erase_sem; |
767 | } | 681 | } |
768 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { | 682 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { |
769 | jffs2_dbg(1, "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", | 683 | D1(printk(KERN_DEBUG "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", ref_offset(ref), je16_to_cpu(n.nodetype))); |
770 | ref_offset(ref), je16_to_cpu(n.nodetype)); | ||
771 | goto out_erase_sem; | 684 | goto out_erase_sem; |
772 | } | 685 | } |
773 | /* XXX FIXME: This is ugly now */ | 686 | /* XXX FIXME: This is ugly now */ |
774 | n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE); | 687 | n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE); |
775 | ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); | 688 | ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); |
776 | if (ret) { | 689 | if (ret) { |
777 | pr_warn("Write error in obliterating obsoleted node at 0x%08x: %d\n", | 690 | printk(KERN_WARNING "Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret); |
778 | ref_offset(ref), ret); | ||
779 | goto out_erase_sem; | 691 | goto out_erase_sem; |
780 | } | 692 | } |
781 | if (retlen != sizeof(n)) { | 693 | if (retlen != sizeof(n)) { |
782 | pr_warn("Short write in obliterating obsoleted node at 0x%08x: %zd\n", | 694 | printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); |
783 | ref_offset(ref), retlen); | ||
784 | goto out_erase_sem; | 695 | goto out_erase_sem; |
785 | } | 696 | } |
786 | 697 | ||
@@ -840,8 +751,8 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) | |||
840 | return 1; | 751 | return 1; |
841 | 752 | ||
842 | if (c->unchecked_size) { | 753 | if (c->unchecked_size) { |
843 | jffs2_dbg(1, "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", | 754 | D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", |
844 | c->unchecked_size, c->checked_ino); | 755 | c->unchecked_size, c->checked_ino)); |
845 | return 1; | 756 | return 1; |
846 | } | 757 | } |
847 | 758 | ||
@@ -869,9 +780,8 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) | |||
869 | } | 780 | } |
870 | } | 781 | } |
871 | 782 | ||
872 | jffs2_dbg(1, "%s(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n", | 783 | D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n", |
873 | __func__, c->nr_free_blocks, c->nr_erasing_blocks, | 784 | c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, nr_very_dirty, ret?"yes":"no")); |
874 | c->dirty_size, nr_very_dirty, ret ? "yes" : "no"); | ||
875 | 785 | ||
876 | return ret; | 786 | return ret; |
877 | } | 787 | } |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index d200a9b8fd5..6c1755c59c0 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -27,8 +27,8 @@ struct kvec; | |||
27 | 27 | ||
28 | #define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size) | 28 | #define JFFS2_F_I_SIZE(f) (OFNI_EDONI_2SFFJ(f)->i_size) |
29 | #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode) | 29 | #define JFFS2_F_I_MODE(f) (OFNI_EDONI_2SFFJ(f)->i_mode) |
30 | #define JFFS2_F_I_UID(f) (i_uid_read(OFNI_EDONI_2SFFJ(f))) | 30 | #define JFFS2_F_I_UID(f) (OFNI_EDONI_2SFFJ(f)->i_uid) |
31 | #define JFFS2_F_I_GID(f) (i_gid_read(OFNI_EDONI_2SFFJ(f))) | 31 | #define JFFS2_F_I_GID(f) (OFNI_EDONI_2SFFJ(f)->i_gid) |
32 | #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev) | 32 | #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev) |
33 | 33 | ||
34 | #define ITIME(sec) ((struct timespec){sec, 0}) | 34 | #define ITIME(sec) ((struct timespec){sec, 0}) |
@@ -76,7 +76,7 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
76 | #define jffs2_write_nand_cleanmarker(c,jeb) (-EIO) | 76 | #define jffs2_write_nand_cleanmarker(c,jeb) (-EIO) |
77 | 77 | ||
78 | #define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf) | 78 | #define jffs2_flash_write(c, ofs, len, retlen, buf) jffs2_flash_direct_write(c, ofs, len, retlen, buf) |
79 | #define jffs2_flash_read(c, ofs, len, retlen, buf) (mtd_read((c)->mtd, ofs, len, retlen, buf)) | 79 | #define jffs2_flash_read(c, ofs, len, retlen, buf) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) |
80 | #define jffs2_flush_wbuf_pad(c) ({ do{} while(0); (void)(c), 0; }) | 80 | #define jffs2_flush_wbuf_pad(c) ({ do{} while(0); (void)(c), 0; }) |
81 | #define jffs2_flush_wbuf_gc(c, i) ({ do{} while(0); (void)(c), (void) i, 0; }) | 81 | #define jffs2_flush_wbuf_gc(c, i) ({ do{} while(0); (void)(c), (void) i, 0; }) |
82 | #define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) | 82 | #define jffs2_write_nand_badblock(c,jeb,bad_offset) (1) |
@@ -95,7 +95,6 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
95 | #define jffs2_ubivol(c) (0) | 95 | #define jffs2_ubivol(c) (0) |
96 | #define jffs2_ubivol_setup(c) (0) | 96 | #define jffs2_ubivol_setup(c) (0) |
97 | #define jffs2_ubivol_cleanup(c) do {} while (0) | 97 | #define jffs2_ubivol_cleanup(c) do {} while (0) |
98 | #define jffs2_dirty_trigger(c) do {} while (0) | ||
99 | 98 | ||
100 | #else /* NAND and/or ECC'd NOR support present */ | 99 | #else /* NAND and/or ECC'd NOR support present */ |
101 | 100 | ||
@@ -109,6 +108,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
109 | 108 | ||
110 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) | 109 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) |
111 | 110 | ||
111 | #define jffs2_flash_write_oob(c, ofs, len, retlen, buf) ((c)->mtd->write_oob((c)->mtd, ofs, len, retlen, buf)) | ||
112 | #define jffs2_flash_read_oob(c, ofs, len, retlen, buf) ((c)->mtd->read_oob((c)->mtd, ofs, len, retlen, buf)) | ||
112 | #define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) | 113 | #define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) |
113 | 114 | ||
114 | /* wbuf.c */ | 115 | /* wbuf.c */ |
@@ -136,10 +137,14 @@ void jffs2_ubivol_cleanup(struct jffs2_sb_info *c); | |||
136 | #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE)) | 137 | #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE)) |
137 | int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); | 138 | int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); |
138 | void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); | 139 | void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); |
139 | void jffs2_dirty_trigger(struct jffs2_sb_info *c); | ||
140 | 140 | ||
141 | #endif /* WRITEBUFFER */ | 141 | #endif /* WRITEBUFFER */ |
142 | 142 | ||
143 | static inline void jffs2_dirty_trigger(struct jffs2_sb_info *c) | ||
144 | { | ||
145 | OFNI_BS_2SFFJ(c)->s_dirt = 1; | ||
146 | } | ||
147 | |||
143 | /* background.c */ | 148 | /* background.c */ |
144 | int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c); | 149 | int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c); |
145 | void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c); | 150 | void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c); |
@@ -171,7 +176,7 @@ void jffs2_dirty_inode(struct inode *inode, int flags); | |||
171 | struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, | 176 | struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, |
172 | struct jffs2_raw_inode *ri); | 177 | struct jffs2_raw_inode *ri); |
173 | int jffs2_statfs (struct dentry *, struct kstatfs *); | 178 | int jffs2_statfs (struct dentry *, struct kstatfs *); |
174 | int jffs2_do_remount_fs(struct super_block *, int *, char *); | 179 | int jffs2_remount_fs (struct super_block *, int *, char *); |
175 | int jffs2_do_fill_super(struct super_block *sb, void *data, int silent); | 180 | int jffs2_do_fill_super(struct super_block *sb, void *data, int silent); |
176 | void jffs2_gc_release_inode(struct jffs2_sb_info *c, | 181 | void jffs2_gc_release_inode(struct jffs2_sb_info *c, |
177 | struct jffs2_inode_info *f); | 182 | struct jffs2_inode_info *f); |
diff --git a/fs/jffs2/read.c b/fs/jffs2/read.c index 0b042b1fc82..3f39be1b045 100644 --- a/fs/jffs2/read.c +++ b/fs/jffs2/read.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
16 | #include <linux/crc32.h> | 14 | #include <linux/crc32.h> |
@@ -38,25 +36,24 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
38 | ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri); | 36 | ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri); |
39 | if (ret) { | 37 | if (ret) { |
40 | jffs2_free_raw_inode(ri); | 38 | jffs2_free_raw_inode(ri); |
41 | pr_warn("Error reading node from 0x%08x: %d\n", | 39 | printk(KERN_WARNING "Error reading node from 0x%08x: %d\n", ref_offset(fd->raw), ret); |
42 | ref_offset(fd->raw), ret); | ||
43 | return ret; | 40 | return ret; |
44 | } | 41 | } |
45 | if (readlen != sizeof(*ri)) { | 42 | if (readlen != sizeof(*ri)) { |
46 | jffs2_free_raw_inode(ri); | 43 | jffs2_free_raw_inode(ri); |
47 | pr_warn("Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", | 44 | printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", |
48 | ref_offset(fd->raw), sizeof(*ri), readlen); | 45 | ref_offset(fd->raw), sizeof(*ri), readlen); |
49 | return -EIO; | 46 | return -EIO; |
50 | } | 47 | } |
51 | crc = crc32(0, ri, sizeof(*ri)-8); | 48 | crc = crc32(0, ri, sizeof(*ri)-8); |
52 | 49 | ||
53 | jffs2_dbg(1, "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n", | 50 | D1(printk(KERN_DEBUG "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n", |
54 | ref_offset(fd->raw), je32_to_cpu(ri->node_crc), | 51 | ref_offset(fd->raw), je32_to_cpu(ri->node_crc), |
55 | crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), | 52 | crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), |
56 | je32_to_cpu(ri->offset), buf); | 53 | je32_to_cpu(ri->offset), buf)); |
57 | if (crc != je32_to_cpu(ri->node_crc)) { | 54 | if (crc != je32_to_cpu(ri->node_crc)) { |
58 | pr_warn("Node CRC %08x != calculated CRC %08x for node at %08x\n", | 55 | printk(KERN_WARNING "Node CRC %08x != calculated CRC %08x for node at %08x\n", |
59 | je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); | 56 | je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); |
60 | ret = -EIO; | 57 | ret = -EIO; |
61 | goto out_ri; | 58 | goto out_ri; |
62 | } | 59 | } |
@@ -69,8 +66,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
69 | } | 66 | } |
70 | 67 | ||
71 | D1(if(ofs + len > je32_to_cpu(ri->dsize)) { | 68 | D1(if(ofs + len > je32_to_cpu(ri->dsize)) { |
72 | pr_warn("jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n", | 69 | printk(KERN_WARNING "jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n", |
73 | len, ofs, je32_to_cpu(ri->dsize)); | 70 | len, ofs, je32_to_cpu(ri->dsize)); |
74 | ret = -EINVAL; | 71 | ret = -EINVAL; |
75 | goto out_ri; | 72 | goto out_ri; |
76 | }); | 73 | }); |
@@ -110,8 +107,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
110 | decomprbuf = readbuf; | 107 | decomprbuf = readbuf; |
111 | } | 108 | } |
112 | 109 | ||
113 | jffs2_dbg(2, "Read %d bytes to %p\n", je32_to_cpu(ri->csize), | 110 | D2(printk(KERN_DEBUG "Read %d bytes to %p\n", je32_to_cpu(ri->csize), |
114 | readbuf); | 111 | readbuf)); |
115 | ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), | 112 | ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), |
116 | je32_to_cpu(ri->csize), &readlen, readbuf); | 113 | je32_to_cpu(ri->csize), &readlen, readbuf); |
117 | 114 | ||
@@ -122,19 +119,18 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
122 | 119 | ||
123 | crc = crc32(0, readbuf, je32_to_cpu(ri->csize)); | 120 | crc = crc32(0, readbuf, je32_to_cpu(ri->csize)); |
124 | if (crc != je32_to_cpu(ri->data_crc)) { | 121 | if (crc != je32_to_cpu(ri->data_crc)) { |
125 | pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n", | 122 | printk(KERN_WARNING "Data CRC %08x != calculated CRC %08x for node at %08x\n", |
126 | je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw)); | 123 | je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw)); |
127 | ret = -EIO; | 124 | ret = -EIO; |
128 | goto out_decomprbuf; | 125 | goto out_decomprbuf; |
129 | } | 126 | } |
130 | jffs2_dbg(2, "Data CRC matches calculated CRC %08x\n", crc); | 127 | D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); |
131 | if (ri->compr != JFFS2_COMPR_NONE) { | 128 | if (ri->compr != JFFS2_COMPR_NONE) { |
132 | jffs2_dbg(2, "Decompress %d bytes from %p to %d bytes at %p\n", | 129 | D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", |
133 | je32_to_cpu(ri->csize), readbuf, | 130 | je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); |
134 | je32_to_cpu(ri->dsize), decomprbuf); | ||
135 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); | 131 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); |
136 | if (ret) { | 132 | if (ret) { |
137 | pr_warn("Error: jffs2_decompress returned %d\n", ret); | 133 | printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); |
138 | goto out_decomprbuf; | 134 | goto out_decomprbuf; |
139 | } | 135 | } |
140 | } | 136 | } |
@@ -161,8 +157,8 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
161 | struct jffs2_node_frag *frag; | 157 | struct jffs2_node_frag *frag; |
162 | int ret; | 158 | int ret; |
163 | 159 | ||
164 | jffs2_dbg(1, "%s(): ino #%u, range 0x%08x-0x%08x\n", | 160 | D1(printk(KERN_DEBUG "jffs2_read_inode_range: ino #%u, range 0x%08x-0x%08x\n", |
165 | __func__, f->inocache->ino, offset, offset + len); | 161 | f->inocache->ino, offset, offset+len)); |
166 | 162 | ||
167 | frag = jffs2_lookup_node_frag(&f->fragtree, offset); | 163 | frag = jffs2_lookup_node_frag(&f->fragtree, offset); |
168 | 164 | ||
@@ -172,27 +168,22 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
172 | * (or perhaps is before it, if we've been asked to read off the | 168 | * (or perhaps is before it, if we've been asked to read off the |
173 | * end of the file). */ | 169 | * end of the file). */ |
174 | while(offset < end) { | 170 | while(offset < end) { |
175 | jffs2_dbg(2, "%s(): offset %d, end %d\n", | 171 | D2(printk(KERN_DEBUG "jffs2_read_inode_range: offset %d, end %d\n", offset, end)); |
176 | __func__, offset, end); | ||
177 | if (unlikely(!frag || frag->ofs > offset || | 172 | if (unlikely(!frag || frag->ofs > offset || |
178 | frag->ofs + frag->size <= offset)) { | 173 | frag->ofs + frag->size <= offset)) { |
179 | uint32_t holesize = end - offset; | 174 | uint32_t holesize = end - offset; |
180 | if (frag && frag->ofs > offset) { | 175 | if (frag && frag->ofs > offset) { |
181 | jffs2_dbg(1, "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", | 176 | D1(printk(KERN_NOTICE "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", f->inocache->ino, frag->ofs, offset)); |
182 | f->inocache->ino, frag->ofs, offset); | ||
183 | holesize = min(holesize, frag->ofs - offset); | 177 | holesize = min(holesize, frag->ofs - offset); |
184 | } | 178 | } |
185 | jffs2_dbg(1, "Filling non-frag hole from %d-%d\n", | 179 | D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); |
186 | offset, offset + holesize); | ||
187 | memset(buf, 0, holesize); | 180 | memset(buf, 0, holesize); |
188 | buf += holesize; | 181 | buf += holesize; |
189 | offset += holesize; | 182 | offset += holesize; |
190 | continue; | 183 | continue; |
191 | } else if (unlikely(!frag->node)) { | 184 | } else if (unlikely(!frag->node)) { |
192 | uint32_t holeend = min(end, frag->ofs + frag->size); | 185 | uint32_t holeend = min(end, frag->ofs + frag->size); |
193 | jffs2_dbg(1, "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", | 186 | D1(printk(KERN_DEBUG "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", offset, holeend, frag->ofs, frag->ofs + frag->size)); |
194 | offset, holeend, frag->ofs, | ||
195 | frag->ofs + frag->size); | ||
196 | memset(buf, 0, holeend - offset); | 187 | memset(buf, 0, holeend - offset); |
197 | buf += holeend - offset; | 188 | buf += holeend - offset; |
198 | offset = holeend; | 189 | offset = holeend; |
@@ -204,23 +195,20 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
204 | 195 | ||
205 | fragofs = offset - frag->ofs; | 196 | fragofs = offset - frag->ofs; |
206 | readlen = min(frag->size - fragofs, end - offset); | 197 | readlen = min(frag->size - fragofs, end - offset); |
207 | jffs2_dbg(1, "Reading %d-%d from node at 0x%08x (%d)\n", | 198 | D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n", |
208 | frag->ofs+fragofs, | 199 | frag->ofs+fragofs, frag->ofs+fragofs+readlen, |
209 | frag->ofs + fragofs+readlen, | 200 | ref_offset(frag->node->raw), ref_flags(frag->node->raw))); |
210 | ref_offset(frag->node->raw), | ||
211 | ref_flags(frag->node->raw)); | ||
212 | ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); | 201 | ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); |
213 | jffs2_dbg(2, "node read done\n"); | 202 | D2(printk(KERN_DEBUG "node read done\n")); |
214 | if (ret) { | 203 | if (ret) { |
215 | jffs2_dbg(1, "%s(): error %d\n", | 204 | D1(printk(KERN_DEBUG"jffs2_read_inode_range error %d\n",ret)); |
216 | __func__, ret); | ||
217 | memset(buf, 0, readlen); | 205 | memset(buf, 0, readlen); |
218 | return ret; | 206 | return ret; |
219 | } | 207 | } |
220 | buf += readlen; | 208 | buf += readlen; |
221 | offset += readlen; | 209 | offset += readlen; |
222 | frag = frag_next(frag); | 210 | frag = frag_next(frag); |
223 | jffs2_dbg(2, "node read was OK. Looping\n"); | 211 | D2(printk(KERN_DEBUG "node read was OK. Looping\n")); |
224 | } | 212 | } |
225 | } | 213 | } |
226 | return 0; | 214 | return 0; |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index ae81b01e6fd..ee57bac1ba6 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
16 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
@@ -64,15 +62,17 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
64 | #ifndef __ECOS | 62 | #ifndef __ECOS |
65 | /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), | 63 | /* TODO: instead, incapsulate point() stuff to jffs2_flash_read(), |
66 | * adding and jffs2_flash_read_end() interface. */ | 64 | * adding and jffs2_flash_read_end() interface. */ |
67 | err = mtd_point(c->mtd, ofs, len, &retlen, (void **)&buffer, NULL); | 65 | if (c->mtd->point) { |
68 | if (!err && retlen < len) { | 66 | err = c->mtd->point(c->mtd, ofs, len, &retlen, |
69 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); | 67 | (void **)&buffer, NULL); |
70 | mtd_unpoint(c->mtd, ofs, retlen); | 68 | if (!err && retlen < len) { |
71 | } else if (err) { | 69 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); |
72 | if (err != -EOPNOTSUPP) | 70 | c->mtd->unpoint(c->mtd, ofs, retlen); |
71 | } else if (err) | ||
73 | JFFS2_WARNING("MTD point failed: error code %d.\n", err); | 72 | JFFS2_WARNING("MTD point failed: error code %d.\n", err); |
74 | } else | 73 | else |
75 | pointed = 1; /* succefully pointed to device */ | 74 | pointed = 1; /* succefully pointed to device */ |
75 | } | ||
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | if (!pointed) { | 78 | if (!pointed) { |
@@ -101,7 +101,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
101 | kfree(buffer); | 101 | kfree(buffer); |
102 | #ifndef __ECOS | 102 | #ifndef __ECOS |
103 | else | 103 | else |
104 | mtd_unpoint(c->mtd, ofs, len); | 104 | c->mtd->unpoint(c->mtd, ofs, len); |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | if (crc != tn->data_crc) { | 107 | if (crc != tn->data_crc) { |
@@ -137,7 +137,7 @@ free_out: | |||
137 | kfree(buffer); | 137 | kfree(buffer); |
138 | #ifndef __ECOS | 138 | #ifndef __ECOS |
139 | else | 139 | else |
140 | mtd_unpoint(c->mtd, ofs, len); | 140 | c->mtd->unpoint(c->mtd, ofs, len); |
141 | #endif | 141 | #endif |
142 | return err; | 142 | return err; |
143 | } | 143 | } |
@@ -394,11 +394,8 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c, | |||
394 | } | 394 | } |
395 | 395 | ||
396 | /* Trivial function to remove the last node in the tree. Which by definition | 396 | /* Trivial function to remove the last node in the tree. Which by definition |
397 | has no right-hand child — so can be removed just by making its left-hand | 397 | has no right-hand -- so can be removed just by making its only child (if |
398 | child (if any) take its place under its parent. Since this is only done | 398 | any) take its place under its parent. */ |
399 | when we're consuming the whole tree, there's no need to use rb_erase() | ||
400 | and let it worry about adjusting colours and balancing the tree. That | ||
401 | would just be a waste of time. */ | ||
402 | static void eat_last(struct rb_root *root, struct rb_node *node) | 399 | static void eat_last(struct rb_root *root, struct rb_node *node) |
403 | { | 400 | { |
404 | struct rb_node *parent = rb_parent(node); | 401 | struct rb_node *parent = rb_parent(node); |
@@ -415,12 +412,12 @@ static void eat_last(struct rb_root *root, struct rb_node *node) | |||
415 | link = &parent->rb_right; | 412 | link = &parent->rb_right; |
416 | 413 | ||
417 | *link = node->rb_left; | 414 | *link = node->rb_left; |
415 | /* Colour doesn't matter now. Only the parent pointer. */ | ||
418 | if (node->rb_left) | 416 | if (node->rb_left) |
419 | node->rb_left->__rb_parent_color = node->__rb_parent_color; | 417 | node->rb_left->rb_parent_color = node->rb_parent_color; |
420 | } | 418 | } |
421 | 419 | ||
422 | /* We put the version tree in reverse order, so we can use the same eat_last() | 420 | /* We put this in reverse order, so we can just use eat_last */ |
423 | function that we use to consume the tmpnode tree (tn_root). */ | ||
424 | static void ver_insert(struct rb_root *ver_root, struct jffs2_tmp_dnode_info *tn) | 421 | static void ver_insert(struct rb_root *ver_root, struct jffs2_tmp_dnode_info *tn) |
425 | { | 422 | { |
426 | struct rb_node **link = &ver_root->rb_node; | 423 | struct rb_node **link = &ver_root->rb_node; |
@@ -1269,25 +1266,19 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1269 | /* Symlink's inode data is the target path. Read it and | 1266 | /* Symlink's inode data is the target path. Read it and |
1270 | * keep in RAM to facilitate quick follow symlink | 1267 | * keep in RAM to facilitate quick follow symlink |
1271 | * operation. */ | 1268 | * operation. */ |
1272 | uint32_t csize = je32_to_cpu(latest_node->csize); | 1269 | f->target = kmalloc(je32_to_cpu(latest_node->csize) + 1, GFP_KERNEL); |
1273 | if (csize > JFFS2_MAX_NAME_LEN) { | ||
1274 | mutex_unlock(&f->sem); | ||
1275 | jffs2_do_clear_inode(c, f); | ||
1276 | return -ENAMETOOLONG; | ||
1277 | } | ||
1278 | f->target = kmalloc(csize + 1, GFP_KERNEL); | ||
1279 | if (!f->target) { | 1270 | if (!f->target) { |
1280 | JFFS2_ERROR("can't allocate %u bytes of memory for the symlink target path cache\n", csize); | 1271 | JFFS2_ERROR("can't allocate %d bytes of memory for the symlink target path cache\n", je32_to_cpu(latest_node->csize)); |
1281 | mutex_unlock(&f->sem); | 1272 | mutex_unlock(&f->sem); |
1282 | jffs2_do_clear_inode(c, f); | 1273 | jffs2_do_clear_inode(c, f); |
1283 | return -ENOMEM; | 1274 | return -ENOMEM; |
1284 | } | 1275 | } |
1285 | 1276 | ||
1286 | ret = jffs2_flash_read(c, ref_offset(rii.latest_ref) + sizeof(*latest_node), | 1277 | ret = jffs2_flash_read(c, ref_offset(rii.latest_ref) + sizeof(*latest_node), |
1287 | csize, &retlen, (char *)f->target); | 1278 | je32_to_cpu(latest_node->csize), &retlen, (char *)f->target); |
1288 | 1279 | ||
1289 | if (ret || retlen != csize) { | 1280 | if (ret || retlen != je32_to_cpu(latest_node->csize)) { |
1290 | if (retlen != csize) | 1281 | if (retlen != je32_to_cpu(latest_node->csize)) |
1291 | ret = -EIO; | 1282 | ret = -EIO; |
1292 | kfree(f->target); | 1283 | kfree(f->target); |
1293 | f->target = NULL; | 1284 | f->target = NULL; |
@@ -1296,7 +1287,7 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, | |||
1296 | return ret; | 1287 | return ret; |
1297 | } | 1288 | } |
1298 | 1289 | ||
1299 | f->target[csize] = '\0'; | 1290 | f->target[je32_to_cpu(latest_node->csize)] = '\0'; |
1300 | dbg_readinode("symlink's target '%s' cached\n", f->target); | 1291 | dbg_readinode("symlink's target '%s' cached\n", f->target); |
1301 | } | 1292 | } |
1302 | 1293 | ||
@@ -1424,7 +1415,6 @@ int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i | |||
1424 | mutex_unlock(&f->sem); | 1415 | mutex_unlock(&f->sem); |
1425 | jffs2_do_clear_inode(c, f); | 1416 | jffs2_do_clear_inode(c, f); |
1426 | } | 1417 | } |
1427 | jffs2_xattr_do_crccheck_inode(c, ic); | ||
1428 | kfree (f); | 1418 | kfree (f); |
1429 | return ret; | 1419 | return ret; |
1430 | } | 1420 | } |
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index 7654e87b042..8d8cd3419d0 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
16 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
@@ -24,15 +22,15 @@ | |||
24 | 22 | ||
25 | #define DEFAULT_EMPTY_SCAN_SIZE 256 | 23 | #define DEFAULT_EMPTY_SCAN_SIZE 256 |
26 | 24 | ||
27 | #define noisy_printk(noise, fmt, ...) \ | 25 | #define noisy_printk(noise, args...) do { \ |
28 | do { \ | 26 | if (*(noise)) { \ |
29 | if (*(noise)) { \ | 27 | printk(KERN_NOTICE args); \ |
30 | pr_notice(fmt, ##__VA_ARGS__); \ | 28 | (*(noise))--; \ |
31 | (*(noise))--; \ | 29 | if (!(*(noise))) { \ |
32 | if (!(*(noise))) \ | 30 | printk(KERN_NOTICE "Further such events for this erase block will not be printed\n"); \ |
33 | pr_notice("Further such events for this erase block will not be printed\n"); \ | 31 | } \ |
34 | } \ | 32 | } \ |
35 | } while (0) | 33 | } while(0) |
36 | 34 | ||
37 | static uint32_t pseudo_random; | 35 | static uint32_t pseudo_random; |
38 | 36 | ||
@@ -98,17 +96,18 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
98 | #ifndef __ECOS | 96 | #ifndef __ECOS |
99 | size_t pointlen, try_size; | 97 | size_t pointlen, try_size; |
100 | 98 | ||
101 | ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen, | 99 | if (c->mtd->point) { |
102 | (void **)&flashbuf, NULL); | 100 | ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, |
103 | if (!ret && pointlen < c->mtd->size) { | 101 | (void **)&flashbuf, NULL); |
104 | /* Don't muck about if it won't let us point to the whole flash */ | 102 | if (!ret && pointlen < c->mtd->size) { |
105 | jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n", | 103 | /* Don't muck about if it won't let us point to the whole flash */ |
106 | pointlen); | 104 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen)); |
107 | mtd_unpoint(c->mtd, 0, pointlen); | 105 | c->mtd->unpoint(c->mtd, 0, pointlen); |
108 | flashbuf = NULL; | 106 | flashbuf = NULL; |
107 | } | ||
108 | if (ret) | ||
109 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); | ||
109 | } | 110 | } |
110 | if (ret && ret != -EOPNOTSUPP) | ||
111 | jffs2_dbg(1, "MTD point failed %d\n", ret); | ||
112 | #endif | 111 | #endif |
113 | if (!flashbuf) { | 112 | if (!flashbuf) { |
114 | /* For NAND it's quicker to read a whole eraseblock at a time, | 113 | /* For NAND it's quicker to read a whole eraseblock at a time, |
@@ -118,15 +117,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
118 | else | 117 | else |
119 | try_size = PAGE_SIZE; | 118 | try_size = PAGE_SIZE; |
120 | 119 | ||
121 | jffs2_dbg(1, "Trying to allocate readbuf of %zu " | 120 | D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu " |
122 | "bytes\n", try_size); | 121 | "bytes\n", try_size)); |
123 | 122 | ||
124 | flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); | 123 | flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); |
125 | if (!flashbuf) | 124 | if (!flashbuf) |
126 | return -ENOMEM; | 125 | return -ENOMEM; |
127 | 126 | ||
128 | jffs2_dbg(1, "Allocated readbuf of %zu bytes\n", | 127 | D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n", |
129 | try_size); | 128 | try_size)); |
130 | 129 | ||
131 | buf_size = (uint32_t)try_size; | 130 | buf_size = (uint32_t)try_size; |
132 | } | 131 | } |
@@ -179,8 +178,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
179 | c->nr_free_blocks++; | 178 | c->nr_free_blocks++; |
180 | } else { | 179 | } else { |
181 | /* Dirt */ | 180 | /* Dirt */ |
182 | jffs2_dbg(1, "Adding all-dirty block at 0x%08x to erase_pending_list\n", | 181 | D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset)); |
183 | jeb->offset); | ||
184 | list_add(&jeb->list, &c->erase_pending_list); | 182 | list_add(&jeb->list, &c->erase_pending_list); |
185 | c->nr_erasing_blocks++; | 183 | c->nr_erasing_blocks++; |
186 | } | 184 | } |
@@ -207,8 +205,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
207 | } | 205 | } |
208 | /* update collected summary information for the current nextblock */ | 206 | /* update collected summary information for the current nextblock */ |
209 | jffs2_sum_move_collected(c, s); | 207 | jffs2_sum_move_collected(c, s); |
210 | jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n", | 208 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); |
211 | __func__, jeb->offset); | ||
212 | c->nextblock = jeb; | 209 | c->nextblock = jeb; |
213 | } else { | 210 | } else { |
214 | ret = file_dirty(c, jeb); | 211 | ret = file_dirty(c, jeb); |
@@ -220,21 +217,20 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
220 | case BLK_STATE_ALLDIRTY: | 217 | case BLK_STATE_ALLDIRTY: |
221 | /* Nothing valid - not even a clean marker. Needs erasing. */ | 218 | /* Nothing valid - not even a clean marker. Needs erasing. */ |
222 | /* For now we just put it on the erasing list. We'll start the erases later */ | 219 | /* For now we just put it on the erasing list. We'll start the erases later */ |
223 | jffs2_dbg(1, "Erase block at 0x%08x is not formatted. It will be erased\n", | 220 | D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset)); |
224 | jeb->offset); | ||
225 | list_add(&jeb->list, &c->erase_pending_list); | 221 | list_add(&jeb->list, &c->erase_pending_list); |
226 | c->nr_erasing_blocks++; | 222 | c->nr_erasing_blocks++; |
227 | break; | 223 | break; |
228 | 224 | ||
229 | case BLK_STATE_BADBLOCK: | 225 | case BLK_STATE_BADBLOCK: |
230 | jffs2_dbg(1, "Block at 0x%08x is bad\n", jeb->offset); | 226 | D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); |
231 | list_add(&jeb->list, &c->bad_list); | 227 | list_add(&jeb->list, &c->bad_list); |
232 | c->bad_size += c->sector_size; | 228 | c->bad_size += c->sector_size; |
233 | c->free_size -= c->sector_size; | 229 | c->free_size -= c->sector_size; |
234 | bad_blocks++; | 230 | bad_blocks++; |
235 | break; | 231 | break; |
236 | default: | 232 | default: |
237 | pr_warn("%s(): unknown block state\n", __func__); | 233 | printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n"); |
238 | BUG(); | 234 | BUG(); |
239 | } | 235 | } |
240 | } | 236 | } |
@@ -254,17 +250,16 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
254 | 250 | ||
255 | uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; | 251 | uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; |
256 | 252 | ||
257 | jffs2_dbg(1, "%s(): Skipping %d bytes in nextblock to ensure page alignment\n", | 253 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n", |
258 | __func__, skip); | 254 | skip)); |
259 | jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); | 255 | jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); |
260 | jffs2_scan_dirty_space(c, c->nextblock, skip); | 256 | jffs2_scan_dirty_space(c, c->nextblock, skip); |
261 | } | 257 | } |
262 | #endif | 258 | #endif |
263 | if (c->nr_erasing_blocks) { | 259 | if (c->nr_erasing_blocks) { |
264 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { | 260 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { |
265 | pr_notice("Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); | 261 | printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); |
266 | pr_notice("empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n", | 262 | printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); |
267 | empty_blocks, bad_blocks, c->nr_blocks); | ||
268 | ret = -EIO; | 263 | ret = -EIO; |
269 | goto out; | 264 | goto out; |
270 | } | 265 | } |
@@ -278,9 +273,11 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
278 | kfree(flashbuf); | 273 | kfree(flashbuf); |
279 | #ifndef __ECOS | 274 | #ifndef __ECOS |
280 | else | 275 | else |
281 | mtd_unpoint(c->mtd, 0, c->mtd->size); | 276 | c->mtd->unpoint(c->mtd, 0, c->mtd->size); |
282 | #endif | 277 | #endif |
283 | kfree(s); | 278 | if (s) |
279 | kfree(s); | ||
280 | |||
284 | return ret; | 281 | return ret; |
285 | } | 282 | } |
286 | 283 | ||
@@ -292,13 +289,11 @@ static int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, | |||
292 | 289 | ||
293 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); | 290 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); |
294 | if (ret) { | 291 | if (ret) { |
295 | jffs2_dbg(1, "mtd->read(0x%x bytes from 0x%x) returned %d\n", | 292 | D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret)); |
296 | len, ofs, ret); | ||
297 | return ret; | 293 | return ret; |
298 | } | 294 | } |
299 | if (retlen < len) { | 295 | if (retlen < len) { |
300 | jffs2_dbg(1, "Read at 0x%x gave only 0x%zx bytes\n", | 296 | D1(printk(KERN_WARNING "Read at 0x%x gave only 0x%zx bytes\n", ofs, retlen)); |
301 | ofs, retlen); | ||
302 | return -EIO; | 297 | return -EIO; |
303 | } | 298 | } |
304 | return 0; | 299 | return 0; |
@@ -375,7 +370,7 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
375 | 370 | ||
376 | if (jffs2_sum_active()) | 371 | if (jffs2_sum_active()) |
377 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); | 372 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); |
378 | dbg_xattr("scanning xdatum at %#08x (xid=%u, version=%u)\n", | 373 | dbg_xattr("scaning xdatum at %#08x (xid=%u, version=%u)\n", |
379 | ofs, xd->xid, xd->version); | 374 | ofs, xd->xid, xd->version); |
380 | return 0; | 375 | return 0; |
381 | } | 376 | } |
@@ -456,17 +451,17 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
456 | ofs = jeb->offset; | 451 | ofs = jeb->offset; |
457 | prevofs = jeb->offset - 1; | 452 | prevofs = jeb->offset - 1; |
458 | 453 | ||
459 | jffs2_dbg(1, "%s(): Scanning block at 0x%x\n", __func__, ofs); | 454 | D1(printk(KERN_DEBUG "jffs2_scan_eraseblock(): Scanning block at 0x%x\n", ofs)); |
460 | 455 | ||
461 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 456 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
462 | if (jffs2_cleanmarker_oob(c)) { | 457 | if (jffs2_cleanmarker_oob(c)) { |
463 | int ret; | 458 | int ret; |
464 | 459 | ||
465 | if (mtd_block_isbad(c->mtd, jeb->offset)) | 460 | if (c->mtd->block_isbad(c->mtd, jeb->offset)) |
466 | return BLK_STATE_BADBLOCK; | 461 | return BLK_STATE_BADBLOCK; |
467 | 462 | ||
468 | ret = jffs2_check_nand_cleanmarker(c, jeb); | 463 | ret = jffs2_check_nand_cleanmarker(c, jeb); |
469 | jffs2_dbg(2, "jffs_check_nand_cleanmarker returned %d\n", ret); | 464 | D2(printk(KERN_NOTICE "jffs_check_nand_cleanmarker returned %d\n",ret)); |
470 | 465 | ||
471 | /* Even if it's not found, we still scan to see | 466 | /* Even if it's not found, we still scan to see |
472 | if the block is empty. We use this information | 467 | if the block is empty. We use this information |
@@ -568,8 +563,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
568 | if (jffs2_cleanmarker_oob(c)) { | 563 | if (jffs2_cleanmarker_oob(c)) { |
569 | /* scan oob, take care of cleanmarker */ | 564 | /* scan oob, take care of cleanmarker */ |
570 | int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); | 565 | int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); |
571 | jffs2_dbg(2, "jffs2_check_oob_empty returned %d\n", | 566 | D2(printk(KERN_NOTICE "jffs2_check_oob_empty returned %d\n",ret)); |
572 | ret); | ||
573 | switch (ret) { | 567 | switch (ret) { |
574 | case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF; | 568 | case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF; |
575 | case 1: return BLK_STATE_ALLDIRTY; | 569 | case 1: return BLK_STATE_ALLDIRTY; |
@@ -577,16 +571,15 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
577 | } | 571 | } |
578 | } | 572 | } |
579 | #endif | 573 | #endif |
580 | jffs2_dbg(1, "Block at 0x%08x is empty (erased)\n", | 574 | D1(printk(KERN_DEBUG "Block at 0x%08x is empty (erased)\n", jeb->offset)); |
581 | jeb->offset); | ||
582 | if (c->cleanmarker_size == 0) | 575 | if (c->cleanmarker_size == 0) |
583 | return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */ | 576 | return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */ |
584 | else | 577 | else |
585 | return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */ | 578 | return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */ |
586 | } | 579 | } |
587 | if (ofs) { | 580 | if (ofs) { |
588 | jffs2_dbg(1, "Free space at %08x ends at %08x\n", jeb->offset, | 581 | D1(printk(KERN_DEBUG "Free space at %08x ends at %08x\n", jeb->offset, |
589 | jeb->offset + ofs); | 582 | jeb->offset + ofs)); |
590 | if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) | 583 | if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) |
591 | return err; | 584 | return err; |
592 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) | 585 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) |
@@ -613,13 +606,12 @@ scan_more: | |||
613 | cond_resched(); | 606 | cond_resched(); |
614 | 607 | ||
615 | if (ofs & 3) { | 608 | if (ofs & 3) { |
616 | pr_warn("Eep. ofs 0x%08x not word-aligned!\n", ofs); | 609 | printk(KERN_WARNING "Eep. ofs 0x%08x not word-aligned!\n", ofs); |
617 | ofs = PAD(ofs); | 610 | ofs = PAD(ofs); |
618 | continue; | 611 | continue; |
619 | } | 612 | } |
620 | if (ofs == prevofs) { | 613 | if (ofs == prevofs) { |
621 | pr_warn("ofs 0x%08x has already been seen. Skipping\n", | 614 | printk(KERN_WARNING "ofs 0x%08x has already been seen. Skipping\n", ofs); |
622 | ofs); | ||
623 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 615 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
624 | return err; | 616 | return err; |
625 | ofs += 4; | 617 | ofs += 4; |
@@ -628,10 +620,8 @@ scan_more: | |||
628 | prevofs = ofs; | 620 | prevofs = ofs; |
629 | 621 | ||
630 | if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { | 622 | if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { |
631 | jffs2_dbg(1, "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n", | 623 | D1(printk(KERN_DEBUG "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n", sizeof(struct jffs2_unknown_node), |
632 | sizeof(struct jffs2_unknown_node), | 624 | jeb->offset, c->sector_size, ofs, sizeof(*node))); |
633 | jeb->offset, c->sector_size, ofs, | ||
634 | sizeof(*node)); | ||
635 | if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) | 625 | if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) |
636 | return err; | 626 | return err; |
637 | break; | 627 | break; |
@@ -639,9 +629,8 @@ scan_more: | |||
639 | 629 | ||
640 | if (buf_ofs + buf_len < ofs + sizeof(*node)) { | 630 | if (buf_ofs + buf_len < ofs + sizeof(*node)) { |
641 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 631 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
642 | jffs2_dbg(1, "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n", | 632 | D1(printk(KERN_DEBUG "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n", |
643 | sizeof(struct jffs2_unknown_node), | 633 | sizeof(struct jffs2_unknown_node), buf_len, ofs)); |
644 | buf_len, ofs); | ||
645 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 634 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
646 | if (err) | 635 | if (err) |
647 | return err; | 636 | return err; |
@@ -658,13 +647,13 @@ scan_more: | |||
658 | ofs += 4; | 647 | ofs += 4; |
659 | scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len); | 648 | scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len); |
660 | 649 | ||
661 | jffs2_dbg(1, "Found empty flash at 0x%08x\n", ofs); | 650 | D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs)); |
662 | more_empty: | 651 | more_empty: |
663 | inbuf_ofs = ofs - buf_ofs; | 652 | inbuf_ofs = ofs - buf_ofs; |
664 | while (inbuf_ofs < scan_end) { | 653 | while (inbuf_ofs < scan_end) { |
665 | if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) { | 654 | if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) { |
666 | pr_warn("Empty flash at 0x%08x ends at 0x%08x\n", | 655 | printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n", |
667 | empty_start, ofs); | 656 | empty_start, ofs); |
668 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) | 657 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) |
669 | return err; | 658 | return err; |
670 | goto scan_more; | 659 | goto scan_more; |
@@ -674,15 +663,13 @@ scan_more: | |||
674 | ofs += 4; | 663 | ofs += 4; |
675 | } | 664 | } |
676 | /* Ran off end. */ | 665 | /* Ran off end. */ |
677 | jffs2_dbg(1, "Empty flash to end of buffer at 0x%08x\n", | 666 | D1(printk(KERN_DEBUG "Empty flash to end of buffer at 0x%08x\n", ofs)); |
678 | ofs); | ||
679 | 667 | ||
680 | /* If we're only checking the beginning of a block with a cleanmarker, | 668 | /* If we're only checking the beginning of a block with a cleanmarker, |
681 | bail now */ | 669 | bail now */ |
682 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && | 670 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && |
683 | c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { | 671 | c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { |
684 | jffs2_dbg(1, "%d bytes at start of block seems clean... assuming all clean\n", | 672 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); |
685 | EMPTY_SCAN_SIZE(c->sector_size)); | ||
686 | return BLK_STATE_CLEANMARKER; | 673 | return BLK_STATE_CLEANMARKER; |
687 | } | 674 | } |
688 | if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */ | 675 | if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */ |
@@ -695,14 +682,13 @@ scan_more: | |||
695 | if (!buf_len) { | 682 | if (!buf_len) { |
696 | /* No more to read. Break out of main loop without marking | 683 | /* No more to read. Break out of main loop without marking |
697 | this range of empty space as dirty (because it's not) */ | 684 | this range of empty space as dirty (because it's not) */ |
698 | jffs2_dbg(1, "Empty flash at %08x runs to end of block. Treating as free_space\n", | 685 | D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", |
699 | empty_start); | 686 | empty_start)); |
700 | break; | 687 | break; |
701 | } | 688 | } |
702 | /* point never reaches here */ | 689 | /* point never reaches here */ |
703 | scan_end = buf_len; | 690 | scan_end = buf_len; |
704 | jffs2_dbg(1, "Reading another 0x%x at 0x%08x\n", | 691 | D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs)); |
705 | buf_len, ofs); | ||
706 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 692 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
707 | if (err) | 693 | if (err) |
708 | return err; | 694 | return err; |
@@ -711,23 +697,22 @@ scan_more: | |||
711 | } | 697 | } |
712 | 698 | ||
713 | if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { | 699 | if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { |
714 | pr_warn("Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", | 700 | printk(KERN_WARNING "Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", ofs); |
715 | ofs); | ||
716 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 701 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
717 | return err; | 702 | return err; |
718 | ofs += 4; | 703 | ofs += 4; |
719 | continue; | 704 | continue; |
720 | } | 705 | } |
721 | if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) { | 706 | if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) { |
722 | jffs2_dbg(1, "Dirty bitmask at 0x%08x\n", ofs); | 707 | D1(printk(KERN_DEBUG "Dirty bitmask at 0x%08x\n", ofs)); |
723 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 708 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
724 | return err; | 709 | return err; |
725 | ofs += 4; | 710 | ofs += 4; |
726 | continue; | 711 | continue; |
727 | } | 712 | } |
728 | if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) { | 713 | if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) { |
729 | pr_warn("Old JFFS2 bitmask found at 0x%08x\n", ofs); | 714 | printk(KERN_WARNING "Old JFFS2 bitmask found at 0x%08x\n", ofs); |
730 | pr_warn("You cannot use older JFFS2 filesystems with newer kernels\n"); | 715 | printk(KERN_WARNING "You cannot use older JFFS2 filesystems with newer kernels\n"); |
731 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 716 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
732 | return err; | 717 | return err; |
733 | ofs += 4; | 718 | ofs += 4; |
@@ -735,8 +720,7 @@ scan_more: | |||
735 | } | 720 | } |
736 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { | 721 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { |
737 | /* OK. We're out of possibilities. Whinge and move on */ | 722 | /* OK. We're out of possibilities. Whinge and move on */ |
738 | noisy_printk(&noise, "%s(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", | 723 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", |
739 | __func__, | ||
740 | JFFS2_MAGIC_BITMASK, ofs, | 724 | JFFS2_MAGIC_BITMASK, ofs, |
741 | je16_to_cpu(node->magic)); | 725 | je16_to_cpu(node->magic)); |
742 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 726 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
@@ -751,8 +735,7 @@ scan_more: | |||
751 | hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4); | 735 | hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4); |
752 | 736 | ||
753 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { | 737 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { |
754 | noisy_printk(&noise, "%s(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", | 738 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", |
755 | __func__, | ||
756 | ofs, je16_to_cpu(node->magic), | 739 | ofs, je16_to_cpu(node->magic), |
757 | je16_to_cpu(node->nodetype), | 740 | je16_to_cpu(node->nodetype), |
758 | je32_to_cpu(node->totlen), | 741 | je32_to_cpu(node->totlen), |
@@ -766,9 +749,9 @@ scan_more: | |||
766 | 749 | ||
767 | if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { | 750 | if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { |
768 | /* Eep. Node goes over the end of the erase block. */ | 751 | /* Eep. Node goes over the end of the erase block. */ |
769 | pr_warn("Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", | 752 | printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", |
770 | ofs, je32_to_cpu(node->totlen)); | 753 | ofs, je32_to_cpu(node->totlen)); |
771 | pr_warn("Perhaps the file system was created with the wrong erase size?\n"); | 754 | printk(KERN_WARNING "Perhaps the file system was created with the wrong erase size?\n"); |
772 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 755 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
773 | return err; | 756 | return err; |
774 | ofs += 4; | 757 | ofs += 4; |
@@ -777,8 +760,7 @@ scan_more: | |||
777 | 760 | ||
778 | if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) { | 761 | if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) { |
779 | /* Wheee. This is an obsoleted node */ | 762 | /* Wheee. This is an obsoleted node */ |
780 | jffs2_dbg(2, "Node at 0x%08x is obsolete. Skipping\n", | 763 | D2(printk(KERN_DEBUG "Node at 0x%08x is obsolete. Skipping\n", ofs)); |
781 | ofs); | ||
782 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) | 764 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) |
783 | return err; | 765 | return err; |
784 | ofs += PAD(je32_to_cpu(node->totlen)); | 766 | ofs += PAD(je32_to_cpu(node->totlen)); |
@@ -789,9 +771,8 @@ scan_more: | |||
789 | case JFFS2_NODETYPE_INODE: | 771 | case JFFS2_NODETYPE_INODE: |
790 | if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { | 772 | if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { |
791 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 773 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
792 | jffs2_dbg(1, "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n", | 774 | D1(printk(KERN_DEBUG "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n", |
793 | sizeof(struct jffs2_raw_inode), | 775 | sizeof(struct jffs2_raw_inode), buf_len, ofs)); |
794 | buf_len, ofs); | ||
795 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 776 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
796 | if (err) | 777 | if (err) |
797 | return err; | 778 | return err; |
@@ -806,9 +787,8 @@ scan_more: | |||
806 | case JFFS2_NODETYPE_DIRENT: | 787 | case JFFS2_NODETYPE_DIRENT: |
807 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 788 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
808 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 789 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
809 | jffs2_dbg(1, "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n", | 790 | D1(printk(KERN_DEBUG "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n", |
810 | je32_to_cpu(node->totlen), buf_len, | 791 | je32_to_cpu(node->totlen), buf_len, ofs)); |
811 | ofs); | ||
812 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 792 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
813 | if (err) | 793 | if (err) |
814 | return err; | 794 | return err; |
@@ -824,9 +804,9 @@ scan_more: | |||
824 | case JFFS2_NODETYPE_XATTR: | 804 | case JFFS2_NODETYPE_XATTR: |
825 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 805 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
826 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 806 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
827 | jffs2_dbg(1, "Fewer than %d bytes (xattr node) left to end of buf. Reading 0x%x at 0x%08x\n", | 807 | D1(printk(KERN_DEBUG "Fewer than %d bytes (xattr node)" |
828 | je32_to_cpu(node->totlen), buf_len, | 808 | " left to end of buf. Reading 0x%x at 0x%08x\n", |
829 | ofs); | 809 | je32_to_cpu(node->totlen), buf_len, ofs)); |
830 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 810 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
831 | if (err) | 811 | if (err) |
832 | return err; | 812 | return err; |
@@ -841,9 +821,9 @@ scan_more: | |||
841 | case JFFS2_NODETYPE_XREF: | 821 | case JFFS2_NODETYPE_XREF: |
842 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 822 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
843 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 823 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
844 | jffs2_dbg(1, "Fewer than %d bytes (xref node) left to end of buf. Reading 0x%x at 0x%08x\n", | 824 | D1(printk(KERN_DEBUG "Fewer than %d bytes (xref node)" |
845 | je32_to_cpu(node->totlen), buf_len, | 825 | " left to end of buf. Reading 0x%x at 0x%08x\n", |
846 | ofs); | 826 | je32_to_cpu(node->totlen), buf_len, ofs)); |
847 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 827 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
848 | if (err) | 828 | if (err) |
849 | return err; | 829 | return err; |
@@ -858,17 +838,15 @@ scan_more: | |||
858 | #endif /* CONFIG_JFFS2_FS_XATTR */ | 838 | #endif /* CONFIG_JFFS2_FS_XATTR */ |
859 | 839 | ||
860 | case JFFS2_NODETYPE_CLEANMARKER: | 840 | case JFFS2_NODETYPE_CLEANMARKER: |
861 | jffs2_dbg(1, "CLEANMARKER node found at 0x%08x\n", ofs); | 841 | D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); |
862 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { | 842 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { |
863 | pr_notice("CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", | 843 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", |
864 | ofs, je32_to_cpu(node->totlen), | 844 | ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); |
865 | c->cleanmarker_size); | ||
866 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) | 845 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) |
867 | return err; | 846 | return err; |
868 | ofs += PAD(sizeof(struct jffs2_unknown_node)); | 847 | ofs += PAD(sizeof(struct jffs2_unknown_node)); |
869 | } else if (jeb->first_node) { | 848 | } else if (jeb->first_node) { |
870 | pr_notice("CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", | 849 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset); |
871 | ofs, jeb->offset); | ||
872 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) | 850 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) |
873 | return err; | 851 | return err; |
874 | ofs += PAD(sizeof(struct jffs2_unknown_node)); | 852 | ofs += PAD(sizeof(struct jffs2_unknown_node)); |
@@ -890,8 +868,7 @@ scan_more: | |||
890 | default: | 868 | default: |
891 | switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { | 869 | switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { |
892 | case JFFS2_FEATURE_ROCOMPAT: | 870 | case JFFS2_FEATURE_ROCOMPAT: |
893 | pr_notice("Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", | 871 | printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); |
894 | je16_to_cpu(node->nodetype), ofs); | ||
895 | c->flags |= JFFS2_SB_FLAG_RO; | 872 | c->flags |= JFFS2_SB_FLAG_RO; |
896 | if (!(jffs2_is_readonly(c))) | 873 | if (!(jffs2_is_readonly(c))) |
897 | return -EROFS; | 874 | return -EROFS; |
@@ -901,21 +878,18 @@ scan_more: | |||
901 | break; | 878 | break; |
902 | 879 | ||
903 | case JFFS2_FEATURE_INCOMPAT: | 880 | case JFFS2_FEATURE_INCOMPAT: |
904 | pr_notice("Incompatible feature node (0x%04x) found at offset 0x%08x\n", | 881 | printk(KERN_NOTICE "Incompatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); |
905 | je16_to_cpu(node->nodetype), ofs); | ||
906 | return -EINVAL; | 882 | return -EINVAL; |
907 | 883 | ||
908 | case JFFS2_FEATURE_RWCOMPAT_DELETE: | 884 | case JFFS2_FEATURE_RWCOMPAT_DELETE: |
909 | jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", | 885 | D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); |
910 | je16_to_cpu(node->nodetype), ofs); | ||
911 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) | 886 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) |
912 | return err; | 887 | return err; |
913 | ofs += PAD(je32_to_cpu(node->totlen)); | 888 | ofs += PAD(je32_to_cpu(node->totlen)); |
914 | break; | 889 | break; |
915 | 890 | ||
916 | case JFFS2_FEATURE_RWCOMPAT_COPY: { | 891 | case JFFS2_FEATURE_RWCOMPAT_COPY: { |
917 | jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", | 892 | D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); |
918 | je16_to_cpu(node->nodetype), ofs); | ||
919 | 893 | ||
920 | jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); | 894 | jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); |
921 | 895 | ||
@@ -936,9 +910,8 @@ scan_more: | |||
936 | } | 910 | } |
937 | } | 911 | } |
938 | 912 | ||
939 | jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", | 913 | D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", |
940 | jeb->offset, jeb->free_size, jeb->dirty_size, | 914 | jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size)); |
941 | jeb->unchecked_size, jeb->used_size, jeb->wasted_size); | ||
942 | 915 | ||
943 | /* mark_node_obsolete can add to wasted !! */ | 916 | /* mark_node_obsolete can add to wasted !! */ |
944 | if (jeb->wasted_size) { | 917 | if (jeb->wasted_size) { |
@@ -964,7 +937,7 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin | |||
964 | 937 | ||
965 | ic = jffs2_alloc_inode_cache(); | 938 | ic = jffs2_alloc_inode_cache(); |
966 | if (!ic) { | 939 | if (!ic) { |
967 | pr_notice("%s(): allocation of inode cache failed\n", __func__); | 940 | printk(KERN_NOTICE "jffs2_scan_make_inode_cache(): allocation of inode cache failed\n"); |
968 | return NULL; | 941 | return NULL; |
969 | } | 942 | } |
970 | memset(ic, 0, sizeof(*ic)); | 943 | memset(ic, 0, sizeof(*ic)); |
@@ -983,7 +956,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
983 | struct jffs2_inode_cache *ic; | 956 | struct jffs2_inode_cache *ic; |
984 | uint32_t crc, ino = je32_to_cpu(ri->ino); | 957 | uint32_t crc, ino = je32_to_cpu(ri->ino); |
985 | 958 | ||
986 | jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs); | 959 | D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); |
987 | 960 | ||
988 | /* We do very little here now. Just check the ino# to which we should attribute | 961 | /* We do very little here now. Just check the ino# to which we should attribute |
989 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- | 962 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- |
@@ -997,8 +970,9 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
997 | /* Check the node CRC in any case. */ | 970 | /* Check the node CRC in any case. */ |
998 | crc = crc32(0, ri, sizeof(*ri)-8); | 971 | crc = crc32(0, ri, sizeof(*ri)-8); |
999 | if (crc != je32_to_cpu(ri->node_crc)) { | 972 | if (crc != je32_to_cpu(ri->node_crc)) { |
1000 | pr_notice("%s(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 973 | printk(KERN_NOTICE "jffs2_scan_inode_node(): CRC failed on " |
1001 | __func__, ofs, je32_to_cpu(ri->node_crc), crc); | 974 | "node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
975 | ofs, je32_to_cpu(ri->node_crc), crc); | ||
1002 | /* | 976 | /* |
1003 | * We believe totlen because the CRC on the node | 977 | * We believe totlen because the CRC on the node |
1004 | * _header_ was OK, just the node itself failed. | 978 | * _header_ was OK, just the node itself failed. |
@@ -1017,10 +991,10 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
1017 | /* Wheee. It worked */ | 991 | /* Wheee. It worked */ |
1018 | jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); | 992 | jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); |
1019 | 993 | ||
1020 | jffs2_dbg(1, "Node is ino #%u, version %d. Range 0x%x-0x%x\n", | 994 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", |
1021 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), | 995 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), |
1022 | je32_to_cpu(ri->offset), | 996 | je32_to_cpu(ri->offset), |
1023 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize)); | 997 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); |
1024 | 998 | ||
1025 | pseudo_random += je32_to_cpu(ri->version); | 999 | pseudo_random += je32_to_cpu(ri->version); |
1026 | 1000 | ||
@@ -1040,15 +1014,15 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1040 | uint32_t crc; | 1014 | uint32_t crc; |
1041 | int err; | 1015 | int err; |
1042 | 1016 | ||
1043 | jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs); | 1017 | D1(printk(KERN_DEBUG "jffs2_scan_dirent_node(): Node at 0x%08x\n", ofs)); |
1044 | 1018 | ||
1045 | /* We don't get here unless the node is still valid, so we don't have to | 1019 | /* We don't get here unless the node is still valid, so we don't have to |
1046 | mask in the ACCURATE bit any more. */ | 1020 | mask in the ACCURATE bit any more. */ |
1047 | crc = crc32(0, rd, sizeof(*rd)-8); | 1021 | crc = crc32(0, rd, sizeof(*rd)-8); |
1048 | 1022 | ||
1049 | if (crc != je32_to_cpu(rd->node_crc)) { | 1023 | if (crc != je32_to_cpu(rd->node_crc)) { |
1050 | pr_notice("%s(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 1024 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
1051 | __func__, ofs, je32_to_cpu(rd->node_crc), crc); | 1025 | ofs, je32_to_cpu(rd->node_crc), crc); |
1052 | /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */ | 1026 | /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */ |
1053 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) | 1027 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) |
1054 | return err; | 1028 | return err; |
@@ -1060,7 +1034,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1060 | /* Should never happen. Did. (OLPC trac #4184)*/ | 1034 | /* Should never happen. Did. (OLPC trac #4184)*/ |
1061 | checkedlen = strnlen(rd->name, rd->nsize); | 1035 | checkedlen = strnlen(rd->name, rd->nsize); |
1062 | if (checkedlen < rd->nsize) { | 1036 | if (checkedlen < rd->nsize) { |
1063 | pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n", | 1037 | printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n", |
1064 | ofs, checkedlen); | 1038 | ofs, checkedlen); |
1065 | } | 1039 | } |
1066 | fd = jffs2_alloc_full_dirent(checkedlen+1); | 1040 | fd = jffs2_alloc_full_dirent(checkedlen+1); |
@@ -1072,10 +1046,9 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1072 | 1046 | ||
1073 | crc = crc32(0, fd->name, rd->nsize); | 1047 | crc = crc32(0, fd->name, rd->nsize); |
1074 | if (crc != je32_to_cpu(rd->name_crc)) { | 1048 | if (crc != je32_to_cpu(rd->name_crc)) { |
1075 | pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 1049 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
1076 | __func__, ofs, je32_to_cpu(rd->name_crc), crc); | 1050 | ofs, je32_to_cpu(rd->name_crc), crc); |
1077 | jffs2_dbg(1, "Name for which CRC failed is (now) '%s', ino #%d\n", | 1051 | D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); |
1078 | fd->name, je32_to_cpu(rd->ino)); | ||
1079 | jffs2_free_full_dirent(fd); | 1052 | jffs2_free_full_dirent(fd); |
1080 | /* FIXME: Why do we believe totlen? */ | 1053 | /* FIXME: Why do we believe totlen? */ |
1081 | /* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */ | 1054 | /* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */ |
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c index aca97f35b29..cfeb7164b08 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -22,29 +22,26 @@ | |||
22 | #include <linux/security.h> | 22 | #include <linux/security.h> |
23 | #include "nodelist.h" | 23 | #include "nodelist.h" |
24 | 24 | ||
25 | /* ---- Initial Security Label(s) Attachment callback --- */ | 25 | /* ---- Initial Security Label Attachment -------------- */ |
26 | static int jffs2_initxattrs(struct inode *inode, | 26 | int jffs2_init_security(struct inode *inode, struct inode *dir, |
27 | const struct xattr *xattr_array, void *fs_info) | 27 | const struct qstr *qstr) |
28 | { | 28 | { |
29 | const struct xattr *xattr; | 29 | int rc; |
30 | int err = 0; | 30 | size_t len; |
31 | void *value; | ||
32 | char *name; | ||
31 | 33 | ||
32 | for (xattr = xattr_array; xattr->name != NULL; xattr++) { | 34 | rc = security_inode_init_security(inode, dir, qstr, &name, &value, &len); |
33 | err = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, | 35 | if (rc) { |
34 | xattr->name, xattr->value, | 36 | if (rc == -EOPNOTSUPP) |
35 | xattr->value_len, 0); | 37 | return 0; |
36 | if (err < 0) | 38 | return rc; |
37 | break; | ||
38 | } | 39 | } |
39 | return err; | 40 | rc = do_jffs2_setxattr(inode, JFFS2_XPREFIX_SECURITY, name, value, len, 0); |
40 | } | ||
41 | 41 | ||
42 | /* ---- Initial Security Label(s) Attachment ----------- */ | 42 | kfree(name); |
43 | int jffs2_init_security(struct inode *inode, struct inode *dir, | 43 | kfree(value); |
44 | const struct qstr *qstr) | 44 | return rc; |
45 | { | ||
46 | return security_inode_init_security(inode, dir, qstr, | ||
47 | &jffs2_initxattrs, NULL); | ||
48 | } | 45 | } |
49 | 46 | ||
50 | /* ---- XATTR Handler for "security.*" ----------------- */ | 47 | /* ---- XATTR Handler for "security.*" ----------------- */ |
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c index c522d098bb4..e537fb0e018 100644 --- a/fs/jffs2/summary.c +++ b/fs/jffs2/summary.c | |||
@@ -11,8 +11,6 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
16 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
17 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
18 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
@@ -444,16 +442,13 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras | |||
444 | /* This should never happen, but https://dev.laptop.org/ticket/4184 */ | 442 | /* This should never happen, but https://dev.laptop.org/ticket/4184 */ |
445 | checkedlen = strnlen(spd->name, spd->nsize); | 443 | checkedlen = strnlen(spd->name, spd->nsize); |
446 | if (!checkedlen) { | 444 | if (!checkedlen) { |
447 | pr_err("Dirent at %08x has zero at start of name. Aborting mount.\n", | 445 | printk(KERN_ERR "Dirent at %08x has zero at start of name. Aborting mount.\n", |
448 | jeb->offset + | 446 | jeb->offset + je32_to_cpu(spd->offset)); |
449 | je32_to_cpu(spd->offset)); | ||
450 | return -EIO; | 447 | return -EIO; |
451 | } | 448 | } |
452 | if (checkedlen < spd->nsize) { | 449 | if (checkedlen < spd->nsize) { |
453 | pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n", | 450 | printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n", |
454 | jeb->offset + | 451 | jeb->offset + je32_to_cpu(spd->offset), checkedlen); |
455 | je32_to_cpu(spd->offset), | ||
456 | checkedlen); | ||
457 | } | 452 | } |
458 | 453 | ||
459 | 454 | ||
@@ -813,7 +808,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
813 | 808 | ||
814 | sum_ofs = jeb->offset + c->sector_size - jeb->free_size; | 809 | sum_ofs = jeb->offset + c->sector_size - jeb->free_size; |
815 | 810 | ||
816 | dbg_summary("writing out data to flash to pos : 0x%08x\n", sum_ofs); | 811 | dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n", |
812 | sum_ofs); | ||
817 | 813 | ||
818 | ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0); | 814 | ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0); |
819 | 815 | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index d3d8799e218..853b8e30008 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/module.h> | 13 | #include <linux/module.h> |
16 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
@@ -19,13 +17,11 @@ | |||
19 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
20 | #include <linux/err.h> | 18 | #include <linux/err.h> |
21 | #include <linux/mount.h> | 19 | #include <linux/mount.h> |
22 | #include <linux/parser.h> | ||
23 | #include <linux/jffs2.h> | 20 | #include <linux/jffs2.h> |
24 | #include <linux/pagemap.h> | 21 | #include <linux/pagemap.h> |
25 | #include <linux/mtd/super.h> | 22 | #include <linux/mtd/super.h> |
26 | #include <linux/ctype.h> | 23 | #include <linux/ctype.h> |
27 | #include <linux/namei.h> | 24 | #include <linux/namei.h> |
28 | #include <linux/seq_file.h> | ||
29 | #include <linux/exportfs.h> | 25 | #include <linux/exportfs.h> |
30 | #include "compr.h" | 26 | #include "compr.h" |
31 | #include "nodelist.h" | 27 | #include "nodelist.h" |
@@ -47,6 +43,7 @@ static struct inode *jffs2_alloc_inode(struct super_block *sb) | |||
47 | static void jffs2_i_callback(struct rcu_head *head) | 43 | static void jffs2_i_callback(struct rcu_head *head) |
48 | { | 44 | { |
49 | struct inode *inode = container_of(head, struct inode, i_rcu); | 45 | struct inode *inode = container_of(head, struct inode, i_rcu); |
46 | INIT_LIST_HEAD(&inode->i_dentry); | ||
50 | kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); | 47 | kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); |
51 | } | 48 | } |
52 | 49 | ||
@@ -63,46 +60,26 @@ static void jffs2_i_init_once(void *foo) | |||
63 | inode_init_once(&f->vfs_inode); | 60 | inode_init_once(&f->vfs_inode); |
64 | } | 61 | } |
65 | 62 | ||
66 | static const char *jffs2_compr_name(unsigned int compr) | 63 | static void jffs2_write_super(struct super_block *sb) |
67 | { | 64 | { |
68 | switch (compr) { | 65 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
69 | case JFFS2_COMPR_MODE_NONE: | ||
70 | return "none"; | ||
71 | #ifdef CONFIG_JFFS2_LZO | ||
72 | case JFFS2_COMPR_MODE_FORCELZO: | ||
73 | return "lzo"; | ||
74 | #endif | ||
75 | #ifdef CONFIG_JFFS2_ZLIB | ||
76 | case JFFS2_COMPR_MODE_FORCEZLIB: | ||
77 | return "zlib"; | ||
78 | #endif | ||
79 | default: | ||
80 | /* should never happen; programmer error */ | ||
81 | WARN_ON(1); | ||
82 | return ""; | ||
83 | } | ||
84 | } | ||
85 | 66 | ||
86 | static int jffs2_show_options(struct seq_file *s, struct dentry *root) | 67 | lock_super(sb); |
87 | { | 68 | sb->s_dirt = 0; |
88 | struct jffs2_sb_info *c = JFFS2_SB_INFO(root->d_sb); | ||
89 | struct jffs2_mount_opts *opts = &c->mount_opts; | ||
90 | 69 | ||
91 | if (opts->override_compr) | 70 | if (!(sb->s_flags & MS_RDONLY)) { |
92 | seq_printf(s, ",compr=%s", jffs2_compr_name(opts->compr)); | 71 | D1(printk(KERN_DEBUG "jffs2_write_super()\n")); |
93 | if (opts->rp_size) | 72 | jffs2_flush_wbuf_gc(c, 0); |
94 | seq_printf(s, ",rp_size=%u", opts->rp_size / 1024); | 73 | } |
95 | 74 | ||
96 | return 0; | 75 | unlock_super(sb); |
97 | } | 76 | } |
98 | 77 | ||
99 | static int jffs2_sync_fs(struct super_block *sb, int wait) | 78 | static int jffs2_sync_fs(struct super_block *sb, int wait) |
100 | { | 79 | { |
101 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 80 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
102 | 81 | ||
103 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 82 | jffs2_write_super(sb); |
104 | cancel_delayed_work_sync(&c->wbuf_dwork); | ||
105 | #endif | ||
106 | 83 | ||
107 | mutex_lock(&c->alloc_sem); | 84 | mutex_lock(&c->alloc_sem); |
108 | jffs2_flush_wbuf_pad(c); | 85 | jffs2_flush_wbuf_pad(c); |
@@ -156,110 +133,16 @@ static const struct export_operations jffs2_export_ops = { | |||
156 | .fh_to_parent = jffs2_fh_to_parent, | 133 | .fh_to_parent = jffs2_fh_to_parent, |
157 | }; | 134 | }; |
158 | 135 | ||
159 | /* | ||
160 | * JFFS2 mount options. | ||
161 | * | ||
162 | * Opt_override_compr: override default compressor | ||
163 | * Opt_rp_size: size of reserved pool in KiB | ||
164 | * Opt_err: just end of array marker | ||
165 | */ | ||
166 | enum { | ||
167 | Opt_override_compr, | ||
168 | Opt_rp_size, | ||
169 | Opt_err, | ||
170 | }; | ||
171 | |||
172 | static const match_table_t tokens = { | ||
173 | {Opt_override_compr, "compr=%s"}, | ||
174 | {Opt_rp_size, "rp_size=%u"}, | ||
175 | {Opt_err, NULL}, | ||
176 | }; | ||
177 | |||
178 | static int jffs2_parse_options(struct jffs2_sb_info *c, char *data) | ||
179 | { | ||
180 | substring_t args[MAX_OPT_ARGS]; | ||
181 | char *p, *name; | ||
182 | unsigned int opt; | ||
183 | |||
184 | if (!data) | ||
185 | return 0; | ||
186 | |||
187 | while ((p = strsep(&data, ","))) { | ||
188 | int token; | ||
189 | |||
190 | if (!*p) | ||
191 | continue; | ||
192 | |||
193 | token = match_token(p, tokens, args); | ||
194 | switch (token) { | ||
195 | case Opt_override_compr: | ||
196 | name = match_strdup(&args[0]); | ||
197 | |||
198 | if (!name) | ||
199 | return -ENOMEM; | ||
200 | if (!strcmp(name, "none")) | ||
201 | c->mount_opts.compr = JFFS2_COMPR_MODE_NONE; | ||
202 | #ifdef CONFIG_JFFS2_LZO | ||
203 | else if (!strcmp(name, "lzo")) | ||
204 | c->mount_opts.compr = JFFS2_COMPR_MODE_FORCELZO; | ||
205 | #endif | ||
206 | #ifdef CONFIG_JFFS2_ZLIB | ||
207 | else if (!strcmp(name, "zlib")) | ||
208 | c->mount_opts.compr = | ||
209 | JFFS2_COMPR_MODE_FORCEZLIB; | ||
210 | #endif | ||
211 | else { | ||
212 | pr_err("Error: unknown compressor \"%s\"\n", | ||
213 | name); | ||
214 | kfree(name); | ||
215 | return -EINVAL; | ||
216 | } | ||
217 | kfree(name); | ||
218 | c->mount_opts.override_compr = true; | ||
219 | break; | ||
220 | case Opt_rp_size: | ||
221 | if (match_int(&args[0], &opt)) | ||
222 | return -EINVAL; | ||
223 | opt *= 1024; | ||
224 | if (opt > c->mtd->size) { | ||
225 | pr_warn("Too large reserve pool specified, max " | ||
226 | "is %llu KB\n", c->mtd->size / 1024); | ||
227 | return -EINVAL; | ||
228 | } | ||
229 | c->mount_opts.rp_size = opt; | ||
230 | break; | ||
231 | default: | ||
232 | pr_err("Error: unrecognized mount option '%s' or missing value\n", | ||
233 | p); | ||
234 | return -EINVAL; | ||
235 | } | ||
236 | } | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static int jffs2_remount_fs(struct super_block *sb, int *flags, char *data) | ||
242 | { | ||
243 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | ||
244 | int err; | ||
245 | |||
246 | err = jffs2_parse_options(c, data); | ||
247 | if (err) | ||
248 | return -EINVAL; | ||
249 | |||
250 | return jffs2_do_remount_fs(sb, flags, data); | ||
251 | } | ||
252 | |||
253 | static const struct super_operations jffs2_super_operations = | 136 | static const struct super_operations jffs2_super_operations = |
254 | { | 137 | { |
255 | .alloc_inode = jffs2_alloc_inode, | 138 | .alloc_inode = jffs2_alloc_inode, |
256 | .destroy_inode =jffs2_destroy_inode, | 139 | .destroy_inode =jffs2_destroy_inode, |
257 | .put_super = jffs2_put_super, | 140 | .put_super = jffs2_put_super, |
141 | .write_super = jffs2_write_super, | ||
258 | .statfs = jffs2_statfs, | 142 | .statfs = jffs2_statfs, |
259 | .remount_fs = jffs2_remount_fs, | 143 | .remount_fs = jffs2_remount_fs, |
260 | .evict_inode = jffs2_evict_inode, | 144 | .evict_inode = jffs2_evict_inode, |
261 | .dirty_inode = jffs2_dirty_inode, | 145 | .dirty_inode = jffs2_dirty_inode, |
262 | .show_options = jffs2_show_options, | ||
263 | .sync_fs = jffs2_sync_fs, | 146 | .sync_fs = jffs2_sync_fs, |
264 | }; | 147 | }; |
265 | 148 | ||
@@ -271,9 +154,9 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | |||
271 | struct jffs2_sb_info *c; | 154 | struct jffs2_sb_info *c; |
272 | int ret; | 155 | int ret; |
273 | 156 | ||
274 | jffs2_dbg(1, "jffs2_get_sb_mtd():" | 157 | D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" |
275 | " New superblock for device %d (\"%s\")\n", | 158 | " New superblock for device %d (\"%s\")\n", |
276 | sb->s_mtd->index, sb->s_mtd->name); | 159 | sb->s_mtd->index, sb->s_mtd->name)); |
277 | 160 | ||
278 | c = kzalloc(sizeof(*c), GFP_KERNEL); | 161 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
279 | if (!c) | 162 | if (!c) |
@@ -283,12 +166,6 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | |||
283 | c->os_priv = sb; | 166 | c->os_priv = sb; |
284 | sb->s_fs_info = c; | 167 | sb->s_fs_info = c; |
285 | 168 | ||
286 | ret = jffs2_parse_options(c, data); | ||
287 | if (ret) { | ||
288 | kfree(c); | ||
289 | return -EINVAL; | ||
290 | } | ||
291 | |||
292 | /* Initialize JFFS2 superblock locks, the further initialization will | 169 | /* Initialize JFFS2 superblock locks, the further initialization will |
293 | * be done later */ | 170 | * be done later */ |
294 | mutex_init(&c->alloc_sem); | 171 | mutex_init(&c->alloc_sem); |
@@ -320,7 +197,10 @@ static void jffs2_put_super (struct super_block *sb) | |||
320 | { | 197 | { |
321 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 198 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
322 | 199 | ||
323 | jffs2_dbg(2, "%s()\n", __func__); | 200 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); |
201 | |||
202 | if (sb->s_dirt) | ||
203 | jffs2_write_super(sb); | ||
324 | 204 | ||
325 | mutex_lock(&c->alloc_sem); | 205 | mutex_lock(&c->alloc_sem); |
326 | jffs2_flush_wbuf_pad(c); | 206 | jffs2_flush_wbuf_pad(c); |
@@ -337,8 +217,10 @@ static void jffs2_put_super (struct super_block *sb) | |||
337 | jffs2_flash_cleanup(c); | 217 | jffs2_flash_cleanup(c); |
338 | kfree(c->inocache_list); | 218 | kfree(c->inocache_list); |
339 | jffs2_clear_xattr_subsystem(c); | 219 | jffs2_clear_xattr_subsystem(c); |
340 | mtd_sync(c->mtd); | 220 | if (c->mtd->sync) |
341 | jffs2_dbg(1, "%s(): returning\n", __func__); | 221 | c->mtd->sync(c->mtd); |
222 | |||
223 | D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); | ||
342 | } | 224 | } |
343 | 225 | ||
344 | static void jffs2_kill_sb(struct super_block *sb) | 226 | static void jffs2_kill_sb(struct super_block *sb) |
@@ -373,7 +255,7 @@ static int __init init_jffs2_fs(void) | |||
373 | BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68); | 255 | BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68); |
374 | BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32); | 256 | BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32); |
375 | 257 | ||
376 | pr_info("version 2.2." | 258 | printk(KERN_INFO "JFFS2 version 2.2." |
377 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 259 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
378 | " (NAND)" | 260 | " (NAND)" |
379 | #endif | 261 | #endif |
@@ -388,22 +270,22 @@ static int __init init_jffs2_fs(void) | |||
388 | SLAB_MEM_SPREAD), | 270 | SLAB_MEM_SPREAD), |
389 | jffs2_i_init_once); | 271 | jffs2_i_init_once); |
390 | if (!jffs2_inode_cachep) { | 272 | if (!jffs2_inode_cachep) { |
391 | pr_err("error: Failed to initialise inode cache\n"); | 273 | printk(KERN_ERR "JFFS2 error: Failed to initialise inode cache\n"); |
392 | return -ENOMEM; | 274 | return -ENOMEM; |
393 | } | 275 | } |
394 | ret = jffs2_compressors_init(); | 276 | ret = jffs2_compressors_init(); |
395 | if (ret) { | 277 | if (ret) { |
396 | pr_err("error: Failed to initialise compressors\n"); | 278 | printk(KERN_ERR "JFFS2 error: Failed to initialise compressors\n"); |
397 | goto out; | 279 | goto out; |
398 | } | 280 | } |
399 | ret = jffs2_create_slab_caches(); | 281 | ret = jffs2_create_slab_caches(); |
400 | if (ret) { | 282 | if (ret) { |
401 | pr_err("error: Failed to initialise slab caches\n"); | 283 | printk(KERN_ERR "JFFS2 error: Failed to initialise slab caches\n"); |
402 | goto out_compressors; | 284 | goto out_compressors; |
403 | } | 285 | } |
404 | ret = register_filesystem(&jffs2_fs_type); | 286 | ret = register_filesystem(&jffs2_fs_type); |
405 | if (ret) { | 287 | if (ret) { |
406 | pr_err("error: Failed to register filesystem\n"); | 288 | printk(KERN_ERR "JFFS2 error: Failed to register filesystem\n"); |
407 | goto out_slab; | 289 | goto out_slab; |
408 | } | 290 | } |
409 | return 0; | 291 | return 0; |
@@ -422,12 +304,6 @@ static void __exit exit_jffs2_fs(void) | |||
422 | unregister_filesystem(&jffs2_fs_type); | 304 | unregister_filesystem(&jffs2_fs_type); |
423 | jffs2_destroy_slab_caches(); | 305 | jffs2_destroy_slab_caches(); |
424 | jffs2_compressors_exit(); | 306 | jffs2_compressors_exit(); |
425 | |||
426 | /* | ||
427 | * Make sure all delayed rcu free inodes are flushed before we | ||
428 | * destroy cache. | ||
429 | */ | ||
430 | rcu_barrier(); | ||
431 | kmem_cache_destroy(jffs2_inode_cachep); | 307 | kmem_cache_destroy(jffs2_inode_cachep); |
432 | } | 308 | } |
433 | 309 | ||
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c index 6e563332bb2..e3035afb181 100644 --- a/fs/jffs2/symlink.c +++ b/fs/jffs2/symlink.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
16 | #include <linux/namei.h> | 14 | #include <linux/namei.h> |
@@ -49,11 +47,10 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
49 | */ | 47 | */ |
50 | 48 | ||
51 | if (!p) { | 49 | if (!p) { |
52 | pr_err("%s(): can't find symlink target\n", __func__); | 50 | printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n"); |
53 | p = ERR_PTR(-EIO); | 51 | p = ERR_PTR(-EIO); |
54 | } | 52 | } |
55 | jffs2_dbg(1, "%s(): target path is '%s'\n", | 53 | D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); |
56 | __func__, (char *)f->target); | ||
57 | 54 | ||
58 | nd_set_link(nd, p); | 55 | nd_set_link(nd, p); |
59 | 56 | ||
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index a6597d60d76..4515bea0268 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -11,8 +11,6 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
16 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
17 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
18 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
@@ -20,7 +18,6 @@ | |||
20 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/nand.h> |
21 | #include <linux/jiffies.h> | 19 | #include <linux/jiffies.h> |
22 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
23 | #include <linux/writeback.h> | ||
24 | 21 | ||
25 | #include "nodelist.h" | 22 | #include "nodelist.h" |
26 | 23 | ||
@@ -86,7 +83,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino) | |||
86 | { | 83 | { |
87 | struct jffs2_inodirty *new; | 84 | struct jffs2_inodirty *new; |
88 | 85 | ||
89 | /* Schedule delayed write-buffer write-out */ | 86 | /* Mark the superblock dirty so that kupdated will flush... */ |
90 | jffs2_dirty_trigger(c); | 87 | jffs2_dirty_trigger(c); |
91 | 88 | ||
92 | if (jffs2_wbuf_pending_for_ino(c, ino)) | 89 | if (jffs2_wbuf_pending_for_ino(c, ino)) |
@@ -94,7 +91,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino) | |||
94 | 91 | ||
95 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 92 | new = kmalloc(sizeof(*new), GFP_KERNEL); |
96 | if (!new) { | 93 | if (!new) { |
97 | jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n"); | 94 | D1(printk(KERN_DEBUG "No memory to allocate inodirty. Fallback to all considered dirty\n")); |
98 | jffs2_clear_wbuf_ino_list(c); | 95 | jffs2_clear_wbuf_ino_list(c); |
99 | c->wbuf_inodes = &inodirty_nomem; | 96 | c->wbuf_inodes = &inodirty_nomem; |
100 | return; | 97 | return; |
@@ -116,20 +113,19 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
116 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { | 113 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { |
117 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 114 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
118 | 115 | ||
119 | jffs2_dbg(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", | 116 | D1(printk(KERN_DEBUG "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset)); |
120 | jeb->offset); | ||
121 | list_del(this); | 117 | list_del(this); |
122 | if ((jiffies + (n++)) & 127) { | 118 | if ((jiffies + (n++)) & 127) { |
123 | /* Most of the time, we just erase it immediately. Otherwise we | 119 | /* Most of the time, we just erase it immediately. Otherwise we |
124 | spend ages scanning it on mount, etc. */ | 120 | spend ages scanning it on mount, etc. */ |
125 | jffs2_dbg(1, "...and adding to erase_pending_list\n"); | 121 | D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); |
126 | list_add_tail(&jeb->list, &c->erase_pending_list); | 122 | list_add_tail(&jeb->list, &c->erase_pending_list); |
127 | c->nr_erasing_blocks++; | 123 | c->nr_erasing_blocks++; |
128 | jffs2_garbage_collect_trigger(c); | 124 | jffs2_garbage_collect_trigger(c); |
129 | } else { | 125 | } else { |
130 | /* Sometimes, however, we leave it elsewhere so it doesn't get | 126 | /* Sometimes, however, we leave it elsewhere so it doesn't get |
131 | immediately reused, and we spread the load a bit. */ | 127 | immediately reused, and we spread the load a bit. */ |
132 | jffs2_dbg(1, "...and adding to erasable_list\n"); | 128 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); |
133 | list_add_tail(&jeb->list, &c->erasable_list); | 129 | list_add_tail(&jeb->list, &c->erasable_list); |
134 | } | 130 | } |
135 | } | 131 | } |
@@ -140,7 +136,7 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
140 | 136 | ||
141 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) | 137 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) |
142 | { | 138 | { |
143 | jffs2_dbg(1, "About to refile bad block at %08x\n", jeb->offset); | 139 | D1(printk("About to refile bad block at %08x\n", jeb->offset)); |
144 | 140 | ||
145 | /* File the existing block on the bad_used_list.... */ | 141 | /* File the existing block on the bad_used_list.... */ |
146 | if (c->nextblock == jeb) | 142 | if (c->nextblock == jeb) |
@@ -148,14 +144,12 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
148 | else /* Not sure this should ever happen... need more coffee */ | 144 | else /* Not sure this should ever happen... need more coffee */ |
149 | list_del(&jeb->list); | 145 | list_del(&jeb->list); |
150 | if (jeb->first_node) { | 146 | if (jeb->first_node) { |
151 | jffs2_dbg(1, "Refiling block at %08x to bad_used_list\n", | 147 | D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); |
152 | jeb->offset); | ||
153 | list_add(&jeb->list, &c->bad_used_list); | 148 | list_add(&jeb->list, &c->bad_used_list); |
154 | } else { | 149 | } else { |
155 | BUG_ON(allow_empty == REFILE_NOTEMPTY); | 150 | BUG_ON(allow_empty == REFILE_NOTEMPTY); |
156 | /* It has to have had some nodes or we couldn't be here */ | 151 | /* It has to have had some nodes or we couldn't be here */ |
157 | jffs2_dbg(1, "Refiling block at %08x to erase_pending_list\n", | 152 | D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); |
158 | jeb->offset); | ||
159 | list_add(&jeb->list, &c->erase_pending_list); | 153 | list_add(&jeb->list, &c->erase_pending_list); |
160 | c->nr_erasing_blocks++; | 154 | c->nr_erasing_blocks++; |
161 | jffs2_garbage_collect_trigger(c); | 155 | jffs2_garbage_collect_trigger(c); |
@@ -234,14 +228,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
234 | size_t retlen; | 228 | size_t retlen; |
235 | char *eccstr; | 229 | char *eccstr; |
236 | 230 | ||
237 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); | 231 | ret = c->mtd->read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); |
238 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { | 232 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { |
239 | pr_warn("%s(): Read back of page at %08x failed: %d\n", | 233 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); |
240 | __func__, c->wbuf_ofs, ret); | ||
241 | return ret; | 234 | return ret; |
242 | } else if (retlen != c->wbuf_pagesize) { | 235 | } else if (retlen != c->wbuf_pagesize) { |
243 | pr_warn("%s(): Read back of page at %08x gave short read: %zd not %d\n", | 236 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x gave short read: %zd not %d.\n", ofs, retlen, c->wbuf_pagesize); |
244 | __func__, ofs, retlen, c->wbuf_pagesize); | ||
245 | return -EIO; | 237 | return -EIO; |
246 | } | 238 | } |
247 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) | 239 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) |
@@ -254,12 +246,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
254 | else | 246 | else |
255 | eccstr = "OK or unused"; | 247 | eccstr = "OK or unused"; |
256 | 248 | ||
257 | pr_warn("Write verify error (ECC %s) at %08x. Wrote:\n", | 249 | printk(KERN_WARNING "Write verify error (ECC %s) at %08x. Wrote:\n", |
258 | eccstr, c->wbuf_ofs); | 250 | eccstr, c->wbuf_ofs); |
259 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 251 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
260 | c->wbuf, c->wbuf_pagesize, 0); | 252 | c->wbuf, c->wbuf_pagesize, 0); |
261 | 253 | ||
262 | pr_warn("Read back:\n"); | 254 | printk(KERN_WARNING "Read back:\n"); |
263 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 255 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
264 | c->wbuf_verify, c->wbuf_pagesize, 0); | 256 | c->wbuf_verify, c->wbuf_pagesize, 0); |
265 | 257 | ||
@@ -316,7 +308,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
316 | 308 | ||
317 | if (!first_raw) { | 309 | if (!first_raw) { |
318 | /* All nodes were obsolete. Nothing to recover. */ | 310 | /* All nodes were obsolete. Nothing to recover. */ |
319 | jffs2_dbg(1, "No non-obsolete nodes to be recovered. Just filing block bad\n"); | 311 | D1(printk(KERN_DEBUG "No non-obsolete nodes to be recovered. Just filing block bad\n")); |
320 | c->wbuf_len = 0; | 312 | c->wbuf_len = 0; |
321 | return; | 313 | return; |
322 | } | 314 | } |
@@ -339,14 +331,13 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
339 | 331 | ||
340 | buf = kmalloc(end - start, GFP_KERNEL); | 332 | buf = kmalloc(end - start, GFP_KERNEL); |
341 | if (!buf) { | 333 | if (!buf) { |
342 | pr_crit("Malloc failure in wbuf recovery. Data loss ensues.\n"); | 334 | printk(KERN_CRIT "Malloc failure in wbuf recovery. Data loss ensues.\n"); |
343 | 335 | ||
344 | goto read_failed; | 336 | goto read_failed; |
345 | } | 337 | } |
346 | 338 | ||
347 | /* Do the read... */ | 339 | /* Do the read... */ |
348 | ret = mtd_read(c->mtd, start, c->wbuf_ofs - start, &retlen, | 340 | ret = c->mtd->read(c->mtd, start, c->wbuf_ofs - start, &retlen, buf); |
349 | buf); | ||
350 | 341 | ||
351 | /* ECC recovered ? */ | 342 | /* ECC recovered ? */ |
352 | if ((ret == -EUCLEAN || ret == -EBADMSG) && | 343 | if ((ret == -EUCLEAN || ret == -EBADMSG) && |
@@ -354,7 +345,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
354 | ret = 0; | 345 | ret = 0; |
355 | 346 | ||
356 | if (ret || retlen != c->wbuf_ofs - start) { | 347 | if (ret || retlen != c->wbuf_ofs - start) { |
357 | pr_crit("Old data are already lost in wbuf recovery. Data loss ensues.\n"); | 348 | printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n"); |
358 | 349 | ||
359 | kfree(buf); | 350 | kfree(buf); |
360 | buf = NULL; | 351 | buf = NULL; |
@@ -388,7 +379,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
388 | /* ... and get an allocation of space from a shiny new block instead */ | 379 | /* ... and get an allocation of space from a shiny new block instead */ |
389 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); | 380 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); |
390 | if (ret) { | 381 | if (ret) { |
391 | pr_warn("Failed to allocate space for wbuf recovery. Data loss ensues.\n"); | 382 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); |
392 | kfree(buf); | 383 | kfree(buf); |
393 | return; | 384 | return; |
394 | } | 385 | } |
@@ -398,7 +389,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
398 | 389 | ||
399 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); | 390 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); |
400 | if (ret) { | 391 | if (ret) { |
401 | pr_warn("Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); | 392 | printk(KERN_WARNING "Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); |
402 | kfree(buf); | 393 | kfree(buf); |
403 | return; | 394 | return; |
404 | } | 395 | } |
@@ -414,24 +405,25 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
414 | unsigned char *rewrite_buf = buf?:c->wbuf; | 405 | unsigned char *rewrite_buf = buf?:c->wbuf; |
415 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 406 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
416 | 407 | ||
417 | jffs2_dbg(1, "Write 0x%x bytes at 0x%08x in wbuf recover\n", | 408 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", |
418 | towrite, ofs); | 409 | towrite, ofs)); |
419 | 410 | ||
420 | #ifdef BREAKMEHEADER | 411 | #ifdef BREAKMEHEADER |
421 | static int breakme; | 412 | static int breakme; |
422 | if (breakme++ == 20) { | 413 | if (breakme++ == 20) { |
423 | pr_notice("Faking write error at 0x%08x\n", ofs); | 414 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", ofs); |
424 | breakme = 0; | 415 | breakme = 0; |
425 | mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); | 416 | c->mtd->write(c->mtd, ofs, towrite, &retlen, |
417 | brokenbuf); | ||
426 | ret = -EIO; | 418 | ret = -EIO; |
427 | } else | 419 | } else |
428 | #endif | 420 | #endif |
429 | ret = mtd_write(c->mtd, ofs, towrite, &retlen, | 421 | ret = c->mtd->write(c->mtd, ofs, towrite, &retlen, |
430 | rewrite_buf); | 422 | rewrite_buf); |
431 | 423 | ||
432 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { | 424 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { |
433 | /* Argh. We tried. Really we did. */ | 425 | /* Argh. We tried. Really we did. */ |
434 | pr_crit("Recovery of wbuf failed due to a second write error\n"); | 426 | printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); |
435 | kfree(buf); | 427 | kfree(buf); |
436 | 428 | ||
437 | if (retlen) | 429 | if (retlen) |
@@ -439,7 +431,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
439 | 431 | ||
440 | return; | 432 | return; |
441 | } | 433 | } |
442 | pr_notice("Recovery of wbuf succeeded to %08x\n", ofs); | 434 | printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs); |
443 | 435 | ||
444 | c->wbuf_len = (end - start) - towrite; | 436 | c->wbuf_len = (end - start) - towrite; |
445 | c->wbuf_ofs = ofs + towrite; | 437 | c->wbuf_ofs = ofs + towrite; |
@@ -467,8 +459,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
467 | struct jffs2_raw_node_ref **adjust_ref = NULL; | 459 | struct jffs2_raw_node_ref **adjust_ref = NULL; |
468 | struct jffs2_inode_info *f = NULL; | 460 | struct jffs2_inode_info *f = NULL; |
469 | 461 | ||
470 | jffs2_dbg(1, "Refiling block of %08x at %08x(%d) to %08x\n", | 462 | D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n", |
471 | rawlen, ref_offset(raw), ref_flags(raw), ofs); | 463 | rawlen, ref_offset(raw), ref_flags(raw), ofs)); |
472 | 464 | ||
473 | ic = jffs2_raw_ref_to_ic(raw); | 465 | ic = jffs2_raw_ref_to_ic(raw); |
474 | 466 | ||
@@ -548,8 +540,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
548 | 540 | ||
549 | /* Fix up the original jeb now it's on the bad_list */ | 541 | /* Fix up the original jeb now it's on the bad_list */ |
550 | if (first_raw == jeb->first_node) { | 542 | if (first_raw == jeb->first_node) { |
551 | jffs2_dbg(1, "Failing block at %08x is now empty. Moving to erase_pending_list\n", | 543 | D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset)); |
552 | jeb->offset); | ||
553 | list_move(&jeb->list, &c->erase_pending_list); | 544 | list_move(&jeb->list, &c->erase_pending_list); |
554 | c->nr_erasing_blocks++; | 545 | c->nr_erasing_blocks++; |
555 | jffs2_garbage_collect_trigger(c); | 546 | jffs2_garbage_collect_trigger(c); |
@@ -563,8 +554,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
563 | 554 | ||
564 | spin_unlock(&c->erase_completion_lock); | 555 | spin_unlock(&c->erase_completion_lock); |
565 | 556 | ||
566 | jffs2_dbg(1, "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", | 557 | D1(printk(KERN_DEBUG "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", c->wbuf_ofs, c->wbuf_len)); |
567 | c->wbuf_ofs, c->wbuf_len); | ||
568 | 558 | ||
569 | } | 559 | } |
570 | 560 | ||
@@ -588,8 +578,9 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
588 | if (!jffs2_is_writebuffered(c)) | 578 | if (!jffs2_is_writebuffered(c)) |
589 | return 0; | 579 | return 0; |
590 | 580 | ||
591 | if (!mutex_is_locked(&c->alloc_sem)) { | 581 | if (mutex_trylock(&c->alloc_sem)) { |
592 | pr_crit("jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | 582 | mutex_unlock(&c->alloc_sem); |
583 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | ||
593 | BUG(); | 584 | BUG(); |
594 | } | 585 | } |
595 | 586 | ||
@@ -627,23 +618,22 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
627 | #ifdef BREAKME | 618 | #ifdef BREAKME |
628 | static int breakme; | 619 | static int breakme; |
629 | if (breakme++ == 20) { | 620 | if (breakme++ == 20) { |
630 | pr_notice("Faking write error at 0x%08x\n", c->wbuf_ofs); | 621 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", c->wbuf_ofs); |
631 | breakme = 0; | 622 | breakme = 0; |
632 | mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, | 623 | c->mtd->write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, |
633 | brokenbuf); | 624 | brokenbuf); |
634 | ret = -EIO; | 625 | ret = -EIO; |
635 | } else | 626 | } else |
636 | #endif | 627 | #endif |
637 | 628 | ||
638 | ret = mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, | 629 | ret = c->mtd->write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, c->wbuf); |
639 | &retlen, c->wbuf); | ||
640 | 630 | ||
641 | if (ret) { | 631 | if (ret) { |
642 | pr_warn("jffs2_flush_wbuf(): Write failed with %d\n", ret); | 632 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write failed with %d\n", ret); |
643 | goto wfail; | 633 | goto wfail; |
644 | } else if (retlen != c->wbuf_pagesize) { | 634 | } else if (retlen != c->wbuf_pagesize) { |
645 | pr_warn("jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", | 635 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", |
646 | retlen, c->wbuf_pagesize); | 636 | retlen, c->wbuf_pagesize); |
647 | ret = -EIO; | 637 | ret = -EIO; |
648 | goto wfail; | 638 | goto wfail; |
649 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { | 639 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { |
@@ -657,18 +647,17 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
657 | if (pad) { | 647 | if (pad) { |
658 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; | 648 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; |
659 | 649 | ||
660 | jffs2_dbg(1, "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", | 650 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", |
661 | (wbuf_jeb == c->nextblock) ? "next" : "", | 651 | (wbuf_jeb==c->nextblock)?"next":"", wbuf_jeb->offset)); |
662 | wbuf_jeb->offset); | ||
663 | 652 | ||
664 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be | 653 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be |
665 | padded. If there is less free space in the block than that, | 654 | padded. If there is less free space in the block than that, |
666 | something screwed up */ | 655 | something screwed up */ |
667 | if (wbuf_jeb->free_size < waste) { | 656 | if (wbuf_jeb->free_size < waste) { |
668 | pr_crit("jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", | 657 | printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", |
669 | c->wbuf_ofs, c->wbuf_len, waste); | 658 | c->wbuf_ofs, c->wbuf_len, waste); |
670 | pr_crit("jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", | 659 | printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", |
671 | wbuf_jeb->offset, wbuf_jeb->free_size); | 660 | wbuf_jeb->offset, wbuf_jeb->free_size); |
672 | BUG(); | 661 | BUG(); |
673 | } | 662 | } |
674 | 663 | ||
@@ -705,14 +694,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
705 | uint32_t old_wbuf_len; | 694 | uint32_t old_wbuf_len; |
706 | int ret = 0; | 695 | int ret = 0; |
707 | 696 | ||
708 | jffs2_dbg(1, "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino); | 697 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino)); |
709 | 698 | ||
710 | if (!c->wbuf) | 699 | if (!c->wbuf) |
711 | return 0; | 700 | return 0; |
712 | 701 | ||
713 | mutex_lock(&c->alloc_sem); | 702 | mutex_lock(&c->alloc_sem); |
714 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { | 703 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { |
715 | jffs2_dbg(1, "Ino #%d not pending in wbuf. Returning\n", ino); | 704 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); |
716 | mutex_unlock(&c->alloc_sem); | 705 | mutex_unlock(&c->alloc_sem); |
717 | return 0; | 706 | return 0; |
718 | } | 707 | } |
@@ -722,8 +711,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
722 | 711 | ||
723 | if (c->unchecked_size) { | 712 | if (c->unchecked_size) { |
724 | /* GC won't make any progress for a while */ | 713 | /* GC won't make any progress for a while */ |
725 | jffs2_dbg(1, "%s(): padding. Not finished checking\n", | 714 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() padding. Not finished checking\n")); |
726 | __func__); | ||
727 | down_write(&c->wbuf_sem); | 715 | down_write(&c->wbuf_sem); |
728 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 716 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
729 | /* retry flushing wbuf in case jffs2_wbuf_recover | 717 | /* retry flushing wbuf in case jffs2_wbuf_recover |
@@ -736,7 +724,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
736 | 724 | ||
737 | mutex_unlock(&c->alloc_sem); | 725 | mutex_unlock(&c->alloc_sem); |
738 | 726 | ||
739 | jffs2_dbg(1, "%s(): calls gc pass\n", __func__); | 727 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); |
740 | 728 | ||
741 | ret = jffs2_garbage_collect_pass(c); | 729 | ret = jffs2_garbage_collect_pass(c); |
742 | if (ret) { | 730 | if (ret) { |
@@ -754,7 +742,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
754 | mutex_lock(&c->alloc_sem); | 742 | mutex_lock(&c->alloc_sem); |
755 | } | 743 | } |
756 | 744 | ||
757 | jffs2_dbg(1, "%s(): ends...\n", __func__); | 745 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); |
758 | 746 | ||
759 | mutex_unlock(&c->alloc_sem); | 747 | mutex_unlock(&c->alloc_sem); |
760 | return ret; | 748 | return ret; |
@@ -823,8 +811,9 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
823 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { | 811 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { |
824 | /* It's a write to a new block */ | 812 | /* It's a write to a new block */ |
825 | if (c->wbuf_len) { | 813 | if (c->wbuf_len) { |
826 | jffs2_dbg(1, "%s(): to 0x%lx causes flush of wbuf at 0x%08x\n", | 814 | D1(printk(KERN_DEBUG "jffs2_flash_writev() to 0x%lx " |
827 | __func__, (unsigned long)to, c->wbuf_ofs); | 815 | "causes flush of wbuf at 0x%08x\n", |
816 | (unsigned long)to, c->wbuf_ofs)); | ||
828 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); | 817 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); |
829 | if (ret) | 818 | if (ret) |
830 | goto outerr; | 819 | goto outerr; |
@@ -836,11 +825,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
836 | 825 | ||
837 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { | 826 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { |
838 | /* We're not writing immediately after the writebuffer. Bad. */ | 827 | /* We're not writing immediately after the writebuffer. Bad. */ |
839 | pr_crit("%s(): Non-contiguous write to %08lx\n", | 828 | printk(KERN_CRIT "jffs2_flash_writev(): Non-contiguous write " |
840 | __func__, (unsigned long)to); | 829 | "to %08lx\n", (unsigned long)to); |
841 | if (c->wbuf_len) | 830 | if (c->wbuf_len) |
842 | pr_crit("wbuf was previously %08x-%08x\n", | 831 | printk(KERN_CRIT "wbuf was previously %08x-%08x\n", |
843 | c->wbuf_ofs, c->wbuf_ofs + c->wbuf_len); | 832 | c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len); |
844 | BUG(); | 833 | BUG(); |
845 | } | 834 | } |
846 | 835 | ||
@@ -873,8 +862,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
873 | v += wbuf_retlen; | 862 | v += wbuf_retlen; |
874 | 863 | ||
875 | if (vlen >= c->wbuf_pagesize) { | 864 | if (vlen >= c->wbuf_pagesize) { |
876 | ret = mtd_write(c->mtd, outvec_to, PAGE_DIV(vlen), | 865 | ret = c->mtd->write(c->mtd, outvec_to, PAGE_DIV(vlen), |
877 | &wbuf_retlen, v); | 866 | &wbuf_retlen, v); |
878 | if (ret < 0 || wbuf_retlen != PAGE_DIV(vlen)) | 867 | if (ret < 0 || wbuf_retlen != PAGE_DIV(vlen)) |
879 | goto outfile; | 868 | goto outfile; |
880 | 869 | ||
@@ -960,16 +949,16 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
960 | int ret; | 949 | int ret; |
961 | 950 | ||
962 | if (!jffs2_is_writebuffered(c)) | 951 | if (!jffs2_is_writebuffered(c)) |
963 | return mtd_read(c->mtd, ofs, len, retlen, buf); | 952 | return c->mtd->read(c->mtd, ofs, len, retlen, buf); |
964 | 953 | ||
965 | /* Read flash */ | 954 | /* Read flash */ |
966 | down_read(&c->wbuf_sem); | 955 | down_read(&c->wbuf_sem); |
967 | ret = mtd_read(c->mtd, ofs, len, retlen, buf); | 956 | ret = c->mtd->read(c->mtd, ofs, len, retlen, buf); |
968 | 957 | ||
969 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { | 958 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { |
970 | if (ret == -EBADMSG) | 959 | if (ret == -EBADMSG) |
971 | pr_warn("mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", | 960 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx)" |
972 | len, ofs); | 961 | " returned ECC error\n", len, ofs); |
973 | /* | 962 | /* |
974 | * We have the raw data without ECC correction in the buffer, | 963 | * We have the raw data without ECC correction in the buffer, |
975 | * maybe we are lucky and all data or parts are correct. We | 964 | * maybe we are lucky and all data or parts are correct. We |
@@ -1037,17 +1026,18 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1037 | int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); | 1026 | int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); |
1038 | struct mtd_oob_ops ops; | 1027 | struct mtd_oob_ops ops; |
1039 | 1028 | ||
1040 | ops.mode = MTD_OPS_AUTO_OOB; | 1029 | ops.mode = MTD_OOB_AUTO; |
1041 | ops.ooblen = NR_OOB_SCAN_PAGES * c->oobavail; | 1030 | ops.ooblen = NR_OOB_SCAN_PAGES * c->oobavail; |
1042 | ops.oobbuf = c->oobbuf; | 1031 | ops.oobbuf = c->oobbuf; |
1043 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; | 1032 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; |
1044 | ops.datbuf = NULL; | 1033 | ops.datbuf = NULL; |
1045 | 1034 | ||
1046 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1035 | ret = c->mtd->read_oob(c->mtd, jeb->offset, &ops); |
1047 | if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) { | 1036 | if (ret || ops.oobretlen != ops.ooblen) { |
1048 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", | 1037 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" |
1049 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | 1038 | " bytes, read %zd bytes, error %d\n", |
1050 | if (!ret || mtd_is_bitflip(ret)) | 1039 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1040 | if (!ret) | ||
1051 | ret = -EIO; | 1041 | ret = -EIO; |
1052 | return ret; | 1042 | return ret; |
1053 | } | 1043 | } |
@@ -1058,8 +1048,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1058 | continue; | 1048 | continue; |
1059 | 1049 | ||
1060 | if (ops.oobbuf[i] != 0xFF) { | 1050 | if (ops.oobbuf[i] != 0xFF) { |
1061 | jffs2_dbg(2, "Found %02x at %x in OOB for " | 1051 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for " |
1062 | "%08x\n", ops.oobbuf[i], i, jeb->offset); | 1052 | "%08x\n", ops.oobbuf[i], i, jeb->offset)); |
1063 | return 1; | 1053 | return 1; |
1064 | } | 1054 | } |
1065 | } | 1055 | } |
@@ -1079,17 +1069,18 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1079 | struct mtd_oob_ops ops; | 1069 | struct mtd_oob_ops ops; |
1080 | int ret, cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); | 1070 | int ret, cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); |
1081 | 1071 | ||
1082 | ops.mode = MTD_OPS_AUTO_OOB; | 1072 | ops.mode = MTD_OOB_AUTO; |
1083 | ops.ooblen = cmlen; | 1073 | ops.ooblen = cmlen; |
1084 | ops.oobbuf = c->oobbuf; | 1074 | ops.oobbuf = c->oobbuf; |
1085 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; | 1075 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; |
1086 | ops.datbuf = NULL; | 1076 | ops.datbuf = NULL; |
1087 | 1077 | ||
1088 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1078 | ret = c->mtd->read_oob(c->mtd, jeb->offset, &ops); |
1089 | if ((ret && !mtd_is_bitflip(ret)) || ops.oobretlen != ops.ooblen) { | 1079 | if (ret || ops.oobretlen != ops.ooblen) { |
1090 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", | 1080 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" |
1091 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | 1081 | " bytes, read %zd bytes, error %d\n", |
1092 | if (!ret || mtd_is_bitflip(ret)) | 1082 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1083 | if (!ret) | ||
1093 | ret = -EIO; | 1084 | ret = -EIO; |
1094 | return ret; | 1085 | return ret; |
1095 | } | 1086 | } |
@@ -1104,16 +1095,17 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1104 | struct mtd_oob_ops ops; | 1095 | struct mtd_oob_ops ops; |
1105 | int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); | 1096 | int cmlen = min_t(int, c->oobavail, OOB_CM_SIZE); |
1106 | 1097 | ||
1107 | ops.mode = MTD_OPS_AUTO_OOB; | 1098 | ops.mode = MTD_OOB_AUTO; |
1108 | ops.ooblen = cmlen; | 1099 | ops.ooblen = cmlen; |
1109 | ops.oobbuf = (uint8_t *)&oob_cleanmarker; | 1100 | ops.oobbuf = (uint8_t *)&oob_cleanmarker; |
1110 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; | 1101 | ops.len = ops.ooboffs = ops.retlen = ops.oobretlen = 0; |
1111 | ops.datbuf = NULL; | 1102 | ops.datbuf = NULL; |
1112 | 1103 | ||
1113 | ret = mtd_write_oob(c->mtd, jeb->offset, &ops); | 1104 | ret = c->mtd->write_oob(c->mtd, jeb->offset, &ops); |
1114 | if (ret || ops.oobretlen != ops.ooblen) { | 1105 | if (ret || ops.oobretlen != ops.ooblen) { |
1115 | pr_err("cannot write OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", | 1106 | printk(KERN_ERR "cannot write OOB for EB at %08x, requested %zd" |
1116 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | 1107 | " bytes, read %zd bytes, error %d\n", |
1108 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1117 | if (!ret) | 1109 | if (!ret) |
1118 | ret = -EIO; | 1110 | ret = -EIO; |
1119 | return ret; | 1111 | return ret; |
@@ -1138,58 +1130,19 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
1138 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) | 1130 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) |
1139 | return 0; | 1131 | return 0; |
1140 | 1132 | ||
1141 | pr_warn("marking eraseblock at %08x as bad\n", bad_offset); | 1133 | if (!c->mtd->block_markbad) |
1142 | ret = mtd_block_markbad(c->mtd, bad_offset); | 1134 | return 1; // What else can we do? |
1135 | |||
1136 | printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); | ||
1137 | ret = c->mtd->block_markbad(c->mtd, bad_offset); | ||
1143 | 1138 | ||
1144 | if (ret) { | 1139 | if (ret) { |
1145 | jffs2_dbg(1, "%s(): Write failed for block at %08x: error %d\n", | 1140 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); |
1146 | __func__, jeb->offset, ret); | ||
1147 | return ret; | 1141 | return ret; |
1148 | } | 1142 | } |
1149 | return 1; | 1143 | return 1; |
1150 | } | 1144 | } |
1151 | 1145 | ||
1152 | static struct jffs2_sb_info *work_to_sb(struct work_struct *work) | ||
1153 | { | ||
1154 | struct delayed_work *dwork; | ||
1155 | |||
1156 | dwork = container_of(work, struct delayed_work, work); | ||
1157 | return container_of(dwork, struct jffs2_sb_info, wbuf_dwork); | ||
1158 | } | ||
1159 | |||
1160 | static void delayed_wbuf_sync(struct work_struct *work) | ||
1161 | { | ||
1162 | struct jffs2_sb_info *c = work_to_sb(work); | ||
1163 | struct super_block *sb = OFNI_BS_2SFFJ(c); | ||
1164 | |||
1165 | spin_lock(&c->wbuf_dwork_lock); | ||
1166 | c->wbuf_queued = 0; | ||
1167 | spin_unlock(&c->wbuf_dwork_lock); | ||
1168 | |||
1169 | if (!(sb->s_flags & MS_RDONLY)) { | ||
1170 | jffs2_dbg(1, "%s()\n", __func__); | ||
1171 | jffs2_flush_wbuf_gc(c, 0); | ||
1172 | } | ||
1173 | } | ||
1174 | |||
1175 | void jffs2_dirty_trigger(struct jffs2_sb_info *c) | ||
1176 | { | ||
1177 | struct super_block *sb = OFNI_BS_2SFFJ(c); | ||
1178 | unsigned long delay; | ||
1179 | |||
1180 | if (sb->s_flags & MS_RDONLY) | ||
1181 | return; | ||
1182 | |||
1183 | spin_lock(&c->wbuf_dwork_lock); | ||
1184 | if (!c->wbuf_queued) { | ||
1185 | jffs2_dbg(1, "%s()\n", __func__); | ||
1186 | delay = msecs_to_jiffies(dirty_writeback_interval * 10); | ||
1187 | queue_delayed_work(system_long_wq, &c->wbuf_dwork, delay); | ||
1188 | c->wbuf_queued = 1; | ||
1189 | } | ||
1190 | spin_unlock(&c->wbuf_dwork_lock); | ||
1191 | } | ||
1192 | |||
1193 | int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | 1146 | int jffs2_nand_flash_setup(struct jffs2_sb_info *c) |
1194 | { | 1147 | { |
1195 | struct nand_ecclayout *oinfo = c->mtd->ecclayout; | 1148 | struct nand_ecclayout *oinfo = c->mtd->ecclayout; |
@@ -1201,18 +1154,16 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
1201 | c->cleanmarker_size = 0; | 1154 | c->cleanmarker_size = 0; |
1202 | 1155 | ||
1203 | if (!oinfo || oinfo->oobavail == 0) { | 1156 | if (!oinfo || oinfo->oobavail == 0) { |
1204 | pr_err("inconsistent device description\n"); | 1157 | printk(KERN_ERR "inconsistent device description\n"); |
1205 | return -EINVAL; | 1158 | return -EINVAL; |
1206 | } | 1159 | } |
1207 | 1160 | ||
1208 | jffs2_dbg(1, "using OOB on NAND\n"); | 1161 | D1(printk(KERN_DEBUG "JFFS2 using OOB on NAND\n")); |
1209 | 1162 | ||
1210 | c->oobavail = oinfo->oobavail; | 1163 | c->oobavail = oinfo->oobavail; |
1211 | 1164 | ||
1212 | /* Initialise write buffer */ | 1165 | /* Initialise write buffer */ |
1213 | init_rwsem(&c->wbuf_sem); | 1166 | init_rwsem(&c->wbuf_sem); |
1214 | spin_lock_init(&c->wbuf_dwork_lock); | ||
1215 | INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); | ||
1216 | c->wbuf_pagesize = c->mtd->writesize; | 1167 | c->wbuf_pagesize = c->mtd->writesize; |
1217 | c->wbuf_ofs = 0xFFFFFFFF; | 1168 | c->wbuf_ofs = 0xFFFFFFFF; |
1218 | 1169 | ||
@@ -1251,8 +1202,8 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1251 | 1202 | ||
1252 | /* Initialize write buffer */ | 1203 | /* Initialize write buffer */ |
1253 | init_rwsem(&c->wbuf_sem); | 1204 | init_rwsem(&c->wbuf_sem); |
1254 | spin_lock_init(&c->wbuf_dwork_lock); | 1205 | |
1255 | INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); | 1206 | |
1256 | c->wbuf_pagesize = c->mtd->erasesize; | 1207 | c->wbuf_pagesize = c->mtd->erasesize; |
1257 | 1208 | ||
1258 | /* Find a suitable c->sector_size | 1209 | /* Find a suitable c->sector_size |
@@ -1274,7 +1225,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1274 | 1225 | ||
1275 | if ((c->flash_size % c->sector_size) != 0) { | 1226 | if ((c->flash_size % c->sector_size) != 0) { |
1276 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; | 1227 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; |
1277 | pr_warn("flash size adjusted to %dKiB\n", c->flash_size); | 1228 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); |
1278 | }; | 1229 | }; |
1279 | 1230 | ||
1280 | c->wbuf_ofs = 0xFFFFFFFF; | 1231 | c->wbuf_ofs = 0xFFFFFFFF; |
@@ -1291,8 +1242,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1291 | } | 1242 | } |
1292 | #endif | 1243 | #endif |
1293 | 1244 | ||
1294 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", | 1245 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); |
1295 | c->wbuf_pagesize, c->sector_size); | ||
1296 | 1246 | ||
1297 | return 0; | 1247 | return 0; |
1298 | } | 1248 | } |
@@ -1311,9 +1261,6 @@ int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c) { | |||
1311 | 1261 | ||
1312 | /* Initialize write buffer */ | 1262 | /* Initialize write buffer */ |
1313 | init_rwsem(&c->wbuf_sem); | 1263 | init_rwsem(&c->wbuf_sem); |
1314 | spin_lock_init(&c->wbuf_dwork_lock); | ||
1315 | INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); | ||
1316 | |||
1317 | c->wbuf_pagesize = c->mtd->writesize; | 1264 | c->wbuf_pagesize = c->mtd->writesize; |
1318 | c->wbuf_ofs = 0xFFFFFFFF; | 1265 | c->wbuf_ofs = 0xFFFFFFFF; |
1319 | 1266 | ||
@@ -1346,8 +1293,6 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) { | |||
1346 | return 0; | 1293 | return 0; |
1347 | 1294 | ||
1348 | init_rwsem(&c->wbuf_sem); | 1295 | init_rwsem(&c->wbuf_sem); |
1349 | spin_lock_init(&c->wbuf_dwork_lock); | ||
1350 | INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); | ||
1351 | 1296 | ||
1352 | c->wbuf_pagesize = c->mtd->writesize; | 1297 | c->wbuf_pagesize = c->mtd->writesize; |
1353 | c->wbuf_ofs = 0xFFFFFFFF; | 1298 | c->wbuf_ofs = 0xFFFFFFFF; |
@@ -1355,8 +1300,7 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) { | |||
1355 | if (!c->wbuf) | 1300 | if (!c->wbuf) |
1356 | return -ENOMEM; | 1301 | return -ENOMEM; |
1357 | 1302 | ||
1358 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", | 1303 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); |
1359 | c->wbuf_pagesize, c->sector_size); | ||
1360 | 1304 | ||
1361 | return 0; | 1305 | return 0; |
1362 | } | 1306 | } |
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index b634de4c810..30d175b6d29 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -9,8 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
15 | #include <linux/fs.h> | 13 | #include <linux/fs.h> |
16 | #include <linux/crc32.h> | 14 | #include <linux/crc32.h> |
@@ -38,7 +36,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
38 | f->inocache->state = INO_STATE_PRESENT; | 36 | f->inocache->state = INO_STATE_PRESENT; |
39 | 37 | ||
40 | jffs2_add_ino_cache(c, f->inocache); | 38 | jffs2_add_ino_cache(c, f->inocache); |
41 | jffs2_dbg(1, "%s(): Assigned ino# %d\n", __func__, f->inocache->ino); | 39 | D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); |
42 | ri->ino = cpu_to_je32(f->inocache->ino); | 40 | ri->ino = cpu_to_je32(f->inocache->ino); |
43 | 41 | ||
44 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 42 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -70,7 +68,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
70 | unsigned long cnt = 2; | 68 | unsigned long cnt = 2; |
71 | 69 | ||
72 | D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs2_unknown_node)-4)) { | 70 | D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs2_unknown_node)-4)) { |
73 | pr_crit("Eep. CRC not correct in jffs2_write_dnode()\n"); | 71 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dnode()\n"); |
74 | BUG(); | 72 | BUG(); |
75 | } | 73 | } |
76 | ); | 74 | ); |
@@ -80,9 +78,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
80 | vecs[1].iov_len = datalen; | 78 | vecs[1].iov_len = datalen; |
81 | 79 | ||
82 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { | 80 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { |
83 | pr_warn("%s(): ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", | 81 | printk(KERN_WARNING "jffs2_write_dnode: ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", je32_to_cpu(ri->totlen), sizeof(*ri), datalen); |
84 | __func__, je32_to_cpu(ri->totlen), | ||
85 | sizeof(*ri), datalen); | ||
86 | } | 82 | } |
87 | 83 | ||
88 | fn = jffs2_alloc_full_dnode(); | 84 | fn = jffs2_alloc_full_dnode(); |
@@ -99,9 +95,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
99 | 95 | ||
100 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { | 96 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { |
101 | BUG_ON(!retried); | 97 | BUG_ON(!retried); |
102 | jffs2_dbg(1, "%s(): dnode_version %d, highest version %d -> updating dnode\n", | 98 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " |
103 | __func__, | 99 | "highest version %d -> updating dnode\n", |
104 | je32_to_cpu(ri->version), f->highest_version); | 100 | je32_to_cpu(ri->version), f->highest_version)); |
105 | ri->version = cpu_to_je32(++f->highest_version); | 101 | ri->version = cpu_to_je32(++f->highest_version); |
106 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 102 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
107 | } | 103 | } |
@@ -110,8 +106,8 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
110 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); | 106 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); |
111 | 107 | ||
112 | if (ret || (retlen != sizeof(*ri) + datalen)) { | 108 | if (ret || (retlen != sizeof(*ri) + datalen)) { |
113 | pr_notice("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 109 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
114 | sizeof(*ri) + datalen, flash_ofs, ret, retlen); | 110 | sizeof(*ri)+datalen, flash_ofs, ret, retlen); |
115 | 111 | ||
116 | /* Mark the space as dirtied */ | 112 | /* Mark the space as dirtied */ |
117 | if (retlen) { | 113 | if (retlen) { |
@@ -122,8 +118,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
122 | this node */ | 118 | this node */ |
123 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*ri)+datalen), NULL); | 119 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*ri)+datalen), NULL); |
124 | } else { | 120 | } else { |
125 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", | 121 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", flash_ofs); |
126 | flash_ofs); | ||
127 | } | 122 | } |
128 | if (!retried && alloc_mode != ALLOC_NORETRY) { | 123 | if (!retried && alloc_mode != ALLOC_NORETRY) { |
129 | /* Try to reallocate space and retry */ | 124 | /* Try to reallocate space and retry */ |
@@ -132,7 +127,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
132 | 127 | ||
133 | retried = 1; | 128 | retried = 1; |
134 | 129 | ||
135 | jffs2_dbg(1, "Retrying failed write.\n"); | 130 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); |
136 | 131 | ||
137 | jffs2_dbg_acct_sanity_check(c,jeb); | 132 | jffs2_dbg_acct_sanity_check(c,jeb); |
138 | jffs2_dbg_acct_paranoia_check(c, jeb); | 133 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -152,16 +147,14 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
152 | 147 | ||
153 | if (!ret) { | 148 | if (!ret) { |
154 | flash_ofs = write_ofs(c); | 149 | flash_ofs = write_ofs(c); |
155 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n", | 150 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); |
156 | flash_ofs); | ||
157 | 151 | ||
158 | jffs2_dbg_acct_sanity_check(c,jeb); | 152 | jffs2_dbg_acct_sanity_check(c,jeb); |
159 | jffs2_dbg_acct_paranoia_check(c, jeb); | 153 | jffs2_dbg_acct_paranoia_check(c, jeb); |
160 | 154 | ||
161 | goto retry; | 155 | goto retry; |
162 | } | 156 | } |
163 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", | 157 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); |
164 | ret); | ||
165 | } | 158 | } |
166 | /* Release the full_dnode which is now useless, and return */ | 159 | /* Release the full_dnode which is now useless, and return */ |
167 | jffs2_free_full_dnode(fn); | 160 | jffs2_free_full_dnode(fn); |
@@ -190,10 +183,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
190 | fn->size = je32_to_cpu(ri->dsize); | 183 | fn->size = je32_to_cpu(ri->dsize); |
191 | fn->frags = 0; | 184 | fn->frags = 0; |
192 | 185 | ||
193 | jffs2_dbg(1, "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", | 186 | D1(printk(KERN_DEBUG "jffs2_write_dnode wrote node at 0x%08x(%d) with dsize 0x%x, csize 0x%x, node_crc 0x%08x, data_crc 0x%08x, totlen 0x%08x\n", |
194 | flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), | 187 | flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), |
195 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), | 188 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), |
196 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen)); | 189 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); |
197 | 190 | ||
198 | if (retried) { | 191 | if (retried) { |
199 | jffs2_dbg_acct_sanity_check(c,NULL); | 192 | jffs2_dbg_acct_sanity_check(c,NULL); |
@@ -213,23 +206,22 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
213 | int retried = 0; | 206 | int retried = 0; |
214 | int ret; | 207 | int ret; |
215 | 208 | ||
216 | jffs2_dbg(1, "%s(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", | 209 | D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", |
217 | __func__, | ||
218 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), | 210 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), |
219 | je32_to_cpu(rd->name_crc)); | 211 | je32_to_cpu(rd->name_crc))); |
220 | 212 | ||
221 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { | 213 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { |
222 | pr_crit("Eep. CRC not correct in jffs2_write_dirent()\n"); | 214 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); |
223 | BUG(); | 215 | BUG(); |
224 | }); | 216 | }); |
225 | 217 | ||
226 | if (strnlen(name, namelen) != namelen) { | 218 | if (strnlen(name, namelen) != namelen) { |
227 | /* This should never happen, but seems to have done on at least one | 219 | /* This should never happen, but seems to have done on at least one |
228 | occasion: https://dev.laptop.org/ticket/4184 */ | 220 | occasion: https://dev.laptop.org/ticket/4184 */ |
229 | pr_crit("Error in jffs2_write_dirent() -- name contains zero bytes!\n"); | 221 | printk(KERN_CRIT "Error in jffs2_write_dirent() -- name contains zero bytes!\n"); |
230 | pr_crit("Directory inode #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x\n", | 222 | printk(KERN_CRIT "Directory inode #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x\n", |
231 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), | 223 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), |
232 | je32_to_cpu(rd->name_crc)); | 224 | je32_to_cpu(rd->name_crc)); |
233 | WARN_ON(1); | 225 | WARN_ON(1); |
234 | return ERR_PTR(-EIO); | 226 | return ERR_PTR(-EIO); |
235 | } | 227 | } |
@@ -257,9 +249,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
257 | 249 | ||
258 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { | 250 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { |
259 | BUG_ON(!retried); | 251 | BUG_ON(!retried); |
260 | jffs2_dbg(1, "%s(): dirent_version %d, highest version %d -> updating dirent\n", | 252 | D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " |
261 | __func__, | 253 | "highest version %d -> updating dirent\n", |
262 | je32_to_cpu(rd->version), f->highest_version); | 254 | je32_to_cpu(rd->version), f->highest_version)); |
263 | rd->version = cpu_to_je32(++f->highest_version); | 255 | rd->version = cpu_to_je32(++f->highest_version); |
264 | fd->version = je32_to_cpu(rd->version); | 256 | fd->version = je32_to_cpu(rd->version); |
265 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); | 257 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); |
@@ -268,14 +260,13 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
268 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, | 260 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, |
269 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); | 261 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); |
270 | if (ret || (retlen != sizeof(*rd) + namelen)) { | 262 | if (ret || (retlen != sizeof(*rd) + namelen)) { |
271 | pr_notice("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 263 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
272 | sizeof(*rd) + namelen, flash_ofs, ret, retlen); | 264 | sizeof(*rd)+namelen, flash_ofs, ret, retlen); |
273 | /* Mark the space as dirtied */ | 265 | /* Mark the space as dirtied */ |
274 | if (retlen) { | 266 | if (retlen) { |
275 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*rd)+namelen), NULL); | 267 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*rd)+namelen), NULL); |
276 | } else { | 268 | } else { |
277 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", | 269 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", flash_ofs); |
278 | flash_ofs); | ||
279 | } | 270 | } |
280 | if (!retried) { | 271 | if (!retried) { |
281 | /* Try to reallocate space and retry */ | 272 | /* Try to reallocate space and retry */ |
@@ -284,7 +275,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
284 | 275 | ||
285 | retried = 1; | 276 | retried = 1; |
286 | 277 | ||
287 | jffs2_dbg(1, "Retrying failed write.\n"); | 278 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); |
288 | 279 | ||
289 | jffs2_dbg_acct_sanity_check(c,jeb); | 280 | jffs2_dbg_acct_sanity_check(c,jeb); |
290 | jffs2_dbg_acct_paranoia_check(c, jeb); | 281 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -304,14 +295,12 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
304 | 295 | ||
305 | if (!ret) { | 296 | if (!ret) { |
306 | flash_ofs = write_ofs(c); | 297 | flash_ofs = write_ofs(c); |
307 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write\n", | 298 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); |
308 | flash_ofs); | ||
309 | jffs2_dbg_acct_sanity_check(c,jeb); | 299 | jffs2_dbg_acct_sanity_check(c,jeb); |
310 | jffs2_dbg_acct_paranoia_check(c, jeb); | 300 | jffs2_dbg_acct_paranoia_check(c, jeb); |
311 | goto retry; | 301 | goto retry; |
312 | } | 302 | } |
313 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", | 303 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); |
314 | ret); | ||
315 | } | 304 | } |
316 | /* Release the full_dnode which is now useless, and return */ | 305 | /* Release the full_dnode which is now useless, and return */ |
317 | jffs2_free_full_dirent(fd); | 306 | jffs2_free_full_dirent(fd); |
@@ -344,8 +333,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
344 | int ret = 0; | 333 | int ret = 0; |
345 | uint32_t writtenlen = 0; | 334 | uint32_t writtenlen = 0; |
346 | 335 | ||
347 | jffs2_dbg(1, "%s(): Ino #%u, ofs 0x%x, len 0x%x\n", | 336 | D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", |
348 | __func__, f->inocache->ino, offset, writelen); | 337 | f->inocache->ino, offset, writelen)); |
349 | 338 | ||
350 | while(writelen) { | 339 | while(writelen) { |
351 | struct jffs2_full_dnode *fn; | 340 | struct jffs2_full_dnode *fn; |
@@ -356,13 +345,12 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
356 | int retried = 0; | 345 | int retried = 0; |
357 | 346 | ||
358 | retry: | 347 | retry: |
359 | jffs2_dbg(2, "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", | 348 | D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); |
360 | writelen, offset); | ||
361 | 349 | ||
362 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, | 350 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, |
363 | &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | 351 | &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); |
364 | if (ret) { | 352 | if (ret) { |
365 | jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret); | 353 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); |
366 | break; | 354 | break; |
367 | } | 355 | } |
368 | mutex_lock(&f->sem); | 356 | mutex_lock(&f->sem); |
@@ -398,7 +386,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
398 | if (!retried) { | 386 | if (!retried) { |
399 | /* Write error to be retried */ | 387 | /* Write error to be retried */ |
400 | retried = 1; | 388 | retried = 1; |
401 | jffs2_dbg(1, "Retrying node write in jffs2_write_inode_range()\n"); | 389 | D1(printk(KERN_DEBUG "Retrying node write in jffs2_write_inode_range()\n")); |
402 | goto retry; | 390 | goto retry; |
403 | } | 391 | } |
404 | break; | 392 | break; |
@@ -411,8 +399,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
411 | } | 399 | } |
412 | if (ret) { | 400 | if (ret) { |
413 | /* Eep */ | 401 | /* Eep */ |
414 | jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", | 402 | D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", ret)); |
415 | ret); | ||
416 | jffs2_mark_node_obsolete(c, fn->raw); | 403 | jffs2_mark_node_obsolete(c, fn->raw); |
417 | jffs2_free_full_dnode(fn); | 404 | jffs2_free_full_dnode(fn); |
418 | 405 | ||
@@ -423,11 +410,11 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
423 | mutex_unlock(&f->sem); | 410 | mutex_unlock(&f->sem); |
424 | jffs2_complete_reservation(c); | 411 | jffs2_complete_reservation(c); |
425 | if (!datalen) { | 412 | if (!datalen) { |
426 | pr_warn("Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); | 413 | printk(KERN_WARNING "Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); |
427 | ret = -EIO; | 414 | ret = -EIO; |
428 | break; | 415 | break; |
429 | } | 416 | } |
430 | jffs2_dbg(1, "increasing writtenlen by %d\n", datalen); | 417 | D1(printk(KERN_DEBUG "increasing writtenlen by %d\n", datalen)); |
431 | writtenlen += datalen; | 418 | writtenlen += datalen; |
432 | offset += datalen; | 419 | offset += datalen; |
433 | writelen -= datalen; | 420 | writelen -= datalen; |
@@ -452,7 +439,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
452 | */ | 439 | */ |
453 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, | 440 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, |
454 | JFFS2_SUMMARY_INODE_SIZE); | 441 | JFFS2_SUMMARY_INODE_SIZE); |
455 | jffs2_dbg(1, "%s(): reserved 0x%x bytes\n", __func__, alloclen); | 442 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); |
456 | if (ret) | 443 | if (ret) |
457 | return ret; | 444 | return ret; |
458 | 445 | ||
@@ -463,11 +450,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
463 | 450 | ||
464 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); | 451 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); |
465 | 452 | ||
466 | jffs2_dbg(1, "jffs2_do_create created file with mode 0x%x\n", | 453 | D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n", |
467 | jemode_to_cpu(ri->mode)); | 454 | jemode_to_cpu(ri->mode))); |
468 | 455 | ||
469 | if (IS_ERR(fn)) { | 456 | if (IS_ERR(fn)) { |
470 | jffs2_dbg(1, "jffs2_write_dnode() failed\n"); | 457 | D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); |
471 | /* Eeek. Wave bye bye */ | 458 | /* Eeek. Wave bye bye */ |
472 | mutex_unlock(&f->sem); | 459 | mutex_unlock(&f->sem); |
473 | jffs2_complete_reservation(c); | 460 | jffs2_complete_reservation(c); |
@@ -493,7 +480,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
493 | 480 | ||
494 | if (ret) { | 481 | if (ret) { |
495 | /* Eep. */ | 482 | /* Eep. */ |
496 | jffs2_dbg(1, "jffs2_reserve_space() for dirent failed\n"); | 483 | D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); |
497 | return ret; | 484 | return ret; |
498 | } | 485 | } |
499 | 486 | ||
@@ -610,8 +597,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
610 | !memcmp(fd->name, name, namelen) && | 597 | !memcmp(fd->name, name, namelen) && |
611 | !fd->name[namelen]) { | 598 | !fd->name[namelen]) { |
612 | 599 | ||
613 | jffs2_dbg(1, "Marking old dirent node (ino #%u) @%08x obsolete\n", | 600 | D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", |
614 | fd->ino, ref_offset(fd->raw)); | 601 | fd->ino, ref_offset(fd->raw))); |
615 | jffs2_mark_node_obsolete(c, fd->raw); | 602 | jffs2_mark_node_obsolete(c, fd->raw); |
616 | /* We don't want to remove it from the list immediately, | 603 | /* We don't want to remove it from the list immediately, |
617 | because that screws up getdents()/seek() semantics even | 604 | because that screws up getdents()/seek() semantics even |
@@ -640,13 +627,11 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
640 | dead_f->dents = fd->next; | 627 | dead_f->dents = fd->next; |
641 | 628 | ||
642 | if (fd->ino) { | 629 | if (fd->ino) { |
643 | pr_warn("Deleting inode #%u with active dentry \"%s\"->ino #%u\n", | 630 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", |
644 | dead_f->inocache->ino, | 631 | dead_f->inocache->ino, fd->name, fd->ino); |
645 | fd->name, fd->ino); | ||
646 | } else { | 632 | } else { |
647 | jffs2_dbg(1, "Removing deletion dirent for \"%s\" from dir ino #%u\n", | 633 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", |
648 | fd->name, | 634 | fd->name, dead_f->inocache->ino)); |
649 | dead_f->inocache->ino); | ||
650 | } | 635 | } |
651 | if (fd->raw) | 636 | if (fd->raw) |
652 | jffs2_mark_node_obsolete(c, fd->raw); | 637 | jffs2_mark_node_obsolete(c, fd->raw); |
diff --git a/fs/jffs2/writev.c b/fs/jffs2/writev.c index a1bda9dab3f..b9276b11bac 100644 --- a/fs/jffs2/writev.c +++ b/fs/jffs2/writev.c | |||
@@ -13,6 +13,30 @@ | |||
13 | #include <linux/mtd/mtd.h> | 13 | #include <linux/mtd/mtd.h> |
14 | #include "nodelist.h" | 14 | #include "nodelist.h" |
15 | 15 | ||
16 | /* This ought to be in core MTD code. All registered MTD devices | ||
17 | without writev should have this put in place. Bug the MTD | ||
18 | maintainer */ | ||
19 | static inline int mtd_fake_writev(struct mtd_info *mtd, const struct kvec *vecs, | ||
20 | unsigned long count, loff_t to, size_t *retlen) | ||
21 | { | ||
22 | unsigned long i; | ||
23 | size_t totlen = 0, thislen; | ||
24 | int ret = 0; | ||
25 | |||
26 | for (i=0; i<count; i++) { | ||
27 | if (!vecs[i].iov_len) | ||
28 | continue; | ||
29 | ret = mtd->write(mtd, to, vecs[i].iov_len, &thislen, vecs[i].iov_base); | ||
30 | totlen += thislen; | ||
31 | if (ret || thislen != vecs[i].iov_len) | ||
32 | break; | ||
33 | to += vecs[i].iov_len; | ||
34 | } | ||
35 | if (retlen) | ||
36 | *retlen = totlen; | ||
37 | return ret; | ||
38 | } | ||
39 | |||
16 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, | 40 | int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, |
17 | unsigned long count, loff_t to, size_t *retlen) | 41 | unsigned long count, loff_t to, size_t *retlen) |
18 | { | 42 | { |
@@ -26,14 +50,18 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs, | |||
26 | } | 50 | } |
27 | } | 51 | } |
28 | 52 | ||
29 | return mtd_writev(c->mtd, vecs, count, to, retlen); | 53 | if (c->mtd->writev) |
54 | return c->mtd->writev(c->mtd, vecs, count, to, retlen); | ||
55 | else { | ||
56 | return mtd_fake_writev(c->mtd, vecs, count, to, retlen); | ||
57 | } | ||
30 | } | 58 | } |
31 | 59 | ||
32 | int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, | 60 | int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len, |
33 | size_t *retlen, const u_char *buf) | 61 | size_t *retlen, const u_char *buf) |
34 | { | 62 | { |
35 | int ret; | 63 | int ret; |
36 | ret = mtd_write(c->mtd, ofs, len, retlen, buf); | 64 | ret = c->mtd->write(c->mtd, ofs, len, retlen, buf); |
37 | 65 | ||
38 | if (jffs2_sum_active()) { | 66 | if (jffs2_sum_active()) { |
39 | struct kvec vecs[1]; | 67 | struct kvec vecs[1]; |
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 3034e970eb9..3e93cdd1900 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
@@ -9,10 +9,6 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
14 | #define JFFS2_XATTR_IS_CORRUPTED 1 | ||
15 | |||
16 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
17 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
18 | #include <linux/fs.h> | 14 | #include <linux/fs.h> |
@@ -155,7 +151,7 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat | |||
155 | JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", | 151 | JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", |
156 | offset, je32_to_cpu(rx.hdr_crc), crc); | 152 | offset, je32_to_cpu(rx.hdr_crc), crc); |
157 | xd->flags |= JFFS2_XFLAGS_INVALID; | 153 | xd->flags |= JFFS2_XFLAGS_INVALID; |
158 | return JFFS2_XATTR_IS_CORRUPTED; | 154 | return -EIO; |
159 | } | 155 | } |
160 | totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len)); | 156 | totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len)); |
161 | if (je16_to_cpu(rx.magic) != JFFS2_MAGIC_BITMASK | 157 | if (je16_to_cpu(rx.magic) != JFFS2_MAGIC_BITMASK |
@@ -171,7 +167,7 @@ static int do_verify_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_dat | |||
171 | je32_to_cpu(rx.xid), xd->xid, | 167 | je32_to_cpu(rx.xid), xd->xid, |
172 | je32_to_cpu(rx.version), xd->version); | 168 | je32_to_cpu(rx.version), xd->version); |
173 | xd->flags |= JFFS2_XFLAGS_INVALID; | 169 | xd->flags |= JFFS2_XFLAGS_INVALID; |
174 | return JFFS2_XATTR_IS_CORRUPTED; | 170 | return -EIO; |
175 | } | 171 | } |
176 | xd->xprefix = rx.xprefix; | 172 | xd->xprefix = rx.xprefix; |
177 | xd->name_len = rx.name_len; | 173 | xd->name_len = rx.name_len; |
@@ -229,12 +225,12 @@ static int do_load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum | |||
229 | data[xd->name_len] = '\0'; | 225 | data[xd->name_len] = '\0'; |
230 | crc = crc32(0, data, length); | 226 | crc = crc32(0, data, length); |
231 | if (crc != xd->data_crc) { | 227 | if (crc != xd->data_crc) { |
232 | JFFS2_WARNING("node CRC failed (JFFS2_NODETYPE_XATTR)" | 228 | JFFS2_WARNING("node CRC failed (JFFS2_NODETYPE_XREF)" |
233 | " at %#08x, read: 0x%08x calculated: 0x%08x\n", | 229 | " at %#08x, read: 0x%08x calculated: 0x%08x\n", |
234 | ref_offset(xd->node), xd->data_crc, crc); | 230 | ref_offset(xd->node), xd->data_crc, crc); |
235 | kfree(data); | 231 | kfree(data); |
236 | xd->flags |= JFFS2_XFLAGS_INVALID; | 232 | xd->flags |= JFFS2_XFLAGS_INVALID; |
237 | return JFFS2_XATTR_IS_CORRUPTED; | 233 | return -EIO; |
238 | } | 234 | } |
239 | 235 | ||
240 | xd->flags |= JFFS2_XFLAGS_HOT; | 236 | xd->flags |= JFFS2_XFLAGS_HOT; |
@@ -272,7 +268,7 @@ static int load_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datum *x | |||
272 | if (xd->xname) | 268 | if (xd->xname) |
273 | return 0; | 269 | return 0; |
274 | if (xd->flags & JFFS2_XFLAGS_INVALID) | 270 | if (xd->flags & JFFS2_XFLAGS_INVALID) |
275 | return JFFS2_XATTR_IS_CORRUPTED; | 271 | return -EIO; |
276 | if (unlikely(is_xattr_datum_unchecked(c, xd))) | 272 | if (unlikely(is_xattr_datum_unchecked(c, xd))) |
277 | rc = do_verify_xattr_datum(c, xd); | 273 | rc = do_verify_xattr_datum(c, xd); |
278 | if (!rc) | 274 | if (!rc) |
@@ -437,8 +433,6 @@ static void unrefer_xattr_datum(struct jffs2_sb_info *c, struct jffs2_xattr_datu | |||
437 | * is called to release xattr related objects when unmounting. | 433 | * is called to release xattr related objects when unmounting. |
438 | * check_xattr_ref_inode(c, ic) | 434 | * check_xattr_ref_inode(c, ic) |
439 | * is used to confirm inode does not have duplicate xattr name/value pair. | 435 | * is used to confirm inode does not have duplicate xattr name/value pair. |
440 | * jffs2_xattr_do_crccheck_inode(c, ic) | ||
441 | * is used to force xattr data integrity check during the initial gc scan. | ||
442 | * -------------------------------------------------- */ | 436 | * -------------------------------------------------- */ |
443 | static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) | 437 | static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref) |
444 | { | 438 | { |
@@ -466,7 +460,7 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref | |||
466 | if (crc != je32_to_cpu(rr.node_crc)) { | 460 | if (crc != je32_to_cpu(rr.node_crc)) { |
467 | JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", | 461 | JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", |
468 | offset, je32_to_cpu(rr.node_crc), crc); | 462 | offset, je32_to_cpu(rr.node_crc), crc); |
469 | return JFFS2_XATTR_IS_CORRUPTED; | 463 | return -EIO; |
470 | } | 464 | } |
471 | if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK | 465 | if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK |
472 | || je16_to_cpu(rr.nodetype) != JFFS2_NODETYPE_XREF | 466 | || je16_to_cpu(rr.nodetype) != JFFS2_NODETYPE_XREF |
@@ -476,7 +470,7 @@ static int verify_xattr_ref(struct jffs2_sb_info *c, struct jffs2_xattr_ref *ref | |||
476 | offset, je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK, | 470 | offset, je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK, |
477 | je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF, | 471 | je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF, |
478 | je32_to_cpu(rr.totlen), PAD(sizeof(rr))); | 472 | je32_to_cpu(rr.totlen), PAD(sizeof(rr))); |
479 | return JFFS2_XATTR_IS_CORRUPTED; | 473 | return -EIO; |
480 | } | 474 | } |
481 | ref->ino = je32_to_cpu(rr.ino); | 475 | ref->ino = je32_to_cpu(rr.ino); |
482 | ref->xid = je32_to_cpu(rr.xid); | 476 | ref->xid = je32_to_cpu(rr.xid); |
@@ -686,11 +680,6 @@ static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cac | |||
686 | return rc; | 680 | return rc; |
687 | } | 681 | } |
688 | 682 | ||
689 | void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) | ||
690 | { | ||
691 | check_xattr_ref_inode(c, ic); | ||
692 | } | ||
693 | |||
694 | /* -------- xattr subsystem functions --------------- | 683 | /* -------- xattr subsystem functions --------------- |
695 | * jffs2_init_xattr_subsystem(c) | 684 | * jffs2_init_xattr_subsystem(c) |
696 | * is used to initialize semaphore and list_head, and some variables. | 685 | * is used to initialize semaphore and list_head, and some variables. |
diff --git a/fs/jffs2/xattr.h b/fs/jffs2/xattr.h index 467ff376ee2..7be4beb306f 100644 --- a/fs/jffs2/xattr.h +++ b/fs/jffs2/xattr.h | |||
@@ -77,7 +77,6 @@ extern void jffs2_clear_xattr_subsystem(struct jffs2_sb_info *c); | |||
77 | extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, | 77 | extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c, |
78 | uint32_t xid, uint32_t version); | 78 | uint32_t xid, uint32_t version); |
79 | 79 | ||
80 | extern void jffs2_xattr_do_crccheck_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); | ||
81 | extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); | 80 | extern void jffs2_xattr_delete_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
82 | extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); | 81 | extern void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic); |
83 | 82 | ||
@@ -109,7 +108,6 @@ extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t); | |||
109 | #define jffs2_build_xattr_subsystem(c) | 108 | #define jffs2_build_xattr_subsystem(c) |
110 | #define jffs2_clear_xattr_subsystem(c) | 109 | #define jffs2_clear_xattr_subsystem(c) |
111 | 110 | ||
112 | #define jffs2_xattr_do_crccheck_inode(c, ic) | ||
113 | #define jffs2_xattr_delete_inode(c, ic) | 111 | #define jffs2_xattr_delete_inode(c, ic) |
114 | #define jffs2_xattr_free_inode(c, ic) | 112 | #define jffs2_xattr_free_inode(c, ic) |
115 | #define jffs2_verify_xattr(c) (1) | 113 | #define jffs2_verify_xattr(c) (1) |