diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-30 20:31:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-30 20:31:56 -0400 |
commit | 623ff7739e7c00fa3d55dbfd42a492a68298fd7a (patch) | |
tree | 0b7461753a1b13b27ea2958a7d48c6efb47bba54 /fs | |
parent | c39e8ede284f469971589f2e04af78216e1a771d (diff) | |
parent | 7b0e67f604e1829e5292e1ad7743eb18dc42ea7c (diff) |
Merge tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6
Pull MTD changes from David Woodhouse:
- Artem's cleanup of the MTD API continues apace.
- Fixes and improvements for ST FSMC and SuperH FLCTL NAND, amongst
others.
- More work on DiskOnChip G3, new driver for DiskOnChip G4.
- Clean up debug/warning printks in JFFS2 to use pr_<level>.
Fix up various trivial conflicts, largely due to changes in calling
conventions for things like dmaengine_prep_slave_sg() (new inline
wrapper to hide new parameter, clashing with rewrite of previously last
parameter that used to be an 'append' flag, and is now a bitmap of
'unsigned long flags').
(Also some header file fallout - like so many merges this merge window -
and silly conflicts with sparse fixes)
* tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6: (120 commits)
mtd: docg3 add protection against concurrency
mtd: docg3 refactor cascade floors structure
mtd: docg3 increase write/erase timeout
mtd: docg3 fix inbound calculations
mtd: nand: gpmi: fix function annotations
mtd: phram: fix section mismatch for phram_setup
mtd: unify initialization of erase_info->fail_addr
mtd: support ONFI multi lun NAND
mtd: sm_ftl: fix typo in major number.
mtd: add device-tree support to spear_smi
mtd: spear_smi: Remove default partition information from driver
mtd: Add device-tree support to fsmc_nand
mtd: fix section mismatch for doc_probe_device
mtd: nand/fsmc: Remove sparse warnings and errors
mtd: nand/fsmc: Add DMA support
mtd: nand/fsmc: Access the NAND device word by word whenever possible
mtd: nand/fsmc: Use dev_err to report error scenario
mtd: nand/fsmc: Use devm routines
mtd: nand/fsmc: Modify fsmc driver to accept nand timing parameters via platform
mtd: fsmc_nand: add pm callbacks to support hibernation
...
Diffstat (limited to 'fs')
-rw-r--r-- | fs/jffs2/acl.c | 2 | ||||
-rw-r--r-- | fs/jffs2/background.c | 29 | ||||
-rw-r--r-- | fs/jffs2/build.c | 6 | ||||
-rw-r--r-- | fs/jffs2/compr.c | 32 | ||||
-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 | 41 | ||||
-rw-r--r-- | fs/jffs2/erase.c | 72 | ||||
-rw-r--r-- | fs/jffs2/file.c | 33 | ||||
-rw-r--r-- | fs/jffs2/fs.c | 67 | ||||
-rw-r--r-- | fs/jffs2/gc.c | 322 | ||||
-rw-r--r-- | fs/jffs2/malloc.c | 2 | ||||
-rw-r--r-- | fs/jffs2/nodelist.c | 30 | ||||
-rw-r--r-- | fs/jffs2/nodemgmt.c | 214 | ||||
-rw-r--r-- | fs/jffs2/os-linux.h | 4 | ||||
-rw-r--r-- | fs/jffs2/read.c | 70 | ||||
-rw-r--r-- | fs/jffs2/readinode.c | 2 | ||||
-rw-r--r-- | fs/jffs2/scan.c | 229 | ||||
-rw-r--r-- | fs/jffs2/security.c | 4 | ||||
-rw-r--r-- | fs/jffs2/summary.c | 16 | ||||
-rw-r--r-- | fs/jffs2/super.c | 30 | ||||
-rw-r--r-- | fs/jffs2/symlink.c | 7 | ||||
-rw-r--r-- | fs/jffs2/wbuf.c | 148 | ||||
-rw-r--r-- | fs/jffs2/write.c | 113 | ||||
-rw-r--r-- | fs/jffs2/xattr.c | 2 | ||||
-rw-r--r-- | fs/romfs/storage.c | 2 |
29 files changed, 916 insertions, 681 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 926d02068a14..922f146e4235 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
14 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c index 404111b016c9..2b60ce1996aa 100644 --- a/fs/jffs2/background.c +++ b/fs/jffs2/background.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/jffs2.h> | 16 | #include <linux/jffs2.h> |
15 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
@@ -42,12 +44,13 @@ int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c) | |||
42 | 44 | ||
43 | tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index); | 45 | tsk = kthread_run(jffs2_garbage_collect_thread, c, "jffs2_gcd_mtd%d", c->mtd->index); |
44 | if (IS_ERR(tsk)) { | 46 | if (IS_ERR(tsk)) { |
45 | printk(KERN_WARNING "fork failed for JFFS2 garbage collect thread: %ld\n", -PTR_ERR(tsk)); | 47 | pr_warn("fork failed for JFFS2 garbage collect thread: %ld\n", |
48 | -PTR_ERR(tsk)); | ||
46 | complete(&c->gc_thread_exit); | 49 | complete(&c->gc_thread_exit); |
47 | ret = PTR_ERR(tsk); | 50 | ret = PTR_ERR(tsk); |
48 | } else { | 51 | } else { |
49 | /* Wait for it... */ | 52 | /* Wait for it... */ |
50 | D1(printk(KERN_DEBUG "JFFS2: Garbage collect thread is pid %d\n", tsk->pid)); | 53 | jffs2_dbg(1, "Garbage collect thread is pid %d\n", tsk->pid); |
51 | wait_for_completion(&c->gc_thread_start); | 54 | wait_for_completion(&c->gc_thread_start); |
52 | ret = tsk->pid; | 55 | ret = tsk->pid; |
53 | } | 56 | } |
@@ -60,7 +63,7 @@ void jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c) | |||
60 | int wait = 0; | 63 | int wait = 0; |
61 | spin_lock(&c->erase_completion_lock); | 64 | spin_lock(&c->erase_completion_lock); |
62 | if (c->gc_task) { | 65 | if (c->gc_task) { |
63 | D1(printk(KERN_DEBUG "jffs2: Killing GC task %d\n", c->gc_task->pid)); | 66 | jffs2_dbg(1, "Killing GC task %d\n", c->gc_task->pid); |
64 | send_sig(SIGKILL, c->gc_task, 1); | 67 | send_sig(SIGKILL, c->gc_task, 1); |
65 | wait = 1; | 68 | wait = 1; |
66 | } | 69 | } |
@@ -90,7 +93,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
90 | if (!jffs2_thread_should_wake(c)) { | 93 | if (!jffs2_thread_should_wake(c)) { |
91 | set_current_state (TASK_INTERRUPTIBLE); | 94 | set_current_state (TASK_INTERRUPTIBLE); |
92 | spin_unlock(&c->erase_completion_lock); | 95 | spin_unlock(&c->erase_completion_lock); |
93 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread sleeping...\n")); | 96 | jffs2_dbg(1, "%s(): sleeping...\n", __func__); |
94 | schedule(); | 97 | schedule(); |
95 | } else | 98 | } else |
96 | spin_unlock(&c->erase_completion_lock); | 99 | spin_unlock(&c->erase_completion_lock); |
@@ -109,7 +112,7 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
109 | schedule_timeout_interruptible(msecs_to_jiffies(50)); | 112 | schedule_timeout_interruptible(msecs_to_jiffies(50)); |
110 | 113 | ||
111 | if (kthread_should_stop()) { | 114 | if (kthread_should_stop()) { |
112 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): kthread_stop() called.\n")); | 115 | jffs2_dbg(1, "%s(): kthread_stop() called\n", __func__); |
113 | goto die; | 116 | goto die; |
114 | } | 117 | } |
115 | 118 | ||
@@ -126,28 +129,32 @@ static int jffs2_garbage_collect_thread(void *_c) | |||
126 | 129 | ||
127 | switch(signr) { | 130 | switch(signr) { |
128 | case SIGSTOP: | 131 | case SIGSTOP: |
129 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGSTOP received.\n")); | 132 | jffs2_dbg(1, "%s(): SIGSTOP received\n", |
133 | __func__); | ||
130 | set_current_state(TASK_STOPPED); | 134 | set_current_state(TASK_STOPPED); |
131 | schedule(); | 135 | schedule(); |
132 | break; | 136 | break; |
133 | 137 | ||
134 | case SIGKILL: | 138 | case SIGKILL: |
135 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGKILL received.\n")); | 139 | jffs2_dbg(1, "%s(): SIGKILL received\n", |
140 | __func__); | ||
136 | goto die; | 141 | goto die; |
137 | 142 | ||
138 | case SIGHUP: | 143 | case SIGHUP: |
139 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): SIGHUP received.\n")); | 144 | jffs2_dbg(1, "%s(): SIGHUP received\n", |
145 | __func__); | ||
140 | break; | 146 | break; |
141 | default: | 147 | default: |
142 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): signal %ld received\n", signr)); | 148 | jffs2_dbg(1, "%s(): signal %ld received\n", |
149 | __func__, signr); | ||
143 | } | 150 | } |
144 | } | 151 | } |
145 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ | 152 | /* We don't want SIGHUP to interrupt us. STOP and KILL are OK though. */ |
146 | disallow_signal(SIGHUP); | 153 | disallow_signal(SIGHUP); |
147 | 154 | ||
148 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_thread(): pass\n")); | 155 | jffs2_dbg(1, "%s(): pass\n", __func__); |
149 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { | 156 | if (jffs2_garbage_collect_pass(c) == -ENOSPC) { |
150 | printk(KERN_NOTICE "No space for garbage collection. Aborting GC thread\n"); | 157 | pr_notice("No space for garbage collection. Aborting GC thread\n"); |
151 | goto die; | 158 | goto die; |
152 | } | 159 | } |
153 | } | 160 | } |
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c index 3005ec4520ad..a3750f902adc 100644 --- a/fs/jffs2/build.c +++ b/fs/jffs2/build.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
@@ -307,8 +309,8 @@ static void jffs2_calc_trigger_levels(struct jffs2_sb_info *c) | |||
307 | trying to GC to make more space. It'll be a fruitless task */ | 309 | trying to GC to make more space. It'll be a fruitless task */ |
308 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); | 310 | c->nospc_dirty_size = c->sector_size + (c->flash_size / 100); |
309 | 311 | ||
310 | dbg_fsbuild("JFFS2 trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", | 312 | dbg_fsbuild("trigger levels (size %d KiB, block size %d KiB, %d blocks)\n", |
311 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks); | 313 | c->flash_size / 1024, c->sector_size / 1024, c->nr_blocks); |
312 | dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n", | 314 | dbg_fsbuild("Blocks required to allow deletion: %d (%d KiB)\n", |
313 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024); | 315 | c->resv_blocks_deletion, c->resv_blocks_deletion*c->sector_size/1024); |
314 | dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n", | 316 | dbg_fsbuild("Blocks required to allow writes: %d (%d KiB)\n", |
diff --git a/fs/jffs2/compr.c b/fs/jffs2/compr.c index 96ed3c9ec3fc..4849a4c9a0e2 100644 --- a/fs/jffs2/compr.c +++ b/fs/jffs2/compr.c | |||
@@ -12,6 +12,8 @@ | |||
12 | * | 12 | * |
13 | */ | 13 | */ |
14 | 14 | ||
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
16 | |||
15 | #include "compr.h" | 17 | #include "compr.h" |
16 | 18 | ||
17 | static DEFINE_SPINLOCK(jffs2_compressor_list_lock); | 19 | static DEFINE_SPINLOCK(jffs2_compressor_list_lock); |
@@ -79,7 +81,7 @@ static int jffs2_selected_compress(u8 compr, unsigned char *data_in, | |||
79 | 81 | ||
80 | output_buf = kmalloc(*cdatalen, GFP_KERNEL); | 82 | output_buf = kmalloc(*cdatalen, GFP_KERNEL); |
81 | if (!output_buf) { | 83 | if (!output_buf) { |
82 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n"); | 84 | pr_warn("No memory for compressor allocation. Compression failed.\n"); |
83 | return ret; | 85 | return ret; |
84 | } | 86 | } |
85 | orig_slen = *datalen; | 87 | orig_slen = *datalen; |
@@ -188,7 +190,8 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
188 | tmp_buf = kmalloc(orig_slen, GFP_KERNEL); | 190 | tmp_buf = kmalloc(orig_slen, GFP_KERNEL); |
189 | spin_lock(&jffs2_compressor_list_lock); | 191 | spin_lock(&jffs2_compressor_list_lock); |
190 | if (!tmp_buf) { | 192 | if (!tmp_buf) { |
191 | printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n", orig_slen); | 193 | pr_warn("No memory for compressor allocation. (%d bytes)\n", |
194 | orig_slen); | ||
192 | continue; | 195 | continue; |
193 | } | 196 | } |
194 | else { | 197 | else { |
@@ -235,7 +238,7 @@ uint16_t jffs2_compress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
235 | cpage_out, datalen, cdatalen); | 238 | cpage_out, datalen, cdatalen); |
236 | break; | 239 | break; |
237 | default: | 240 | default: |
238 | printk(KERN_ERR "JFFS2: unknown compression mode.\n"); | 241 | pr_err("unknown compression mode\n"); |
239 | } | 242 | } |
240 | 243 | ||
241 | if (ret == JFFS2_COMPR_NONE) { | 244 | if (ret == JFFS2_COMPR_NONE) { |
@@ -277,7 +280,8 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
277 | ret = this->decompress(cdata_in, data_out, cdatalen, datalen); | 280 | ret = this->decompress(cdata_in, data_out, cdatalen, datalen); |
278 | spin_lock(&jffs2_compressor_list_lock); | 281 | spin_lock(&jffs2_compressor_list_lock); |
279 | if (ret) { | 282 | if (ret) { |
280 | printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret); | 283 | pr_warn("Decompressor \"%s\" returned %d\n", |
284 | this->name, ret); | ||
281 | } | 285 | } |
282 | else { | 286 | else { |
283 | this->stat_decompr_blocks++; | 287 | this->stat_decompr_blocks++; |
@@ -287,7 +291,7 @@ int jffs2_decompress(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
287 | return ret; | 291 | return ret; |
288 | } | 292 | } |
289 | } | 293 | } |
290 | printk(KERN_WARNING "JFFS2 compression type 0x%02x not available.\n", comprtype); | 294 | pr_warn("compression type 0x%02x not available\n", comprtype); |
291 | spin_unlock(&jffs2_compressor_list_lock); | 295 | spin_unlock(&jffs2_compressor_list_lock); |
292 | return -EIO; | 296 | return -EIO; |
293 | } | 297 | } |
@@ -299,7 +303,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) | |||
299 | struct jffs2_compressor *this; | 303 | struct jffs2_compressor *this; |
300 | 304 | ||
301 | if (!comp->name) { | 305 | if (!comp->name) { |
302 | printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n"); | 306 | pr_warn("NULL compressor name at registering JFFS2 compressor. Failed.\n"); |
303 | return -1; | 307 | return -1; |
304 | } | 308 | } |
305 | comp->compr_buf_size=0; | 309 | comp->compr_buf_size=0; |
@@ -309,7 +313,7 @@ int jffs2_register_compressor(struct jffs2_compressor *comp) | |||
309 | comp->stat_compr_new_size=0; | 313 | comp->stat_compr_new_size=0; |
310 | comp->stat_compr_blocks=0; | 314 | comp->stat_compr_blocks=0; |
311 | comp->stat_decompr_blocks=0; | 315 | comp->stat_decompr_blocks=0; |
312 | D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name)); | 316 | jffs2_dbg(1, "Registering JFFS2 compressor \"%s\"\n", comp->name); |
313 | 317 | ||
314 | spin_lock(&jffs2_compressor_list_lock); | 318 | spin_lock(&jffs2_compressor_list_lock); |
315 | 319 | ||
@@ -332,15 +336,15 @@ out: | |||
332 | 336 | ||
333 | int jffs2_unregister_compressor(struct jffs2_compressor *comp) | 337 | int jffs2_unregister_compressor(struct jffs2_compressor *comp) |
334 | { | 338 | { |
335 | D2(struct jffs2_compressor *this;) | 339 | D2(struct jffs2_compressor *this); |
336 | 340 | ||
337 | D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name)); | 341 | jffs2_dbg(1, "Unregistering JFFS2 compressor \"%s\"\n", comp->name); |
338 | 342 | ||
339 | spin_lock(&jffs2_compressor_list_lock); | 343 | spin_lock(&jffs2_compressor_list_lock); |
340 | 344 | ||
341 | if (comp->usecount) { | 345 | if (comp->usecount) { |
342 | spin_unlock(&jffs2_compressor_list_lock); | 346 | spin_unlock(&jffs2_compressor_list_lock); |
343 | printk(KERN_WARNING "JFFS2: Compressor module is in use. Unregister failed.\n"); | 347 | pr_warn("Compressor module is in use. Unregister failed.\n"); |
344 | return -1; | 348 | return -1; |
345 | } | 349 | } |
346 | list_del(&comp->list); | 350 | list_del(&comp->list); |
@@ -377,17 +381,17 @@ int __init jffs2_compressors_init(void) | |||
377 | /* Setting default compression mode */ | 381 | /* Setting default compression mode */ |
378 | #ifdef CONFIG_JFFS2_CMODE_NONE | 382 | #ifdef CONFIG_JFFS2_CMODE_NONE |
379 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; | 383 | jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; |
380 | D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");) | 384 | jffs2_dbg(1, "default compression mode: none\n"); |
381 | #else | 385 | #else |
382 | #ifdef CONFIG_JFFS2_CMODE_SIZE | 386 | #ifdef CONFIG_JFFS2_CMODE_SIZE |
383 | jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; | 387 | jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE; |
384 | D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");) | 388 | jffs2_dbg(1, "default compression mode: size\n"); |
385 | #else | 389 | #else |
386 | #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO | 390 | #ifdef CONFIG_JFFS2_CMODE_FAVOURLZO |
387 | jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; | 391 | jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO; |
388 | D1(printk(KERN_INFO "JFFS2: default compression mode: favourlzo\n");) | 392 | jffs2_dbg(1, "default compression mode: favourlzo\n"); |
389 | #else | 393 | #else |
390 | D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");) | 394 | jffs2_dbg(1, "default compression mode: priority\n"); |
391 | #endif | 395 | #endif |
392 | #endif | 396 | #endif |
393 | #endif | 397 | #endif |
diff --git a/fs/jffs2/compr_lzo.c b/fs/jffs2/compr_lzo.c index af186ee674d8..c553bd6506da 100644 --- a/fs/jffs2/compr_lzo.c +++ b/fs/jffs2/compr_lzo.c | |||
@@ -33,7 +33,6 @@ 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"); | ||
37 | free_workspace(); | 36 | free_workspace(); |
38 | return -ENOMEM; | 37 | return -ENOMEM; |
39 | } | 38 | } |
diff --git a/fs/jffs2/compr_rubin.c b/fs/jffs2/compr_rubin.c index 9e7cec808c4c..92e0644bf867 100644 --- a/fs/jffs2/compr_rubin.c +++ b/fs/jffs2/compr_rubin.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/string.h> | 15 | #include <linux/string.h> |
14 | #include <linux/types.h> | 16 | #include <linux/types.h> |
15 | #include <linux/jffs2.h> | 17 | #include <linux/jffs2.h> |
diff --git a/fs/jffs2/compr_zlib.c b/fs/jffs2/compr_zlib.c index 5a001020c542..0b9a1e44e833 100644 --- a/fs/jffs2/compr_zlib.c +++ b/fs/jffs2/compr_zlib.c | |||
@@ -14,6 +14,8 @@ | |||
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 | |||
17 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
18 | #include <linux/zlib.h> | 20 | #include <linux/zlib.h> |
19 | #include <linux/zutil.h> | 21 | #include <linux/zutil.h> |
@@ -42,18 +44,18 @@ static int __init alloc_workspaces(void) | |||
42 | { | 44 | { |
43 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize(MAX_WBITS, | 45 | def_strm.workspace = vmalloc(zlib_deflate_workspacesize(MAX_WBITS, |
44 | MAX_MEM_LEVEL)); | 46 | MAX_MEM_LEVEL)); |
45 | if (!def_strm.workspace) { | 47 | 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)); | ||
47 | return -ENOMEM; | 48 | return -ENOMEM; |
48 | } | 49 | |
49 | D1(printk(KERN_DEBUG "Allocated %d bytes for deflate workspace\n", zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL))); | 50 | jffs2_dbg(1, "Allocated %d bytes for deflate workspace\n", |
51 | zlib_deflate_workspacesize(MAX_WBITS, MAX_MEM_LEVEL)); | ||
50 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); | 52 | inf_strm.workspace = vmalloc(zlib_inflate_workspacesize()); |
51 | if (!inf_strm.workspace) { | 53 | if (!inf_strm.workspace) { |
52 | printk(KERN_WARNING "Failed to allocate %d bytes for inflate workspace\n", zlib_inflate_workspacesize()); | ||
53 | vfree(def_strm.workspace); | 54 | vfree(def_strm.workspace); |
54 | return -ENOMEM; | 55 | return -ENOMEM; |
55 | } | 56 | } |
56 | D1(printk(KERN_DEBUG "Allocated %d bytes for inflate workspace\n", zlib_inflate_workspacesize())); | 57 | jffs2_dbg(1, "Allocated %d bytes for inflate workspace\n", |
58 | zlib_inflate_workspacesize()); | ||
57 | return 0; | 59 | return 0; |
58 | } | 60 | } |
59 | 61 | ||
@@ -79,7 +81,7 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
79 | mutex_lock(&deflate_mutex); | 81 | mutex_lock(&deflate_mutex); |
80 | 82 | ||
81 | if (Z_OK != zlib_deflateInit(&def_strm, 3)) { | 83 | if (Z_OK != zlib_deflateInit(&def_strm, 3)) { |
82 | printk(KERN_WARNING "deflateInit failed\n"); | 84 | pr_warn("deflateInit failed\n"); |
83 | mutex_unlock(&deflate_mutex); | 85 | mutex_unlock(&deflate_mutex); |
84 | return -1; | 86 | return -1; |
85 | } | 87 | } |
@@ -93,13 +95,14 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
93 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { | 95 | while (def_strm.total_out < *dstlen - STREAM_END_SPACE && def_strm.total_in < *sourcelen) { |
94 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); | 96 | def_strm.avail_out = *dstlen - (def_strm.total_out + STREAM_END_SPACE); |
95 | def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); | 97 | def_strm.avail_in = min((unsigned)(*sourcelen-def_strm.total_in), def_strm.avail_out); |
96 | D1(printk(KERN_DEBUG "calling deflate with avail_in %d, avail_out %d\n", | 98 | jffs2_dbg(1, "calling deflate with avail_in %d, avail_out %d\n", |
97 | def_strm.avail_in, def_strm.avail_out)); | 99 | def_strm.avail_in, def_strm.avail_out); |
98 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); | 100 | ret = zlib_deflate(&def_strm, Z_PARTIAL_FLUSH); |
99 | D1(printk(KERN_DEBUG "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", | 101 | jffs2_dbg(1, "deflate returned with avail_in %d, avail_out %d, total_in %ld, total_out %ld\n", |
100 | def_strm.avail_in, def_strm.avail_out, def_strm.total_in, def_strm.total_out)); | 102 | def_strm.avail_in, def_strm.avail_out, |
103 | def_strm.total_in, def_strm.total_out); | ||
101 | if (ret != Z_OK) { | 104 | if (ret != Z_OK) { |
102 | D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret)); | 105 | jffs2_dbg(1, "deflate in loop returned %d\n", ret); |
103 | zlib_deflateEnd(&def_strm); | 106 | zlib_deflateEnd(&def_strm); |
104 | mutex_unlock(&deflate_mutex); | 107 | mutex_unlock(&deflate_mutex); |
105 | return -1; | 108 | return -1; |
@@ -111,20 +114,20 @@ static int jffs2_zlib_compress(unsigned char *data_in, | |||
111 | zlib_deflateEnd(&def_strm); | 114 | zlib_deflateEnd(&def_strm); |
112 | 115 | ||
113 | if (ret != Z_STREAM_END) { | 116 | if (ret != Z_STREAM_END) { |
114 | D1(printk(KERN_DEBUG "final deflate returned %d\n", ret)); | 117 | jffs2_dbg(1, "final deflate returned %d\n", ret); |
115 | ret = -1; | 118 | ret = -1; |
116 | goto out; | 119 | goto out; |
117 | } | 120 | } |
118 | 121 | ||
119 | if (def_strm.total_out >= def_strm.total_in) { | 122 | if (def_strm.total_out >= def_strm.total_in) { |
120 | D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld; failing\n", | 123 | jffs2_dbg(1, "zlib compressed %ld bytes into %ld; failing\n", |
121 | def_strm.total_in, def_strm.total_out)); | 124 | def_strm.total_in, def_strm.total_out); |
122 | ret = -1; | 125 | ret = -1; |
123 | goto out; | 126 | goto out; |
124 | } | 127 | } |
125 | 128 | ||
126 | D1(printk(KERN_DEBUG "zlib compressed %ld bytes into %ld\n", | 129 | jffs2_dbg(1, "zlib compressed %ld bytes into %ld\n", |
127 | def_strm.total_in, def_strm.total_out)); | 130 | def_strm.total_in, def_strm.total_out); |
128 | 131 | ||
129 | *dstlen = def_strm.total_out; | 132 | *dstlen = def_strm.total_out; |
130 | *sourcelen = def_strm.total_in; | 133 | *sourcelen = def_strm.total_in; |
@@ -157,18 +160,18 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | |||
157 | ((data_in[0] & 0x0f) == Z_DEFLATED) && | 160 | ((data_in[0] & 0x0f) == Z_DEFLATED) && |
158 | !(((data_in[0]<<8) + data_in[1]) % 31)) { | 161 | !(((data_in[0]<<8) + data_in[1]) % 31)) { |
159 | 162 | ||
160 | D2(printk(KERN_DEBUG "inflate skipping adler32\n")); | 163 | jffs2_dbg(2, "inflate skipping adler32\n"); |
161 | wbits = -((data_in[0] >> 4) + 8); | 164 | wbits = -((data_in[0] >> 4) + 8); |
162 | inf_strm.next_in += 2; | 165 | inf_strm.next_in += 2; |
163 | inf_strm.avail_in -= 2; | 166 | inf_strm.avail_in -= 2; |
164 | } else { | 167 | } else { |
165 | /* Let this remain D1 for now -- it should never happen */ | 168 | /* Let this remain D1 for now -- it should never happen */ |
166 | D1(printk(KERN_DEBUG "inflate not skipping adler32\n")); | 169 | jffs2_dbg(1, "inflate not skipping adler32\n"); |
167 | } | 170 | } |
168 | 171 | ||
169 | 172 | ||
170 | if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { | 173 | if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) { |
171 | printk(KERN_WARNING "inflateInit failed\n"); | 174 | pr_warn("inflateInit failed\n"); |
172 | mutex_unlock(&inflate_mutex); | 175 | mutex_unlock(&inflate_mutex); |
173 | return 1; | 176 | return 1; |
174 | } | 177 | } |
@@ -176,7 +179,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in, | |||
176 | while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK) | 179 | while((ret = zlib_inflate(&inf_strm, Z_FINISH)) == Z_OK) |
177 | ; | 180 | ; |
178 | if (ret != Z_STREAM_END) { | 181 | if (ret != Z_STREAM_END) { |
179 | printk(KERN_NOTICE "inflate returned %d\n", ret); | 182 | pr_notice("inflate returned %d\n", ret); |
180 | } | 183 | } |
181 | zlib_inflateEnd(&inf_strm); | 184 | zlib_inflateEnd(&inf_strm); |
182 | mutex_unlock(&inflate_mutex); | 185 | mutex_unlock(&inflate_mutex); |
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index e0b76c87a91a..1090eb64b90d 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/types.h> | 16 | #include <linux/types.h> |
15 | #include <linux/pagemap.h> | 17 | #include <linux/pagemap.h> |
@@ -261,12 +263,15 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c) | |||
261 | bad += c->sector_size; | 263 | bad += c->sector_size; |
262 | } | 264 | } |
263 | 265 | ||
264 | #define check(sz) \ | 266 | #define check(sz) \ |
265 | if (sz != c->sz##_size) { \ | 267 | do { \ |
266 | printk(KERN_WARNING #sz "_size mismatch counted 0x%x, c->" #sz "_size 0x%x\n", \ | 268 | if (sz != c->sz##_size) { \ |
267 | sz, c->sz##_size); \ | 269 | pr_warn("%s_size mismatch counted 0x%x, c->%s_size 0x%x\n", \ |
268 | dump = 1; \ | 270 | #sz, sz, #sz, c->sz##_size); \ |
269 | } | 271 | dump = 1; \ |
272 | } \ | ||
273 | } while (0) | ||
274 | |||
270 | check(free); | 275 | check(free); |
271 | check(dirty); | 276 | check(dirty); |
272 | check(used); | 277 | check(used); |
@@ -274,11 +279,12 @@ void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c) | |||
274 | check(unchecked); | 279 | check(unchecked); |
275 | check(bad); | 280 | check(bad); |
276 | check(erasing); | 281 | check(erasing); |
282 | |||
277 | #undef check | 283 | #undef check |
278 | 284 | ||
279 | if (nr_counted != c->nr_blocks) { | 285 | if (nr_counted != c->nr_blocks) { |
280 | printk(KERN_WARNING "%s counted only 0x%x blocks of 0x%x. Where are the others?\n", | 286 | pr_warn("%s counted only 0x%x blocks of 0x%x. Where are the others?\n", |
281 | __func__, nr_counted, c->nr_blocks); | 287 | __func__, nr_counted, c->nr_blocks); |
282 | dump = 1; | 288 | dump = 1; |
283 | } | 289 | } |
284 | 290 | ||
diff --git a/fs/jffs2/debug.h b/fs/jffs2/debug.h index c4f8eef5ca68..4fd9be4cbc98 100644 --- a/fs/jffs2/debug.h +++ b/fs/jffs2/debug.h | |||
@@ -51,6 +51,7 @@ | |||
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 | ||
54 | #define D1(x) x | 55 | #define D1(x) x |
55 | #else | 56 | #else |
56 | #define D1(x) | 57 | #define D1(x) |
@@ -62,50 +63,33 @@ | |||
62 | #define D2(x) | 63 | #define D2(x) |
63 | #endif | 64 | #endif |
64 | 65 | ||
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 | |||
65 | /* The prefixes of JFFS2 messages */ | 72 | /* The prefixes of JFFS2 messages */ |
73 | #define JFFS2_DBG KERN_DEBUG | ||
66 | #define JFFS2_DBG_PREFIX "[JFFS2 DBG]" | 74 | #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 | |||
76 | #define JFFS2_DBG_MSG_PREFIX JFFS2_DBG JFFS2_DBG_PREFIX | 75 | #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 | ||
80 | 76 | ||
81 | /* JFFS2 message macros */ | 77 | /* JFFS2 message macros */ |
82 | #define JFFS2_ERROR(fmt, ...) \ | 78 | #define JFFS2_ERROR(fmt, ...) \ |
83 | do { \ | 79 | pr_err("error: (%d) %s: " fmt, \ |
84 | printk(JFFS2_ERR_MSG_PREFIX \ | 80 | task_pid_nr(current), __func__, ##__VA_ARGS__) |
85 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
86 | __func__ , ##__VA_ARGS__); \ | ||
87 | } while(0) | ||
88 | 81 | ||
89 | #define JFFS2_WARNING(fmt, ...) \ | 82 | #define JFFS2_WARNING(fmt, ...) \ |
90 | do { \ | 83 | pr_warn("warning: (%d) %s: " fmt, \ |
91 | printk(JFFS2_WARN_MSG_PREFIX \ | 84 | task_pid_nr(current), __func__, ##__VA_ARGS__) |
92 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
93 | __func__ , ##__VA_ARGS__); \ | ||
94 | } while(0) | ||
95 | 85 | ||
96 | #define JFFS2_NOTICE(fmt, ...) \ | 86 | #define JFFS2_NOTICE(fmt, ...) \ |
97 | do { \ | 87 | pr_notice("notice: (%d) %s: " fmt, \ |
98 | printk(JFFS2_NOTICE_MSG_PREFIX \ | 88 | task_pid_nr(current), __func__, ##__VA_ARGS__) |
99 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
100 | __func__ , ##__VA_ARGS__); \ | ||
101 | } while(0) | ||
102 | 89 | ||
103 | #define JFFS2_DEBUG(fmt, ...) \ | 90 | #define JFFS2_DEBUG(fmt, ...) \ |
104 | do { \ | 91 | printk(KERN_DEBUG "[JFFS2 DBG] (%d) %s: " fmt, \ |
105 | printk(JFFS2_DBG_MSG_PREFIX \ | 92 | task_pid_nr(current), __func__, ##__VA_ARGS__) |
106 | " (%d) %s: " fmt, task_pid_nr(current), \ | ||
107 | __func__ , ##__VA_ARGS__); \ | ||
108 | } while(0) | ||
109 | 93 | ||
110 | /* | 94 | /* |
111 | * We split our debugging messages on several parts, depending on the JFFS2 | 95 | * 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 973ac5822bd7..b56018896d5e 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
15 | #include <linux/fs.h> | 17 | #include <linux/fs.h> |
@@ -79,7 +81,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
79 | uint32_t ino = 0; | 81 | uint32_t ino = 0; |
80 | struct inode *inode = NULL; | 82 | struct inode *inode = NULL; |
81 | 83 | ||
82 | D1(printk(KERN_DEBUG "jffs2_lookup()\n")); | 84 | jffs2_dbg(1, "jffs2_lookup()\n"); |
83 | 85 | ||
84 | if (target->d_name.len > JFFS2_MAX_NAME_LEN) | 86 | if (target->d_name.len > JFFS2_MAX_NAME_LEN) |
85 | return ERR_PTR(-ENAMETOOLONG); | 87 | return ERR_PTR(-ENAMETOOLONG); |
@@ -103,7 +105,7 @@ static struct dentry *jffs2_lookup(struct inode *dir_i, struct dentry *target, | |||
103 | if (ino) { | 105 | if (ino) { |
104 | inode = jffs2_iget(dir_i->i_sb, ino); | 106 | inode = jffs2_iget(dir_i->i_sb, ino); |
105 | if (IS_ERR(inode)) | 107 | if (IS_ERR(inode)) |
106 | printk(KERN_WARNING "iget() failed for ino #%u\n", ino); | 108 | pr_warn("iget() failed for ino #%u\n", ino); |
107 | } | 109 | } |
108 | 110 | ||
109 | return d_splice_alias(inode, target); | 111 | return d_splice_alias(inode, target); |
@@ -119,21 +121,22 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
119 | struct jffs2_full_dirent *fd; | 121 | struct jffs2_full_dirent *fd; |
120 | unsigned long offset, curofs; | 122 | unsigned long offset, curofs; |
121 | 123 | ||
122 | D1(printk(KERN_DEBUG "jffs2_readdir() for dir_i #%lu\n", filp->f_path.dentry->d_inode->i_ino)); | 124 | jffs2_dbg(1, "jffs2_readdir() for dir_i #%lu\n", |
125 | filp->f_path.dentry->d_inode->i_ino); | ||
123 | 126 | ||
124 | f = JFFS2_INODE_INFO(inode); | 127 | f = JFFS2_INODE_INFO(inode); |
125 | 128 | ||
126 | offset = filp->f_pos; | 129 | offset = filp->f_pos; |
127 | 130 | ||
128 | if (offset == 0) { | 131 | if (offset == 0) { |
129 | D1(printk(KERN_DEBUG "Dirent 0: \".\", ino #%lu\n", inode->i_ino)); | 132 | jffs2_dbg(1, "Dirent 0: \".\", ino #%lu\n", inode->i_ino); |
130 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) | 133 | if (filldir(dirent, ".", 1, 0, inode->i_ino, DT_DIR) < 0) |
131 | goto out; | 134 | goto out; |
132 | offset++; | 135 | offset++; |
133 | } | 136 | } |
134 | if (offset == 1) { | 137 | if (offset == 1) { |
135 | unsigned long pino = parent_ino(filp->f_path.dentry); | 138 | unsigned long pino = parent_ino(filp->f_path.dentry); |
136 | D1(printk(KERN_DEBUG "Dirent 1: \"..\", ino #%lu\n", pino)); | 139 | jffs2_dbg(1, "Dirent 1: \"..\", ino #%lu\n", pino); |
137 | if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) | 140 | if (filldir(dirent, "..", 2, 1, pino, DT_DIR) < 0) |
138 | goto out; | 141 | goto out; |
139 | offset++; | 142 | offset++; |
@@ -146,16 +149,18 @@ static int jffs2_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
146 | curofs++; | 149 | curofs++; |
147 | /* First loop: curofs = 2; offset = 2 */ | 150 | /* First loop: curofs = 2; offset = 2 */ |
148 | if (curofs < offset) { | 151 | if (curofs < offset) { |
149 | D2(printk(KERN_DEBUG "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", | 152 | jffs2_dbg(2, "Skipping dirent: \"%s\", ino #%u, type %d, because curofs %ld < offset %ld\n", |
150 | fd->name, fd->ino, fd->type, curofs, offset)); | 153 | fd->name, fd->ino, fd->type, curofs, offset); |
151 | continue; | 154 | continue; |
152 | } | 155 | } |
153 | if (!fd->ino) { | 156 | if (!fd->ino) { |
154 | D2(printk(KERN_DEBUG "Skipping deletion dirent \"%s\"\n", fd->name)); | 157 | jffs2_dbg(2, "Skipping deletion dirent \"%s\"\n", |
158 | fd->name); | ||
155 | offset++; | 159 | offset++; |
156 | continue; | 160 | continue; |
157 | } | 161 | } |
158 | D2(printk(KERN_DEBUG "Dirent %ld: \"%s\", ino #%u, type %d\n", offset, fd->name, fd->ino, fd->type)); | 162 | jffs2_dbg(2, "Dirent %ld: \"%s\", ino #%u, type %d\n", |
163 | offset, fd->name, fd->ino, fd->type); | ||
159 | if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) | 164 | if (filldir(dirent, fd->name, strlen(fd->name), offset, fd->ino, fd->type) < 0) |
160 | break; | 165 | break; |
161 | offset++; | 166 | offset++; |
@@ -184,12 +189,12 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | |||
184 | 189 | ||
185 | c = JFFS2_SB_INFO(dir_i->i_sb); | 190 | c = JFFS2_SB_INFO(dir_i->i_sb); |
186 | 191 | ||
187 | D1(printk(KERN_DEBUG "jffs2_create()\n")); | 192 | jffs2_dbg(1, "%s()\n", __func__); |
188 | 193 | ||
189 | inode = jffs2_new_inode(dir_i, mode, ri); | 194 | inode = jffs2_new_inode(dir_i, mode, ri); |
190 | 195 | ||
191 | if (IS_ERR(inode)) { | 196 | if (IS_ERR(inode)) { |
192 | D1(printk(KERN_DEBUG "jffs2_new_inode() failed\n")); | 197 | jffs2_dbg(1, "jffs2_new_inode() failed\n"); |
193 | jffs2_free_raw_inode(ri); | 198 | jffs2_free_raw_inode(ri); |
194 | return PTR_ERR(inode); | 199 | return PTR_ERR(inode); |
195 | } | 200 | } |
@@ -217,9 +222,9 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, | |||
217 | 222 | ||
218 | jffs2_free_raw_inode(ri); | 223 | jffs2_free_raw_inode(ri); |
219 | 224 | ||
220 | D1(printk(KERN_DEBUG "jffs2_create: Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", | 225 | jffs2_dbg(1, "%s(): Created ino #%lu with mode %o, nlink %d(%d). nrpages %ld\n", |
221 | inode->i_ino, inode->i_mode, inode->i_nlink, | 226 | __func__, inode->i_ino, inode->i_mode, inode->i_nlink, |
222 | f->inocache->pino_nlink, inode->i_mapping->nrpages)); | 227 | f->inocache->pino_nlink, inode->i_mapping->nrpages); |
223 | 228 | ||
224 | d_instantiate(dentry, inode); | 229 | d_instantiate(dentry, inode); |
225 | unlock_new_inode(inode); | 230 | unlock_new_inode(inode); |
@@ -362,14 +367,15 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char | |||
362 | /* We use f->target field to store the target path. */ | 367 | /* We use f->target field to store the target path. */ |
363 | f->target = kmemdup(target, targetlen + 1, GFP_KERNEL); | 368 | f->target = kmemdup(target, targetlen + 1, GFP_KERNEL); |
364 | if (!f->target) { | 369 | if (!f->target) { |
365 | printk(KERN_WARNING "Can't allocate %d bytes of memory\n", targetlen + 1); | 370 | pr_warn("Can't allocate %d bytes of memory\n", targetlen + 1); |
366 | mutex_unlock(&f->sem); | 371 | mutex_unlock(&f->sem); |
367 | jffs2_complete_reservation(c); | 372 | jffs2_complete_reservation(c); |
368 | ret = -ENOMEM; | 373 | ret = -ENOMEM; |
369 | goto fail; | 374 | goto fail; |
370 | } | 375 | } |
371 | 376 | ||
372 | D1(printk(KERN_DEBUG "jffs2_symlink: symlink's target '%s' cached\n", (char *)f->target)); | 377 | jffs2_dbg(1, "%s(): symlink's target '%s' cached\n", |
378 | __func__, (char *)f->target); | ||
373 | 379 | ||
374 | /* No data here. Only a metadata node, which will be | 380 | /* No data here. Only a metadata node, which will be |
375 | obsoleted by the first data write | 381 | obsoleted by the first data write |
@@ -856,7 +862,8 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, | |||
856 | f->inocache->pino_nlink++; | 862 | f->inocache->pino_nlink++; |
857 | mutex_unlock(&f->sem); | 863 | mutex_unlock(&f->sem); |
858 | 864 | ||
859 | printk(KERN_NOTICE "jffs2_rename(): Link succeeded, unlink failed (err %d). You now have a hard link\n", ret); | 865 | pr_notice("%s(): Link succeeded, unlink failed (err %d). You now have a hard link\n", |
866 | __func__, ret); | ||
860 | /* Might as well let the VFS know */ | 867 | /* Might as well let the VFS know */ |
861 | d_instantiate(new_dentry, old_dentry->d_inode); | 868 | d_instantiate(new_dentry, old_dentry->d_inode); |
862 | ihold(old_dentry->d_inode); | 869 | ihold(old_dentry->d_inode); |
diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c index eafb8d37a6fb..4a6cf289be24 100644 --- a/fs/jffs2/erase.c +++ b/fs/jffs2/erase.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
15 | #include <linux/mtd/mtd.h> | 17 | #include <linux/mtd/mtd.h> |
@@ -46,11 +48,12 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
46 | #else /* Linux */ | 48 | #else /* Linux */ |
47 | struct erase_info *instr; | 49 | struct erase_info *instr; |
48 | 50 | ||
49 | D1(printk(KERN_DEBUG "jffs2_erase_block(): erase block %#08x (range %#08x-%#08x)\n", | 51 | jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n", |
50 | jeb->offset, jeb->offset, jeb->offset + c->sector_size)); | 52 | __func__, |
53 | jeb->offset, jeb->offset, jeb->offset + c->sector_size); | ||
51 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); | 54 | instr = kmalloc(sizeof(struct erase_info) + sizeof(struct erase_priv_struct), GFP_KERNEL); |
52 | if (!instr) { | 55 | if (!instr) { |
53 | printk(KERN_WARNING "kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); | 56 | pr_warn("kmalloc for struct erase_info in jffs2_erase_block failed. Refiling block for later\n"); |
54 | mutex_lock(&c->erase_free_sem); | 57 | mutex_lock(&c->erase_free_sem); |
55 | spin_lock(&c->erase_completion_lock); | 58 | spin_lock(&c->erase_completion_lock); |
56 | list_move(&jeb->list, &c->erase_pending_list); | 59 | list_move(&jeb->list, &c->erase_pending_list); |
@@ -69,7 +72,6 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
69 | instr->len = c->sector_size; | 72 | instr->len = c->sector_size; |
70 | instr->callback = jffs2_erase_callback; | 73 | instr->callback = jffs2_erase_callback; |
71 | instr->priv = (unsigned long)(&instr[1]); | 74 | instr->priv = (unsigned long)(&instr[1]); |
72 | instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; | ||
73 | 75 | ||
74 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; | 76 | ((struct erase_priv_struct *)instr->priv)->jeb = jeb; |
75 | ((struct erase_priv_struct *)instr->priv)->c = c; | 77 | ((struct erase_priv_struct *)instr->priv)->c = c; |
@@ -84,7 +86,8 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
84 | 86 | ||
85 | if (ret == -ENOMEM || ret == -EAGAIN) { | 87 | if (ret == -ENOMEM || ret == -EAGAIN) { |
86 | /* Erase failed immediately. Refile it on the list */ | 88 | /* Erase failed immediately. Refile it on the list */ |
87 | D1(printk(KERN_DEBUG "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", jeb->offset, ret)); | 89 | jffs2_dbg(1, "Erase at 0x%08x failed: %d. Refiling on erase_pending_list\n", |
90 | jeb->offset, ret); | ||
88 | mutex_lock(&c->erase_free_sem); | 91 | mutex_lock(&c->erase_free_sem); |
89 | spin_lock(&c->erase_completion_lock); | 92 | spin_lock(&c->erase_completion_lock); |
90 | list_move(&jeb->list, &c->erase_pending_list); | 93 | list_move(&jeb->list, &c->erase_pending_list); |
@@ -97,9 +100,11 @@ static void jffs2_erase_block(struct jffs2_sb_info *c, | |||
97 | } | 100 | } |
98 | 101 | ||
99 | if (ret == -EROFS) | 102 | if (ret == -EROFS) |
100 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", jeb->offset); | 103 | pr_warn("Erase at 0x%08x failed immediately: -EROFS. Is the sector locked?\n", |
104 | jeb->offset); | ||
101 | else | 105 | else |
102 | printk(KERN_WARNING "Erase at 0x%08x failed immediately: errno %d\n", jeb->offset, ret); | 106 | pr_warn("Erase at 0x%08x failed immediately: errno %d\n", |
107 | jeb->offset, ret); | ||
103 | 108 | ||
104 | jffs2_erase_failed(c, jeb, bad_offset); | 109 | jffs2_erase_failed(c, jeb, bad_offset); |
105 | } | 110 | } |
@@ -125,13 +130,14 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
125 | 130 | ||
126 | work_done++; | 131 | work_done++; |
127 | if (!--count) { | 132 | if (!--count) { |
128 | D1(printk(KERN_DEBUG "Count reached. jffs2_erase_pending_blocks leaving\n")); | 133 | jffs2_dbg(1, "Count reached. jffs2_erase_pending_blocks leaving\n"); |
129 | goto done; | 134 | goto done; |
130 | } | 135 | } |
131 | 136 | ||
132 | } else if (!list_empty(&c->erase_pending_list)) { | 137 | } else if (!list_empty(&c->erase_pending_list)) { |
133 | jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); | 138 | jeb = list_entry(c->erase_pending_list.next, struct jffs2_eraseblock, list); |
134 | D1(printk(KERN_DEBUG "Starting erase of pending block 0x%08x\n", jeb->offset)); | 139 | jffs2_dbg(1, "Starting erase of pending block 0x%08x\n", |
140 | jeb->offset); | ||
135 | list_del(&jeb->list); | 141 | list_del(&jeb->list); |
136 | c->erasing_size += c->sector_size; | 142 | c->erasing_size += c->sector_size; |
137 | c->wasted_size -= jeb->wasted_size; | 143 | c->wasted_size -= jeb->wasted_size; |
@@ -159,13 +165,13 @@ int jffs2_erase_pending_blocks(struct jffs2_sb_info *c, int count) | |||
159 | spin_unlock(&c->erase_completion_lock); | 165 | spin_unlock(&c->erase_completion_lock); |
160 | mutex_unlock(&c->erase_free_sem); | 166 | mutex_unlock(&c->erase_free_sem); |
161 | done: | 167 | done: |
162 | D1(printk(KERN_DEBUG "jffs2_erase_pending_blocks completed\n")); | 168 | jffs2_dbg(1, "jffs2_erase_pending_blocks completed\n"); |
163 | return work_done; | 169 | return work_done; |
164 | } | 170 | } |
165 | 171 | ||
166 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 172 | static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
167 | { | 173 | { |
168 | D1(printk(KERN_DEBUG "Erase completed successfully at 0x%08x\n", jeb->offset)); | 174 | jffs2_dbg(1, "Erase completed successfully at 0x%08x\n", jeb->offset); |
169 | mutex_lock(&c->erase_free_sem); | 175 | mutex_lock(&c->erase_free_sem); |
170 | spin_lock(&c->erase_completion_lock); | 176 | spin_lock(&c->erase_completion_lock); |
171 | list_move_tail(&jeb->list, &c->erase_complete_list); | 177 | list_move_tail(&jeb->list, &c->erase_complete_list); |
@@ -214,7 +220,7 @@ static void jffs2_erase_callback(struct erase_info *instr) | |||
214 | struct erase_priv_struct *priv = (void *)instr->priv; | 220 | struct erase_priv_struct *priv = (void *)instr->priv; |
215 | 221 | ||
216 | if(instr->state != MTD_ERASE_DONE) { | 222 | if(instr->state != MTD_ERASE_DONE) { |
217 | printk(KERN_WARNING "Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n", | 223 | pr_warn("Erase at 0x%08llx finished, but state != MTD_ERASE_DONE. State is 0x%x instead.\n", |
218 | (unsigned long long)instr->addr, instr->state); | 224 | (unsigned long long)instr->addr, instr->state); |
219 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); | 225 | jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr); |
220 | } else { | 226 | } else { |
@@ -269,8 +275,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
269 | return; | 275 | return; |
270 | } | 276 | } |
271 | 277 | ||
272 | D1(printk(KERN_DEBUG "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", | 278 | jffs2_dbg(1, "Removed nodes in range 0x%08x-0x%08x from ino #%u\n", |
273 | jeb->offset, jeb->offset + c->sector_size, ic->ino)); | 279 | jeb->offset, jeb->offset + c->sector_size, ic->ino); |
274 | 280 | ||
275 | D2({ | 281 | D2({ |
276 | int i=0; | 282 | int i=0; |
@@ -281,7 +287,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
281 | 287 | ||
282 | printk(KERN_DEBUG); | 288 | printk(KERN_DEBUG); |
283 | while(this) { | 289 | while(this) { |
284 | printk(KERN_CONT "0x%08x(%d)->", | 290 | pr_cont("0x%08x(%d)->", |
285 | ref_offset(this), ref_flags(this)); | 291 | ref_offset(this), ref_flags(this)); |
286 | if (++i == 5) { | 292 | if (++i == 5) { |
287 | printk(KERN_DEBUG); | 293 | printk(KERN_DEBUG); |
@@ -289,7 +295,7 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
289 | } | 295 | } |
290 | this = this->next_in_ino; | 296 | this = this->next_in_ino; |
291 | } | 297 | } |
292 | printk(KERN_CONT "\n"); | 298 | pr_cont("\n"); |
293 | }); | 299 | }); |
294 | 300 | ||
295 | switch (ic->class) { | 301 | switch (ic->class) { |
@@ -310,7 +316,8 @@ static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info *c, | |||
310 | void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) | 316 | void jffs2_free_jeb_node_refs(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb) |
311 | { | 317 | { |
312 | struct jffs2_raw_node_ref *block, *ref; | 318 | struct jffs2_raw_node_ref *block, *ref; |
313 | D1(printk(KERN_DEBUG "Freeing all node refs for eraseblock offset 0x%08x\n", jeb->offset)); | 319 | jffs2_dbg(1, "Freeing all node refs for eraseblock offset 0x%08x\n", |
320 | jeb->offset); | ||
314 | 321 | ||
315 | block = ref = jeb->first_node; | 322 | block = ref = jeb->first_node; |
316 | 323 | ||
@@ -342,12 +349,13 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
342 | &ebuf, NULL); | 349 | &ebuf, NULL); |
343 | if (ret != -EOPNOTSUPP) { | 350 | if (ret != -EOPNOTSUPP) { |
344 | if (ret) { | 351 | if (ret) { |
345 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); | 352 | jffs2_dbg(1, "MTD point failed %d\n", ret); |
346 | goto do_flash_read; | 353 | goto do_flash_read; |
347 | } | 354 | } |
348 | if (retlen < c->sector_size) { | 355 | if (retlen < c->sector_size) { |
349 | /* Don't muck about if it won't let us point to the whole erase sector */ | 356 | /* Don't muck about if it won't let us point to the whole erase sector */ |
350 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", retlen)); | 357 | jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n", |
358 | retlen); | ||
351 | mtd_unpoint(c->mtd, jeb->offset, retlen); | 359 | mtd_unpoint(c->mtd, jeb->offset, retlen); |
352 | goto do_flash_read; | 360 | goto do_flash_read; |
353 | } | 361 | } |
@@ -359,8 +367,10 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
359 | } while(--retlen); | 367 | } while(--retlen); |
360 | mtd_unpoint(c->mtd, jeb->offset, c->sector_size); | 368 | mtd_unpoint(c->mtd, jeb->offset, c->sector_size); |
361 | if (retlen) { | 369 | if (retlen) { |
362 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08tx\n", | 370 | pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08tx\n", |
363 | *wordebuf, jeb->offset + c->sector_size-retlen*sizeof(*wordebuf)); | 371 | *wordebuf, |
372 | jeb->offset + | ||
373 | c->sector_size-retlen * sizeof(*wordebuf)); | ||
364 | return -EIO; | 374 | return -EIO; |
365 | } | 375 | } |
366 | return 0; | 376 | return 0; |
@@ -368,11 +378,12 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
368 | do_flash_read: | 378 | do_flash_read: |
369 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 379 | ebuf = kmalloc(PAGE_SIZE, GFP_KERNEL); |
370 | if (!ebuf) { | 380 | if (!ebuf) { |
371 | printk(KERN_WARNING "Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", jeb->offset); | 381 | pr_warn("Failed to allocate page buffer for verifying erase at 0x%08x. Refiling\n", |
382 | jeb->offset); | ||
372 | return -EAGAIN; | 383 | return -EAGAIN; |
373 | } | 384 | } |
374 | 385 | ||
375 | D1(printk(KERN_DEBUG "Verifying erase at 0x%08x\n", jeb->offset)); | 386 | jffs2_dbg(1, "Verifying erase at 0x%08x\n", jeb->offset); |
376 | 387 | ||
377 | for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { | 388 | for (ofs = jeb->offset; ofs < jeb->offset + c->sector_size; ) { |
378 | uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); | 389 | uint32_t readlen = min((uint32_t)PAGE_SIZE, jeb->offset + c->sector_size - ofs); |
@@ -382,12 +393,14 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
382 | 393 | ||
383 | ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf); | 394 | ret = mtd_read(c->mtd, ofs, readlen, &retlen, ebuf); |
384 | if (ret) { | 395 | if (ret) { |
385 | printk(KERN_WARNING "Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", ofs, ret); | 396 | pr_warn("Read of newly-erased block at 0x%08x failed: %d. Putting on bad_list\n", |
397 | ofs, ret); | ||
386 | ret = -EIO; | 398 | ret = -EIO; |
387 | goto fail; | 399 | goto fail; |
388 | } | 400 | } |
389 | if (retlen != readlen) { | 401 | if (retlen != readlen) { |
390 | printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen); | 402 | pr_warn("Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", |
403 | ofs, readlen, retlen); | ||
391 | ret = -EIO; | 404 | ret = -EIO; |
392 | goto fail; | 405 | goto fail; |
393 | } | 406 | } |
@@ -396,7 +409,8 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl | |||
396 | unsigned long *datum = ebuf + i; | 409 | unsigned long *datum = ebuf + i; |
397 | if (*datum + 1) { | 410 | if (*datum + 1) { |
398 | *bad_offset += i; | 411 | *bad_offset += i; |
399 | printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset); | 412 | pr_warn("Newly-erased block contained word 0x%lx at offset 0x%08x\n", |
413 | *datum, *bad_offset); | ||
400 | ret = -EIO; | 414 | ret = -EIO; |
401 | goto fail; | 415 | goto fail; |
402 | } | 416 | } |
@@ -422,7 +436,7 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
422 | } | 436 | } |
423 | 437 | ||
424 | /* Write the erase complete marker */ | 438 | /* Write the erase complete marker */ |
425 | D1(printk(KERN_DEBUG "Writing erased marker to block at 0x%08x\n", jeb->offset)); | 439 | jffs2_dbg(1, "Writing erased marker to block at 0x%08x\n", jeb->offset); |
426 | bad_offset = jeb->offset; | 440 | bad_offset = jeb->offset; |
427 | 441 | ||
428 | /* Cleanmarker in oob area or no cleanmarker at all ? */ | 442 | /* Cleanmarker in oob area or no cleanmarker at all ? */ |
@@ -451,10 +465,10 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb | |||
451 | 465 | ||
452 | if (ret || retlen != sizeof(marker)) { | 466 | if (ret || retlen != sizeof(marker)) { |
453 | if (ret) | 467 | if (ret) |
454 | printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n", | 468 | pr_warn("Write clean marker to block at 0x%08x failed: %d\n", |
455 | jeb->offset, ret); | 469 | jeb->offset, ret); |
456 | else | 470 | else |
457 | printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", | 471 | pr_warn("Short write to newly-erased block at 0x%08x: Wanted %zd, got %zd\n", |
458 | jeb->offset, sizeof(marker), retlen); | 472 | jeb->offset, sizeof(marker), retlen); |
459 | 473 | ||
460 | goto filebad; | 474 | goto filebad; |
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 61e6723535b9..db3889ba8818 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
15 | #include <linux/time.h> | 17 | #include <linux/time.h> |
@@ -85,7 +87,8 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) | |||
85 | unsigned char *pg_buf; | 87 | unsigned char *pg_buf; |
86 | int ret; | 88 | int ret; |
87 | 89 | ||
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)); | 90 | jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n", |
91 | __func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT); | ||
89 | 92 | ||
90 | BUG_ON(!PageLocked(pg)); | 93 | BUG_ON(!PageLocked(pg)); |
91 | 94 | ||
@@ -105,7 +108,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg) | |||
105 | flush_dcache_page(pg); | 108 | flush_dcache_page(pg); |
106 | kunmap(pg); | 109 | kunmap(pg); |
107 | 110 | ||
108 | D2(printk(KERN_DEBUG "readpage finished\n")); | 111 | jffs2_dbg(2, "readpage finished\n"); |
109 | return ret; | 112 | return ret; |
110 | } | 113 | } |
111 | 114 | ||
@@ -144,7 +147,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
144 | return -ENOMEM; | 147 | return -ENOMEM; |
145 | *pagep = pg; | 148 | *pagep = pg; |
146 | 149 | ||
147 | D1(printk(KERN_DEBUG "jffs2_write_begin()\n")); | 150 | jffs2_dbg(1, "%s()\n", __func__); |
148 | 151 | ||
149 | if (pageofs > inode->i_size) { | 152 | if (pageofs > inode->i_size) { |
150 | /* Make new hole frag from old EOF to new page */ | 153 | /* Make new hole frag from old EOF to new page */ |
@@ -153,8 +156,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
153 | struct jffs2_full_dnode *fn; | 156 | struct jffs2_full_dnode *fn; |
154 | uint32_t alloc_len; | 157 | uint32_t alloc_len; |
155 | 158 | ||
156 | D1(printk(KERN_DEBUG "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", | 159 | jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", |
157 | (unsigned int)inode->i_size, pageofs)); | 160 | (unsigned int)inode->i_size, pageofs); |
158 | 161 | ||
159 | ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, | 162 | ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, |
160 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | 163 | ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); |
@@ -198,7 +201,8 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
198 | f->metadata = NULL; | 201 | f->metadata = NULL; |
199 | } | 202 | } |
200 | if (ret) { | 203 | if (ret) { |
201 | D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n", ret)); | 204 | jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in write_begin, returned %d\n", |
205 | ret); | ||
202 | jffs2_mark_node_obsolete(c, fn->raw); | 206 | jffs2_mark_node_obsolete(c, fn->raw); |
203 | jffs2_free_full_dnode(fn); | 207 | jffs2_free_full_dnode(fn); |
204 | jffs2_complete_reservation(c); | 208 | jffs2_complete_reservation(c); |
@@ -222,7 +226,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, | |||
222 | if (ret) | 226 | if (ret) |
223 | goto out_page; | 227 | goto out_page; |
224 | } | 228 | } |
225 | D1(printk(KERN_DEBUG "end write_begin(). pg->flags %lx\n", pg->flags)); | 229 | jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags); |
226 | return ret; | 230 | return ret; |
227 | 231 | ||
228 | out_page: | 232 | out_page: |
@@ -248,8 +252,9 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
248 | int ret = 0; | 252 | int ret = 0; |
249 | uint32_t writtenlen = 0; | 253 | uint32_t writtenlen = 0; |
250 | 254 | ||
251 | D1(printk(KERN_DEBUG "jffs2_write_end(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n", | 255 | jffs2_dbg(1, "%s(): ino #%lu, page at 0x%lx, range %d-%d, flags %lx\n", |
252 | inode->i_ino, pg->index << PAGE_CACHE_SHIFT, start, end, pg->flags)); | 256 | __func__, inode->i_ino, pg->index << PAGE_CACHE_SHIFT, |
257 | start, end, pg->flags); | ||
253 | 258 | ||
254 | /* We need to avoid deadlock with page_cache_read() in | 259 | /* We need to avoid deadlock with page_cache_read() in |
255 | jffs2_garbage_collect_pass(). So the page must be | 260 | jffs2_garbage_collect_pass(). So the page must be |
@@ -268,7 +273,8 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
268 | ri = jffs2_alloc_raw_inode(); | 273 | ri = jffs2_alloc_raw_inode(); |
269 | 274 | ||
270 | if (!ri) { | 275 | if (!ri) { |
271 | D1(printk(KERN_DEBUG "jffs2_write_end(): Allocation of raw inode failed\n")); | 276 | jffs2_dbg(1, "%s(): Allocation of raw inode failed\n", |
277 | __func__); | ||
272 | unlock_page(pg); | 278 | unlock_page(pg); |
273 | page_cache_release(pg); | 279 | page_cache_release(pg); |
274 | return -ENOMEM; | 280 | return -ENOMEM; |
@@ -315,13 +321,14 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, | |||
315 | /* generic_file_write has written more to the page cache than we've | 321 | /* generic_file_write has written more to the page cache than we've |
316 | actually written to the medium. Mark the page !Uptodate so that | 322 | actually written to the medium. Mark the page !Uptodate so that |
317 | it gets reread */ | 323 | it gets reread */ |
318 | D1(printk(KERN_DEBUG "jffs2_write_end(): Not all bytes written. Marking page !uptodate\n")); | 324 | jffs2_dbg(1, "%s(): Not all bytes written. Marking page !uptodate\n", |
325 | __func__); | ||
319 | SetPageError(pg); | 326 | SetPageError(pg); |
320 | ClearPageUptodate(pg); | 327 | ClearPageUptodate(pg); |
321 | } | 328 | } |
322 | 329 | ||
323 | D1(printk(KERN_DEBUG "jffs2_write_end() returning %d\n", | 330 | jffs2_dbg(1, "%s() returning %d\n", |
324 | writtenlen > 0 ? writtenlen : ret)); | 331 | __func__, writtenlen > 0 ? writtenlen : ret); |
325 | unlock_page(pg); | 332 | unlock_page(pg); |
326 | page_cache_release(pg); | 333 | page_cache_release(pg); |
327 | return writtenlen > 0 ? writtenlen : ret; | 334 | return writtenlen > 0 ? writtenlen : ret; |
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index c0d5c9d770da..bb6f993ebca9 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
@@ -39,7 +41,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
39 | int ret; | 41 | int ret; |
40 | int alloc_type = ALLOC_NORMAL; | 42 | int alloc_type = ALLOC_NORMAL; |
41 | 43 | ||
42 | D1(printk(KERN_DEBUG "jffs2_setattr(): ino #%lu\n", inode->i_ino)); | 44 | jffs2_dbg(1, "%s(): ino #%lu\n", __func__, inode->i_ino); |
43 | 45 | ||
44 | /* Special cases - we don't want more than one data node | 46 | /* Special cases - we don't want more than one data node |
45 | for these types on the medium at any time. So setattr | 47 | for these types on the medium at any time. So setattr |
@@ -50,7 +52,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
50 | /* For these, we don't actually need to read the old node */ | 52 | /* For these, we don't actually need to read the old node */ |
51 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); | 53 | mdatalen = jffs2_encode_dev(&dev, inode->i_rdev); |
52 | mdata = (char *)&dev; | 54 | mdata = (char *)&dev; |
53 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of kdev_t\n", mdatalen)); | 55 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", |
56 | __func__, mdatalen); | ||
54 | } else if (S_ISLNK(inode->i_mode)) { | 57 | } else if (S_ISLNK(inode->i_mode)) { |
55 | mutex_lock(&f->sem); | 58 | mutex_lock(&f->sem); |
56 | mdatalen = f->metadata->size; | 59 | mdatalen = f->metadata->size; |
@@ -66,7 +69,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) | |||
66 | return ret; | 69 | return ret; |
67 | } | 70 | } |
68 | mutex_unlock(&f->sem); | 71 | mutex_unlock(&f->sem); |
69 | D1(printk(KERN_DEBUG "jffs2_setattr(): Writing %d bytes of symlink target\n", mdatalen)); | 72 | jffs2_dbg(1, "%s(): Writing %d bytes of symlink target\n", |
73 | __func__, mdatalen); | ||
70 | } | 74 | } |
71 | 75 | ||
72 | ri = jffs2_alloc_raw_inode(); | 76 | ri = jffs2_alloc_raw_inode(); |
@@ -233,7 +237,8 @@ void jffs2_evict_inode (struct inode *inode) | |||
233 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); | 237 | struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); |
234 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); | 238 | struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); |
235 | 239 | ||
236 | D1(printk(KERN_DEBUG "jffs2_evict_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode)); | 240 | jffs2_dbg(1, "%s(): ino #%lu mode %o\n", |
241 | __func__, inode->i_ino, inode->i_mode); | ||
237 | truncate_inode_pages(&inode->i_data, 0); | 242 | truncate_inode_pages(&inode->i_data, 0); |
238 | end_writeback(inode); | 243 | end_writeback(inode); |
239 | jffs2_do_clear_inode(c, f); | 244 | jffs2_do_clear_inode(c, f); |
@@ -249,7 +254,7 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
249 | dev_t rdev = 0; | 254 | dev_t rdev = 0; |
250 | int ret; | 255 | int ret; |
251 | 256 | ||
252 | D1(printk(KERN_DEBUG "jffs2_iget(): ino == %lu\n", ino)); | 257 | jffs2_dbg(1, "%s(): ino == %lu\n", __func__, ino); |
253 | 258 | ||
254 | inode = iget_locked(sb, ino); | 259 | inode = iget_locked(sb, ino); |
255 | if (!inode) | 260 | if (!inode) |
@@ -317,14 +322,16 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
317 | /* Read the device numbers from the media */ | 322 | /* Read the device numbers from the media */ |
318 | if (f->metadata->size != sizeof(jdev.old_id) && | 323 | if (f->metadata->size != sizeof(jdev.old_id) && |
319 | f->metadata->size != sizeof(jdev.new_id)) { | 324 | f->metadata->size != sizeof(jdev.new_id)) { |
320 | printk(KERN_NOTICE "Device node has strange size %d\n", f->metadata->size); | 325 | pr_notice("Device node has strange size %d\n", |
326 | f->metadata->size); | ||
321 | goto error_io; | 327 | goto error_io; |
322 | } | 328 | } |
323 | D1(printk(KERN_DEBUG "Reading device numbers from flash\n")); | 329 | jffs2_dbg(1, "Reading device numbers from flash\n"); |
324 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); | 330 | ret = jffs2_read_dnode(c, f, f->metadata, (char *)&jdev, 0, f->metadata->size); |
325 | if (ret < 0) { | 331 | if (ret < 0) { |
326 | /* Eep */ | 332 | /* Eep */ |
327 | printk(KERN_NOTICE "Read device numbers for inode %lu failed\n", (unsigned long)inode->i_ino); | 333 | pr_notice("Read device numbers for inode %lu failed\n", |
334 | (unsigned long)inode->i_ino); | ||
328 | goto error; | 335 | goto error; |
329 | } | 336 | } |
330 | if (f->metadata->size == sizeof(jdev.old_id)) | 337 | if (f->metadata->size == sizeof(jdev.old_id)) |
@@ -339,12 +346,13 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) | |||
339 | break; | 346 | break; |
340 | 347 | ||
341 | default: | 348 | default: |
342 | printk(KERN_WARNING "jffs2_read_inode(): Bogus imode %o for ino %lu\n", inode->i_mode, (unsigned long)inode->i_ino); | 349 | pr_warn("%s(): Bogus i_mode %o for ino %lu\n", |
350 | __func__, inode->i_mode, (unsigned long)inode->i_ino); | ||
343 | } | 351 | } |
344 | 352 | ||
345 | mutex_unlock(&f->sem); | 353 | mutex_unlock(&f->sem); |
346 | 354 | ||
347 | D1(printk(KERN_DEBUG "jffs2_read_inode() returning\n")); | 355 | jffs2_dbg(1, "jffs2_read_inode() returning\n"); |
348 | unlock_new_inode(inode); | 356 | unlock_new_inode(inode); |
349 | return inode; | 357 | return inode; |
350 | 358 | ||
@@ -362,11 +370,13 @@ void jffs2_dirty_inode(struct inode *inode, int flags) | |||
362 | struct iattr iattr; | 370 | struct iattr iattr; |
363 | 371 | ||
364 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { | 372 | if (!(inode->i_state & I_DIRTY_DATASYNC)) { |
365 | D2(printk(KERN_DEBUG "jffs2_dirty_inode() not calling setattr() for ino #%lu\n", inode->i_ino)); | 373 | jffs2_dbg(2, "%s(): not calling setattr() for ino #%lu\n", |
374 | __func__, inode->i_ino); | ||
366 | return; | 375 | return; |
367 | } | 376 | } |
368 | 377 | ||
369 | D1(printk(KERN_DEBUG "jffs2_dirty_inode() calling setattr() for ino #%lu\n", inode->i_ino)); | 378 | jffs2_dbg(1, "%s(): calling setattr() for ino #%lu\n", |
379 | __func__, inode->i_ino); | ||
370 | 380 | ||
371 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; | 381 | iattr.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_MTIME|ATTR_CTIME; |
372 | iattr.ia_mode = inode->i_mode; | 382 | iattr.ia_mode = inode->i_mode; |
@@ -414,7 +424,8 @@ struct inode *jffs2_new_inode (struct inode *dir_i, umode_t mode, struct jffs2_r | |||
414 | struct jffs2_inode_info *f; | 424 | struct jffs2_inode_info *f; |
415 | int ret; | 425 | int ret; |
416 | 426 | ||
417 | D1(printk(KERN_DEBUG "jffs2_new_inode(): dir_i %ld, mode 0x%x\n", dir_i->i_ino, mode)); | 427 | jffs2_dbg(1, "%s(): dir_i %ld, mode 0x%x\n", |
428 | __func__, dir_i->i_ino, mode); | ||
418 | 429 | ||
419 | c = JFFS2_SB_INFO(sb); | 430 | c = JFFS2_SB_INFO(sb); |
420 | 431 | ||
@@ -504,11 +515,11 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
504 | 515 | ||
505 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER | 516 | #ifndef CONFIG_JFFS2_FS_WRITEBUFFER |
506 | if (c->mtd->type == MTD_NANDFLASH) { | 517 | if (c->mtd->type == MTD_NANDFLASH) { |
507 | printk(KERN_ERR "jffs2: Cannot operate on NAND flash unless jffs2 NAND support is compiled in.\n"); | 518 | pr_err("Cannot operate on NAND flash unless jffs2 NAND support is compiled in\n"); |
508 | return -EINVAL; | 519 | return -EINVAL; |
509 | } | 520 | } |
510 | if (c->mtd->type == MTD_DATAFLASH) { | 521 | if (c->mtd->type == MTD_DATAFLASH) { |
511 | printk(KERN_ERR "jffs2: Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in.\n"); | 522 | pr_err("Cannot operate on DataFlash unless jffs2 DataFlash support is compiled in\n"); |
512 | return -EINVAL; | 523 | return -EINVAL; |
513 | } | 524 | } |
514 | #endif | 525 | #endif |
@@ -522,12 +533,13 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
522 | */ | 533 | */ |
523 | if ((c->sector_size * blocks) != c->flash_size) { | 534 | if ((c->sector_size * blocks) != c->flash_size) { |
524 | c->flash_size = c->sector_size * blocks; | 535 | c->flash_size = c->sector_size * blocks; |
525 | printk(KERN_INFO "jffs2: Flash size not aligned to erasesize, reducing to %dKiB\n", | 536 | pr_info("Flash size not aligned to erasesize, reducing to %dKiB\n", |
526 | c->flash_size / 1024); | 537 | c->flash_size / 1024); |
527 | } | 538 | } |
528 | 539 | ||
529 | if (c->flash_size < 5*c->sector_size) { | 540 | if (c->flash_size < 5*c->sector_size) { |
530 | printk(KERN_ERR "jffs2: Too few erase blocks (%d)\n", c->flash_size / c->sector_size); | 541 | pr_err("Too few erase blocks (%d)\n", |
542 | c->flash_size / c->sector_size); | ||
531 | return -EINVAL; | 543 | return -EINVAL; |
532 | } | 544 | } |
533 | 545 | ||
@@ -550,17 +562,17 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent) | |||
550 | if ((ret = jffs2_do_mount_fs(c))) | 562 | if ((ret = jffs2_do_mount_fs(c))) |
551 | goto out_inohash; | 563 | goto out_inohash; |
552 | 564 | ||
553 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): Getting root inode\n")); | 565 | jffs2_dbg(1, "%s(): Getting root inode\n", __func__); |
554 | root_i = jffs2_iget(sb, 1); | 566 | root_i = jffs2_iget(sb, 1); |
555 | if (IS_ERR(root_i)) { | 567 | if (IS_ERR(root_i)) { |
556 | D1(printk(KERN_WARNING "get root inode failed\n")); | 568 | jffs2_dbg(1, "get root inode failed\n"); |
557 | ret = PTR_ERR(root_i); | 569 | ret = PTR_ERR(root_i); |
558 | goto out_root; | 570 | goto out_root; |
559 | } | 571 | } |
560 | 572 | ||
561 | ret = -ENOMEM; | 573 | ret = -ENOMEM; |
562 | 574 | ||
563 | D1(printk(KERN_DEBUG "jffs2_do_fill_super(): d_alloc_root()\n")); | 575 | jffs2_dbg(1, "%s(): d_make_root()\n", __func__); |
564 | sb->s_root = d_make_root(root_i); | 576 | sb->s_root = d_make_root(root_i); |
565 | if (!sb->s_root) | 577 | if (!sb->s_root) |
566 | goto out_root; | 578 | goto out_root; |
@@ -618,20 +630,21 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
618 | */ | 630 | */ |
619 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); | 631 | inode = ilookup(OFNI_BS_2SFFJ(c), inum); |
620 | if (!inode) { | 632 | if (!inode) { |
621 | D1(printk(KERN_DEBUG "ilookup() failed for ino #%u; inode is probably deleted.\n", | 633 | jffs2_dbg(1, "ilookup() failed for ino #%u; inode is probably deleted.\n", |
622 | inum)); | 634 | inum); |
623 | 635 | ||
624 | spin_lock(&c->inocache_lock); | 636 | spin_lock(&c->inocache_lock); |
625 | ic = jffs2_get_ino_cache(c, inum); | 637 | ic = jffs2_get_ino_cache(c, inum); |
626 | if (!ic) { | 638 | if (!ic) { |
627 | D1(printk(KERN_DEBUG "Inode cache for ino #%u is gone.\n", inum)); | 639 | jffs2_dbg(1, "Inode cache for ino #%u is gone\n", |
640 | inum); | ||
628 | spin_unlock(&c->inocache_lock); | 641 | spin_unlock(&c->inocache_lock); |
629 | return NULL; | 642 | return NULL; |
630 | } | 643 | } |
631 | if (ic->state != INO_STATE_CHECKEDABSENT) { | 644 | if (ic->state != INO_STATE_CHECKEDABSENT) { |
632 | /* Wait for progress. Don't just loop */ | 645 | /* Wait for progress. Don't just loop */ |
633 | D1(printk(KERN_DEBUG "Waiting for ino #%u in state %d\n", | 646 | jffs2_dbg(1, "Waiting for ino #%u in state %d\n", |
634 | ic->ino, ic->state)); | 647 | ic->ino, ic->state); |
635 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 648 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
636 | } else { | 649 | } else { |
637 | spin_unlock(&c->inocache_lock); | 650 | spin_unlock(&c->inocache_lock); |
@@ -649,8 +662,8 @@ struct jffs2_inode_info *jffs2_gc_fetch_inode(struct jffs2_sb_info *c, | |||
649 | return ERR_CAST(inode); | 662 | return ERR_CAST(inode); |
650 | } | 663 | } |
651 | if (is_bad_inode(inode)) { | 664 | if (is_bad_inode(inode)) { |
652 | printk(KERN_NOTICE "Eep. read_inode() failed for ino #%u. unlinked %d\n", | 665 | pr_notice("Eep. read_inode() failed for ino #%u. unlinked %d\n", |
653 | inum, unlinked); | 666 | inum, unlinked); |
654 | /* NB. This will happen again. We need to do something appropriate here. */ | 667 | /* NB. This will happen again. We need to do something appropriate here. */ |
655 | iput(inode); | 668 | iput(inode); |
656 | return ERR_PTR(-EIO); | 669 | return ERR_PTR(-EIO); |
diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 31dce611337c..ad271c70aa25 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c | |||
@@ -10,6 +10,8 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
14 | |||
13 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
14 | #include <linux/mtd/mtd.h> | 16 | #include <linux/mtd/mtd.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
@@ -51,44 +53,44 @@ static struct jffs2_eraseblock *jffs2_find_gc_block(struct jffs2_sb_info *c) | |||
51 | number of free blocks is low. */ | 53 | number of free blocks is low. */ |
52 | again: | 54 | again: |
53 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { | 55 | if (!list_empty(&c->bad_used_list) && c->nr_free_blocks > c->resv_blocks_gcbad) { |
54 | D1(printk(KERN_DEBUG "Picking block from bad_used_list to GC next\n")); | 56 | jffs2_dbg(1, "Picking block from bad_used_list to GC next\n"); |
55 | nextlist = &c->bad_used_list; | 57 | nextlist = &c->bad_used_list; |
56 | } else if (n < 50 && !list_empty(&c->erasable_list)) { | 58 | } else if (n < 50 && !list_empty(&c->erasable_list)) { |
57 | /* Note that most of them will have gone directly to be erased. | 59 | /* Note that most of them will have gone directly to be erased. |
58 | So don't favour the erasable_list _too_ much. */ | 60 | So don't favour the erasable_list _too_ much. */ |
59 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next\n")); | 61 | jffs2_dbg(1, "Picking block from erasable_list to GC next\n"); |
60 | nextlist = &c->erasable_list; | 62 | nextlist = &c->erasable_list; |
61 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { | 63 | } else if (n < 110 && !list_empty(&c->very_dirty_list)) { |
62 | /* Most of the time, pick one off the very_dirty list */ | 64 | /* Most of the time, pick one off the very_dirty list */ |
63 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next\n")); | 65 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next\n"); |
64 | nextlist = &c->very_dirty_list; | 66 | nextlist = &c->very_dirty_list; |
65 | } else if (n < 126 && !list_empty(&c->dirty_list)) { | 67 | } else if (n < 126 && !list_empty(&c->dirty_list)) { |
66 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next\n")); | 68 | jffs2_dbg(1, "Picking block from dirty_list to GC next\n"); |
67 | nextlist = &c->dirty_list; | 69 | nextlist = &c->dirty_list; |
68 | } else if (!list_empty(&c->clean_list)) { | 70 | } else if (!list_empty(&c->clean_list)) { |
69 | D1(printk(KERN_DEBUG "Picking block from clean_list to GC next\n")); | 71 | jffs2_dbg(1, "Picking block from clean_list to GC next\n"); |
70 | nextlist = &c->clean_list; | 72 | nextlist = &c->clean_list; |
71 | } else if (!list_empty(&c->dirty_list)) { | 73 | } else if (!list_empty(&c->dirty_list)) { |
72 | D1(printk(KERN_DEBUG "Picking block from dirty_list to GC next (clean_list was empty)\n")); | 74 | jffs2_dbg(1, "Picking block from dirty_list to GC next (clean_list was empty)\n"); |
73 | 75 | ||
74 | nextlist = &c->dirty_list; | 76 | nextlist = &c->dirty_list; |
75 | } else if (!list_empty(&c->very_dirty_list)) { | 77 | } else if (!list_empty(&c->very_dirty_list)) { |
76 | D1(printk(KERN_DEBUG "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n")); | 78 | jffs2_dbg(1, "Picking block from very_dirty_list to GC next (clean_list and dirty_list were empty)\n"); |
77 | nextlist = &c->very_dirty_list; | 79 | nextlist = &c->very_dirty_list; |
78 | } else if (!list_empty(&c->erasable_list)) { | 80 | } else if (!list_empty(&c->erasable_list)) { |
79 | D1(printk(KERN_DEBUG "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n")); | 81 | jffs2_dbg(1, "Picking block from erasable_list to GC next (clean_list and {very_,}dirty_list were empty)\n"); |
80 | 82 | ||
81 | nextlist = &c->erasable_list; | 83 | nextlist = &c->erasable_list; |
82 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { | 84 | } else if (!list_empty(&c->erasable_pending_wbuf_list)) { |
83 | /* There are blocks are wating for the wbuf sync */ | 85 | /* There are blocks are wating for the wbuf sync */ |
84 | D1(printk(KERN_DEBUG "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n")); | 86 | jffs2_dbg(1, "Synching wbuf in order to reuse erasable_pending_wbuf_list blocks\n"); |
85 | spin_unlock(&c->erase_completion_lock); | 87 | spin_unlock(&c->erase_completion_lock); |
86 | jffs2_flush_wbuf_pad(c); | 88 | jffs2_flush_wbuf_pad(c); |
87 | spin_lock(&c->erase_completion_lock); | 89 | spin_lock(&c->erase_completion_lock); |
88 | goto again; | 90 | goto again; |
89 | } else { | 91 | } else { |
90 | /* Eep. All were empty */ | 92 | /* Eep. All were empty */ |
91 | D1(printk(KERN_NOTICE "jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n")); | 93 | jffs2_dbg(1, "No clean, dirty _or_ erasable blocks to GC from! Where are they all?\n"); |
92 | return NULL; | 94 | return NULL; |
93 | } | 95 | } |
94 | 96 | ||
@@ -97,13 +99,15 @@ again: | |||
97 | c->gcblock = ret; | 99 | c->gcblock = ret; |
98 | ret->gc_node = ret->first_node; | 100 | ret->gc_node = ret->first_node; |
99 | if (!ret->gc_node) { | 101 | if (!ret->gc_node) { |
100 | printk(KERN_WARNING "Eep. ret->gc_node for block at 0x%08x is NULL\n", ret->offset); | 102 | pr_warn("Eep. ret->gc_node for block at 0x%08x is NULL\n", |
103 | ret->offset); | ||
101 | BUG(); | 104 | BUG(); |
102 | } | 105 | } |
103 | 106 | ||
104 | /* Have we accidentally picked a clean block with wasted space ? */ | 107 | /* Have we accidentally picked a clean block with wasted space ? */ |
105 | if (ret->wasted_size) { | 108 | if (ret->wasted_size) { |
106 | D1(printk(KERN_DEBUG "Converting wasted_size %08x to dirty_size\n", ret->wasted_size)); | 109 | jffs2_dbg(1, "Converting wasted_size %08x to dirty_size\n", |
110 | ret->wasted_size); | ||
107 | ret->dirty_size += ret->wasted_size; | 111 | ret->dirty_size += ret->wasted_size; |
108 | c->wasted_size -= ret->wasted_size; | 112 | c->wasted_size -= ret->wasted_size; |
109 | c->dirty_size += ret->wasted_size; | 113 | c->dirty_size += ret->wasted_size; |
@@ -140,8 +144,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
140 | 144 | ||
141 | /* checked_ino is protected by the alloc_sem */ | 145 | /* checked_ino is protected by the alloc_sem */ |
142 | if (c->checked_ino > c->highest_ino && xattr) { | 146 | if (c->checked_ino > c->highest_ino && xattr) { |
143 | printk(KERN_CRIT "Checked all inodes but still 0x%x bytes of unchecked space?\n", | 147 | pr_crit("Checked all inodes but still 0x%x bytes of unchecked space?\n", |
144 | c->unchecked_size); | 148 | c->unchecked_size); |
145 | jffs2_dbg_dump_block_lists_nolock(c); | 149 | jffs2_dbg_dump_block_lists_nolock(c); |
146 | spin_unlock(&c->erase_completion_lock); | 150 | spin_unlock(&c->erase_completion_lock); |
147 | mutex_unlock(&c->alloc_sem); | 151 | mutex_unlock(&c->alloc_sem); |
@@ -163,8 +167,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
163 | } | 167 | } |
164 | 168 | ||
165 | if (!ic->pino_nlink) { | 169 | if (!ic->pino_nlink) { |
166 | D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink/pino zero\n", | 170 | jffs2_dbg(1, "Skipping check of ino #%d with nlink/pino zero\n", |
167 | ic->ino)); | 171 | ic->ino); |
168 | spin_unlock(&c->inocache_lock); | 172 | spin_unlock(&c->inocache_lock); |
169 | jffs2_xattr_delete_inode(c, ic); | 173 | jffs2_xattr_delete_inode(c, ic); |
170 | continue; | 174 | continue; |
@@ -172,13 +176,15 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
172 | switch(ic->state) { | 176 | switch(ic->state) { |
173 | case INO_STATE_CHECKEDABSENT: | 177 | case INO_STATE_CHECKEDABSENT: |
174 | case INO_STATE_PRESENT: | 178 | case INO_STATE_PRESENT: |
175 | D1(printk(KERN_DEBUG "Skipping ino #%u already checked\n", ic->ino)); | 179 | jffs2_dbg(1, "Skipping ino #%u already checked\n", |
180 | ic->ino); | ||
176 | spin_unlock(&c->inocache_lock); | 181 | spin_unlock(&c->inocache_lock); |
177 | continue; | 182 | continue; |
178 | 183 | ||
179 | case INO_STATE_GC: | 184 | case INO_STATE_GC: |
180 | case INO_STATE_CHECKING: | 185 | case INO_STATE_CHECKING: |
181 | printk(KERN_WARNING "Inode #%u is in state %d during CRC check phase!\n", ic->ino, ic->state); | 186 | pr_warn("Inode #%u is in state %d during CRC check phase!\n", |
187 | ic->ino, ic->state); | ||
182 | spin_unlock(&c->inocache_lock); | 188 | spin_unlock(&c->inocache_lock); |
183 | BUG(); | 189 | BUG(); |
184 | 190 | ||
@@ -186,7 +192,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
186 | /* We need to wait for it to finish, lest we move on | 192 | /* We need to wait for it to finish, lest we move on |
187 | and trigger the BUG() above while we haven't yet | 193 | and trigger the BUG() above while we haven't yet |
188 | finished checking all its nodes */ | 194 | finished checking all its nodes */ |
189 | D1(printk(KERN_DEBUG "Waiting for ino #%u to finish reading\n", ic->ino)); | 195 | jffs2_dbg(1, "Waiting for ino #%u to finish reading\n", |
196 | ic->ino); | ||
190 | /* We need to come back again for the _same_ inode. We've | 197 | /* We need to come back again for the _same_ inode. We've |
191 | made no progress in this case, but that should be OK */ | 198 | made no progress in this case, but that should be OK */ |
192 | c->checked_ino--; | 199 | c->checked_ino--; |
@@ -204,11 +211,13 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
204 | ic->state = INO_STATE_CHECKING; | 211 | ic->state = INO_STATE_CHECKING; |
205 | spin_unlock(&c->inocache_lock); | 212 | spin_unlock(&c->inocache_lock); |
206 | 213 | ||
207 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%u\n", ic->ino)); | 214 | jffs2_dbg(1, "%s(): triggering inode scan of ino#%u\n", |
215 | __func__, ic->ino); | ||
208 | 216 | ||
209 | ret = jffs2_do_crccheck_inode(c, ic); | 217 | ret = jffs2_do_crccheck_inode(c, ic); |
210 | if (ret) | 218 | if (ret) |
211 | printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino); | 219 | pr_warn("Returned error for crccheck of ino #%u. Expect badness...\n", |
220 | ic->ino); | ||
212 | 221 | ||
213 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); | 222 | jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT); |
214 | mutex_unlock(&c->alloc_sem); | 223 | mutex_unlock(&c->alloc_sem); |
@@ -220,11 +229,11 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
220 | !list_empty(&c->erase_pending_list)) { | 229 | !list_empty(&c->erase_pending_list)) { |
221 | spin_unlock(&c->erase_completion_lock); | 230 | spin_unlock(&c->erase_completion_lock); |
222 | mutex_unlock(&c->alloc_sem); | 231 | mutex_unlock(&c->alloc_sem); |
223 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() erasing pending blocks\n")); | 232 | jffs2_dbg(1, "%s(): erasing pending blocks\n", __func__); |
224 | if (jffs2_erase_pending_blocks(c, 1)) | 233 | if (jffs2_erase_pending_blocks(c, 1)) |
225 | return 0; | 234 | return 0; |
226 | 235 | ||
227 | D1(printk(KERN_DEBUG "No progress from erasing blocks; doing GC anyway\n")); | 236 | jffs2_dbg(1, "No progress from erasing block; doing GC anyway\n"); |
228 | spin_lock(&c->erase_completion_lock); | 237 | spin_lock(&c->erase_completion_lock); |
229 | mutex_lock(&c->alloc_sem); | 238 | mutex_lock(&c->alloc_sem); |
230 | } | 239 | } |
@@ -242,13 +251,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
242 | mutex_unlock(&c->alloc_sem); | 251 | mutex_unlock(&c->alloc_sem); |
243 | return -EAGAIN; | 252 | return -EAGAIN; |
244 | } | 253 | } |
245 | D1(printk(KERN_NOTICE "jffs2: Couldn't find erase block to garbage collect!\n")); | 254 | jffs2_dbg(1, "Couldn't find erase block to garbage collect!\n"); |
246 | spin_unlock(&c->erase_completion_lock); | 255 | spin_unlock(&c->erase_completion_lock); |
247 | mutex_unlock(&c->alloc_sem); | 256 | mutex_unlock(&c->alloc_sem); |
248 | return -EIO; | 257 | return -EIO; |
249 | } | 258 | } |
250 | 259 | ||
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)); | 260 | jffs2_dbg(1, "GC from block %08x, used_size %08x, dirty_size %08x, free_size %08x\n", |
261 | jeb->offset, jeb->used_size, jeb->dirty_size, jeb->free_size); | ||
252 | D1(if (c->nextblock) | 262 | D1(if (c->nextblock) |
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)); | 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)); |
254 | 264 | ||
@@ -261,12 +271,14 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
261 | gcblock_dirty = jeb->dirty_size; | 271 | gcblock_dirty = jeb->dirty_size; |
262 | 272 | ||
263 | while(ref_obsolete(raw)) { | 273 | while(ref_obsolete(raw)) { |
264 | D1(printk(KERN_DEBUG "Node at 0x%08x is obsolete... skipping\n", ref_offset(raw))); | 274 | jffs2_dbg(1, "Node at 0x%08x is obsolete... skipping\n", |
275 | ref_offset(raw)); | ||
265 | raw = ref_next(raw); | 276 | raw = ref_next(raw); |
266 | if (unlikely(!raw)) { | 277 | if (unlikely(!raw)) { |
267 | printk(KERN_WARNING "eep. End of raw list while still supposedly nodes to GC\n"); | 278 | pr_warn("eep. End of raw list while still supposedly nodes to GC\n"); |
268 | printk(KERN_WARNING "erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", | 279 | pr_warn("erase block at 0x%08x. free_size 0x%08x, dirty_size 0x%08x, used_size 0x%08x\n", |
269 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size); | 280 | jeb->offset, jeb->free_size, |
281 | jeb->dirty_size, jeb->used_size); | ||
270 | jeb->gc_node = raw; | 282 | jeb->gc_node = raw; |
271 | spin_unlock(&c->erase_completion_lock); | 283 | spin_unlock(&c->erase_completion_lock); |
272 | mutex_unlock(&c->alloc_sem); | 284 | mutex_unlock(&c->alloc_sem); |
@@ -275,7 +287,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
275 | } | 287 | } |
276 | jeb->gc_node = raw; | 288 | jeb->gc_node = raw; |
277 | 289 | ||
278 | D1(printk(KERN_DEBUG "Going to garbage collect node at 0x%08x\n", ref_offset(raw))); | 290 | jffs2_dbg(1, "Going to garbage collect node at 0x%08x\n", |
291 | ref_offset(raw)); | ||
279 | 292 | ||
280 | if (!raw->next_in_ino) { | 293 | if (!raw->next_in_ino) { |
281 | /* Inode-less node. Clean marker, snapshot or something like that */ | 294 | /* Inode-less node. Clean marker, snapshot or something like that */ |
@@ -316,7 +329,9 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
316 | 329 | ||
317 | spin_unlock(&c->erase_completion_lock); | 330 | spin_unlock(&c->erase_completion_lock); |
318 | 331 | ||
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)); | 332 | jffs2_dbg(1, "%s(): collecting from block @0x%08x. Node @0x%08x(%d), ino #%u\n", |
333 | __func__, jeb->offset, ref_offset(raw), ref_flags(raw), | ||
334 | ic->ino); | ||
320 | 335 | ||
321 | /* Three possibilities: | 336 | /* Three possibilities: |
322 | 1. Inode is already in-core. We must iget it and do proper | 337 | 1. Inode is already in-core. We must iget it and do proper |
@@ -336,8 +351,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
336 | if (ref_flags(raw) == REF_PRISTINE) | 351 | if (ref_flags(raw) == REF_PRISTINE) |
337 | ic->state = INO_STATE_GC; | 352 | ic->state = INO_STATE_GC; |
338 | else { | 353 | else { |
339 | D1(printk(KERN_DEBUG "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", | 354 | jffs2_dbg(1, "Ino #%u is absent but node not REF_PRISTINE. Reading.\n", |
340 | ic->ino)); | 355 | ic->ino); |
341 | } | 356 | } |
342 | break; | 357 | break; |
343 | 358 | ||
@@ -353,8 +368,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
353 | we're holding the alloc_sem, no other garbage collection | 368 | we're holding the alloc_sem, no other garbage collection |
354 | can happen. | 369 | can happen. |
355 | */ | 370 | */ |
356 | printk(KERN_CRIT "Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", | 371 | pr_crit("Inode #%u already in state %d in jffs2_garbage_collect_pass()!\n", |
357 | ic->ino, ic->state); | 372 | ic->ino, ic->state); |
358 | mutex_unlock(&c->alloc_sem); | 373 | mutex_unlock(&c->alloc_sem); |
359 | spin_unlock(&c->inocache_lock); | 374 | spin_unlock(&c->inocache_lock); |
360 | BUG(); | 375 | BUG(); |
@@ -367,8 +382,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
367 | drop the alloc_sem before sleeping. */ | 382 | drop the alloc_sem before sleeping. */ |
368 | 383 | ||
369 | mutex_unlock(&c->alloc_sem); | 384 | mutex_unlock(&c->alloc_sem); |
370 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() waiting for ino #%u in state %d\n", | 385 | jffs2_dbg(1, "%s(): waiting for ino #%u in state %d\n", |
371 | ic->ino, ic->state)); | 386 | __func__, ic->ino, ic->state); |
372 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); | 387 | sleep_on_spinunlock(&c->inocache_wq, &c->inocache_lock); |
373 | /* And because we dropped the alloc_sem we must start again from the | 388 | /* And because we dropped the alloc_sem we must start again from the |
374 | beginning. Ponder chance of livelock here -- we're returning success | 389 | beginning. Ponder chance of livelock here -- we're returning success |
@@ -433,7 +448,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
433 | test_gcnode: | 448 | test_gcnode: |
434 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { | 449 | if (jeb->dirty_size == gcblock_dirty && !ref_obsolete(jeb->gc_node)) { |
435 | /* Eep. This really should never happen. GC is broken */ | 450 | /* Eep. This really should never happen. GC is broken */ |
436 | printk(KERN_ERR "Error garbage collecting node at %08x!\n", ref_offset(jeb->gc_node)); | 451 | pr_err("Error garbage collecting node at %08x!\n", |
452 | ref_offset(jeb->gc_node)); | ||
437 | ret = -ENOSPC; | 453 | ret = -ENOSPC; |
438 | } | 454 | } |
439 | release_sem: | 455 | release_sem: |
@@ -445,7 +461,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) | |||
445 | 461 | ||
446 | eraseit: | 462 | eraseit: |
447 | if (c->gcblock && !c->gcblock->used_size) { | 463 | if (c->gcblock && !c->gcblock->used_size) { |
448 | D1(printk(KERN_DEBUG "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", c->gcblock->offset)); | 464 | jffs2_dbg(1, "Block at 0x%08x completely obsoleted by GC. Moving to erase_pending_list\n", |
465 | c->gcblock->offset); | ||
449 | /* We're GC'ing an empty block? */ | 466 | /* We're GC'ing an empty block? */ |
450 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); | 467 | list_add_tail(&c->gcblock->list, &c->erase_pending_list); |
451 | c->gcblock = NULL; | 468 | c->gcblock = NULL; |
@@ -475,12 +492,12 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
475 | 492 | ||
476 | if (c->gcblock != jeb) { | 493 | if (c->gcblock != jeb) { |
477 | spin_unlock(&c->erase_completion_lock); | 494 | spin_unlock(&c->erase_completion_lock); |
478 | D1(printk(KERN_DEBUG "GC block is no longer gcblock. Restart\n")); | 495 | jffs2_dbg(1, "GC block is no longer gcblock. Restart\n"); |
479 | goto upnout; | 496 | goto upnout; |
480 | } | 497 | } |
481 | if (ref_obsolete(raw)) { | 498 | if (ref_obsolete(raw)) { |
482 | spin_unlock(&c->erase_completion_lock); | 499 | spin_unlock(&c->erase_completion_lock); |
483 | D1(printk(KERN_DEBUG "node to be GC'd was obsoleted in the meantime.\n")); | 500 | jffs2_dbg(1, "node to be GC'd was obsoleted in the meantime.\n"); |
484 | /* They'll call again */ | 501 | /* They'll call again */ |
485 | goto upnout; | 502 | goto upnout; |
486 | } | 503 | } |
@@ -536,10 +553,10 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info *c, struct jffs2_era | |||
536 | } else if (fd) { | 553 | } else if (fd) { |
537 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); | 554 | ret = jffs2_garbage_collect_deletion_dirent(c, jeb, f, fd); |
538 | } else { | 555 | } else { |
539 | printk(KERN_WARNING "Raw node at 0x%08x wasn't in node lists for ino #%u\n", | 556 | pr_warn("Raw node at 0x%08x wasn't in node lists for ino #%u\n", |
540 | ref_offset(raw), f->inocache->ino); | 557 | ref_offset(raw), f->inocache->ino); |
541 | if (ref_obsolete(raw)) { | 558 | if (ref_obsolete(raw)) { |
542 | printk(KERN_WARNING "But it's obsolete so we don't mind too much\n"); | 559 | pr_warn("But it's obsolete so we don't mind too much\n"); |
543 | } else { | 560 | } else { |
544 | jffs2_dbg_dump_node(c, ref_offset(raw)); | 561 | jffs2_dbg_dump_node(c, ref_offset(raw)); |
545 | BUG(); | 562 | BUG(); |
@@ -562,7 +579,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
562 | uint32_t crc, rawlen; | 579 | uint32_t crc, rawlen; |
563 | int retried = 0; | 580 | int retried = 0; |
564 | 581 | ||
565 | D1(printk(KERN_DEBUG "Going to GC REF_PRISTINE node at 0x%08x\n", ref_offset(raw))); | 582 | jffs2_dbg(1, "Going to GC REF_PRISTINE node at 0x%08x\n", |
583 | ref_offset(raw)); | ||
566 | 584 | ||
567 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); | 585 | alloclen = rawlen = ref_totlen(c, c->gcblock, raw); |
568 | 586 | ||
@@ -595,8 +613,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
595 | 613 | ||
596 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); | 614 | crc = crc32(0, node, sizeof(struct jffs2_unknown_node)-4); |
597 | if (je32_to_cpu(node->u.hdr_crc) != crc) { | 615 | if (je32_to_cpu(node->u.hdr_crc) != crc) { |
598 | printk(KERN_WARNING "Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 616 | pr_warn("Header CRC failed on REF_PRISTINE node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
599 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); | 617 | ref_offset(raw), je32_to_cpu(node->u.hdr_crc), crc); |
600 | goto bail; | 618 | goto bail; |
601 | } | 619 | } |
602 | 620 | ||
@@ -604,16 +622,18 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
604 | case JFFS2_NODETYPE_INODE: | 622 | case JFFS2_NODETYPE_INODE: |
605 | crc = crc32(0, node, sizeof(node->i)-8); | 623 | crc = crc32(0, node, sizeof(node->i)-8); |
606 | if (je32_to_cpu(node->i.node_crc) != crc) { | 624 | if (je32_to_cpu(node->i.node_crc) != crc) { |
607 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 625 | pr_warn("Node CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
608 | ref_offset(raw), je32_to_cpu(node->i.node_crc), crc); | 626 | ref_offset(raw), je32_to_cpu(node->i.node_crc), |
627 | crc); | ||
609 | goto bail; | 628 | goto bail; |
610 | } | 629 | } |
611 | 630 | ||
612 | if (je32_to_cpu(node->i.dsize)) { | 631 | if (je32_to_cpu(node->i.dsize)) { |
613 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); | 632 | crc = crc32(0, node->i.data, je32_to_cpu(node->i.csize)); |
614 | if (je32_to_cpu(node->i.data_crc) != crc) { | 633 | if (je32_to_cpu(node->i.data_crc) != crc) { |
615 | printk(KERN_WARNING "Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 634 | pr_warn("Data CRC failed on REF_PRISTINE data node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
616 | ref_offset(raw), je32_to_cpu(node->i.data_crc), crc); | 635 | ref_offset(raw), |
636 | je32_to_cpu(node->i.data_crc), crc); | ||
617 | goto bail; | 637 | goto bail; |
618 | } | 638 | } |
619 | } | 639 | } |
@@ -622,21 +642,24 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
622 | case JFFS2_NODETYPE_DIRENT: | 642 | case JFFS2_NODETYPE_DIRENT: |
623 | crc = crc32(0, node, sizeof(node->d)-8); | 643 | crc = crc32(0, node, sizeof(node->d)-8); |
624 | if (je32_to_cpu(node->d.node_crc) != crc) { | 644 | if (je32_to_cpu(node->d.node_crc) != crc) { |
625 | printk(KERN_WARNING "Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 645 | pr_warn("Node CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
626 | ref_offset(raw), je32_to_cpu(node->d.node_crc), crc); | 646 | ref_offset(raw), |
647 | je32_to_cpu(node->d.node_crc), crc); | ||
627 | goto bail; | 648 | goto bail; |
628 | } | 649 | } |
629 | 650 | ||
630 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { | 651 | if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { |
631 | printk(KERN_WARNING "Name in dirent node at 0x%08x contains zeroes\n", ref_offset(raw)); | 652 | pr_warn("Name in dirent node at 0x%08x contains zeroes\n", |
653 | ref_offset(raw)); | ||
632 | goto bail; | 654 | goto bail; |
633 | } | 655 | } |
634 | 656 | ||
635 | if (node->d.nsize) { | 657 | if (node->d.nsize) { |
636 | crc = crc32(0, node->d.name, node->d.nsize); | 658 | crc = crc32(0, node->d.name, node->d.nsize); |
637 | if (je32_to_cpu(node->d.name_crc) != crc) { | 659 | if (je32_to_cpu(node->d.name_crc) != crc) { |
638 | printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 660 | pr_warn("Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
639 | ref_offset(raw), je32_to_cpu(node->d.name_crc), crc); | 661 | ref_offset(raw), |
662 | je32_to_cpu(node->d.name_crc), crc); | ||
640 | goto bail; | 663 | goto bail; |
641 | } | 664 | } |
642 | } | 665 | } |
@@ -644,8 +667,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
644 | default: | 667 | default: |
645 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ | 668 | /* If it's inode-less, we don't _know_ what it is. Just copy it intact */ |
646 | if (ic) { | 669 | if (ic) { |
647 | printk(KERN_WARNING "Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", | 670 | pr_warn("Unknown node type for REF_PRISTINE node at 0x%08x: 0x%04x\n", |
648 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); | 671 | ref_offset(raw), je16_to_cpu(node->u.nodetype)); |
649 | goto bail; | 672 | goto bail; |
650 | } | 673 | } |
651 | } | 674 | } |
@@ -657,12 +680,13 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
657 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); | 680 | ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node); |
658 | 681 | ||
659 | if (ret || (retlen != rawlen)) { | 682 | if (ret || (retlen != rawlen)) { |
660 | printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", | 683 | pr_notice("Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n", |
661 | rawlen, phys_ofs, ret, retlen); | 684 | rawlen, phys_ofs, ret, retlen); |
662 | if (retlen) { | 685 | if (retlen) { |
663 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); | 686 | jffs2_add_physical_node_ref(c, phys_ofs | REF_OBSOLETE, rawlen, NULL); |
664 | } else { | 687 | } else { |
665 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", phys_ofs); | 688 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", |
689 | phys_ofs); | ||
666 | } | 690 | } |
667 | if (!retried) { | 691 | if (!retried) { |
668 | /* Try to reallocate space and retry */ | 692 | /* Try to reallocate space and retry */ |
@@ -671,7 +695,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
671 | 695 | ||
672 | retried = 1; | 696 | retried = 1; |
673 | 697 | ||
674 | D1(printk(KERN_DEBUG "Retrying failed write of REF_PRISTINE node.\n")); | 698 | jffs2_dbg(1, "Retrying failed write of REF_PRISTINE node.\n"); |
675 | 699 | ||
676 | jffs2_dbg_acct_sanity_check(c,jeb); | 700 | jffs2_dbg_acct_sanity_check(c,jeb); |
677 | jffs2_dbg_acct_paranoia_check(c, jeb); | 701 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -681,14 +705,16 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
681 | it is only an upper estimation */ | 705 | it is only an upper estimation */ |
682 | 706 | ||
683 | if (!ret) { | 707 | if (!ret) { |
684 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", phys_ofs)); | 708 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n", |
709 | phys_ofs); | ||
685 | 710 | ||
686 | jffs2_dbg_acct_sanity_check(c,jeb); | 711 | jffs2_dbg_acct_sanity_check(c,jeb); |
687 | jffs2_dbg_acct_paranoia_check(c, jeb); | 712 | jffs2_dbg_acct_paranoia_check(c, jeb); |
688 | 713 | ||
689 | goto retry; | 714 | goto retry; |
690 | } | 715 | } |
691 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 716 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", |
717 | ret); | ||
692 | } | 718 | } |
693 | 719 | ||
694 | if (!ret) | 720 | if (!ret) |
@@ -698,7 +724,8 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, | |||
698 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); | 724 | jffs2_add_physical_node_ref(c, phys_ofs | REF_PRISTINE, rawlen, ic); |
699 | 725 | ||
700 | jffs2_mark_node_obsolete(c, raw); | 726 | jffs2_mark_node_obsolete(c, raw); |
701 | D1(printk(KERN_DEBUG "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", ref_offset(raw))); | 727 | jffs2_dbg(1, "WHEEE! GC REF_PRISTINE node at 0x%08x succeeded\n", |
728 | ref_offset(raw)); | ||
702 | 729 | ||
703 | out_node: | 730 | out_node: |
704 | kfree(node); | 731 | kfree(node); |
@@ -725,29 +752,32 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
725 | /* For these, we don't actually need to read the old node */ | 752 | /* For these, we don't actually need to read the old node */ |
726 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); | 753 | mdatalen = jffs2_encode_dev(&dev, JFFS2_F_I_RDEV(f)); |
727 | mdata = (char *)&dev; | 754 | mdata = (char *)&dev; |
728 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bytes of kdev_t\n", mdatalen)); | 755 | jffs2_dbg(1, "%s(): Writing %d bytes of kdev_t\n", |
756 | __func__, mdatalen); | ||
729 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { | 757 | } else if (S_ISLNK(JFFS2_F_I_MODE(f))) { |
730 | mdatalen = fn->size; | 758 | mdatalen = fn->size; |
731 | mdata = kmalloc(fn->size, GFP_KERNEL); | 759 | mdata = kmalloc(fn->size, GFP_KERNEL); |
732 | if (!mdata) { | 760 | if (!mdata) { |
733 | printk(KERN_WARNING "kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); | 761 | pr_warn("kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n"); |
734 | return -ENOMEM; | 762 | return -ENOMEM; |
735 | } | 763 | } |
736 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); | 764 | ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen); |
737 | if (ret) { | 765 | if (ret) { |
738 | printk(KERN_WARNING "read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", ret); | 766 | pr_warn("read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", |
767 | ret); | ||
739 | kfree(mdata); | 768 | kfree(mdata); |
740 | return ret; | 769 | return ret; |
741 | } | 770 | } |
742 | D1(printk(KERN_DEBUG "jffs2_garbage_collect_metadata(): Writing %d bites of symlink target\n", mdatalen)); | 771 | jffs2_dbg(1, "%s(): Writing %d bites of symlink target\n", |
772 | __func__, mdatalen); | ||
743 | 773 | ||
744 | } | 774 | } |
745 | 775 | ||
746 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, | 776 | ret = jffs2_reserve_space_gc(c, sizeof(ri) + mdatalen, &alloclen, |
747 | JFFS2_SUMMARY_INODE_SIZE); | 777 | JFFS2_SUMMARY_INODE_SIZE); |
748 | if (ret) { | 778 | if (ret) { |
749 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", | 779 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_metadata failed: %d\n", |
750 | sizeof(ri)+ mdatalen, ret); | 780 | sizeof(ri) + mdatalen, ret); |
751 | goto out; | 781 | goto out; |
752 | } | 782 | } |
753 | 783 | ||
@@ -784,7 +814,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_ | |||
784 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); | 814 | new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, ALLOC_GC); |
785 | 815 | ||
786 | if (IS_ERR(new_fn)) { | 816 | if (IS_ERR(new_fn)) { |
787 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 817 | pr_warn("Error writing new dnode: %ld\n", PTR_ERR(new_fn)); |
788 | ret = PTR_ERR(new_fn); | 818 | ret = PTR_ERR(new_fn); |
789 | goto out; | 819 | goto out; |
790 | } | 820 | } |
@@ -827,14 +857,15 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er | |||
827 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, | 857 | ret = jffs2_reserve_space_gc(c, sizeof(rd)+rd.nsize, &alloclen, |
828 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); | 858 | JFFS2_SUMMARY_DIRENT_SIZE(rd.nsize)); |
829 | if (ret) { | 859 | if (ret) { |
830 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", | 860 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dirent failed: %d\n", |
831 | sizeof(rd)+rd.nsize, ret); | 861 | sizeof(rd)+rd.nsize, ret); |
832 | return ret; | 862 | return ret; |
833 | } | 863 | } |
834 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); | 864 | new_fd = jffs2_write_dirent(c, f, &rd, fd->name, rd.nsize, ALLOC_GC); |
835 | 865 | ||
836 | if (IS_ERR(new_fd)) { | 866 | if (IS_ERR(new_fd)) { |
837 | printk(KERN_WARNING "jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", PTR_ERR(new_fd)); | 867 | pr_warn("jffs2_write_dirent in garbage_collect_dirent failed: %ld\n", |
868 | PTR_ERR(new_fd)); | ||
838 | return PTR_ERR(new_fd); | 869 | return PTR_ERR(new_fd); |
839 | } | 870 | } |
840 | jffs2_add_fd_to_list(c, new_fd, &f->dents); | 871 | jffs2_add_fd_to_list(c, new_fd, &f->dents); |
@@ -887,19 +918,22 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
887 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) | 918 | if (SECTOR_ADDR(raw->flash_offset) == SECTOR_ADDR(fd->raw->flash_offset)) |
888 | continue; | 919 | continue; |
889 | 920 | ||
890 | D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw))); | 921 | jffs2_dbg(1, "Check potential deletion dirent at %08x\n", |
922 | ref_offset(raw)); | ||
891 | 923 | ||
892 | /* This is an obsolete node belonging to the same directory, and it's of the right | 924 | /* This is an obsolete node belonging to the same directory, and it's of the right |
893 | length. We need to take a closer look...*/ | 925 | length. We need to take a closer look...*/ |
894 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); | 926 | ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd); |
895 | if (ret) { | 927 | if (ret) { |
896 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw)); | 928 | pr_warn("%s(): Read error (%d) reading obsolete node at %08x\n", |
929 | __func__, ret, ref_offset(raw)); | ||
897 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ | 930 | /* If we can't read it, we don't need to continue to obsolete it. Continue */ |
898 | continue; | 931 | continue; |
899 | } | 932 | } |
900 | if (retlen != rawlen) { | 933 | if (retlen != rawlen) { |
901 | printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Short read (%zd not %u) reading header from obsolete node at %08x\n", | 934 | pr_warn("%s(): Short read (%zd not %u) reading header from obsolete node at %08x\n", |
902 | retlen, rawlen, ref_offset(raw)); | 935 | __func__, retlen, rawlen, |
936 | ref_offset(raw)); | ||
903 | continue; | 937 | continue; |
904 | } | 938 | } |
905 | 939 | ||
@@ -923,8 +957,9 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
923 | a new deletion dirent to replace it */ | 957 | a new deletion dirent to replace it */ |
924 | mutex_unlock(&c->erase_free_sem); | 958 | mutex_unlock(&c->erase_free_sem); |
925 | 959 | ||
926 | D1(printk(KERN_DEBUG "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", | 960 | jffs2_dbg(1, "Deletion dirent at %08x still obsoletes real dirent \"%s\" at %08x for ino #%u\n", |
927 | ref_offset(fd->raw), fd->name, ref_offset(raw), je32_to_cpu(rd->ino))); | 961 | ref_offset(fd->raw), fd->name, |
962 | ref_offset(raw), je32_to_cpu(rd->ino)); | ||
928 | kfree(rd); | 963 | kfree(rd); |
929 | 964 | ||
930 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); | 965 | return jffs2_garbage_collect_dirent(c, jeb, f, fd); |
@@ -947,7 +982,8 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct | |||
947 | fdp = &(*fdp)->next; | 982 | fdp = &(*fdp)->next; |
948 | } | 983 | } |
949 | if (!found) { | 984 | if (!found) { |
950 | printk(KERN_WARNING "Deletion dirent \"%s\" not found in list for ino #%u\n", fd->name, f->inocache->ino); | 985 | pr_warn("Deletion dirent \"%s\" not found in list for ino #%u\n", |
986 | fd->name, f->inocache->ino); | ||
951 | } | 987 | } |
952 | jffs2_mark_node_obsolete(c, fd->raw); | 988 | jffs2_mark_node_obsolete(c, fd->raw); |
953 | jffs2_free_full_dirent(fd); | 989 | jffs2_free_full_dirent(fd); |
@@ -964,8 +1000,8 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
964 | uint32_t alloclen, ilen; | 1000 | uint32_t alloclen, ilen; |
965 | int ret; | 1001 | int ret; |
966 | 1002 | ||
967 | D1(printk(KERN_DEBUG "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", | 1003 | jffs2_dbg(1, "Writing replacement hole node for ino #%u from offset 0x%x to 0x%x\n", |
968 | f->inocache->ino, start, end)); | 1004 | f->inocache->ino, start, end); |
969 | 1005 | ||
970 | memset(&ri, 0, sizeof(ri)); | 1006 | memset(&ri, 0, sizeof(ri)); |
971 | 1007 | ||
@@ -976,35 +1012,37 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
976 | write it out again with the _same_ version as before */ | 1012 | write it out again with the _same_ version as before */ |
977 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); | 1013 | ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri); |
978 | if (readlen != sizeof(ri) || ret) { | 1014 | if (readlen != sizeof(ri) || ret) { |
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); | 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", |
1016 | ret, readlen); | ||
980 | goto fill; | 1017 | goto fill; |
981 | } | 1018 | } |
982 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { | 1019 | if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) { |
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", | 1020 | pr_warn("%s(): Node at 0x%08x had node type 0x%04x instead of JFFS2_NODETYPE_INODE(0x%04x)\n", |
984 | ref_offset(fn->raw), | 1021 | __func__, ref_offset(fn->raw), |
985 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); | 1022 | je16_to_cpu(ri.nodetype), JFFS2_NODETYPE_INODE); |
986 | return -EIO; | 1023 | return -EIO; |
987 | } | 1024 | } |
988 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { | 1025 | if (je32_to_cpu(ri.totlen) != sizeof(ri)) { |
989 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", | 1026 | pr_warn("%s(): Node at 0x%08x had totlen 0x%x instead of expected 0x%zx\n", |
990 | ref_offset(fn->raw), | 1027 | __func__, ref_offset(fn->raw), |
991 | je32_to_cpu(ri.totlen), sizeof(ri)); | 1028 | je32_to_cpu(ri.totlen), sizeof(ri)); |
992 | return -EIO; | 1029 | return -EIO; |
993 | } | 1030 | } |
994 | crc = crc32(0, &ri, sizeof(ri)-8); | 1031 | crc = crc32(0, &ri, sizeof(ri)-8); |
995 | if (crc != je32_to_cpu(ri.node_crc)) { | 1032 | if (crc != je32_to_cpu(ri.node_crc)) { |
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", | 1033 | pr_warn("%s: Node at 0x%08x had CRC 0x%08x which doesn't match calculated CRC 0x%08x\n", |
997 | ref_offset(fn->raw), | 1034 | __func__, ref_offset(fn->raw), |
998 | je32_to_cpu(ri.node_crc), crc); | 1035 | je32_to_cpu(ri.node_crc), crc); |
999 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ | 1036 | /* FIXME: We could possibly deal with this by writing new holes for each frag */ |
1000 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1037 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1001 | start, end, f->inocache->ino); | 1038 | start, end, f->inocache->ino); |
1002 | goto fill; | 1039 | goto fill; |
1003 | } | 1040 | } |
1004 | if (ri.compr != JFFS2_COMPR_ZERO) { | 1041 | if (ri.compr != JFFS2_COMPR_ZERO) { |
1005 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Node 0x%08x wasn't a hole node!\n", ref_offset(fn->raw)); | 1042 | pr_warn("%s(): Node 0x%08x wasn't a hole node!\n", |
1006 | printk(KERN_WARNING "Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", | 1043 | __func__, ref_offset(fn->raw)); |
1007 | start, end, f->inocache->ino); | 1044 | pr_warn("Data in the range 0x%08x to 0x%08x of inode #%u will be lost\n", |
1045 | start, end, f->inocache->ino); | ||
1008 | goto fill; | 1046 | goto fill; |
1009 | } | 1047 | } |
1010 | } else { | 1048 | } else { |
@@ -1043,14 +1081,14 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1043 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, | 1081 | ret = jffs2_reserve_space_gc(c, sizeof(ri), &alloclen, |
1044 | JFFS2_SUMMARY_INODE_SIZE); | 1082 | JFFS2_SUMMARY_INODE_SIZE); |
1045 | if (ret) { | 1083 | if (ret) { |
1046 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", | 1084 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_hole failed: %d\n", |
1047 | sizeof(ri), ret); | 1085 | sizeof(ri), ret); |
1048 | return ret; | 1086 | return ret; |
1049 | } | 1087 | } |
1050 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); | 1088 | new_fn = jffs2_write_dnode(c, f, &ri, NULL, 0, ALLOC_GC); |
1051 | 1089 | ||
1052 | if (IS_ERR(new_fn)) { | 1090 | if (IS_ERR(new_fn)) { |
1053 | printk(KERN_WARNING "Error writing new hole node: %ld\n", PTR_ERR(new_fn)); | 1091 | pr_warn("Error writing new hole node: %ld\n", PTR_ERR(new_fn)); |
1054 | return PTR_ERR(new_fn); | 1092 | return PTR_ERR(new_fn); |
1055 | } | 1093 | } |
1056 | if (je32_to_cpu(ri.version) == f->highest_version) { | 1094 | if (je32_to_cpu(ri.version) == f->highest_version) { |
@@ -1070,9 +1108,9 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1070 | * above.) | 1108 | * above.) |
1071 | */ | 1109 | */ |
1072 | D1(if(unlikely(fn->frags <= 1)) { | 1110 | D1(if(unlikely(fn->frags <= 1)) { |
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", | 1111 | pr_warn("%s(): Replacing fn with %d frag(s) but new ver %d != highest_version %d of ino #%d\n", |
1074 | fn->frags, je32_to_cpu(ri.version), f->highest_version, | 1112 | __func__, fn->frags, je32_to_cpu(ri.version), |
1075 | je32_to_cpu(ri.ino)); | 1113 | f->highest_version, je32_to_cpu(ri.ino)); |
1076 | }); | 1114 | }); |
1077 | 1115 | ||
1078 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ | 1116 | /* This is a partially-overlapped hole node. Mark it REF_NORMAL not REF_PRISTINE */ |
@@ -1089,11 +1127,11 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras | |||
1089 | } | 1127 | } |
1090 | } | 1128 | } |
1091 | if (fn->frags) { | 1129 | if (fn->frags) { |
1092 | printk(KERN_WARNING "jffs2_garbage_collect_hole: Old node still has frags!\n"); | 1130 | pr_warn("%s(): Old node still has frags!\n", __func__); |
1093 | BUG(); | 1131 | BUG(); |
1094 | } | 1132 | } |
1095 | if (!new_fn->frags) { | 1133 | if (!new_fn->frags) { |
1096 | printk(KERN_WARNING "jffs2_garbage_collect_hole: New node has no frags!\n"); | 1134 | pr_warn("%s(): New node has no frags!\n", __func__); |
1097 | BUG(); | 1135 | BUG(); |
1098 | } | 1136 | } |
1099 | 1137 | ||
@@ -1117,8 +1155,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1117 | 1155 | ||
1118 | memset(&ri, 0, sizeof(ri)); | 1156 | memset(&ri, 0, sizeof(ri)); |
1119 | 1157 | ||
1120 | D1(printk(KERN_DEBUG "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", | 1158 | jffs2_dbg(1, "Writing replacement dnode for ino #%u from offset 0x%x to 0x%x\n", |
1121 | f->inocache->ino, start, end)); | 1159 | f->inocache->ino, start, end); |
1122 | 1160 | ||
1123 | orig_end = end; | 1161 | orig_end = end; |
1124 | orig_start = start; | 1162 | orig_start = start; |
@@ -1149,15 +1187,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1149 | /* If the previous frag doesn't even reach the beginning, there's | 1187 | /* If the previous frag doesn't even reach the beginning, there's |
1150 | excessive fragmentation. Just merge. */ | 1188 | excessive fragmentation. Just merge. */ |
1151 | if (frag->ofs > min) { | 1189 | if (frag->ofs > min) { |
1152 | D1(printk(KERN_DEBUG "Expanding down to cover partial frag (0x%x-0x%x)\n", | 1190 | jffs2_dbg(1, "Expanding down to cover partial frag (0x%x-0x%x)\n", |
1153 | frag->ofs, frag->ofs+frag->size)); | 1191 | frag->ofs, frag->ofs+frag->size); |
1154 | start = frag->ofs; | 1192 | start = frag->ofs; |
1155 | continue; | 1193 | continue; |
1156 | } | 1194 | } |
1157 | /* OK. This frag holds the first byte of the page. */ | 1195 | /* OK. This frag holds the first byte of the page. */ |
1158 | if (!frag->node || !frag->node->raw) { | 1196 | if (!frag->node || !frag->node->raw) { |
1159 | D1(printk(KERN_DEBUG "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", | 1197 | jffs2_dbg(1, "First frag in page is hole (0x%x-0x%x). Not expanding down.\n", |
1160 | frag->ofs, frag->ofs+frag->size)); | 1198 | frag->ofs, frag->ofs+frag->size); |
1161 | break; | 1199 | break; |
1162 | } else { | 1200 | } else { |
1163 | 1201 | ||
@@ -1171,19 +1209,25 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1171 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1209 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1172 | 1210 | ||
1173 | if (jeb == c->gcblock) { | 1211 | if (jeb == c->gcblock) { |
1174 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1212 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1175 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); | 1213 | frag->ofs, |
1214 | frag->ofs + frag->size, | ||
1215 | ref_offset(raw)); | ||
1176 | start = frag->ofs; | 1216 | start = frag->ofs; |
1177 | break; | 1217 | break; |
1178 | } | 1218 | } |
1179 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1219 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1180 | D1(printk(KERN_DEBUG "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", | 1220 | jffs2_dbg(1, "Not expanding down to cover frag (0x%x-0x%x) in clean block %08x\n", |
1181 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1221 | frag->ofs, |
1222 | frag->ofs + frag->size, | ||
1223 | jeb->offset); | ||
1182 | break; | 1224 | break; |
1183 | } | 1225 | } |
1184 | 1226 | ||
1185 | D1(printk(KERN_DEBUG "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1227 | jffs2_dbg(1, "Expanding down to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1186 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1228 | frag->ofs, |
1229 | frag->ofs + frag->size, | ||
1230 | jeb->offset); | ||
1187 | start = frag->ofs; | 1231 | start = frag->ofs; |
1188 | break; | 1232 | break; |
1189 | } | 1233 | } |
@@ -1199,15 +1243,15 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1199 | /* If the previous frag doesn't even reach the beginning, there's lots | 1243 | /* If the previous frag doesn't even reach the beginning, there's lots |
1200 | of fragmentation. Just merge. */ | 1244 | of fragmentation. Just merge. */ |
1201 | if (frag->ofs+frag->size < max) { | 1245 | if (frag->ofs+frag->size < max) { |
1202 | D1(printk(KERN_DEBUG "Expanding up to cover partial frag (0x%x-0x%x)\n", | 1246 | jffs2_dbg(1, "Expanding up to cover partial frag (0x%x-0x%x)\n", |
1203 | frag->ofs, frag->ofs+frag->size)); | 1247 | frag->ofs, frag->ofs+frag->size); |
1204 | end = frag->ofs + frag->size; | 1248 | end = frag->ofs + frag->size; |
1205 | continue; | 1249 | continue; |
1206 | } | 1250 | } |
1207 | 1251 | ||
1208 | if (!frag->node || !frag->node->raw) { | 1252 | if (!frag->node || !frag->node->raw) { |
1209 | D1(printk(KERN_DEBUG "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", | 1253 | jffs2_dbg(1, "Last frag in page is hole (0x%x-0x%x). Not expanding up.\n", |
1210 | frag->ofs, frag->ofs+frag->size)); | 1254 | frag->ofs, frag->ofs+frag->size); |
1211 | break; | 1255 | break; |
1212 | } else { | 1256 | } else { |
1213 | 1257 | ||
@@ -1221,25 +1265,31 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1221 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; | 1265 | jeb = &c->blocks[raw->flash_offset / c->sector_size]; |
1222 | 1266 | ||
1223 | if (jeb == c->gcblock) { | 1267 | if (jeb == c->gcblock) { |
1224 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", | 1268 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in gcblock at %08x\n", |
1225 | frag->ofs, frag->ofs+frag->size, ref_offset(raw))); | 1269 | frag->ofs, |
1270 | frag->ofs + frag->size, | ||
1271 | ref_offset(raw)); | ||
1226 | end = frag->ofs + frag->size; | 1272 | end = frag->ofs + frag->size; |
1227 | break; | 1273 | break; |
1228 | } | 1274 | } |
1229 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { | 1275 | if (!ISDIRTY(jeb->dirty_size + jeb->wasted_size)) { |
1230 | D1(printk(KERN_DEBUG "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", | 1276 | jffs2_dbg(1, "Not expanding up to cover frag (0x%x-0x%x) in clean block %08x\n", |
1231 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1277 | frag->ofs, |
1278 | frag->ofs + frag->size, | ||
1279 | jeb->offset); | ||
1232 | break; | 1280 | break; |
1233 | } | 1281 | } |
1234 | 1282 | ||
1235 | D1(printk(KERN_DEBUG "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", | 1283 | jffs2_dbg(1, "Expanding up to cover frag (0x%x-0x%x) in dirty block %08x\n", |
1236 | frag->ofs, frag->ofs+frag->size, jeb->offset)); | 1284 | frag->ofs, |
1285 | frag->ofs + frag->size, | ||
1286 | jeb->offset); | ||
1237 | end = frag->ofs + frag->size; | 1287 | end = frag->ofs + frag->size; |
1238 | break; | 1288 | break; |
1239 | } | 1289 | } |
1240 | } | 1290 | } |
1241 | D1(printk(KERN_DEBUG "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", | 1291 | jffs2_dbg(1, "Expanded dnode to write from (0x%x-0x%x) to (0x%x-0x%x)\n", |
1242 | orig_start, orig_end, start, end)); | 1292 | orig_start, orig_end, start, end); |
1243 | 1293 | ||
1244 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); | 1294 | D1(BUG_ON(end > frag_last(&f->fragtree)->ofs + frag_last(&f->fragtree)->size)); |
1245 | BUG_ON(end < orig_end); | 1295 | BUG_ON(end < orig_end); |
@@ -1256,7 +1306,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1256 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); | 1306 | pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg); |
1257 | 1307 | ||
1258 | if (IS_ERR(pg_ptr)) { | 1308 | if (IS_ERR(pg_ptr)) { |
1259 | printk(KERN_WARNING "read_cache_page() returned error: %ld\n", PTR_ERR(pg_ptr)); | 1309 | pr_warn("read_cache_page() returned error: %ld\n", |
1310 | PTR_ERR(pg_ptr)); | ||
1260 | return PTR_ERR(pg_ptr); | 1311 | return PTR_ERR(pg_ptr); |
1261 | } | 1312 | } |
1262 | 1313 | ||
@@ -1270,8 +1321,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1270 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); | 1321 | &alloclen, JFFS2_SUMMARY_INODE_SIZE); |
1271 | 1322 | ||
1272 | if (ret) { | 1323 | if (ret) { |
1273 | printk(KERN_WARNING "jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", | 1324 | pr_warn("jffs2_reserve_space_gc of %zd bytes for garbage_collect_dnode failed: %d\n", |
1274 | sizeof(ri)+ JFFS2_MIN_DATA_LEN, ret); | 1325 | sizeof(ri) + JFFS2_MIN_DATA_LEN, ret); |
1275 | break; | 1326 | break; |
1276 | } | 1327 | } |
1277 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); | 1328 | cdatalen = min_t(uint32_t, alloclen - sizeof(ri), end - offset); |
@@ -1308,7 +1359,8 @@ static int jffs2_garbage_collect_dnode(struct jffs2_sb_info *c, struct jffs2_era | |||
1308 | jffs2_free_comprbuf(comprbuf, writebuf); | 1359 | jffs2_free_comprbuf(comprbuf, writebuf); |
1309 | 1360 | ||
1310 | if (IS_ERR(new_fn)) { | 1361 | if (IS_ERR(new_fn)) { |
1311 | printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn)); | 1362 | pr_warn("Error writing new dnode: %ld\n", |
1363 | PTR_ERR(new_fn)); | ||
1312 | ret = PTR_ERR(new_fn); | 1364 | ret = PTR_ERR(new_fn); |
1313 | break; | 1365 | break; |
1314 | } | 1366 | } |
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c index c082868910f2..4f47aa24b556 100644 --- a/fs/jffs2/malloc.c +++ b/fs/jffs2/malloc.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
14 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c index 5e03233c2363..975a1f562c10 100644 --- a/fs/jffs2/nodelist.c +++ b/fs/jffs2/nodelist.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
14 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
@@ -687,8 +689,8 @@ int jffs2_scan_dirty_space(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb | |||
687 | if (!size) | 689 | if (!size) |
688 | return 0; | 690 | return 0; |
689 | if (unlikely(size > jeb->free_size)) { | 691 | if (unlikely(size > jeb->free_size)) { |
690 | printk(KERN_CRIT "Dirty space 0x%x larger then free_size 0x%x (wasted 0x%x)\n", | 692 | pr_crit("Dirty space 0x%x larger then free_size 0x%x (wasted 0x%x)\n", |
691 | size, jeb->free_size, jeb->wasted_size); | 693 | size, jeb->free_size, jeb->wasted_size); |
692 | BUG(); | 694 | BUG(); |
693 | } | 695 | } |
694 | /* REF_EMPTY_NODE is !obsolete, so that works OK */ | 696 | /* REF_EMPTY_NODE is !obsolete, so that works OK */ |
@@ -726,8 +728,10 @@ static inline uint32_t __ref_totlen(struct jffs2_sb_info *c, | |||
726 | 728 | ||
727 | /* Last node in block. Use free_space */ | 729 | /* Last node in block. Use free_space */ |
728 | if (unlikely(ref != jeb->last_node)) { | 730 | if (unlikely(ref != jeb->last_node)) { |
729 | printk(KERN_CRIT "ref %p @0x%08x is not jeb->last_node (%p @0x%08x)\n", | 731 | pr_crit("ref %p @0x%08x is not jeb->last_node (%p @0x%08x)\n", |
730 | ref, ref_offset(ref), jeb->last_node, jeb->last_node?ref_offset(jeb->last_node):0); | 732 | ref, ref_offset(ref), jeb->last_node, |
733 | jeb->last_node ? | ||
734 | ref_offset(jeb->last_node) : 0); | ||
731 | BUG(); | 735 | BUG(); |
732 | } | 736 | } |
733 | ref_end = jeb->offset + c->sector_size - jeb->free_size; | 737 | ref_end = jeb->offset + c->sector_size - jeb->free_size; |
@@ -747,16 +751,20 @@ uint32_t __jffs2_ref_totlen(struct jffs2_sb_info *c, struct jffs2_eraseblock *je | |||
747 | if (!jeb) | 751 | if (!jeb) |
748 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; | 752 | jeb = &c->blocks[ref->flash_offset / c->sector_size]; |
749 | 753 | ||
750 | printk(KERN_CRIT "Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", | 754 | pr_crit("Totlen for ref at %p (0x%08x-0x%08x) miscalculated as 0x%x instead of %x\n", |
751 | ref, ref_offset(ref), ref_offset(ref)+ref->__totlen, | 755 | ref, ref_offset(ref), ref_offset(ref) + ref->__totlen, |
752 | ret, ref->__totlen); | 756 | ret, ref->__totlen); |
753 | if (ref_next(ref)) { | 757 | if (ref_next(ref)) { |
754 | printk(KERN_CRIT "next %p (0x%08x-0x%08x)\n", ref_next(ref), ref_offset(ref_next(ref)), | 758 | pr_crit("next %p (0x%08x-0x%08x)\n", |
755 | ref_offset(ref_next(ref))+ref->__totlen); | 759 | ref_next(ref), ref_offset(ref_next(ref)), |
760 | ref_offset(ref_next(ref)) + ref->__totlen); | ||
756 | } else | 761 | } else |
757 | printk(KERN_CRIT "No next ref. jeb->last_node is %p\n", jeb->last_node); | 762 | pr_crit("No next ref. jeb->last_node is %p\n", |
763 | jeb->last_node); | ||
758 | 764 | ||
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); | 765 | pr_crit("jeb->wasted_size %x, dirty_size %x, used_size %x, free_size %x\n", |
766 | jeb->wasted_size, jeb->dirty_size, jeb->used_size, | ||
767 | jeb->free_size); | ||
760 | 768 | ||
761 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) | 769 | #if defined(JFFS2_DBG_DUMPS) || defined(JFFS2_DBG_PARANOIA_CHECKS) |
762 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); | 770 | __jffs2_dbg_dump_node_refs_nolock(c, jeb); |
diff --git a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c index 694aa5b03505..6784d1e7a7eb 100644 --- a/fs/jffs2/nodemgmt.c +++ b/fs/jffs2/nodemgmt.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/mtd/mtd.h> | 15 | #include <linux/mtd/mtd.h> |
14 | #include <linux/compiler.h> | 16 | #include <linux/compiler.h> |
@@ -46,10 +48,10 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
46 | /* align it */ | 48 | /* align it */ |
47 | minsize = PAD(minsize); | 49 | minsize = PAD(minsize); |
48 | 50 | ||
49 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): Requested 0x%x bytes\n", minsize)); | 51 | jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize); |
50 | mutex_lock(&c->alloc_sem); | 52 | mutex_lock(&c->alloc_sem); |
51 | 53 | ||
52 | D1(printk(KERN_DEBUG "jffs2_reserve_space(): alloc sem got\n")); | 54 | jffs2_dbg(1, "%s(): alloc sem got\n", __func__); |
53 | 55 | ||
54 | spin_lock(&c->erase_completion_lock); | 56 | spin_lock(&c->erase_completion_lock); |
55 | 57 | ||
@@ -73,11 +75,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
73 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size; | 75 | dirty = c->dirty_size + c->erasing_size - c->nr_erasing_blocks * c->sector_size + c->unchecked_size; |
74 | if (dirty < c->nospc_dirty_size) { | 76 | if (dirty < c->nospc_dirty_size) { |
75 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { | 77 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { |
76 | D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on dirty space to GC, but it's a deletion. Allowing...\n")); | 78 | jffs2_dbg(1, "%s(): Low on dirty space to GC, but it's a deletion. Allowing...\n", |
79 | __func__); | ||
77 | break; | 80 | break; |
78 | } | 81 | } |
79 | D1(printk(KERN_DEBUG "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n", | 82 | jffs2_dbg(1, "dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n", |
80 | dirty, c->unchecked_size, c->sector_size)); | 83 | dirty, c->unchecked_size, |
84 | c->sector_size); | ||
81 | 85 | ||
82 | spin_unlock(&c->erase_completion_lock); | 86 | spin_unlock(&c->erase_completion_lock); |
83 | mutex_unlock(&c->alloc_sem); | 87 | mutex_unlock(&c->alloc_sem); |
@@ -96,12 +100,13 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
96 | avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size; | 100 | avail = c->free_size + c->dirty_size + c->erasing_size + c->unchecked_size; |
97 | if ( (avail / c->sector_size) <= blocksneeded) { | 101 | if ( (avail / c->sector_size) <= blocksneeded) { |
98 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { | 102 | if (prio == ALLOC_DELETION && c->nr_free_blocks + c->nr_erasing_blocks >= c->resv_blocks_deletion) { |
99 | D1(printk(KERN_NOTICE "jffs2_reserve_space(): Low on possibly available space, but it's a deletion. Allowing...\n")); | 103 | jffs2_dbg(1, "%s(): Low on possibly available space, but it's a deletion. Allowing...\n", |
104 | __func__); | ||
100 | break; | 105 | break; |
101 | } | 106 | } |
102 | 107 | ||
103 | D1(printk(KERN_DEBUG "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", | 108 | jffs2_dbg(1, "max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n", |
104 | avail, blocksneeded * c->sector_size)); | 109 | avail, blocksneeded * c->sector_size); |
105 | spin_unlock(&c->erase_completion_lock); | 110 | spin_unlock(&c->erase_completion_lock); |
106 | mutex_unlock(&c->alloc_sem); | 111 | mutex_unlock(&c->alloc_sem); |
107 | return -ENOSPC; | 112 | return -ENOSPC; |
@@ -109,9 +114,14 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
109 | 114 | ||
110 | mutex_unlock(&c->alloc_sem); | 115 | mutex_unlock(&c->alloc_sem); |
111 | 116 | ||
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", | 117 | 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", |
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, | 118 | c->nr_free_blocks, c->nr_erasing_blocks, |
114 | c->free_size + c->dirty_size + c->wasted_size + c->used_size + c->erasing_size + c->bad_size, c->flash_size)); | 119 | c->free_size, c->dirty_size, c->wasted_size, |
120 | c->used_size, c->erasing_size, c->bad_size, | ||
121 | c->free_size + c->dirty_size + | ||
122 | c->wasted_size + c->used_size + | ||
123 | c->erasing_size + c->bad_size, | ||
124 | c->flash_size); | ||
115 | spin_unlock(&c->erase_completion_lock); | 125 | spin_unlock(&c->erase_completion_lock); |
116 | 126 | ||
117 | ret = jffs2_garbage_collect_pass(c); | 127 | ret = jffs2_garbage_collect_pass(c); |
@@ -124,7 +134,8 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
124 | DECLARE_WAITQUEUE(wait, current); | 134 | DECLARE_WAITQUEUE(wait, current); |
125 | set_current_state(TASK_UNINTERRUPTIBLE); | 135 | set_current_state(TASK_UNINTERRUPTIBLE); |
126 | add_wait_queue(&c->erase_wait, &wait); | 136 | add_wait_queue(&c->erase_wait, &wait); |
127 | D1(printk(KERN_DEBUG "%s waiting for erase to complete\n", __func__)); | 137 | jffs2_dbg(1, "%s waiting for erase to complete\n", |
138 | __func__); | ||
128 | spin_unlock(&c->erase_completion_lock); | 139 | spin_unlock(&c->erase_completion_lock); |
129 | 140 | ||
130 | schedule(); | 141 | schedule(); |
@@ -144,7 +155,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
144 | 155 | ||
145 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); | 156 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
146 | if (ret) { | 157 | if (ret) { |
147 | D1(printk(KERN_DEBUG "jffs2_reserve_space: ret is %d\n", ret)); | 158 | jffs2_dbg(1, "%s(): ret is %d\n", __func__, ret); |
148 | } | 159 | } |
149 | } | 160 | } |
150 | spin_unlock(&c->erase_completion_lock); | 161 | spin_unlock(&c->erase_completion_lock); |
@@ -161,13 +172,14 @@ int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize, | |||
161 | int ret = -EAGAIN; | 172 | int ret = -EAGAIN; |
162 | minsize = PAD(minsize); | 173 | minsize = PAD(minsize); |
163 | 174 | ||
164 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc(): Requested 0x%x bytes\n", minsize)); | 175 | jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize); |
165 | 176 | ||
166 | spin_lock(&c->erase_completion_lock); | 177 | spin_lock(&c->erase_completion_lock); |
167 | while(ret == -EAGAIN) { | 178 | while(ret == -EAGAIN) { |
168 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); | 179 | ret = jffs2_do_reserve_space(c, minsize, len, sumsize); |
169 | if (ret) { | 180 | if (ret) { |
170 | D1(printk(KERN_DEBUG "jffs2_reserve_space_gc: looping, ret is %d\n", ret)); | 181 | jffs2_dbg(1, "%s(): looping, ret is %d\n", |
182 | __func__, ret); | ||
171 | } | 183 | } |
172 | } | 184 | } |
173 | spin_unlock(&c->erase_completion_lock); | 185 | spin_unlock(&c->erase_completion_lock); |
@@ -184,8 +196,8 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
184 | { | 196 | { |
185 | 197 | ||
186 | if (c->nextblock == NULL) { | 198 | if (c->nextblock == NULL) { |
187 | D1(printk(KERN_DEBUG "jffs2_close_nextblock: Erase block at 0x%08x has already been placed in a list\n", | 199 | jffs2_dbg(1, "%s(): Erase block at 0x%08x has already been placed in a list\n", |
188 | jeb->offset)); | 200 | __func__, jeb->offset); |
189 | return; | 201 | return; |
190 | } | 202 | } |
191 | /* Check, if we have a dirty block now, or if it was dirty already */ | 203 | /* Check, if we have a dirty block now, or if it was dirty already */ |
@@ -195,17 +207,20 @@ static void jffs2_close_nextblock(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
195 | jeb->dirty_size += jeb->wasted_size; | 207 | jeb->dirty_size += jeb->wasted_size; |
196 | jeb->wasted_size = 0; | 208 | jeb->wasted_size = 0; |
197 | if (VERYDIRTY(c, jeb->dirty_size)) { | 209 | if (VERYDIRTY(c, jeb->dirty_size)) { |
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", | 210 | jffs2_dbg(1, "Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
199 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 211 | jeb->offset, jeb->free_size, jeb->dirty_size, |
212 | jeb->used_size); | ||
200 | list_add_tail(&jeb->list, &c->very_dirty_list); | 213 | list_add_tail(&jeb->list, &c->very_dirty_list); |
201 | } else { | 214 | } else { |
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", | 215 | jffs2_dbg(1, "Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
203 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 216 | jeb->offset, jeb->free_size, jeb->dirty_size, |
217 | jeb->used_size); | ||
204 | list_add_tail(&jeb->list, &c->dirty_list); | 218 | list_add_tail(&jeb->list, &c->dirty_list); |
205 | } | 219 | } |
206 | } else { | 220 | } else { |
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", | 221 | jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
208 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 222 | jeb->offset, jeb->free_size, jeb->dirty_size, |
223 | jeb->used_size); | ||
209 | list_add_tail(&jeb->list, &c->clean_list); | 224 | list_add_tail(&jeb->list, &c->clean_list); |
210 | } | 225 | } |
211 | c->nextblock = NULL; | 226 | c->nextblock = NULL; |
@@ -230,13 +245,14 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
230 | list_move_tail(&ejeb->list, &c->erase_pending_list); | 245 | list_move_tail(&ejeb->list, &c->erase_pending_list); |
231 | c->nr_erasing_blocks++; | 246 | c->nr_erasing_blocks++; |
232 | jffs2_garbage_collect_trigger(c); | 247 | jffs2_garbage_collect_trigger(c); |
233 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n", | 248 | jffs2_dbg(1, "%s(): Triggering erase of erasable block at 0x%08x\n", |
234 | ejeb->offset)); | 249 | __func__, ejeb->offset); |
235 | } | 250 | } |
236 | 251 | ||
237 | if (!c->nr_erasing_blocks && | 252 | if (!c->nr_erasing_blocks && |
238 | !list_empty(&c->erasable_pending_wbuf_list)) { | 253 | !list_empty(&c->erasable_pending_wbuf_list)) { |
239 | D1(printk(KERN_DEBUG "jffs2_find_nextblock: Flushing write buffer\n")); | 254 | jffs2_dbg(1, "%s(): Flushing write buffer\n", |
255 | __func__); | ||
240 | /* c->nextblock is NULL, no update to c->nextblock allowed */ | 256 | /* c->nextblock is NULL, no update to c->nextblock allowed */ |
241 | spin_unlock(&c->erase_completion_lock); | 257 | spin_unlock(&c->erase_completion_lock); |
242 | jffs2_flush_wbuf_pad(c); | 258 | jffs2_flush_wbuf_pad(c); |
@@ -248,9 +264,11 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
248 | if (!c->nr_erasing_blocks) { | 264 | if (!c->nr_erasing_blocks) { |
249 | /* Ouch. We're in GC, or we wouldn't have got here. | 265 | /* Ouch. We're in GC, or we wouldn't have got here. |
250 | And there's no space left. At all. */ | 266 | And there's no space left. At all. */ |
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", | 267 | 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", |
252 | c->nr_erasing_blocks, c->nr_free_blocks, list_empty(&c->erasable_list)?"yes":"no", | 268 | c->nr_erasing_blocks, c->nr_free_blocks, |
253 | list_empty(&c->erasing_list)?"yes":"no", list_empty(&c->erase_pending_list)?"yes":"no"); | 269 | list_empty(&c->erasable_list) ? "yes" : "no", |
270 | list_empty(&c->erasing_list) ? "yes" : "no", | ||
271 | list_empty(&c->erase_pending_list) ? "yes" : "no"); | ||
254 | return -ENOSPC; | 272 | return -ENOSPC; |
255 | } | 273 | } |
256 | 274 | ||
@@ -278,7 +296,8 @@ static int jffs2_find_nextblock(struct jffs2_sb_info *c) | |||
278 | c->wbuf_ofs = 0xffffffff; | 296 | c->wbuf_ofs = 0xffffffff; |
279 | #endif | 297 | #endif |
280 | 298 | ||
281 | D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); | 299 | jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n", |
300 | __func__, c->nextblock->offset); | ||
282 | 301 | ||
283 | return 0; | 302 | return 0; |
284 | } | 303 | } |
@@ -345,7 +364,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
345 | 364 | ||
346 | if (jffs2_wbuf_dirty(c)) { | 365 | if (jffs2_wbuf_dirty(c)) { |
347 | spin_unlock(&c->erase_completion_lock); | 366 | spin_unlock(&c->erase_completion_lock); |
348 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space: Flushing write buffer\n")); | 367 | jffs2_dbg(1, "%s(): Flushing write buffer\n", |
368 | __func__); | ||
349 | jffs2_flush_wbuf_pad(c); | 369 | jffs2_flush_wbuf_pad(c); |
350 | spin_lock(&c->erase_completion_lock); | 370 | spin_lock(&c->erase_completion_lock); |
351 | jeb = c->nextblock; | 371 | jeb = c->nextblock; |
@@ -387,7 +407,8 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
387 | jeb = c->nextblock; | 407 | jeb = c->nextblock; |
388 | 408 | ||
389 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { | 409 | if (jeb->free_size != c->sector_size - c->cleanmarker_size) { |
390 | printk(KERN_WARNING "Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", jeb->offset, jeb->free_size); | 410 | pr_warn("Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n", |
411 | jeb->offset, jeb->free_size); | ||
391 | goto restart; | 412 | goto restart; |
392 | } | 413 | } |
393 | } | 414 | } |
@@ -408,8 +429,9 @@ static int jffs2_do_reserve_space(struct jffs2_sb_info *c, uint32_t minsize, | |||
408 | spin_lock(&c->erase_completion_lock); | 429 | spin_lock(&c->erase_completion_lock); |
409 | } | 430 | } |
410 | 431 | ||
411 | D1(printk(KERN_DEBUG "jffs2_do_reserve_space(): Giving 0x%x bytes at 0x%x\n", | 432 | jffs2_dbg(1, "%s(): Giving 0x%x bytes at 0x%x\n", |
412 | *len, jeb->offset + (c->sector_size - jeb->free_size))); | 433 | __func__, |
434 | *len, jeb->offset + (c->sector_size - jeb->free_size)); | ||
413 | return 0; | 435 | return 0; |
414 | } | 436 | } |
415 | 437 | ||
@@ -434,20 +456,22 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
434 | 456 | ||
435 | jeb = &c->blocks[ofs / c->sector_size]; | 457 | jeb = &c->blocks[ofs / c->sector_size]; |
436 | 458 | ||
437 | D1(printk(KERN_DEBUG "jffs2_add_physical_node_ref(): Node at 0x%x(%d), size 0x%x\n", | 459 | jffs2_dbg(1, "%s(): Node at 0x%x(%d), size 0x%x\n", |
438 | ofs & ~3, ofs & 3, len)); | 460 | __func__, ofs & ~3, ofs & 3, len); |
439 | #if 1 | 461 | #if 1 |
440 | /* Allow non-obsolete nodes only to be added at the end of c->nextblock, | 462 | /* Allow non-obsolete nodes only to be added at the end of c->nextblock, |
441 | if c->nextblock is set. Note that wbuf.c will file obsolete nodes | 463 | if c->nextblock is set. Note that wbuf.c will file obsolete nodes |
442 | even after refiling c->nextblock */ | 464 | even after refiling c->nextblock */ |
443 | if ((c->nextblock || ((ofs & 3) != REF_OBSOLETE)) | 465 | if ((c->nextblock || ((ofs & 3) != REF_OBSOLETE)) |
444 | && (jeb != c->nextblock || (ofs & ~3) != jeb->offset + (c->sector_size - jeb->free_size))) { | 466 | && (jeb != c->nextblock || (ofs & ~3) != jeb->offset + (c->sector_size - jeb->free_size))) { |
445 | printk(KERN_WARNING "argh. node added in wrong place at 0x%08x(%d)\n", ofs & ~3, ofs & 3); | 467 | pr_warn("argh. node added in wrong place at 0x%08x(%d)\n", |
468 | ofs & ~3, ofs & 3); | ||
446 | if (c->nextblock) | 469 | if (c->nextblock) |
447 | printk(KERN_WARNING "nextblock 0x%08x", c->nextblock->offset); | 470 | pr_warn("nextblock 0x%08x", c->nextblock->offset); |
448 | else | 471 | else |
449 | printk(KERN_WARNING "No nextblock"); | 472 | pr_warn("No nextblock"); |
450 | printk(", expected at %08x\n", jeb->offset + (c->sector_size - jeb->free_size)); | 473 | pr_cont(", expected at %08x\n", |
474 | jeb->offset + (c->sector_size - jeb->free_size)); | ||
451 | return ERR_PTR(-EINVAL); | 475 | return ERR_PTR(-EINVAL); |
452 | } | 476 | } |
453 | #endif | 477 | #endif |
@@ -457,8 +481,9 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
457 | 481 | ||
458 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { | 482 | if (!jeb->free_size && !jeb->dirty_size && !ISDIRTY(jeb->wasted_size)) { |
459 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ | 483 | /* If it lives on the dirty_list, jffs2_reserve_space will put it there */ |
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", | 484 | jffs2_dbg(1, "Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n", |
461 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 485 | jeb->offset, jeb->free_size, jeb->dirty_size, |
486 | jeb->used_size); | ||
462 | if (jffs2_wbuf_dirty(c)) { | 487 | if (jffs2_wbuf_dirty(c)) { |
463 | /* Flush the last write in the block if it's outstanding */ | 488 | /* Flush the last write in the block if it's outstanding */ |
464 | spin_unlock(&c->erase_completion_lock); | 489 | spin_unlock(&c->erase_completion_lock); |
@@ -480,7 +505,7 @@ struct jffs2_raw_node_ref *jffs2_add_physical_node_ref(struct jffs2_sb_info *c, | |||
480 | 505 | ||
481 | void jffs2_complete_reservation(struct jffs2_sb_info *c) | 506 | void jffs2_complete_reservation(struct jffs2_sb_info *c) |
482 | { | 507 | { |
483 | D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n")); | 508 | jffs2_dbg(1, "jffs2_complete_reservation()\n"); |
484 | spin_lock(&c->erase_completion_lock); | 509 | spin_lock(&c->erase_completion_lock); |
485 | jffs2_garbage_collect_trigger(c); | 510 | jffs2_garbage_collect_trigger(c); |
486 | spin_unlock(&c->erase_completion_lock); | 511 | spin_unlock(&c->erase_completion_lock); |
@@ -493,7 +518,7 @@ static inline int on_list(struct list_head *obj, struct list_head *head) | |||
493 | 518 | ||
494 | list_for_each(this, head) { | 519 | list_for_each(this, head) { |
495 | if (this == obj) { | 520 | if (this == obj) { |
496 | D1(printk("%p is on list at %p\n", obj, head)); | 521 | jffs2_dbg(1, "%p is on list at %p\n", obj, head); |
497 | return 1; | 522 | return 1; |
498 | 523 | ||
499 | } | 524 | } |
@@ -511,16 +536,18 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
511 | uint32_t freed_len; | 536 | uint32_t freed_len; |
512 | 537 | ||
513 | if(unlikely(!ref)) { | 538 | if(unlikely(!ref)) { |
514 | printk(KERN_NOTICE "EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); | 539 | pr_notice("EEEEEK. jffs2_mark_node_obsolete called with NULL node\n"); |
515 | return; | 540 | return; |
516 | } | 541 | } |
517 | if (ref_obsolete(ref)) { | 542 | if (ref_obsolete(ref)) { |
518 | D1(printk(KERN_DEBUG "jffs2_mark_node_obsolete called with already obsolete node at 0x%08x\n", ref_offset(ref))); | 543 | jffs2_dbg(1, "%s(): called with already obsolete node at 0x%08x\n", |
544 | __func__, ref_offset(ref)); | ||
519 | return; | 545 | return; |
520 | } | 546 | } |
521 | blocknr = ref->flash_offset / c->sector_size; | 547 | blocknr = ref->flash_offset / c->sector_size; |
522 | if (blocknr >= c->nr_blocks) { | 548 | if (blocknr >= c->nr_blocks) { |
523 | printk(KERN_NOTICE "raw node at 0x%08x is off the end of device!\n", ref->flash_offset); | 549 | pr_notice("raw node at 0x%08x is off the end of device!\n", |
550 | ref->flash_offset); | ||
524 | BUG(); | 551 | BUG(); |
525 | } | 552 | } |
526 | jeb = &c->blocks[blocknr]; | 553 | jeb = &c->blocks[blocknr]; |
@@ -542,27 +569,31 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
542 | 569 | ||
543 | if (ref_flags(ref) == REF_UNCHECKED) { | 570 | if (ref_flags(ref) == REF_UNCHECKED) { |
544 | D1(if (unlikely(jeb->unchecked_size < freed_len)) { | 571 | D1(if (unlikely(jeb->unchecked_size < freed_len)) { |
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", | 572 | 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", |
546 | freed_len, blocknr, ref->flash_offset, jeb->used_size); | 573 | freed_len, blocknr, |
574 | ref->flash_offset, jeb->used_size); | ||
547 | BUG(); | 575 | BUG(); |
548 | }) | 576 | }) |
549 | D1(printk(KERN_DEBUG "Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), freed_len)); | 577 | jffs2_dbg(1, "Obsoleting previously unchecked node at 0x%08x of len %x\n", |
578 | ref_offset(ref), freed_len); | ||
550 | jeb->unchecked_size -= freed_len; | 579 | jeb->unchecked_size -= freed_len; |
551 | c->unchecked_size -= freed_len; | 580 | c->unchecked_size -= freed_len; |
552 | } else { | 581 | } else { |
553 | D1(if (unlikely(jeb->used_size < freed_len)) { | 582 | D1(if (unlikely(jeb->used_size < freed_len)) { |
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", | 583 | pr_notice("raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n", |
555 | freed_len, blocknr, ref->flash_offset, jeb->used_size); | 584 | freed_len, blocknr, |
585 | ref->flash_offset, jeb->used_size); | ||
556 | BUG(); | 586 | BUG(); |
557 | }) | 587 | }) |
558 | D1(printk(KERN_DEBUG "Obsoleting node at 0x%08x of len %#x: ", ref_offset(ref), freed_len)); | 588 | jffs2_dbg(1, "Obsoleting node at 0x%08x of len %#x: ", |
589 | ref_offset(ref), freed_len); | ||
559 | jeb->used_size -= freed_len; | 590 | jeb->used_size -= freed_len; |
560 | c->used_size -= freed_len; | 591 | c->used_size -= freed_len; |
561 | } | 592 | } |
562 | 593 | ||
563 | // Take care, that wasted size is taken into concern | 594 | // Take care, that wasted size is taken into concern |
564 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { | 595 | if ((jeb->dirty_size || ISDIRTY(jeb->wasted_size + freed_len)) && jeb != c->nextblock) { |
565 | D1(printk("Dirtying\n")); | 596 | jffs2_dbg(1, "Dirtying\n"); |
566 | addedsize = freed_len; | 597 | addedsize = freed_len; |
567 | jeb->dirty_size += freed_len; | 598 | jeb->dirty_size += freed_len; |
568 | c->dirty_size += freed_len; | 599 | c->dirty_size += freed_len; |
@@ -570,12 +601,12 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
570 | /* Convert wasted space to dirty, if not a bad block */ | 601 | /* Convert wasted space to dirty, if not a bad block */ |
571 | if (jeb->wasted_size) { | 602 | if (jeb->wasted_size) { |
572 | if (on_list(&jeb->list, &c->bad_used_list)) { | 603 | if (on_list(&jeb->list, &c->bad_used_list)) { |
573 | D1(printk(KERN_DEBUG "Leaving block at %08x on the bad_used_list\n", | 604 | jffs2_dbg(1, "Leaving block at %08x on the bad_used_list\n", |
574 | jeb->offset)); | 605 | jeb->offset); |
575 | addedsize = 0; /* To fool the refiling code later */ | 606 | addedsize = 0; /* To fool the refiling code later */ |
576 | } else { | 607 | } else { |
577 | D1(printk(KERN_DEBUG "Converting %d bytes of wasted space to dirty in block at %08x\n", | 608 | jffs2_dbg(1, "Converting %d bytes of wasted space to dirty in block at %08x\n", |
578 | jeb->wasted_size, jeb->offset)); | 609 | jeb->wasted_size, jeb->offset); |
579 | addedsize += jeb->wasted_size; | 610 | addedsize += jeb->wasted_size; |
580 | jeb->dirty_size += jeb->wasted_size; | 611 | jeb->dirty_size += jeb->wasted_size; |
581 | c->dirty_size += jeb->wasted_size; | 612 | c->dirty_size += jeb->wasted_size; |
@@ -584,7 +615,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
584 | } | 615 | } |
585 | } | 616 | } |
586 | } else { | 617 | } else { |
587 | D1(printk("Wasting\n")); | 618 | jffs2_dbg(1, "Wasting\n"); |
588 | addedsize = 0; | 619 | addedsize = 0; |
589 | jeb->wasted_size += freed_len; | 620 | jeb->wasted_size += freed_len; |
590 | c->wasted_size += freed_len; | 621 | c->wasted_size += freed_len; |
@@ -606,50 +637,57 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
606 | } | 637 | } |
607 | 638 | ||
608 | if (jeb == c->nextblock) { | 639 | if (jeb == c->nextblock) { |
609 | D2(printk(KERN_DEBUG "Not moving nextblock 0x%08x to dirty/erase_pending list\n", jeb->offset)); | 640 | jffs2_dbg(2, "Not moving nextblock 0x%08x to dirty/erase_pending list\n", |
641 | jeb->offset); | ||
610 | } else if (!jeb->used_size && !jeb->unchecked_size) { | 642 | } else if (!jeb->used_size && !jeb->unchecked_size) { |
611 | if (jeb == c->gcblock) { | 643 | if (jeb == c->gcblock) { |
612 | D1(printk(KERN_DEBUG "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", jeb->offset)); | 644 | jffs2_dbg(1, "gcblock at 0x%08x completely dirtied. Clearing gcblock...\n", |
645 | jeb->offset); | ||
613 | c->gcblock = NULL; | 646 | c->gcblock = NULL; |
614 | } else { | 647 | } else { |
615 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", jeb->offset)); | 648 | jffs2_dbg(1, "Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n", |
649 | jeb->offset); | ||
616 | list_del(&jeb->list); | 650 | list_del(&jeb->list); |
617 | } | 651 | } |
618 | if (jffs2_wbuf_dirty(c)) { | 652 | if (jffs2_wbuf_dirty(c)) { |
619 | D1(printk(KERN_DEBUG "...and adding to erasable_pending_wbuf_list\n")); | 653 | jffs2_dbg(1, "...and adding to erasable_pending_wbuf_list\n"); |
620 | list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list); | 654 | list_add_tail(&jeb->list, &c->erasable_pending_wbuf_list); |
621 | } else { | 655 | } else { |
622 | if (jiffies & 127) { | 656 | if (jiffies & 127) { |
623 | /* Most of the time, we just erase it immediately. Otherwise we | 657 | /* Most of the time, we just erase it immediately. Otherwise we |
624 | spend ages scanning it on mount, etc. */ | 658 | spend ages scanning it on mount, etc. */ |
625 | D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); | 659 | jffs2_dbg(1, "...and adding to erase_pending_list\n"); |
626 | list_add_tail(&jeb->list, &c->erase_pending_list); | 660 | list_add_tail(&jeb->list, &c->erase_pending_list); |
627 | c->nr_erasing_blocks++; | 661 | c->nr_erasing_blocks++; |
628 | jffs2_garbage_collect_trigger(c); | 662 | jffs2_garbage_collect_trigger(c); |
629 | } else { | 663 | } else { |
630 | /* Sometimes, however, we leave it elsewhere so it doesn't get | 664 | /* Sometimes, however, we leave it elsewhere so it doesn't get |
631 | immediately reused, and we spread the load a bit. */ | 665 | immediately reused, and we spread the load a bit. */ |
632 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); | 666 | jffs2_dbg(1, "...and adding to erasable_list\n"); |
633 | list_add_tail(&jeb->list, &c->erasable_list); | 667 | list_add_tail(&jeb->list, &c->erasable_list); |
634 | } | 668 | } |
635 | } | 669 | } |
636 | D1(printk(KERN_DEBUG "Done OK\n")); | 670 | jffs2_dbg(1, "Done OK\n"); |
637 | } else if (jeb == c->gcblock) { | 671 | } else if (jeb == c->gcblock) { |
638 | D2(printk(KERN_DEBUG "Not moving gcblock 0x%08x to dirty_list\n", jeb->offset)); | 672 | jffs2_dbg(2, "Not moving gcblock 0x%08x to dirty_list\n", |
673 | jeb->offset); | ||
639 | } else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) { | 674 | } else if (ISDIRTY(jeb->dirty_size) && !ISDIRTY(jeb->dirty_size - addedsize)) { |
640 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", jeb->offset)); | 675 | jffs2_dbg(1, "Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n", |
676 | jeb->offset); | ||
641 | list_del(&jeb->list); | 677 | list_del(&jeb->list); |
642 | D1(printk(KERN_DEBUG "...and adding to dirty_list\n")); | 678 | jffs2_dbg(1, "...and adding to dirty_list\n"); |
643 | list_add_tail(&jeb->list, &c->dirty_list); | 679 | list_add_tail(&jeb->list, &c->dirty_list); |
644 | } else if (VERYDIRTY(c, jeb->dirty_size) && | 680 | } else if (VERYDIRTY(c, jeb->dirty_size) && |
645 | !VERYDIRTY(c, jeb->dirty_size - addedsize)) { | 681 | !VERYDIRTY(c, jeb->dirty_size - addedsize)) { |
646 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", jeb->offset)); | 682 | jffs2_dbg(1, "Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n", |
683 | jeb->offset); | ||
647 | list_del(&jeb->list); | 684 | list_del(&jeb->list); |
648 | D1(printk(KERN_DEBUG "...and adding to very_dirty_list\n")); | 685 | jffs2_dbg(1, "...and adding to very_dirty_list\n"); |
649 | list_add_tail(&jeb->list, &c->very_dirty_list); | 686 | list_add_tail(&jeb->list, &c->very_dirty_list); |
650 | } else { | 687 | } else { |
651 | D1(printk(KERN_DEBUG "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", | 688 | jffs2_dbg(1, "Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n", |
652 | jeb->offset, jeb->free_size, jeb->dirty_size, jeb->used_size)); | 689 | jeb->offset, jeb->free_size, jeb->dirty_size, |
690 | jeb->used_size); | ||
653 | } | 691 | } |
654 | 692 | ||
655 | spin_unlock(&c->erase_completion_lock); | 693 | spin_unlock(&c->erase_completion_lock); |
@@ -665,33 +703,40 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref | |||
665 | the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet | 703 | the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet |
666 | by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */ | 704 | by jffs2_free_jeb_node_refs() in erase.c. Which is nice. */ |
667 | 705 | ||
668 | D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref))); | 706 | jffs2_dbg(1, "obliterating obsoleted node at 0x%08x\n", |
707 | ref_offset(ref)); | ||
669 | ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); | 708 | ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); |
670 | if (ret) { | 709 | if (ret) { |
671 | printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret); | 710 | pr_warn("Read error reading from obsoleted node at 0x%08x: %d\n", |
711 | ref_offset(ref), ret); | ||
672 | goto out_erase_sem; | 712 | goto out_erase_sem; |
673 | } | 713 | } |
674 | if (retlen != sizeof(n)) { | 714 | if (retlen != sizeof(n)) { |
675 | printk(KERN_WARNING "Short read from obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); | 715 | pr_warn("Short read from obsoleted node at 0x%08x: %zd\n", |
716 | ref_offset(ref), retlen); | ||
676 | goto out_erase_sem; | 717 | goto out_erase_sem; |
677 | } | 718 | } |
678 | if (PAD(je32_to_cpu(n.totlen)) != PAD(freed_len)) { | 719 | if (PAD(je32_to_cpu(n.totlen)) != PAD(freed_len)) { |
679 | printk(KERN_WARNING "Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", je32_to_cpu(n.totlen), freed_len); | 720 | pr_warn("Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n", |
721 | je32_to_cpu(n.totlen), freed_len); | ||
680 | goto out_erase_sem; | 722 | goto out_erase_sem; |
681 | } | 723 | } |
682 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { | 724 | if (!(je16_to_cpu(n.nodetype) & JFFS2_NODE_ACCURATE)) { |
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))); | 725 | jffs2_dbg(1, "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", |
726 | ref_offset(ref), je16_to_cpu(n.nodetype)); | ||
684 | goto out_erase_sem; | 727 | goto out_erase_sem; |
685 | } | 728 | } |
686 | /* XXX FIXME: This is ugly now */ | 729 | /* XXX FIXME: This is ugly now */ |
687 | n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE); | 730 | n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE); |
688 | ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); | 731 | ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n); |
689 | if (ret) { | 732 | if (ret) { |
690 | printk(KERN_WARNING "Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret); | 733 | pr_warn("Write error in obliterating obsoleted node at 0x%08x: %d\n", |
734 | ref_offset(ref), ret); | ||
691 | goto out_erase_sem; | 735 | goto out_erase_sem; |
692 | } | 736 | } |
693 | if (retlen != sizeof(n)) { | 737 | if (retlen != sizeof(n)) { |
694 | printk(KERN_WARNING "Short write in obliterating obsoleted node at 0x%08x: %zd\n", ref_offset(ref), retlen); | 738 | pr_warn("Short write in obliterating obsoleted node at 0x%08x: %zd\n", |
739 | ref_offset(ref), retlen); | ||
695 | goto out_erase_sem; | 740 | goto out_erase_sem; |
696 | } | 741 | } |
697 | 742 | ||
@@ -751,8 +796,8 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) | |||
751 | return 1; | 796 | return 1; |
752 | 797 | ||
753 | if (c->unchecked_size) { | 798 | if (c->unchecked_size) { |
754 | D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", | 799 | jffs2_dbg(1, "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n", |
755 | c->unchecked_size, c->checked_ino)); | 800 | c->unchecked_size, c->checked_ino); |
756 | return 1; | 801 | return 1; |
757 | } | 802 | } |
758 | 803 | ||
@@ -780,8 +825,9 @@ int jffs2_thread_should_wake(struct jffs2_sb_info *c) | |||
780 | } | 825 | } |
781 | } | 826 | } |
782 | 827 | ||
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", | 828 | jffs2_dbg(1, "%s(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n", |
784 | c->nr_free_blocks, c->nr_erasing_blocks, c->dirty_size, nr_very_dirty, ret?"yes":"no")); | 829 | __func__, c->nr_free_blocks, c->nr_erasing_blocks, |
830 | c->dirty_size, nr_very_dirty, ret ? "yes" : "no"); | ||
785 | 831 | ||
786 | return ret; | 832 | return ret; |
787 | } | 833 | } |
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index ab65ee3ec858..1cd3aec9d9ae 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h | |||
@@ -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) ((c)->mtd->read((c)->mtd, ofs, len, retlen, buf)) | 79 | #define jffs2_flash_read(c, ofs, len, retlen, buf) (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) |
@@ -108,8 +108,6 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f) | |||
108 | 108 | ||
109 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) | 109 | #define jffs2_cleanmarker_oob(c) (c->mtd->type == MTD_NANDFLASH) |
110 | 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)) | ||
113 | #define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) | 111 | #define jffs2_wbuf_dirty(c) (!!(c)->wbuf_len) |
114 | 112 | ||
115 | /* wbuf.c */ | 113 | /* wbuf.c */ |
diff --git a/fs/jffs2/read.c b/fs/jffs2/read.c index 3f39be1b0455..0b042b1fc82f 100644 --- a/fs/jffs2/read.c +++ b/fs/jffs2/read.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
14 | #include <linux/crc32.h> | 16 | #include <linux/crc32.h> |
@@ -36,24 +38,25 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
36 | ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri); | 38 | ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri); |
37 | if (ret) { | 39 | if (ret) { |
38 | jffs2_free_raw_inode(ri); | 40 | jffs2_free_raw_inode(ri); |
39 | printk(KERN_WARNING "Error reading node from 0x%08x: %d\n", ref_offset(fd->raw), ret); | 41 | pr_warn("Error reading node from 0x%08x: %d\n", |
42 | ref_offset(fd->raw), ret); | ||
40 | return ret; | 43 | return ret; |
41 | } | 44 | } |
42 | if (readlen != sizeof(*ri)) { | 45 | if (readlen != sizeof(*ri)) { |
43 | jffs2_free_raw_inode(ri); | 46 | jffs2_free_raw_inode(ri); |
44 | printk(KERN_WARNING "Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", | 47 | pr_warn("Short read from 0x%08x: wanted 0x%zx bytes, got 0x%zx\n", |
45 | ref_offset(fd->raw), sizeof(*ri), readlen); | 48 | ref_offset(fd->raw), sizeof(*ri), readlen); |
46 | return -EIO; | 49 | return -EIO; |
47 | } | 50 | } |
48 | crc = crc32(0, ri, sizeof(*ri)-8); | 51 | crc = crc32(0, ri, sizeof(*ri)-8); |
49 | 52 | ||
50 | D1(printk(KERN_DEBUG "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n", | 53 | jffs2_dbg(1, "Node read from %08x: node_crc %08x, calculated CRC %08x. dsize %x, csize %x, offset %x, buf %p\n", |
51 | ref_offset(fd->raw), je32_to_cpu(ri->node_crc), | 54 | ref_offset(fd->raw), je32_to_cpu(ri->node_crc), |
52 | crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), | 55 | crc, je32_to_cpu(ri->dsize), je32_to_cpu(ri->csize), |
53 | je32_to_cpu(ri->offset), buf)); | 56 | je32_to_cpu(ri->offset), buf); |
54 | if (crc != je32_to_cpu(ri->node_crc)) { | 57 | if (crc != je32_to_cpu(ri->node_crc)) { |
55 | printk(KERN_WARNING "Node CRC %08x != calculated CRC %08x for node at %08x\n", | 58 | pr_warn("Node CRC %08x != calculated CRC %08x for node at %08x\n", |
56 | je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); | 59 | je32_to_cpu(ri->node_crc), crc, ref_offset(fd->raw)); |
57 | ret = -EIO; | 60 | ret = -EIO; |
58 | goto out_ri; | 61 | goto out_ri; |
59 | } | 62 | } |
@@ -66,8 +69,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
66 | } | 69 | } |
67 | 70 | ||
68 | D1(if(ofs + len > je32_to_cpu(ri->dsize)) { | 71 | D1(if(ofs + len > je32_to_cpu(ri->dsize)) { |
69 | printk(KERN_WARNING "jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n", | 72 | pr_warn("jffs2_read_dnode() asked for %d bytes at %d from %d-byte node\n", |
70 | len, ofs, je32_to_cpu(ri->dsize)); | 73 | len, ofs, je32_to_cpu(ri->dsize)); |
71 | ret = -EINVAL; | 74 | ret = -EINVAL; |
72 | goto out_ri; | 75 | goto out_ri; |
73 | }); | 76 | }); |
@@ -107,8 +110,8 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
107 | decomprbuf = readbuf; | 110 | decomprbuf = readbuf; |
108 | } | 111 | } |
109 | 112 | ||
110 | D2(printk(KERN_DEBUG "Read %d bytes to %p\n", je32_to_cpu(ri->csize), | 113 | jffs2_dbg(2, "Read %d bytes to %p\n", je32_to_cpu(ri->csize), |
111 | readbuf)); | 114 | readbuf); |
112 | ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), | 115 | ret = jffs2_flash_read(c, (ref_offset(fd->raw)) + sizeof(*ri), |
113 | je32_to_cpu(ri->csize), &readlen, readbuf); | 116 | je32_to_cpu(ri->csize), &readlen, readbuf); |
114 | 117 | ||
@@ -119,18 +122,19 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
119 | 122 | ||
120 | crc = crc32(0, readbuf, je32_to_cpu(ri->csize)); | 123 | crc = crc32(0, readbuf, je32_to_cpu(ri->csize)); |
121 | if (crc != je32_to_cpu(ri->data_crc)) { | 124 | if (crc != je32_to_cpu(ri->data_crc)) { |
122 | printk(KERN_WARNING "Data CRC %08x != calculated CRC %08x for node at %08x\n", | 125 | pr_warn("Data CRC %08x != calculated CRC %08x for node at %08x\n", |
123 | je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw)); | 126 | je32_to_cpu(ri->data_crc), crc, ref_offset(fd->raw)); |
124 | ret = -EIO; | 127 | ret = -EIO; |
125 | goto out_decomprbuf; | 128 | goto out_decomprbuf; |
126 | } | 129 | } |
127 | D2(printk(KERN_DEBUG "Data CRC matches calculated CRC %08x\n", crc)); | 130 | jffs2_dbg(2, "Data CRC matches calculated CRC %08x\n", crc); |
128 | if (ri->compr != JFFS2_COMPR_NONE) { | 131 | if (ri->compr != JFFS2_COMPR_NONE) { |
129 | D2(printk(KERN_DEBUG "Decompress %d bytes from %p to %d bytes at %p\n", | 132 | jffs2_dbg(2, "Decompress %d bytes from %p to %d bytes at %p\n", |
130 | je32_to_cpu(ri->csize), readbuf, je32_to_cpu(ri->dsize), decomprbuf)); | 133 | je32_to_cpu(ri->csize), readbuf, |
134 | je32_to_cpu(ri->dsize), decomprbuf); | ||
131 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); | 135 | ret = jffs2_decompress(c, f, ri->compr | (ri->usercompr << 8), readbuf, decomprbuf, je32_to_cpu(ri->csize), je32_to_cpu(ri->dsize)); |
132 | if (ret) { | 136 | if (ret) { |
133 | printk(KERN_WARNING "Error: jffs2_decompress returned %d\n", ret); | 137 | pr_warn("Error: jffs2_decompress returned %d\n", ret); |
134 | goto out_decomprbuf; | 138 | goto out_decomprbuf; |
135 | } | 139 | } |
136 | } | 140 | } |
@@ -157,8 +161,8 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
157 | struct jffs2_node_frag *frag; | 161 | struct jffs2_node_frag *frag; |
158 | int ret; | 162 | int ret; |
159 | 163 | ||
160 | D1(printk(KERN_DEBUG "jffs2_read_inode_range: ino #%u, range 0x%08x-0x%08x\n", | 164 | jffs2_dbg(1, "%s(): ino #%u, range 0x%08x-0x%08x\n", |
161 | f->inocache->ino, offset, offset+len)); | 165 | __func__, f->inocache->ino, offset, offset + len); |
162 | 166 | ||
163 | frag = jffs2_lookup_node_frag(&f->fragtree, offset); | 167 | frag = jffs2_lookup_node_frag(&f->fragtree, offset); |
164 | 168 | ||
@@ -168,22 +172,27 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
168 | * (or perhaps is before it, if we've been asked to read off the | 172 | * (or perhaps is before it, if we've been asked to read off the |
169 | * end of the file). */ | 173 | * end of the file). */ |
170 | while(offset < end) { | 174 | while(offset < end) { |
171 | D2(printk(KERN_DEBUG "jffs2_read_inode_range: offset %d, end %d\n", offset, end)); | 175 | jffs2_dbg(2, "%s(): offset %d, end %d\n", |
176 | __func__, offset, end); | ||
172 | if (unlikely(!frag || frag->ofs > offset || | 177 | if (unlikely(!frag || frag->ofs > offset || |
173 | frag->ofs + frag->size <= offset)) { | 178 | frag->ofs + frag->size <= offset)) { |
174 | uint32_t holesize = end - offset; | 179 | uint32_t holesize = end - offset; |
175 | if (frag && frag->ofs > offset) { | 180 | if (frag && frag->ofs > offset) { |
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)); | 181 | jffs2_dbg(1, "Eep. Hole in ino #%u fraglist. frag->ofs = 0x%08x, offset = 0x%08x\n", |
182 | f->inocache->ino, frag->ofs, offset); | ||
177 | holesize = min(holesize, frag->ofs - offset); | 183 | holesize = min(holesize, frag->ofs - offset); |
178 | } | 184 | } |
179 | D1(printk(KERN_DEBUG "Filling non-frag hole from %d-%d\n", offset, offset+holesize)); | 185 | jffs2_dbg(1, "Filling non-frag hole from %d-%d\n", |
186 | offset, offset + holesize); | ||
180 | memset(buf, 0, holesize); | 187 | memset(buf, 0, holesize); |
181 | buf += holesize; | 188 | buf += holesize; |
182 | offset += holesize; | 189 | offset += holesize; |
183 | continue; | 190 | continue; |
184 | } else if (unlikely(!frag->node)) { | 191 | } else if (unlikely(!frag->node)) { |
185 | uint32_t holeend = min(end, frag->ofs + frag->size); | 192 | uint32_t holeend = min(end, frag->ofs + frag->size); |
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)); | 193 | jffs2_dbg(1, "Filling frag hole from %d-%d (frag 0x%x 0x%x)\n", |
194 | offset, holeend, frag->ofs, | ||
195 | frag->ofs + frag->size); | ||
187 | memset(buf, 0, holeend - offset); | 196 | memset(buf, 0, holeend - offset); |
188 | buf += holeend - offset; | 197 | buf += holeend - offset; |
189 | offset = holeend; | 198 | offset = holeend; |
@@ -195,20 +204,23 @@ int jffs2_read_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
195 | 204 | ||
196 | fragofs = offset - frag->ofs; | 205 | fragofs = offset - frag->ofs; |
197 | readlen = min(frag->size - fragofs, end - offset); | 206 | readlen = min(frag->size - fragofs, end - offset); |
198 | D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%08x (%d)\n", | 207 | jffs2_dbg(1, "Reading %d-%d from node at 0x%08x (%d)\n", |
199 | frag->ofs+fragofs, frag->ofs+fragofs+readlen, | 208 | frag->ofs+fragofs, |
200 | ref_offset(frag->node->raw), ref_flags(frag->node->raw))); | 209 | frag->ofs + fragofs+readlen, |
210 | ref_offset(frag->node->raw), | ||
211 | ref_flags(frag->node->raw)); | ||
201 | ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); | 212 | ret = jffs2_read_dnode(c, f, frag->node, buf, fragofs + frag->ofs - frag->node->ofs, readlen); |
202 | D2(printk(KERN_DEBUG "node read done\n")); | 213 | jffs2_dbg(2, "node read done\n"); |
203 | if (ret) { | 214 | if (ret) { |
204 | D1(printk(KERN_DEBUG"jffs2_read_inode_range error %d\n",ret)); | 215 | jffs2_dbg(1, "%s(): error %d\n", |
216 | __func__, ret); | ||
205 | memset(buf, 0, readlen); | 217 | memset(buf, 0, readlen); |
206 | return ret; | 218 | return ret; |
207 | } | 219 | } |
208 | buf += readlen; | 220 | buf += readlen; |
209 | offset += readlen; | 221 | offset += readlen; |
210 | frag = frag_next(frag); | 222 | frag = frag_next(frag); |
211 | D2(printk(KERN_DEBUG "node read was OK. Looping\n")); | 223 | jffs2_dbg(2, "node read was OK. Looping\n"); |
212 | } | 224 | } |
213 | } | 225 | } |
214 | return 0; | 226 | return 0; |
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 3093ac4fb24c..dc0437e84763 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index f99464833bb2..7654e87b0428 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
@@ -22,15 +24,15 @@ | |||
22 | 24 | ||
23 | #define DEFAULT_EMPTY_SCAN_SIZE 256 | 25 | #define DEFAULT_EMPTY_SCAN_SIZE 256 |
24 | 26 | ||
25 | #define noisy_printk(noise, args...) do { \ | 27 | #define noisy_printk(noise, fmt, ...) \ |
26 | if (*(noise)) { \ | 28 | do { \ |
27 | printk(KERN_NOTICE args); \ | 29 | if (*(noise)) { \ |
28 | (*(noise))--; \ | 30 | pr_notice(fmt, ##__VA_ARGS__); \ |
29 | if (!(*(noise))) { \ | 31 | (*(noise))--; \ |
30 | printk(KERN_NOTICE "Further such events for this erase block will not be printed\n"); \ | 32 | if (!(*(noise))) \ |
31 | } \ | 33 | pr_notice("Further such events for this erase block will not be printed\n"); \ |
32 | } \ | 34 | } \ |
33 | } while(0) | 35 | } while (0) |
34 | 36 | ||
35 | static uint32_t pseudo_random; | 37 | static uint32_t pseudo_random; |
36 | 38 | ||
@@ -96,18 +98,17 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
96 | #ifndef __ECOS | 98 | #ifndef __ECOS |
97 | size_t pointlen, try_size; | 99 | size_t pointlen, try_size; |
98 | 100 | ||
99 | if (c->mtd->point) { | 101 | ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen, |
100 | ret = mtd_point(c->mtd, 0, c->mtd->size, &pointlen, | 102 | (void **)&flashbuf, NULL); |
101 | (void **)&flashbuf, NULL); | 103 | if (!ret && pointlen < c->mtd->size) { |
102 | if (!ret && pointlen < c->mtd->size) { | 104 | /* Don't muck about if it won't let us point to the whole flash */ |
103 | /* Don't muck about if it won't let us point to the whole flash */ | 105 | jffs2_dbg(1, "MTD point returned len too short: 0x%zx\n", |
104 | D1(printk(KERN_DEBUG "MTD point returned len too short: 0x%zx\n", pointlen)); | 106 | pointlen); |
105 | mtd_unpoint(c->mtd, 0, pointlen); | 107 | mtd_unpoint(c->mtd, 0, pointlen); |
106 | flashbuf = NULL; | 108 | flashbuf = NULL; |
107 | } | ||
108 | if (ret && ret != -EOPNOTSUPP) | ||
109 | D1(printk(KERN_DEBUG "MTD point failed %d\n", ret)); | ||
110 | } | 109 | } |
110 | if (ret && ret != -EOPNOTSUPP) | ||
111 | jffs2_dbg(1, "MTD point failed %d\n", ret); | ||
111 | #endif | 112 | #endif |
112 | if (!flashbuf) { | 113 | if (!flashbuf) { |
113 | /* For NAND it's quicker to read a whole eraseblock at a time, | 114 | /* For NAND it's quicker to read a whole eraseblock at a time, |
@@ -117,15 +118,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
117 | else | 118 | else |
118 | try_size = PAGE_SIZE; | 119 | try_size = PAGE_SIZE; |
119 | 120 | ||
120 | D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu " | 121 | jffs2_dbg(1, "Trying to allocate readbuf of %zu " |
121 | "bytes\n", try_size)); | 122 | "bytes\n", try_size); |
122 | 123 | ||
123 | flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); | 124 | flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size); |
124 | if (!flashbuf) | 125 | if (!flashbuf) |
125 | return -ENOMEM; | 126 | return -ENOMEM; |
126 | 127 | ||
127 | D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n", | 128 | jffs2_dbg(1, "Allocated readbuf of %zu bytes\n", |
128 | try_size)); | 129 | try_size); |
129 | 130 | ||
130 | buf_size = (uint32_t)try_size; | 131 | buf_size = (uint32_t)try_size; |
131 | } | 132 | } |
@@ -178,7 +179,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
178 | c->nr_free_blocks++; | 179 | c->nr_free_blocks++; |
179 | } else { | 180 | } else { |
180 | /* Dirt */ | 181 | /* Dirt */ |
181 | D1(printk(KERN_DEBUG "Adding all-dirty block at 0x%08x to erase_pending_list\n", jeb->offset)); | 182 | jffs2_dbg(1, "Adding all-dirty block at 0x%08x to erase_pending_list\n", |
183 | jeb->offset); | ||
182 | list_add(&jeb->list, &c->erase_pending_list); | 184 | list_add(&jeb->list, &c->erase_pending_list); |
183 | c->nr_erasing_blocks++; | 185 | c->nr_erasing_blocks++; |
184 | } | 186 | } |
@@ -205,7 +207,8 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
205 | } | 207 | } |
206 | /* update collected summary information for the current nextblock */ | 208 | /* update collected summary information for the current nextblock */ |
207 | jffs2_sum_move_collected(c, s); | 209 | jffs2_sum_move_collected(c, s); |
208 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): new nextblock = 0x%08x\n", jeb->offset)); | 210 | jffs2_dbg(1, "%s(): new nextblock = 0x%08x\n", |
211 | __func__, jeb->offset); | ||
209 | c->nextblock = jeb; | 212 | c->nextblock = jeb; |
210 | } else { | 213 | } else { |
211 | ret = file_dirty(c, jeb); | 214 | ret = file_dirty(c, jeb); |
@@ -217,20 +220,21 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
217 | case BLK_STATE_ALLDIRTY: | 220 | case BLK_STATE_ALLDIRTY: |
218 | /* Nothing valid - not even a clean marker. Needs erasing. */ | 221 | /* Nothing valid - not even a clean marker. Needs erasing. */ |
219 | /* For now we just put it on the erasing list. We'll start the erases later */ | 222 | /* For now we just put it on the erasing list. We'll start the erases later */ |
220 | D1(printk(KERN_NOTICE "JFFS2: Erase block at 0x%08x is not formatted. It will be erased\n", jeb->offset)); | 223 | jffs2_dbg(1, "Erase block at 0x%08x is not formatted. It will be erased\n", |
224 | jeb->offset); | ||
221 | list_add(&jeb->list, &c->erase_pending_list); | 225 | list_add(&jeb->list, &c->erase_pending_list); |
222 | c->nr_erasing_blocks++; | 226 | c->nr_erasing_blocks++; |
223 | break; | 227 | break; |
224 | 228 | ||
225 | case BLK_STATE_BADBLOCK: | 229 | case BLK_STATE_BADBLOCK: |
226 | D1(printk(KERN_NOTICE "JFFS2: Block at 0x%08x is bad\n", jeb->offset)); | 230 | jffs2_dbg(1, "Block at 0x%08x is bad\n", jeb->offset); |
227 | list_add(&jeb->list, &c->bad_list); | 231 | list_add(&jeb->list, &c->bad_list); |
228 | c->bad_size += c->sector_size; | 232 | c->bad_size += c->sector_size; |
229 | c->free_size -= c->sector_size; | 233 | c->free_size -= c->sector_size; |
230 | bad_blocks++; | 234 | bad_blocks++; |
231 | break; | 235 | break; |
232 | default: | 236 | default: |
233 | printk(KERN_WARNING "jffs2_scan_medium(): unknown block state\n"); | 237 | pr_warn("%s(): unknown block state\n", __func__); |
234 | BUG(); | 238 | BUG(); |
235 | } | 239 | } |
236 | } | 240 | } |
@@ -250,16 +254,17 @@ int jffs2_scan_medium(struct jffs2_sb_info *c) | |||
250 | 254 | ||
251 | uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; | 255 | uint32_t skip = c->nextblock->free_size % c->wbuf_pagesize; |
252 | 256 | ||
253 | D1(printk(KERN_DEBUG "jffs2_scan_medium(): Skipping %d bytes in nextblock to ensure page alignment\n", | 257 | jffs2_dbg(1, "%s(): Skipping %d bytes in nextblock to ensure page alignment\n", |
254 | skip)); | 258 | __func__, skip); |
255 | jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); | 259 | jffs2_prealloc_raw_node_refs(c, c->nextblock, 1); |
256 | jffs2_scan_dirty_space(c, c->nextblock, skip); | 260 | jffs2_scan_dirty_space(c, c->nextblock, skip); |
257 | } | 261 | } |
258 | #endif | 262 | #endif |
259 | if (c->nr_erasing_blocks) { | 263 | if (c->nr_erasing_blocks) { |
260 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { | 264 | if ( !c->used_size && ((c->nr_free_blocks+empty_blocks+bad_blocks)!= c->nr_blocks || bad_blocks == c->nr_blocks) ) { |
261 | printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); | 265 | pr_notice("Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n"); |
262 | printk(KERN_NOTICE "empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n",empty_blocks,bad_blocks,c->nr_blocks); | 266 | pr_notice("empty_blocks %d, bad_blocks %d, c->nr_blocks %d\n", |
267 | empty_blocks, bad_blocks, c->nr_blocks); | ||
263 | ret = -EIO; | 268 | ret = -EIO; |
264 | goto out; | 269 | goto out; |
265 | } | 270 | } |
@@ -287,11 +292,13 @@ static int jffs2_fill_scan_buf(struct jffs2_sb_info *c, void *buf, | |||
287 | 292 | ||
288 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); | 293 | ret = jffs2_flash_read(c, ofs, len, &retlen, buf); |
289 | if (ret) { | 294 | if (ret) { |
290 | D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", len, ofs, ret)); | 295 | jffs2_dbg(1, "mtd->read(0x%x bytes from 0x%x) returned %d\n", |
296 | len, ofs, ret); | ||
291 | return ret; | 297 | return ret; |
292 | } | 298 | } |
293 | if (retlen < len) { | 299 | if (retlen < len) { |
294 | D1(printk(KERN_WARNING "Read at 0x%x gave only 0x%zx bytes\n", ofs, retlen)); | 300 | jffs2_dbg(1, "Read at 0x%x gave only 0x%zx bytes\n", |
301 | ofs, retlen); | ||
295 | return -EIO; | 302 | return -EIO; |
296 | } | 303 | } |
297 | return 0; | 304 | return 0; |
@@ -368,7 +375,7 @@ static int jffs2_scan_xattr_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
368 | 375 | ||
369 | if (jffs2_sum_active()) | 376 | if (jffs2_sum_active()) |
370 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); | 377 | jffs2_sum_add_xattr_mem(s, rx, ofs - jeb->offset); |
371 | dbg_xattr("scaning xdatum at %#08x (xid=%u, version=%u)\n", | 378 | dbg_xattr("scanning xdatum at %#08x (xid=%u, version=%u)\n", |
372 | ofs, xd->xid, xd->version); | 379 | ofs, xd->xid, xd->version); |
373 | return 0; | 380 | return 0; |
374 | } | 381 | } |
@@ -449,7 +456,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
449 | ofs = jeb->offset; | 456 | ofs = jeb->offset; |
450 | prevofs = jeb->offset - 1; | 457 | prevofs = jeb->offset - 1; |
451 | 458 | ||
452 | D1(printk(KERN_DEBUG "jffs2_scan_eraseblock(): Scanning block at 0x%x\n", ofs)); | 459 | jffs2_dbg(1, "%s(): Scanning block at 0x%x\n", __func__, ofs); |
453 | 460 | ||
454 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 461 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
455 | if (jffs2_cleanmarker_oob(c)) { | 462 | if (jffs2_cleanmarker_oob(c)) { |
@@ -459,7 +466,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
459 | return BLK_STATE_BADBLOCK; | 466 | return BLK_STATE_BADBLOCK; |
460 | 467 | ||
461 | ret = jffs2_check_nand_cleanmarker(c, jeb); | 468 | ret = jffs2_check_nand_cleanmarker(c, jeb); |
462 | D2(printk(KERN_NOTICE "jffs_check_nand_cleanmarker returned %d\n",ret)); | 469 | jffs2_dbg(2, "jffs_check_nand_cleanmarker returned %d\n", ret); |
463 | 470 | ||
464 | /* Even if it's not found, we still scan to see | 471 | /* Even if it's not found, we still scan to see |
465 | if the block is empty. We use this information | 472 | if the block is empty. We use this information |
@@ -561,7 +568,8 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
561 | if (jffs2_cleanmarker_oob(c)) { | 568 | if (jffs2_cleanmarker_oob(c)) { |
562 | /* scan oob, take care of cleanmarker */ | 569 | /* scan oob, take care of cleanmarker */ |
563 | int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); | 570 | int ret = jffs2_check_oob_empty(c, jeb, cleanmarkerfound); |
564 | D2(printk(KERN_NOTICE "jffs2_check_oob_empty returned %d\n",ret)); | 571 | jffs2_dbg(2, "jffs2_check_oob_empty returned %d\n", |
572 | ret); | ||
565 | switch (ret) { | 573 | switch (ret) { |
566 | case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF; | 574 | case 0: return cleanmarkerfound ? BLK_STATE_CLEANMARKER : BLK_STATE_ALLFF; |
567 | case 1: return BLK_STATE_ALLDIRTY; | 575 | case 1: return BLK_STATE_ALLDIRTY; |
@@ -569,15 +577,16 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
569 | } | 577 | } |
570 | } | 578 | } |
571 | #endif | 579 | #endif |
572 | D1(printk(KERN_DEBUG "Block at 0x%08x is empty (erased)\n", jeb->offset)); | 580 | jffs2_dbg(1, "Block at 0x%08x is empty (erased)\n", |
581 | jeb->offset); | ||
573 | if (c->cleanmarker_size == 0) | 582 | if (c->cleanmarker_size == 0) |
574 | return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */ | 583 | return BLK_STATE_CLEANMARKER; /* don't bother with re-erase */ |
575 | else | 584 | else |
576 | return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */ | 585 | return BLK_STATE_ALLFF; /* OK to erase if all blocks are like this */ |
577 | } | 586 | } |
578 | if (ofs) { | 587 | if (ofs) { |
579 | D1(printk(KERN_DEBUG "Free space at %08x ends at %08x\n", jeb->offset, | 588 | jffs2_dbg(1, "Free space at %08x ends at %08x\n", jeb->offset, |
580 | jeb->offset + ofs)); | 589 | jeb->offset + ofs); |
581 | if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) | 590 | if ((err = jffs2_prealloc_raw_node_refs(c, jeb, 1))) |
582 | return err; | 591 | return err; |
583 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) | 592 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs))) |
@@ -604,12 +613,13 @@ scan_more: | |||
604 | cond_resched(); | 613 | cond_resched(); |
605 | 614 | ||
606 | if (ofs & 3) { | 615 | if (ofs & 3) { |
607 | printk(KERN_WARNING "Eep. ofs 0x%08x not word-aligned!\n", ofs); | 616 | pr_warn("Eep. ofs 0x%08x not word-aligned!\n", ofs); |
608 | ofs = PAD(ofs); | 617 | ofs = PAD(ofs); |
609 | continue; | 618 | continue; |
610 | } | 619 | } |
611 | if (ofs == prevofs) { | 620 | if (ofs == prevofs) { |
612 | printk(KERN_WARNING "ofs 0x%08x has already been seen. Skipping\n", ofs); | 621 | pr_warn("ofs 0x%08x has already been seen. Skipping\n", |
622 | ofs); | ||
613 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 623 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
614 | return err; | 624 | return err; |
615 | ofs += 4; | 625 | ofs += 4; |
@@ -618,8 +628,10 @@ scan_more: | |||
618 | prevofs = ofs; | 628 | prevofs = ofs; |
619 | 629 | ||
620 | if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { | 630 | if (jeb->offset + c->sector_size < ofs + sizeof(*node)) { |
621 | 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), | 631 | jffs2_dbg(1, "Fewer than %zd bytes left to end of block. (%x+%x<%x+%zx) Not reading\n", |
622 | jeb->offset, c->sector_size, ofs, sizeof(*node))); | 632 | sizeof(struct jffs2_unknown_node), |
633 | jeb->offset, c->sector_size, ofs, | ||
634 | sizeof(*node)); | ||
623 | if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) | 635 | if ((err = jffs2_scan_dirty_space(c, jeb, (jeb->offset + c->sector_size)-ofs))) |
624 | return err; | 636 | return err; |
625 | break; | 637 | break; |
@@ -627,8 +639,9 @@ scan_more: | |||
627 | 639 | ||
628 | if (buf_ofs + buf_len < ofs + sizeof(*node)) { | 640 | if (buf_ofs + buf_len < ofs + sizeof(*node)) { |
629 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 641 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
630 | D1(printk(KERN_DEBUG "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n", | 642 | jffs2_dbg(1, "Fewer than %zd bytes (node header) left to end of buf. Reading 0x%x at 0x%08x\n", |
631 | sizeof(struct jffs2_unknown_node), buf_len, ofs)); | 643 | sizeof(struct jffs2_unknown_node), |
644 | buf_len, ofs); | ||
632 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 645 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
633 | if (err) | 646 | if (err) |
634 | return err; | 647 | return err; |
@@ -645,13 +658,13 @@ scan_more: | |||
645 | ofs += 4; | 658 | ofs += 4; |
646 | scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len); | 659 | scan_end = min_t(uint32_t, EMPTY_SCAN_SIZE(c->sector_size)/8, buf_len); |
647 | 660 | ||
648 | D1(printk(KERN_DEBUG "Found empty flash at 0x%08x\n", ofs)); | 661 | jffs2_dbg(1, "Found empty flash at 0x%08x\n", ofs); |
649 | more_empty: | 662 | more_empty: |
650 | inbuf_ofs = ofs - buf_ofs; | 663 | inbuf_ofs = ofs - buf_ofs; |
651 | while (inbuf_ofs < scan_end) { | 664 | while (inbuf_ofs < scan_end) { |
652 | if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) { | 665 | if (unlikely(*(uint32_t *)(&buf[inbuf_ofs]) != 0xffffffff)) { |
653 | printk(KERN_WARNING "Empty flash at 0x%08x ends at 0x%08x\n", | 666 | pr_warn("Empty flash at 0x%08x ends at 0x%08x\n", |
654 | empty_start, ofs); | 667 | empty_start, ofs); |
655 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) | 668 | if ((err = jffs2_scan_dirty_space(c, jeb, ofs-empty_start))) |
656 | return err; | 669 | return err; |
657 | goto scan_more; | 670 | goto scan_more; |
@@ -661,13 +674,15 @@ scan_more: | |||
661 | ofs += 4; | 674 | ofs += 4; |
662 | } | 675 | } |
663 | /* Ran off end. */ | 676 | /* Ran off end. */ |
664 | D1(printk(KERN_DEBUG "Empty flash to end of buffer at 0x%08x\n", ofs)); | 677 | jffs2_dbg(1, "Empty flash to end of buffer at 0x%08x\n", |
678 | ofs); | ||
665 | 679 | ||
666 | /* If we're only checking the beginning of a block with a cleanmarker, | 680 | /* If we're only checking the beginning of a block with a cleanmarker, |
667 | bail now */ | 681 | bail now */ |
668 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && | 682 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && |
669 | c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { | 683 | c->cleanmarker_size && !jeb->dirty_size && !ref_next(jeb->first_node)) { |
670 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); | 684 | jffs2_dbg(1, "%d bytes at start of block seems clean... assuming all clean\n", |
685 | EMPTY_SCAN_SIZE(c->sector_size)); | ||
671 | return BLK_STATE_CLEANMARKER; | 686 | return BLK_STATE_CLEANMARKER; |
672 | } | 687 | } |
673 | if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */ | 688 | if (!buf_size && (scan_end != buf_len)) {/* XIP/point case */ |
@@ -680,13 +695,14 @@ scan_more: | |||
680 | if (!buf_len) { | 695 | if (!buf_len) { |
681 | /* No more to read. Break out of main loop without marking | 696 | /* No more to read. Break out of main loop without marking |
682 | this range of empty space as dirty (because it's not) */ | 697 | this range of empty space as dirty (because it's not) */ |
683 | D1(printk(KERN_DEBUG "Empty flash at %08x runs to end of block. Treating as free_space\n", | 698 | jffs2_dbg(1, "Empty flash at %08x runs to end of block. Treating as free_space\n", |
684 | empty_start)); | 699 | empty_start); |
685 | break; | 700 | break; |
686 | } | 701 | } |
687 | /* point never reaches here */ | 702 | /* point never reaches here */ |
688 | scan_end = buf_len; | 703 | scan_end = buf_len; |
689 | D1(printk(KERN_DEBUG "Reading another 0x%x at 0x%08x\n", buf_len, ofs)); | 704 | jffs2_dbg(1, "Reading another 0x%x at 0x%08x\n", |
705 | buf_len, ofs); | ||
690 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 706 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
691 | if (err) | 707 | if (err) |
692 | return err; | 708 | return err; |
@@ -695,22 +711,23 @@ scan_more: | |||
695 | } | 711 | } |
696 | 712 | ||
697 | if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { | 713 | if (ofs == jeb->offset && je16_to_cpu(node->magic) == KSAMTIB_CIGAM_2SFFJ) { |
698 | printk(KERN_WARNING "Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", ofs); | 714 | pr_warn("Magic bitmask is backwards at offset 0x%08x. Wrong endian filesystem?\n", |
715 | ofs); | ||
699 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 716 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
700 | return err; | 717 | return err; |
701 | ofs += 4; | 718 | ofs += 4; |
702 | continue; | 719 | continue; |
703 | } | 720 | } |
704 | if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) { | 721 | if (je16_to_cpu(node->magic) == JFFS2_DIRTY_BITMASK) { |
705 | D1(printk(KERN_DEBUG "Dirty bitmask at 0x%08x\n", ofs)); | 722 | jffs2_dbg(1, "Dirty bitmask at 0x%08x\n", ofs); |
706 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 723 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
707 | return err; | 724 | return err; |
708 | ofs += 4; | 725 | ofs += 4; |
709 | continue; | 726 | continue; |
710 | } | 727 | } |
711 | if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) { | 728 | if (je16_to_cpu(node->magic) == JFFS2_OLD_MAGIC_BITMASK) { |
712 | printk(KERN_WARNING "Old JFFS2 bitmask found at 0x%08x\n", ofs); | 729 | pr_warn("Old JFFS2 bitmask found at 0x%08x\n", ofs); |
713 | printk(KERN_WARNING "You cannot use older JFFS2 filesystems with newer kernels\n"); | 730 | pr_warn("You cannot use older JFFS2 filesystems with newer kernels\n"); |
714 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 731 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
715 | return err; | 732 | return err; |
716 | ofs += 4; | 733 | ofs += 4; |
@@ -718,7 +735,8 @@ scan_more: | |||
718 | } | 735 | } |
719 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { | 736 | if (je16_to_cpu(node->magic) != JFFS2_MAGIC_BITMASK) { |
720 | /* OK. We're out of possibilities. Whinge and move on */ | 737 | /* OK. We're out of possibilities. Whinge and move on */ |
721 | noisy_printk(&noise, "jffs2_scan_eraseblock(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", | 738 | noisy_printk(&noise, "%s(): Magic bitmask 0x%04x not found at 0x%08x: 0x%04x instead\n", |
739 | __func__, | ||
722 | JFFS2_MAGIC_BITMASK, ofs, | 740 | JFFS2_MAGIC_BITMASK, ofs, |
723 | je16_to_cpu(node->magic)); | 741 | je16_to_cpu(node->magic)); |
724 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 742 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
@@ -733,7 +751,8 @@ scan_more: | |||
733 | hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4); | 751 | hdr_crc = crc32(0, &crcnode, sizeof(crcnode)-4); |
734 | 752 | ||
735 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { | 753 | if (hdr_crc != je32_to_cpu(node->hdr_crc)) { |
736 | 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", | 754 | noisy_printk(&noise, "%s(): Node at 0x%08x {0x%04x, 0x%04x, 0x%08x) has invalid CRC 0x%08x (calculated 0x%08x)\n", |
755 | __func__, | ||
737 | ofs, je16_to_cpu(node->magic), | 756 | ofs, je16_to_cpu(node->magic), |
738 | je16_to_cpu(node->nodetype), | 757 | je16_to_cpu(node->nodetype), |
739 | je32_to_cpu(node->totlen), | 758 | je32_to_cpu(node->totlen), |
@@ -747,9 +766,9 @@ scan_more: | |||
747 | 766 | ||
748 | if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { | 767 | if (ofs + je32_to_cpu(node->totlen) > jeb->offset + c->sector_size) { |
749 | /* Eep. Node goes over the end of the erase block. */ | 768 | /* Eep. Node goes over the end of the erase block. */ |
750 | printk(KERN_WARNING "Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", | 769 | pr_warn("Node at 0x%08x with length 0x%08x would run over the end of the erase block\n", |
751 | ofs, je32_to_cpu(node->totlen)); | 770 | ofs, je32_to_cpu(node->totlen)); |
752 | printk(KERN_WARNING "Perhaps the file system was created with the wrong erase size?\n"); | 771 | pr_warn("Perhaps the file system was created with the wrong erase size?\n"); |
753 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) | 772 | if ((err = jffs2_scan_dirty_space(c, jeb, 4))) |
754 | return err; | 773 | return err; |
755 | ofs += 4; | 774 | ofs += 4; |
@@ -758,7 +777,8 @@ scan_more: | |||
758 | 777 | ||
759 | if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) { | 778 | if (!(je16_to_cpu(node->nodetype) & JFFS2_NODE_ACCURATE)) { |
760 | /* Wheee. This is an obsoleted node */ | 779 | /* Wheee. This is an obsoleted node */ |
761 | D2(printk(KERN_DEBUG "Node at 0x%08x is obsolete. Skipping\n", ofs)); | 780 | jffs2_dbg(2, "Node at 0x%08x is obsolete. Skipping\n", |
781 | ofs); | ||
762 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) | 782 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) |
763 | return err; | 783 | return err; |
764 | ofs += PAD(je32_to_cpu(node->totlen)); | 784 | ofs += PAD(je32_to_cpu(node->totlen)); |
@@ -769,8 +789,9 @@ scan_more: | |||
769 | case JFFS2_NODETYPE_INODE: | 789 | case JFFS2_NODETYPE_INODE: |
770 | if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { | 790 | if (buf_ofs + buf_len < ofs + sizeof(struct jffs2_raw_inode)) { |
771 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 791 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
772 | D1(printk(KERN_DEBUG "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n", | 792 | jffs2_dbg(1, "Fewer than %zd bytes (inode node) left to end of buf. Reading 0x%x at 0x%08x\n", |
773 | sizeof(struct jffs2_raw_inode), buf_len, ofs)); | 793 | sizeof(struct jffs2_raw_inode), |
794 | buf_len, ofs); | ||
774 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 795 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
775 | if (err) | 796 | if (err) |
776 | return err; | 797 | return err; |
@@ -785,8 +806,9 @@ scan_more: | |||
785 | case JFFS2_NODETYPE_DIRENT: | 806 | case JFFS2_NODETYPE_DIRENT: |
786 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 807 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
787 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 808 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
788 | D1(printk(KERN_DEBUG "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n", | 809 | jffs2_dbg(1, "Fewer than %d bytes (dirent node) left to end of buf. Reading 0x%x at 0x%08x\n", |
789 | je32_to_cpu(node->totlen), buf_len, ofs)); | 810 | je32_to_cpu(node->totlen), buf_len, |
811 | ofs); | ||
790 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 812 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
791 | if (err) | 813 | if (err) |
792 | return err; | 814 | return err; |
@@ -802,9 +824,9 @@ scan_more: | |||
802 | case JFFS2_NODETYPE_XATTR: | 824 | case JFFS2_NODETYPE_XATTR: |
803 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 825 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
804 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 826 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
805 | D1(printk(KERN_DEBUG "Fewer than %d bytes (xattr node)" | 827 | jffs2_dbg(1, "Fewer than %d bytes (xattr node) left to end of buf. Reading 0x%x at 0x%08x\n", |
806 | " left to end of buf. Reading 0x%x at 0x%08x\n", | 828 | je32_to_cpu(node->totlen), buf_len, |
807 | je32_to_cpu(node->totlen), buf_len, ofs)); | 829 | ofs); |
808 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 830 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
809 | if (err) | 831 | if (err) |
810 | return err; | 832 | return err; |
@@ -819,9 +841,9 @@ scan_more: | |||
819 | case JFFS2_NODETYPE_XREF: | 841 | case JFFS2_NODETYPE_XREF: |
820 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { | 842 | if (buf_ofs + buf_len < ofs + je32_to_cpu(node->totlen)) { |
821 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); | 843 | buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs); |
822 | D1(printk(KERN_DEBUG "Fewer than %d bytes (xref node)" | 844 | jffs2_dbg(1, "Fewer than %d bytes (xref node) left to end of buf. Reading 0x%x at 0x%08x\n", |
823 | " left to end of buf. Reading 0x%x at 0x%08x\n", | 845 | je32_to_cpu(node->totlen), buf_len, |
824 | je32_to_cpu(node->totlen), buf_len, ofs)); | 846 | ofs); |
825 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); | 847 | err = jffs2_fill_scan_buf(c, buf, ofs, buf_len); |
826 | if (err) | 848 | if (err) |
827 | return err; | 849 | return err; |
@@ -836,15 +858,17 @@ scan_more: | |||
836 | #endif /* CONFIG_JFFS2_FS_XATTR */ | 858 | #endif /* CONFIG_JFFS2_FS_XATTR */ |
837 | 859 | ||
838 | case JFFS2_NODETYPE_CLEANMARKER: | 860 | case JFFS2_NODETYPE_CLEANMARKER: |
839 | D1(printk(KERN_DEBUG "CLEANMARKER node found at 0x%08x\n", ofs)); | 861 | jffs2_dbg(1, "CLEANMARKER node found at 0x%08x\n", ofs); |
840 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { | 862 | if (je32_to_cpu(node->totlen) != c->cleanmarker_size) { |
841 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", | 863 | pr_notice("CLEANMARKER node found at 0x%08x has totlen 0x%x != normal 0x%x\n", |
842 | ofs, je32_to_cpu(node->totlen), c->cleanmarker_size); | 864 | ofs, je32_to_cpu(node->totlen), |
865 | c->cleanmarker_size); | ||
843 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) | 866 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) |
844 | return err; | 867 | return err; |
845 | ofs += PAD(sizeof(struct jffs2_unknown_node)); | 868 | ofs += PAD(sizeof(struct jffs2_unknown_node)); |
846 | } else if (jeb->first_node) { | 869 | } else if (jeb->first_node) { |
847 | printk(KERN_NOTICE "CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", ofs, jeb->offset); | 870 | pr_notice("CLEANMARKER node found at 0x%08x, not first node in block (0x%08x)\n", |
871 | ofs, jeb->offset); | ||
848 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) | 872 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(sizeof(struct jffs2_unknown_node))))) |
849 | return err; | 873 | return err; |
850 | ofs += PAD(sizeof(struct jffs2_unknown_node)); | 874 | ofs += PAD(sizeof(struct jffs2_unknown_node)); |
@@ -866,7 +890,8 @@ scan_more: | |||
866 | default: | 890 | default: |
867 | switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { | 891 | switch (je16_to_cpu(node->nodetype) & JFFS2_COMPAT_MASK) { |
868 | case JFFS2_FEATURE_ROCOMPAT: | 892 | case JFFS2_FEATURE_ROCOMPAT: |
869 | printk(KERN_NOTICE "Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); | 893 | pr_notice("Read-only compatible feature node (0x%04x) found at offset 0x%08x\n", |
894 | je16_to_cpu(node->nodetype), ofs); | ||
870 | c->flags |= JFFS2_SB_FLAG_RO; | 895 | c->flags |= JFFS2_SB_FLAG_RO; |
871 | if (!(jffs2_is_readonly(c))) | 896 | if (!(jffs2_is_readonly(c))) |
872 | return -EROFS; | 897 | return -EROFS; |
@@ -876,18 +901,21 @@ scan_more: | |||
876 | break; | 901 | break; |
877 | 902 | ||
878 | case JFFS2_FEATURE_INCOMPAT: | 903 | case JFFS2_FEATURE_INCOMPAT: |
879 | printk(KERN_NOTICE "Incompatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs); | 904 | pr_notice("Incompatible feature node (0x%04x) found at offset 0x%08x\n", |
905 | je16_to_cpu(node->nodetype), ofs); | ||
880 | return -EINVAL; | 906 | return -EINVAL; |
881 | 907 | ||
882 | case JFFS2_FEATURE_RWCOMPAT_DELETE: | 908 | case JFFS2_FEATURE_RWCOMPAT_DELETE: |
883 | D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); | 909 | jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", |
910 | je16_to_cpu(node->nodetype), ofs); | ||
884 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) | 911 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(node->totlen))))) |
885 | return err; | 912 | return err; |
886 | ofs += PAD(je32_to_cpu(node->totlen)); | 913 | ofs += PAD(je32_to_cpu(node->totlen)); |
887 | break; | 914 | break; |
888 | 915 | ||
889 | case JFFS2_FEATURE_RWCOMPAT_COPY: { | 916 | case JFFS2_FEATURE_RWCOMPAT_COPY: { |
890 | D1(printk(KERN_NOTICE "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", je16_to_cpu(node->nodetype), ofs)); | 917 | jffs2_dbg(1, "Unknown but compatible feature node (0x%04x) found at offset 0x%08x\n", |
918 | je16_to_cpu(node->nodetype), ofs); | ||
891 | 919 | ||
892 | jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); | 920 | jffs2_link_node_ref(c, jeb, ofs | REF_PRISTINE, PAD(je32_to_cpu(node->totlen)), NULL); |
893 | 921 | ||
@@ -908,8 +936,9 @@ scan_more: | |||
908 | } | 936 | } |
909 | } | 937 | } |
910 | 938 | ||
911 | D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", | 939 | jffs2_dbg(1, "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n", |
912 | jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size)); | 940 | jeb->offset, jeb->free_size, jeb->dirty_size, |
941 | jeb->unchecked_size, jeb->used_size, jeb->wasted_size); | ||
913 | 942 | ||
914 | /* mark_node_obsolete can add to wasted !! */ | 943 | /* mark_node_obsolete can add to wasted !! */ |
915 | if (jeb->wasted_size) { | 944 | if (jeb->wasted_size) { |
@@ -935,7 +964,7 @@ struct jffs2_inode_cache *jffs2_scan_make_ino_cache(struct jffs2_sb_info *c, uin | |||
935 | 964 | ||
936 | ic = jffs2_alloc_inode_cache(); | 965 | ic = jffs2_alloc_inode_cache(); |
937 | if (!ic) { | 966 | if (!ic) { |
938 | printk(KERN_NOTICE "jffs2_scan_make_inode_cache(): allocation of inode cache failed\n"); | 967 | pr_notice("%s(): allocation of inode cache failed\n", __func__); |
939 | return NULL; | 968 | return NULL; |
940 | } | 969 | } |
941 | memset(ic, 0, sizeof(*ic)); | 970 | memset(ic, 0, sizeof(*ic)); |
@@ -954,7 +983,7 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
954 | struct jffs2_inode_cache *ic; | 983 | struct jffs2_inode_cache *ic; |
955 | uint32_t crc, ino = je32_to_cpu(ri->ino); | 984 | uint32_t crc, ino = je32_to_cpu(ri->ino); |
956 | 985 | ||
957 | D1(printk(KERN_DEBUG "jffs2_scan_inode_node(): Node at 0x%08x\n", ofs)); | 986 | jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs); |
958 | 987 | ||
959 | /* We do very little here now. Just check the ino# to which we should attribute | 988 | /* We do very little here now. Just check the ino# to which we should attribute |
960 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- | 989 | this node; we can do all the CRC checking etc. later. There's a tradeoff here -- |
@@ -968,9 +997,8 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
968 | /* Check the node CRC in any case. */ | 997 | /* Check the node CRC in any case. */ |
969 | crc = crc32(0, ri, sizeof(*ri)-8); | 998 | crc = crc32(0, ri, sizeof(*ri)-8); |
970 | if (crc != je32_to_cpu(ri->node_crc)) { | 999 | if (crc != je32_to_cpu(ri->node_crc)) { |
971 | printk(KERN_NOTICE "jffs2_scan_inode_node(): CRC failed on " | 1000 | pr_notice("%s(): CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
972 | "node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 1001 | __func__, ofs, je32_to_cpu(ri->node_crc), crc); |
973 | ofs, je32_to_cpu(ri->node_crc), crc); | ||
974 | /* | 1002 | /* |
975 | * We believe totlen because the CRC on the node | 1003 | * We believe totlen because the CRC on the node |
976 | * _header_ was OK, just the node itself failed. | 1004 | * _header_ was OK, just the node itself failed. |
@@ -989,10 +1017,10 @@ static int jffs2_scan_inode_node(struct jffs2_sb_info *c, struct jffs2_erasebloc | |||
989 | /* Wheee. It worked */ | 1017 | /* Wheee. It worked */ |
990 | jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); | 1018 | jffs2_link_node_ref(c, jeb, ofs | REF_UNCHECKED, PAD(je32_to_cpu(ri->totlen)), ic); |
991 | 1019 | ||
992 | D1(printk(KERN_DEBUG "Node is ino #%u, version %d. Range 0x%x-0x%x\n", | 1020 | jffs2_dbg(1, "Node is ino #%u, version %d. Range 0x%x-0x%x\n", |
993 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), | 1021 | je32_to_cpu(ri->ino), je32_to_cpu(ri->version), |
994 | je32_to_cpu(ri->offset), | 1022 | je32_to_cpu(ri->offset), |
995 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize))); | 1023 | je32_to_cpu(ri->offset)+je32_to_cpu(ri->dsize)); |
996 | 1024 | ||
997 | pseudo_random += je32_to_cpu(ri->version); | 1025 | pseudo_random += je32_to_cpu(ri->version); |
998 | 1026 | ||
@@ -1012,15 +1040,15 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1012 | uint32_t crc; | 1040 | uint32_t crc; |
1013 | int err; | 1041 | int err; |
1014 | 1042 | ||
1015 | D1(printk(KERN_DEBUG "jffs2_scan_dirent_node(): Node at 0x%08x\n", ofs)); | 1043 | jffs2_dbg(1, "%s(): Node at 0x%08x\n", __func__, ofs); |
1016 | 1044 | ||
1017 | /* We don't get here unless the node is still valid, so we don't have to | 1045 | /* We don't get here unless the node is still valid, so we don't have to |
1018 | mask in the ACCURATE bit any more. */ | 1046 | mask in the ACCURATE bit any more. */ |
1019 | crc = crc32(0, rd, sizeof(*rd)-8); | 1047 | crc = crc32(0, rd, sizeof(*rd)-8); |
1020 | 1048 | ||
1021 | if (crc != je32_to_cpu(rd->node_crc)) { | 1049 | if (crc != je32_to_cpu(rd->node_crc)) { |
1022 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 1050 | pr_notice("%s(): Node CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
1023 | ofs, je32_to_cpu(rd->node_crc), crc); | 1051 | __func__, ofs, je32_to_cpu(rd->node_crc), crc); |
1024 | /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */ | 1052 | /* We believe totlen because the CRC on the node _header_ was OK, just the node itself failed. */ |
1025 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) | 1053 | if ((err = jffs2_scan_dirty_space(c, jeb, PAD(je32_to_cpu(rd->totlen))))) |
1026 | return err; | 1054 | return err; |
@@ -1032,7 +1060,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1032 | /* Should never happen. Did. (OLPC trac #4184)*/ | 1060 | /* Should never happen. Did. (OLPC trac #4184)*/ |
1033 | checkedlen = strnlen(rd->name, rd->nsize); | 1061 | checkedlen = strnlen(rd->name, rd->nsize); |
1034 | if (checkedlen < rd->nsize) { | 1062 | if (checkedlen < rd->nsize) { |
1035 | printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n", | 1063 | pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n", |
1036 | ofs, checkedlen); | 1064 | ofs, checkedlen); |
1037 | } | 1065 | } |
1038 | fd = jffs2_alloc_full_dirent(checkedlen+1); | 1066 | fd = jffs2_alloc_full_dirent(checkedlen+1); |
@@ -1044,9 +1072,10 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
1044 | 1072 | ||
1045 | crc = crc32(0, fd->name, rd->nsize); | 1073 | crc = crc32(0, fd->name, rd->nsize); |
1046 | if (crc != je32_to_cpu(rd->name_crc)) { | 1074 | if (crc != je32_to_cpu(rd->name_crc)) { |
1047 | printk(KERN_NOTICE "jffs2_scan_dirent_node(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", | 1075 | pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", |
1048 | ofs, je32_to_cpu(rd->name_crc), crc); | 1076 | __func__, ofs, je32_to_cpu(rd->name_crc), crc); |
1049 | D1(printk(KERN_NOTICE "Name for which CRC failed is (now) '%s', ino #%d\n", fd->name, je32_to_cpu(rd->ino))); | 1077 | jffs2_dbg(1, "Name for which CRC failed is (now) '%s', ino #%d\n", |
1078 | fd->name, je32_to_cpu(rd->ino)); | ||
1050 | jffs2_free_full_dirent(fd); | 1079 | jffs2_free_full_dirent(fd); |
1051 | /* FIXME: Why do we believe totlen? */ | 1080 | /* FIXME: Why do we believe totlen? */ |
1052 | /* We believe totlen because the CRC on the node _header_ was OK, just the name failed. */ | 1081 | /* 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 0f20208df602..aca97f35b292 100644 --- a/fs/jffs2/security.c +++ b/fs/jffs2/security.c | |||
@@ -23,8 +23,8 @@ | |||
23 | #include "nodelist.h" | 23 | #include "nodelist.h" |
24 | 24 | ||
25 | /* ---- Initial Security Label(s) Attachment callback --- */ | 25 | /* ---- Initial Security Label(s) Attachment callback --- */ |
26 | int jffs2_initxattrs(struct inode *inode, const struct xattr *xattr_array, | 26 | static int jffs2_initxattrs(struct inode *inode, |
27 | void *fs_info) | 27 | const struct xattr *xattr_array, void *fs_info) |
28 | { | 28 | { |
29 | const struct xattr *xattr; | 29 | const struct xattr *xattr; |
30 | int err = 0; | 30 | int err = 0; |
diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c index e537fb0e0184..c522d098bb4f 100644 --- a/fs/jffs2/summary.c +++ b/fs/jffs2/summary.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
16 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
@@ -442,13 +444,16 @@ static int jffs2_sum_process_sum_data(struct jffs2_sb_info *c, struct jffs2_eras | |||
442 | /* This should never happen, but https://dev.laptop.org/ticket/4184 */ | 444 | /* This should never happen, but https://dev.laptop.org/ticket/4184 */ |
443 | checkedlen = strnlen(spd->name, spd->nsize); | 445 | checkedlen = strnlen(spd->name, spd->nsize); |
444 | if (!checkedlen) { | 446 | if (!checkedlen) { |
445 | printk(KERN_ERR "Dirent at %08x has zero at start of name. Aborting mount.\n", | 447 | pr_err("Dirent at %08x has zero at start of name. Aborting mount.\n", |
446 | jeb->offset + je32_to_cpu(spd->offset)); | 448 | jeb->offset + |
449 | je32_to_cpu(spd->offset)); | ||
447 | return -EIO; | 450 | return -EIO; |
448 | } | 451 | } |
449 | if (checkedlen < spd->nsize) { | 452 | if (checkedlen < spd->nsize) { |
450 | printk(KERN_ERR "Dirent at %08x has zeroes in name. Truncating to %d chars\n", | 453 | pr_err("Dirent at %08x has zeroes in name. Truncating to %d chars\n", |
451 | jeb->offset + je32_to_cpu(spd->offset), checkedlen); | 454 | jeb->offset + |
455 | je32_to_cpu(spd->offset), | ||
456 | checkedlen); | ||
452 | } | 457 | } |
453 | 458 | ||
454 | 459 | ||
@@ -808,8 +813,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
808 | 813 | ||
809 | sum_ofs = jeb->offset + c->sector_size - jeb->free_size; | 814 | sum_ofs = jeb->offset + c->sector_size - jeb->free_size; |
810 | 815 | ||
811 | dbg_summary("JFFS2: writing out data to flash to pos : 0x%08x\n", | 816 | dbg_summary("writing out data to flash to pos : 0x%08x\n", sum_ofs); |
812 | sum_ofs); | ||
813 | 817 | ||
814 | ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0); | 818 | ret = jffs2_flash_writev(c, vecs, 2, sum_ofs, &retlen, 0); |
815 | 819 | ||
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c index f2d96b5e64f6..f9916f312bd8 100644 --- a/fs/jffs2/super.c +++ b/fs/jffs2/super.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/module.h> | 15 | #include <linux/module.h> |
14 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
@@ -69,7 +71,7 @@ static void jffs2_write_super(struct super_block *sb) | |||
69 | sb->s_dirt = 0; | 71 | sb->s_dirt = 0; |
70 | 72 | ||
71 | if (!(sb->s_flags & MS_RDONLY)) { | 73 | if (!(sb->s_flags & MS_RDONLY)) { |
72 | D1(printk(KERN_DEBUG "jffs2_write_super()\n")); | 74 | jffs2_dbg(1, "%s()\n", __func__); |
73 | jffs2_flush_wbuf_gc(c, 0); | 75 | jffs2_flush_wbuf_gc(c, 0); |
74 | } | 76 | } |
75 | 77 | ||
@@ -214,8 +216,8 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data) | |||
214 | JFFS2_COMPR_MODE_FORCEZLIB; | 216 | JFFS2_COMPR_MODE_FORCEZLIB; |
215 | #endif | 217 | #endif |
216 | else { | 218 | else { |
217 | printk(KERN_ERR "JFFS2 Error: unknown compressor \"%s\"", | 219 | pr_err("Error: unknown compressor \"%s\"\n", |
218 | name); | 220 | name); |
219 | kfree(name); | 221 | kfree(name); |
220 | return -EINVAL; | 222 | return -EINVAL; |
221 | } | 223 | } |
@@ -223,8 +225,8 @@ static int jffs2_parse_options(struct jffs2_sb_info *c, char *data) | |||
223 | c->mount_opts.override_compr = true; | 225 | c->mount_opts.override_compr = true; |
224 | break; | 226 | break; |
225 | default: | 227 | default: |
226 | printk(KERN_ERR "JFFS2 Error: unrecognized mount option '%s' or missing value\n", | 228 | pr_err("Error: unrecognized mount option '%s' or missing value\n", |
227 | p); | 229 | p); |
228 | return -EINVAL; | 230 | return -EINVAL; |
229 | } | 231 | } |
230 | } | 232 | } |
@@ -266,9 +268,9 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent) | |||
266 | struct jffs2_sb_info *c; | 268 | struct jffs2_sb_info *c; |
267 | int ret; | 269 | int ret; |
268 | 270 | ||
269 | D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" | 271 | jffs2_dbg(1, "jffs2_get_sb_mtd():" |
270 | " New superblock for device %d (\"%s\")\n", | 272 | " New superblock for device %d (\"%s\")\n", |
271 | sb->s_mtd->index, sb->s_mtd->name)); | 273 | sb->s_mtd->index, sb->s_mtd->name); |
272 | 274 | ||
273 | c = kzalloc(sizeof(*c), GFP_KERNEL); | 275 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
274 | if (!c) | 276 | if (!c) |
@@ -315,7 +317,7 @@ static void jffs2_put_super (struct super_block *sb) | |||
315 | { | 317 | { |
316 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); | 318 | struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); |
317 | 319 | ||
318 | D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); | 320 | jffs2_dbg(2, "%s()\n", __func__); |
319 | 321 | ||
320 | if (sb->s_dirt) | 322 | if (sb->s_dirt) |
321 | jffs2_write_super(sb); | 323 | jffs2_write_super(sb); |
@@ -336,7 +338,7 @@ static void jffs2_put_super (struct super_block *sb) | |||
336 | kfree(c->inocache_list); | 338 | kfree(c->inocache_list); |
337 | jffs2_clear_xattr_subsystem(c); | 339 | jffs2_clear_xattr_subsystem(c); |
338 | mtd_sync(c->mtd); | 340 | mtd_sync(c->mtd); |
339 | D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); | 341 | jffs2_dbg(1, "%s(): returning\n", __func__); |
340 | } | 342 | } |
341 | 343 | ||
342 | static void jffs2_kill_sb(struct super_block *sb) | 344 | static void jffs2_kill_sb(struct super_block *sb) |
@@ -371,7 +373,7 @@ static int __init init_jffs2_fs(void) | |||
371 | BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68); | 373 | BUILD_BUG_ON(sizeof(struct jffs2_raw_inode) != 68); |
372 | BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32); | 374 | BUILD_BUG_ON(sizeof(struct jffs2_raw_summary) != 32); |
373 | 375 | ||
374 | printk(KERN_INFO "JFFS2 version 2.2." | 376 | pr_info("version 2.2." |
375 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER | 377 | #ifdef CONFIG_JFFS2_FS_WRITEBUFFER |
376 | " (NAND)" | 378 | " (NAND)" |
377 | #endif | 379 | #endif |
@@ -386,22 +388,22 @@ static int __init init_jffs2_fs(void) | |||
386 | SLAB_MEM_SPREAD), | 388 | SLAB_MEM_SPREAD), |
387 | jffs2_i_init_once); | 389 | jffs2_i_init_once); |
388 | if (!jffs2_inode_cachep) { | 390 | if (!jffs2_inode_cachep) { |
389 | printk(KERN_ERR "JFFS2 error: Failed to initialise inode cache\n"); | 391 | pr_err("error: Failed to initialise inode cache\n"); |
390 | return -ENOMEM; | 392 | return -ENOMEM; |
391 | } | 393 | } |
392 | ret = jffs2_compressors_init(); | 394 | ret = jffs2_compressors_init(); |
393 | if (ret) { | 395 | if (ret) { |
394 | printk(KERN_ERR "JFFS2 error: Failed to initialise compressors\n"); | 396 | pr_err("error: Failed to initialise compressors\n"); |
395 | goto out; | 397 | goto out; |
396 | } | 398 | } |
397 | ret = jffs2_create_slab_caches(); | 399 | ret = jffs2_create_slab_caches(); |
398 | if (ret) { | 400 | if (ret) { |
399 | printk(KERN_ERR "JFFS2 error: Failed to initialise slab caches\n"); | 401 | pr_err("error: Failed to initialise slab caches\n"); |
400 | goto out_compressors; | 402 | goto out_compressors; |
401 | } | 403 | } |
402 | ret = register_filesystem(&jffs2_fs_type); | 404 | ret = register_filesystem(&jffs2_fs_type); |
403 | if (ret) { | 405 | if (ret) { |
404 | printk(KERN_ERR "JFFS2 error: Failed to register filesystem\n"); | 406 | pr_err("error: Failed to register filesystem\n"); |
405 | goto out_slab; | 407 | goto out_slab; |
406 | } | 408 | } |
407 | return 0; | 409 | return 0; |
diff --git a/fs/jffs2/symlink.c b/fs/jffs2/symlink.c index e3035afb1814..6e563332bb24 100644 --- a/fs/jffs2/symlink.c +++ b/fs/jffs2/symlink.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
14 | #include <linux/namei.h> | 16 | #include <linux/namei.h> |
@@ -47,10 +49,11 @@ static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd) | |||
47 | */ | 49 | */ |
48 | 50 | ||
49 | if (!p) { | 51 | if (!p) { |
50 | printk(KERN_ERR "jffs2_follow_link(): can't find symlink target\n"); | 52 | pr_err("%s(): can't find symlink target\n", __func__); |
51 | p = ERR_PTR(-EIO); | 53 | p = ERR_PTR(-EIO); |
52 | } | 54 | } |
53 | D1(printk(KERN_DEBUG "jffs2_follow_link(): target path is '%s'\n", (char *) f->target)); | 55 | jffs2_dbg(1, "%s(): target path is '%s'\n", |
56 | __func__, (char *)f->target); | ||
54 | 57 | ||
55 | nd_set_link(nd, p); | 58 | nd_set_link(nd, p); |
56 | 59 | ||
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 30e8f47e8a23..74d9be19df3f 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -11,6 +11,8 @@ | |||
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
15 | |||
14 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
15 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
16 | #include <linux/mtd/mtd.h> | 18 | #include <linux/mtd/mtd.h> |
@@ -91,7 +93,7 @@ static void jffs2_wbuf_dirties_inode(struct jffs2_sb_info *c, uint32_t ino) | |||
91 | 93 | ||
92 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 94 | new = kmalloc(sizeof(*new), GFP_KERNEL); |
93 | if (!new) { | 95 | if (!new) { |
94 | D1(printk(KERN_DEBUG "No memory to allocate inodirty. Fallback to all considered dirty\n")); | 96 | jffs2_dbg(1, "No memory to allocate inodirty. Fallback to all considered dirty\n"); |
95 | jffs2_clear_wbuf_ino_list(c); | 97 | jffs2_clear_wbuf_ino_list(c); |
96 | c->wbuf_inodes = &inodirty_nomem; | 98 | c->wbuf_inodes = &inodirty_nomem; |
97 | return; | 99 | return; |
@@ -113,19 +115,20 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
113 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { | 115 | list_for_each_safe(this, next, &c->erasable_pending_wbuf_list) { |
114 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); | 116 | struct jffs2_eraseblock *jeb = list_entry(this, struct jffs2_eraseblock, list); |
115 | 117 | ||
116 | D1(printk(KERN_DEBUG "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", jeb->offset)); | 118 | jffs2_dbg(1, "Removing eraseblock at 0x%08x from erasable_pending_wbuf_list...\n", |
119 | jeb->offset); | ||
117 | list_del(this); | 120 | list_del(this); |
118 | if ((jiffies + (n++)) & 127) { | 121 | if ((jiffies + (n++)) & 127) { |
119 | /* Most of the time, we just erase it immediately. Otherwise we | 122 | /* Most of the time, we just erase it immediately. Otherwise we |
120 | spend ages scanning it on mount, etc. */ | 123 | spend ages scanning it on mount, etc. */ |
121 | D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n")); | 124 | jffs2_dbg(1, "...and adding to erase_pending_list\n"); |
122 | list_add_tail(&jeb->list, &c->erase_pending_list); | 125 | list_add_tail(&jeb->list, &c->erase_pending_list); |
123 | c->nr_erasing_blocks++; | 126 | c->nr_erasing_blocks++; |
124 | jffs2_garbage_collect_trigger(c); | 127 | jffs2_garbage_collect_trigger(c); |
125 | } else { | 128 | } else { |
126 | /* Sometimes, however, we leave it elsewhere so it doesn't get | 129 | /* Sometimes, however, we leave it elsewhere so it doesn't get |
127 | immediately reused, and we spread the load a bit. */ | 130 | immediately reused, and we spread the load a bit. */ |
128 | D1(printk(KERN_DEBUG "...and adding to erasable_list\n")); | 131 | jffs2_dbg(1, "...and adding to erasable_list\n"); |
129 | list_add_tail(&jeb->list, &c->erasable_list); | 132 | list_add_tail(&jeb->list, &c->erasable_list); |
130 | } | 133 | } |
131 | } | 134 | } |
@@ -136,7 +139,7 @@ static inline void jffs2_refile_wbuf_blocks(struct jffs2_sb_info *c) | |||
136 | 139 | ||
137 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) | 140 | static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, int allow_empty) |
138 | { | 141 | { |
139 | D1(printk("About to refile bad block at %08x\n", jeb->offset)); | 142 | jffs2_dbg(1, "About to refile bad block at %08x\n", jeb->offset); |
140 | 143 | ||
141 | /* File the existing block on the bad_used_list.... */ | 144 | /* File the existing block on the bad_used_list.... */ |
142 | if (c->nextblock == jeb) | 145 | if (c->nextblock == jeb) |
@@ -144,12 +147,14 @@ static void jffs2_block_refile(struct jffs2_sb_info *c, struct jffs2_eraseblock | |||
144 | else /* Not sure this should ever happen... need more coffee */ | 147 | else /* Not sure this should ever happen... need more coffee */ |
145 | list_del(&jeb->list); | 148 | list_del(&jeb->list); |
146 | if (jeb->first_node) { | 149 | if (jeb->first_node) { |
147 | D1(printk("Refiling block at %08x to bad_used_list\n", jeb->offset)); | 150 | jffs2_dbg(1, "Refiling block at %08x to bad_used_list\n", |
151 | jeb->offset); | ||
148 | list_add(&jeb->list, &c->bad_used_list); | 152 | list_add(&jeb->list, &c->bad_used_list); |
149 | } else { | 153 | } else { |
150 | BUG_ON(allow_empty == REFILE_NOTEMPTY); | 154 | BUG_ON(allow_empty == REFILE_NOTEMPTY); |
151 | /* It has to have had some nodes or we couldn't be here */ | 155 | /* It has to have had some nodes or we couldn't be here */ |
152 | D1(printk("Refiling block at %08x to erase_pending_list\n", jeb->offset)); | 156 | jffs2_dbg(1, "Refiling block at %08x to erase_pending_list\n", |
157 | jeb->offset); | ||
153 | list_add(&jeb->list, &c->erase_pending_list); | 158 | list_add(&jeb->list, &c->erase_pending_list); |
154 | c->nr_erasing_blocks++; | 159 | c->nr_erasing_blocks++; |
155 | jffs2_garbage_collect_trigger(c); | 160 | jffs2_garbage_collect_trigger(c); |
@@ -230,10 +235,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
230 | 235 | ||
231 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); | 236 | ret = mtd_read(c->mtd, ofs, c->wbuf_pagesize, &retlen, c->wbuf_verify); |
232 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { | 237 | if (ret && ret != -EUCLEAN && ret != -EBADMSG) { |
233 | printk(KERN_WARNING "jffs2_verify_write(): Read back of page at %08x failed: %d\n", c->wbuf_ofs, ret); | 238 | pr_warn("%s(): Read back of page at %08x failed: %d\n", |
239 | __func__, c->wbuf_ofs, ret); | ||
234 | return ret; | 240 | return ret; |
235 | } else if (retlen != c->wbuf_pagesize) { | 241 | } else if (retlen != c->wbuf_pagesize) { |
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); | 242 | pr_warn("%s(): Read back of page at %08x gave short read: %zd not %d\n", |
243 | __func__, ofs, retlen, c->wbuf_pagesize); | ||
237 | return -EIO; | 244 | return -EIO; |
238 | } | 245 | } |
239 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) | 246 | if (!memcmp(buf, c->wbuf_verify, c->wbuf_pagesize)) |
@@ -246,12 +253,12 @@ static int jffs2_verify_write(struct jffs2_sb_info *c, unsigned char *buf, | |||
246 | else | 253 | else |
247 | eccstr = "OK or unused"; | 254 | eccstr = "OK or unused"; |
248 | 255 | ||
249 | printk(KERN_WARNING "Write verify error (ECC %s) at %08x. Wrote:\n", | 256 | pr_warn("Write verify error (ECC %s) at %08x. Wrote:\n", |
250 | eccstr, c->wbuf_ofs); | 257 | eccstr, c->wbuf_ofs); |
251 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 258 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
252 | c->wbuf, c->wbuf_pagesize, 0); | 259 | c->wbuf, c->wbuf_pagesize, 0); |
253 | 260 | ||
254 | printk(KERN_WARNING "Read back:\n"); | 261 | pr_warn("Read back:\n"); |
255 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, | 262 | print_hex_dump(KERN_WARNING, "", DUMP_PREFIX_OFFSET, 16, 1, |
256 | c->wbuf_verify, c->wbuf_pagesize, 0); | 263 | c->wbuf_verify, c->wbuf_pagesize, 0); |
257 | 264 | ||
@@ -308,7 +315,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
308 | 315 | ||
309 | if (!first_raw) { | 316 | if (!first_raw) { |
310 | /* All nodes were obsolete. Nothing to recover. */ | 317 | /* All nodes were obsolete. Nothing to recover. */ |
311 | D1(printk(KERN_DEBUG "No non-obsolete nodes to be recovered. Just filing block bad\n")); | 318 | jffs2_dbg(1, "No non-obsolete nodes to be recovered. Just filing block bad\n"); |
312 | c->wbuf_len = 0; | 319 | c->wbuf_len = 0; |
313 | return; | 320 | return; |
314 | } | 321 | } |
@@ -331,7 +338,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
331 | 338 | ||
332 | buf = kmalloc(end - start, GFP_KERNEL); | 339 | buf = kmalloc(end - start, GFP_KERNEL); |
333 | if (!buf) { | 340 | if (!buf) { |
334 | printk(KERN_CRIT "Malloc failure in wbuf recovery. Data loss ensues.\n"); | 341 | pr_crit("Malloc failure in wbuf recovery. Data loss ensues.\n"); |
335 | 342 | ||
336 | goto read_failed; | 343 | goto read_failed; |
337 | } | 344 | } |
@@ -346,7 +353,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
346 | ret = 0; | 353 | ret = 0; |
347 | 354 | ||
348 | if (ret || retlen != c->wbuf_ofs - start) { | 355 | if (ret || retlen != c->wbuf_ofs - start) { |
349 | printk(KERN_CRIT "Old data are already lost in wbuf recovery. Data loss ensues.\n"); | 356 | pr_crit("Old data are already lost in wbuf recovery. Data loss ensues.\n"); |
350 | 357 | ||
351 | kfree(buf); | 358 | kfree(buf); |
352 | buf = NULL; | 359 | buf = NULL; |
@@ -380,7 +387,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
380 | /* ... and get an allocation of space from a shiny new block instead */ | 387 | /* ... and get an allocation of space from a shiny new block instead */ |
381 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); | 388 | ret = jffs2_reserve_space_gc(c, end-start, &len, JFFS2_SUMMARY_NOSUM_SIZE); |
382 | if (ret) { | 389 | if (ret) { |
383 | printk(KERN_WARNING "Failed to allocate space for wbuf recovery. Data loss ensues.\n"); | 390 | pr_warn("Failed to allocate space for wbuf recovery. Data loss ensues.\n"); |
384 | kfree(buf); | 391 | kfree(buf); |
385 | return; | 392 | return; |
386 | } | 393 | } |
@@ -390,7 +397,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
390 | 397 | ||
391 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); | 398 | ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, nr_refile); |
392 | if (ret) { | 399 | if (ret) { |
393 | printk(KERN_WARNING "Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); | 400 | pr_warn("Failed to allocate node refs for wbuf recovery. Data loss ensues.\n"); |
394 | kfree(buf); | 401 | kfree(buf); |
395 | return; | 402 | return; |
396 | } | 403 | } |
@@ -406,13 +413,13 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
406 | unsigned char *rewrite_buf = buf?:c->wbuf; | 413 | unsigned char *rewrite_buf = buf?:c->wbuf; |
407 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); | 414 | uint32_t towrite = (end-start) - ((end-start)%c->wbuf_pagesize); |
408 | 415 | ||
409 | D1(printk(KERN_DEBUG "Write 0x%x bytes at 0x%08x in wbuf recover\n", | 416 | jffs2_dbg(1, "Write 0x%x bytes at 0x%08x in wbuf recover\n", |
410 | towrite, ofs)); | 417 | towrite, ofs); |
411 | 418 | ||
412 | #ifdef BREAKMEHEADER | 419 | #ifdef BREAKMEHEADER |
413 | static int breakme; | 420 | static int breakme; |
414 | if (breakme++ == 20) { | 421 | if (breakme++ == 20) { |
415 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", ofs); | 422 | pr_notice("Faking write error at 0x%08x\n", ofs); |
416 | breakme = 0; | 423 | breakme = 0; |
417 | mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); | 424 | mtd_write(c->mtd, ofs, towrite, &retlen, brokenbuf); |
418 | ret = -EIO; | 425 | ret = -EIO; |
@@ -423,7 +430,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
423 | 430 | ||
424 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { | 431 | if (ret || retlen != towrite || jffs2_verify_write(c, rewrite_buf, ofs)) { |
425 | /* Argh. We tried. Really we did. */ | 432 | /* Argh. We tried. Really we did. */ |
426 | printk(KERN_CRIT "Recovery of wbuf failed due to a second write error\n"); | 433 | pr_crit("Recovery of wbuf failed due to a second write error\n"); |
427 | kfree(buf); | 434 | kfree(buf); |
428 | 435 | ||
429 | if (retlen) | 436 | if (retlen) |
@@ -431,7 +438,7 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
431 | 438 | ||
432 | return; | 439 | return; |
433 | } | 440 | } |
434 | printk(KERN_NOTICE "Recovery of wbuf succeeded to %08x\n", ofs); | 441 | pr_notice("Recovery of wbuf succeeded to %08x\n", ofs); |
435 | 442 | ||
436 | c->wbuf_len = (end - start) - towrite; | 443 | c->wbuf_len = (end - start) - towrite; |
437 | c->wbuf_ofs = ofs + towrite; | 444 | c->wbuf_ofs = ofs + towrite; |
@@ -459,8 +466,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
459 | struct jffs2_raw_node_ref **adjust_ref = NULL; | 466 | struct jffs2_raw_node_ref **adjust_ref = NULL; |
460 | struct jffs2_inode_info *f = NULL; | 467 | struct jffs2_inode_info *f = NULL; |
461 | 468 | ||
462 | D1(printk(KERN_DEBUG "Refiling block of %08x at %08x(%d) to %08x\n", | 469 | jffs2_dbg(1, "Refiling block of %08x at %08x(%d) to %08x\n", |
463 | rawlen, ref_offset(raw), ref_flags(raw), ofs)); | 470 | rawlen, ref_offset(raw), ref_flags(raw), ofs); |
464 | 471 | ||
465 | ic = jffs2_raw_ref_to_ic(raw); | 472 | ic = jffs2_raw_ref_to_ic(raw); |
466 | 473 | ||
@@ -540,7 +547,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
540 | 547 | ||
541 | /* Fix up the original jeb now it's on the bad_list */ | 548 | /* Fix up the original jeb now it's on the bad_list */ |
542 | if (first_raw == jeb->first_node) { | 549 | if (first_raw == jeb->first_node) { |
543 | D1(printk(KERN_DEBUG "Failing block at %08x is now empty. Moving to erase_pending_list\n", jeb->offset)); | 550 | jffs2_dbg(1, "Failing block at %08x is now empty. Moving to erase_pending_list\n", |
551 | jeb->offset); | ||
544 | list_move(&jeb->list, &c->erase_pending_list); | 552 | list_move(&jeb->list, &c->erase_pending_list); |
545 | c->nr_erasing_blocks++; | 553 | c->nr_erasing_blocks++; |
546 | jffs2_garbage_collect_trigger(c); | 554 | jffs2_garbage_collect_trigger(c); |
@@ -554,7 +562,8 @@ static void jffs2_wbuf_recover(struct jffs2_sb_info *c) | |||
554 | 562 | ||
555 | spin_unlock(&c->erase_completion_lock); | 563 | spin_unlock(&c->erase_completion_lock); |
556 | 564 | ||
557 | D1(printk(KERN_DEBUG "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", c->wbuf_ofs, c->wbuf_len)); | 565 | jffs2_dbg(1, "wbuf recovery completed OK. wbuf_ofs 0x%08x, len 0x%x\n", |
566 | c->wbuf_ofs, c->wbuf_len); | ||
558 | 567 | ||
559 | } | 568 | } |
560 | 569 | ||
@@ -579,7 +588,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
579 | return 0; | 588 | return 0; |
580 | 589 | ||
581 | if (!mutex_is_locked(&c->alloc_sem)) { | 590 | if (!mutex_is_locked(&c->alloc_sem)) { |
582 | printk(KERN_CRIT "jffs2_flush_wbuf() called with alloc_sem not locked!\n"); | 591 | pr_crit("jffs2_flush_wbuf() called with alloc_sem not locked!\n"); |
583 | BUG(); | 592 | BUG(); |
584 | } | 593 | } |
585 | 594 | ||
@@ -617,7 +626,7 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
617 | #ifdef BREAKME | 626 | #ifdef BREAKME |
618 | static int breakme; | 627 | static int breakme; |
619 | if (breakme++ == 20) { | 628 | if (breakme++ == 20) { |
620 | printk(KERN_NOTICE "Faking write error at 0x%08x\n", c->wbuf_ofs); | 629 | pr_notice("Faking write error at 0x%08x\n", c->wbuf_ofs); |
621 | breakme = 0; | 630 | breakme = 0; |
622 | mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, | 631 | mtd_write(c->mtd, c->wbuf_ofs, c->wbuf_pagesize, &retlen, |
623 | brokenbuf); | 632 | brokenbuf); |
@@ -629,11 +638,11 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
629 | &retlen, c->wbuf); | 638 | &retlen, c->wbuf); |
630 | 639 | ||
631 | if (ret) { | 640 | if (ret) { |
632 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write failed with %d\n", ret); | 641 | pr_warn("jffs2_flush_wbuf(): Write failed with %d\n", ret); |
633 | goto wfail; | 642 | goto wfail; |
634 | } else if (retlen != c->wbuf_pagesize) { | 643 | } else if (retlen != c->wbuf_pagesize) { |
635 | printk(KERN_WARNING "jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", | 644 | pr_warn("jffs2_flush_wbuf(): Write was short: %zd instead of %d\n", |
636 | retlen, c->wbuf_pagesize); | 645 | retlen, c->wbuf_pagesize); |
637 | ret = -EIO; | 646 | ret = -EIO; |
638 | goto wfail; | 647 | goto wfail; |
639 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { | 648 | } else if ((ret = jffs2_verify_write(c, c->wbuf, c->wbuf_ofs))) { |
@@ -647,17 +656,18 @@ static int __jffs2_flush_wbuf(struct jffs2_sb_info *c, int pad) | |||
647 | if (pad) { | 656 | if (pad) { |
648 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; | 657 | uint32_t waste = c->wbuf_pagesize - c->wbuf_len; |
649 | 658 | ||
650 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", | 659 | jffs2_dbg(1, "jffs2_flush_wbuf() adjusting free_size of %sblock at %08x\n", |
651 | (wbuf_jeb==c->nextblock)?"next":"", wbuf_jeb->offset)); | 660 | (wbuf_jeb == c->nextblock) ? "next" : "", |
661 | wbuf_jeb->offset); | ||
652 | 662 | ||
653 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be | 663 | /* wbuf_pagesize - wbuf_len is the amount of space that's to be |
654 | padded. If there is less free space in the block than that, | 664 | padded. If there is less free space in the block than that, |
655 | something screwed up */ | 665 | something screwed up */ |
656 | if (wbuf_jeb->free_size < waste) { | 666 | if (wbuf_jeb->free_size < waste) { |
657 | printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", | 667 | pr_crit("jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n", |
658 | c->wbuf_ofs, c->wbuf_len, waste); | 668 | c->wbuf_ofs, c->wbuf_len, waste); |
659 | printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", | 669 | pr_crit("jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n", |
660 | wbuf_jeb->offset, wbuf_jeb->free_size); | 670 | wbuf_jeb->offset, wbuf_jeb->free_size); |
661 | BUG(); | 671 | BUG(); |
662 | } | 672 | } |
663 | 673 | ||
@@ -694,14 +704,14 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
694 | uint32_t old_wbuf_len; | 704 | uint32_t old_wbuf_len; |
695 | int ret = 0; | 705 | int ret = 0; |
696 | 706 | ||
697 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino)); | 707 | jffs2_dbg(1, "jffs2_flush_wbuf_gc() called for ino #%u...\n", ino); |
698 | 708 | ||
699 | if (!c->wbuf) | 709 | if (!c->wbuf) |
700 | return 0; | 710 | return 0; |
701 | 711 | ||
702 | mutex_lock(&c->alloc_sem); | 712 | mutex_lock(&c->alloc_sem); |
703 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { | 713 | if (!jffs2_wbuf_pending_for_ino(c, ino)) { |
704 | D1(printk(KERN_DEBUG "Ino #%d not pending in wbuf. Returning\n", ino)); | 714 | jffs2_dbg(1, "Ino #%d not pending in wbuf. Returning\n", ino); |
705 | mutex_unlock(&c->alloc_sem); | 715 | mutex_unlock(&c->alloc_sem); |
706 | return 0; | 716 | return 0; |
707 | } | 717 | } |
@@ -711,7 +721,8 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
711 | 721 | ||
712 | if (c->unchecked_size) { | 722 | if (c->unchecked_size) { |
713 | /* GC won't make any progress for a while */ | 723 | /* GC won't make any progress for a while */ |
714 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() padding. Not finished checking\n")); | 724 | jffs2_dbg(1, "%s(): padding. Not finished checking\n", |
725 | __func__); | ||
715 | down_write(&c->wbuf_sem); | 726 | down_write(&c->wbuf_sem); |
716 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); | 727 | ret = __jffs2_flush_wbuf(c, PAD_ACCOUNTING); |
717 | /* retry flushing wbuf in case jffs2_wbuf_recover | 728 | /* retry flushing wbuf in case jffs2_wbuf_recover |
@@ -724,7 +735,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
724 | 735 | ||
725 | mutex_unlock(&c->alloc_sem); | 736 | mutex_unlock(&c->alloc_sem); |
726 | 737 | ||
727 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() calls gc pass\n")); | 738 | jffs2_dbg(1, "%s(): calls gc pass\n", __func__); |
728 | 739 | ||
729 | ret = jffs2_garbage_collect_pass(c); | 740 | ret = jffs2_garbage_collect_pass(c); |
730 | if (ret) { | 741 | if (ret) { |
@@ -742,7 +753,7 @@ int jffs2_flush_wbuf_gc(struct jffs2_sb_info *c, uint32_t ino) | |||
742 | mutex_lock(&c->alloc_sem); | 753 | mutex_lock(&c->alloc_sem); |
743 | } | 754 | } |
744 | 755 | ||
745 | D1(printk(KERN_DEBUG "jffs2_flush_wbuf_gc() ends...\n")); | 756 | jffs2_dbg(1, "%s(): ends...\n", __func__); |
746 | 757 | ||
747 | mutex_unlock(&c->alloc_sem); | 758 | mutex_unlock(&c->alloc_sem); |
748 | return ret; | 759 | return ret; |
@@ -811,9 +822,8 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
811 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { | 822 | if (SECTOR_ADDR(to) != SECTOR_ADDR(c->wbuf_ofs)) { |
812 | /* It's a write to a new block */ | 823 | /* It's a write to a new block */ |
813 | if (c->wbuf_len) { | 824 | if (c->wbuf_len) { |
814 | D1(printk(KERN_DEBUG "jffs2_flash_writev() to 0x%lx " | 825 | jffs2_dbg(1, "%s(): to 0x%lx causes flush of wbuf at 0x%08x\n", |
815 | "causes flush of wbuf at 0x%08x\n", | 826 | __func__, (unsigned long)to, c->wbuf_ofs); |
816 | (unsigned long)to, c->wbuf_ofs)); | ||
817 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); | 827 | ret = __jffs2_flush_wbuf(c, PAD_NOACCOUNT); |
818 | if (ret) | 828 | if (ret) |
819 | goto outerr; | 829 | goto outerr; |
@@ -825,11 +835,11 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, | |||
825 | 835 | ||
826 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { | 836 | if (to != PAD(c->wbuf_ofs + c->wbuf_len)) { |
827 | /* We're not writing immediately after the writebuffer. Bad. */ | 837 | /* We're not writing immediately after the writebuffer. Bad. */ |
828 | printk(KERN_CRIT "jffs2_flash_writev(): Non-contiguous write " | 838 | pr_crit("%s(): Non-contiguous write to %08lx\n", |
829 | "to %08lx\n", (unsigned long)to); | 839 | __func__, (unsigned long)to); |
830 | if (c->wbuf_len) | 840 | if (c->wbuf_len) |
831 | printk(KERN_CRIT "wbuf was previously %08x-%08x\n", | 841 | pr_crit("wbuf was previously %08x-%08x\n", |
832 | c->wbuf_ofs, c->wbuf_ofs+c->wbuf_len); | 842 | c->wbuf_ofs, c->wbuf_ofs + c->wbuf_len); |
833 | BUG(); | 843 | BUG(); |
834 | } | 844 | } |
835 | 845 | ||
@@ -957,8 +967,8 @@ int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len, size_t *re | |||
957 | 967 | ||
958 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { | 968 | if ( (ret == -EBADMSG || ret == -EUCLEAN) && (*retlen == len) ) { |
959 | if (ret == -EBADMSG) | 969 | if (ret == -EBADMSG) |
960 | printk(KERN_WARNING "mtd->read(0x%zx bytes from 0x%llx)" | 970 | pr_warn("mtd->read(0x%zx bytes from 0x%llx) returned ECC error\n", |
961 | " returned ECC error\n", len, ofs); | 971 | len, ofs); |
962 | /* | 972 | /* |
963 | * We have the raw data without ECC correction in the buffer, | 973 | * We have the raw data without ECC correction in the buffer, |
964 | * maybe we are lucky and all data or parts are correct. We | 974 | * maybe we are lucky and all data or parts are correct. We |
@@ -1034,9 +1044,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1034 | 1044 | ||
1035 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1045 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); |
1036 | if (ret || ops.oobretlen != ops.ooblen) { | 1046 | if (ret || ops.oobretlen != ops.ooblen) { |
1037 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" | 1047 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1038 | " bytes, read %zd bytes, error %d\n", | 1048 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1039 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1040 | if (!ret) | 1049 | if (!ret) |
1041 | ret = -EIO; | 1050 | ret = -EIO; |
1042 | return ret; | 1051 | return ret; |
@@ -1048,8 +1057,8 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1048 | continue; | 1057 | continue; |
1049 | 1058 | ||
1050 | if (ops.oobbuf[i] != 0xFF) { | 1059 | if (ops.oobbuf[i] != 0xFF) { |
1051 | D2(printk(KERN_DEBUG "Found %02x at %x in OOB for " | 1060 | jffs2_dbg(2, "Found %02x at %x in OOB for " |
1052 | "%08x\n", ops.oobbuf[i], i, jeb->offset)); | 1061 | "%08x\n", ops.oobbuf[i], i, jeb->offset); |
1053 | return 1; | 1062 | return 1; |
1054 | } | 1063 | } |
1055 | } | 1064 | } |
@@ -1077,9 +1086,8 @@ int jffs2_check_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1077 | 1086 | ||
1078 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); | 1087 | ret = mtd_read_oob(c->mtd, jeb->offset, &ops); |
1079 | if (ret || ops.oobretlen != ops.ooblen) { | 1088 | if (ret || ops.oobretlen != ops.ooblen) { |
1080 | printk(KERN_ERR "cannot read OOB for EB at %08x, requested %zd" | 1089 | pr_err("cannot read OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1081 | " bytes, read %zd bytes, error %d\n", | 1090 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1082 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1083 | if (!ret) | 1091 | if (!ret) |
1084 | ret = -EIO; | 1092 | ret = -EIO; |
1085 | return ret; | 1093 | return ret; |
@@ -1103,9 +1111,8 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1103 | 1111 | ||
1104 | ret = mtd_write_oob(c->mtd, jeb->offset, &ops); | 1112 | ret = mtd_write_oob(c->mtd, jeb->offset, &ops); |
1105 | if (ret || ops.oobretlen != ops.ooblen) { | 1113 | if (ret || ops.oobretlen != ops.ooblen) { |
1106 | printk(KERN_ERR "cannot write OOB for EB at %08x, requested %zd" | 1114 | pr_err("cannot write OOB for EB at %08x, requested %zd bytes, read %zd bytes, error %d\n", |
1107 | " bytes, read %zd bytes, error %d\n", | 1115 | jeb->offset, ops.ooblen, ops.oobretlen, ret); |
1108 | jeb->offset, ops.ooblen, ops.oobretlen, ret); | ||
1109 | if (!ret) | 1116 | if (!ret) |
1110 | ret = -EIO; | 1117 | ret = -EIO; |
1111 | return ret; | 1118 | return ret; |
@@ -1130,11 +1137,12 @@ int jffs2_write_nand_badblock(struct jffs2_sb_info *c, struct jffs2_eraseblock * | |||
1130 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) | 1137 | if( ++jeb->bad_count < MAX_ERASE_FAILURES) |
1131 | return 0; | 1138 | return 0; |
1132 | 1139 | ||
1133 | printk(KERN_WARNING "JFFS2: marking eraseblock at %08x\n as bad", bad_offset); | 1140 | pr_warn("marking eraseblock at %08x as bad\n", bad_offset); |
1134 | ret = mtd_block_markbad(c->mtd, bad_offset); | 1141 | ret = mtd_block_markbad(c->mtd, bad_offset); |
1135 | 1142 | ||
1136 | if (ret) { | 1143 | if (ret) { |
1137 | D1(printk(KERN_WARNING "jffs2_write_nand_badblock(): Write failed for block at %08x: error %d\n", jeb->offset, ret)); | 1144 | jffs2_dbg(1, "%s(): Write failed for block at %08x: error %d\n", |
1145 | __func__, jeb->offset, ret); | ||
1138 | return ret; | 1146 | return ret; |
1139 | } | 1147 | } |
1140 | return 1; | 1148 | return 1; |
@@ -1151,11 +1159,11 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
1151 | c->cleanmarker_size = 0; | 1159 | c->cleanmarker_size = 0; |
1152 | 1160 | ||
1153 | if (!oinfo || oinfo->oobavail == 0) { | 1161 | if (!oinfo || oinfo->oobavail == 0) { |
1154 | printk(KERN_ERR "inconsistent device description\n"); | 1162 | pr_err("inconsistent device description\n"); |
1155 | return -EINVAL; | 1163 | return -EINVAL; |
1156 | } | 1164 | } |
1157 | 1165 | ||
1158 | D1(printk(KERN_DEBUG "JFFS2 using OOB on NAND\n")); | 1166 | jffs2_dbg(1, "using OOB on NAND\n"); |
1159 | 1167 | ||
1160 | c->oobavail = oinfo->oobavail; | 1168 | c->oobavail = oinfo->oobavail; |
1161 | 1169 | ||
@@ -1222,7 +1230,7 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1222 | 1230 | ||
1223 | if ((c->flash_size % c->sector_size) != 0) { | 1231 | if ((c->flash_size % c->sector_size) != 0) { |
1224 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; | 1232 | c->flash_size = (c->flash_size / c->sector_size) * c->sector_size; |
1225 | printk(KERN_WARNING "JFFS2 flash size adjusted to %dKiB\n", c->flash_size); | 1233 | pr_warn("flash size adjusted to %dKiB\n", c->flash_size); |
1226 | }; | 1234 | }; |
1227 | 1235 | ||
1228 | c->wbuf_ofs = 0xFFFFFFFF; | 1236 | c->wbuf_ofs = 0xFFFFFFFF; |
@@ -1239,7 +1247,8 @@ int jffs2_dataflash_setup(struct jffs2_sb_info *c) { | |||
1239 | } | 1247 | } |
1240 | #endif | 1248 | #endif |
1241 | 1249 | ||
1242 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); | 1250 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", |
1251 | c->wbuf_pagesize, c->sector_size); | ||
1243 | 1252 | ||
1244 | return 0; | 1253 | return 0; |
1245 | } | 1254 | } |
@@ -1297,7 +1306,8 @@ int jffs2_ubivol_setup(struct jffs2_sb_info *c) { | |||
1297 | if (!c->wbuf) | 1306 | if (!c->wbuf) |
1298 | return -ENOMEM; | 1307 | return -ENOMEM; |
1299 | 1308 | ||
1300 | printk(KERN_INFO "JFFS2 write-buffering enabled buffer (%d) erasesize (%d)\n", c->wbuf_pagesize, c->sector_size); | 1309 | pr_info("write-buffering enabled buffer (%d) erasesize (%d)\n", |
1310 | c->wbuf_pagesize, c->sector_size); | ||
1301 | 1311 | ||
1302 | return 0; | 1312 | return 0; |
1303 | } | 1313 | } |
diff --git a/fs/jffs2/write.c b/fs/jffs2/write.c index 30d175b6d290..b634de4c8101 100644 --- a/fs/jffs2/write.c +++ b/fs/jffs2/write.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
14 | #include <linux/crc32.h> | 16 | #include <linux/crc32.h> |
@@ -36,7 +38,7 @@ int jffs2_do_new_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
36 | f->inocache->state = INO_STATE_PRESENT; | 38 | f->inocache->state = INO_STATE_PRESENT; |
37 | 39 | ||
38 | jffs2_add_ino_cache(c, f->inocache); | 40 | jffs2_add_ino_cache(c, f->inocache); |
39 | D1(printk(KERN_DEBUG "jffs2_do_new_inode(): Assigned ino# %d\n", f->inocache->ino)); | 41 | jffs2_dbg(1, "%s(): Assigned ino# %d\n", __func__, f->inocache->ino); |
40 | ri->ino = cpu_to_je32(f->inocache->ino); | 42 | ri->ino = cpu_to_je32(f->inocache->ino); |
41 | 43 | ||
42 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); | 44 | ri->magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); |
@@ -68,7 +70,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
68 | unsigned long cnt = 2; | 70 | unsigned long cnt = 2; |
69 | 71 | ||
70 | D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs2_unknown_node)-4)) { | 72 | D1(if(je32_to_cpu(ri->hdr_crc) != crc32(0, ri, sizeof(struct jffs2_unknown_node)-4)) { |
71 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dnode()\n"); | 73 | pr_crit("Eep. CRC not correct in jffs2_write_dnode()\n"); |
72 | BUG(); | 74 | BUG(); |
73 | } | 75 | } |
74 | ); | 76 | ); |
@@ -78,7 +80,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
78 | vecs[1].iov_len = datalen; | 80 | vecs[1].iov_len = datalen; |
79 | 81 | ||
80 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { | 82 | if (je32_to_cpu(ri->totlen) != sizeof(*ri) + datalen) { |
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); | 83 | pr_warn("%s(): ri->totlen (0x%08x) != sizeof(*ri) (0x%08zx) + datalen (0x%08x)\n", |
84 | __func__, je32_to_cpu(ri->totlen), | ||
85 | sizeof(*ri), datalen); | ||
82 | } | 86 | } |
83 | 87 | ||
84 | fn = jffs2_alloc_full_dnode(); | 88 | fn = jffs2_alloc_full_dnode(); |
@@ -95,9 +99,9 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
95 | 99 | ||
96 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { | 100 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(ri->version) < f->highest_version)) { |
97 | BUG_ON(!retried); | 101 | BUG_ON(!retried); |
98 | D1(printk(KERN_DEBUG "jffs2_write_dnode : dnode_version %d, " | 102 | jffs2_dbg(1, "%s(): dnode_version %d, highest version %d -> updating dnode\n", |
99 | "highest version %d -> updating dnode\n", | 103 | __func__, |
100 | je32_to_cpu(ri->version), f->highest_version)); | 104 | je32_to_cpu(ri->version), f->highest_version); |
101 | ri->version = cpu_to_je32(++f->highest_version); | 105 | ri->version = cpu_to_je32(++f->highest_version); |
102 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); | 106 | ri->node_crc = cpu_to_je32(crc32(0, ri, sizeof(*ri)-8)); |
103 | } | 107 | } |
@@ -106,8 +110,8 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
106 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); | 110 | (alloc_mode==ALLOC_GC)?0:f->inocache->ino); |
107 | 111 | ||
108 | if (ret || (retlen != sizeof(*ri) + datalen)) { | 112 | if (ret || (retlen != sizeof(*ri) + datalen)) { |
109 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 113 | pr_notice("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
110 | sizeof(*ri)+datalen, flash_ofs, ret, retlen); | 114 | sizeof(*ri) + datalen, flash_ofs, ret, retlen); |
111 | 115 | ||
112 | /* Mark the space as dirtied */ | 116 | /* Mark the space as dirtied */ |
113 | if (retlen) { | 117 | if (retlen) { |
@@ -118,7 +122,8 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
118 | this node */ | 122 | this node */ |
119 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*ri)+datalen), NULL); | 123 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*ri)+datalen), NULL); |
120 | } else { | 124 | } else { |
121 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", flash_ofs); | 125 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", |
126 | flash_ofs); | ||
122 | } | 127 | } |
123 | if (!retried && alloc_mode != ALLOC_NORETRY) { | 128 | if (!retried && alloc_mode != ALLOC_NORETRY) { |
124 | /* Try to reallocate space and retry */ | 129 | /* Try to reallocate space and retry */ |
@@ -127,7 +132,7 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
127 | 132 | ||
128 | retried = 1; | 133 | retried = 1; |
129 | 134 | ||
130 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); | 135 | jffs2_dbg(1, "Retrying failed write.\n"); |
131 | 136 | ||
132 | jffs2_dbg_acct_sanity_check(c,jeb); | 137 | jffs2_dbg_acct_sanity_check(c,jeb); |
133 | jffs2_dbg_acct_paranoia_check(c, jeb); | 138 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -147,14 +152,16 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
147 | 152 | ||
148 | if (!ret) { | 153 | if (!ret) { |
149 | flash_ofs = write_ofs(c); | 154 | flash_ofs = write_ofs(c); |
150 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); | 155 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write.\n", |
156 | flash_ofs); | ||
151 | 157 | ||
152 | jffs2_dbg_acct_sanity_check(c,jeb); | 158 | jffs2_dbg_acct_sanity_check(c,jeb); |
153 | jffs2_dbg_acct_paranoia_check(c, jeb); | 159 | jffs2_dbg_acct_paranoia_check(c, jeb); |
154 | 160 | ||
155 | goto retry; | 161 | goto retry; |
156 | } | 162 | } |
157 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 163 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", |
164 | ret); | ||
158 | } | 165 | } |
159 | /* Release the full_dnode which is now useless, and return */ | 166 | /* Release the full_dnode which is now useless, and return */ |
160 | jffs2_free_full_dnode(fn); | 167 | jffs2_free_full_dnode(fn); |
@@ -183,10 +190,10 @@ struct jffs2_full_dnode *jffs2_write_dnode(struct jffs2_sb_info *c, struct jffs2 | |||
183 | fn->size = je32_to_cpu(ri->dsize); | 190 | fn->size = je32_to_cpu(ri->dsize); |
184 | fn->frags = 0; | 191 | fn->frags = 0; |
185 | 192 | ||
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", | 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", |
187 | flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), | 194 | flash_ofs & ~3, flash_ofs & 3, je32_to_cpu(ri->dsize), |
188 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), | 195 | je32_to_cpu(ri->csize), je32_to_cpu(ri->node_crc), |
189 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen))); | 196 | je32_to_cpu(ri->data_crc), je32_to_cpu(ri->totlen)); |
190 | 197 | ||
191 | if (retried) { | 198 | if (retried) { |
192 | jffs2_dbg_acct_sanity_check(c,NULL); | 199 | jffs2_dbg_acct_sanity_check(c,NULL); |
@@ -206,22 +213,23 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
206 | int retried = 0; | 213 | int retried = 0; |
207 | int ret; | 214 | int ret; |
208 | 215 | ||
209 | D1(printk(KERN_DEBUG "jffs2_write_dirent(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", | 216 | jffs2_dbg(1, "%s(ino #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x)\n", |
217 | __func__, | ||
210 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), | 218 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), |
211 | je32_to_cpu(rd->name_crc))); | 219 | je32_to_cpu(rd->name_crc)); |
212 | 220 | ||
213 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { | 221 | D1(if(je32_to_cpu(rd->hdr_crc) != crc32(0, rd, sizeof(struct jffs2_unknown_node)-4)) { |
214 | printk(KERN_CRIT "Eep. CRC not correct in jffs2_write_dirent()\n"); | 222 | pr_crit("Eep. CRC not correct in jffs2_write_dirent()\n"); |
215 | BUG(); | 223 | BUG(); |
216 | }); | 224 | }); |
217 | 225 | ||
218 | if (strnlen(name, namelen) != namelen) { | 226 | if (strnlen(name, namelen) != namelen) { |
219 | /* This should never happen, but seems to have done on at least one | 227 | /* This should never happen, but seems to have done on at least one |
220 | occasion: https://dev.laptop.org/ticket/4184 */ | 228 | occasion: https://dev.laptop.org/ticket/4184 */ |
221 | printk(KERN_CRIT "Error in jffs2_write_dirent() -- name contains zero bytes!\n"); | 229 | pr_crit("Error in jffs2_write_dirent() -- name contains zero bytes!\n"); |
222 | printk(KERN_CRIT "Directory inode #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x\n", | 230 | pr_crit("Directory inode #%u, name at *0x%p \"%s\"->ino #%u, name_crc 0x%08x\n", |
223 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), | 231 | je32_to_cpu(rd->pino), name, name, je32_to_cpu(rd->ino), |
224 | je32_to_cpu(rd->name_crc)); | 232 | je32_to_cpu(rd->name_crc)); |
225 | WARN_ON(1); | 233 | WARN_ON(1); |
226 | return ERR_PTR(-EIO); | 234 | return ERR_PTR(-EIO); |
227 | } | 235 | } |
@@ -249,9 +257,9 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
249 | 257 | ||
250 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { | 258 | if ((alloc_mode!=ALLOC_GC) && (je32_to_cpu(rd->version) < f->highest_version)) { |
251 | BUG_ON(!retried); | 259 | BUG_ON(!retried); |
252 | D1(printk(KERN_DEBUG "jffs2_write_dirent : dirent_version %d, " | 260 | jffs2_dbg(1, "%s(): dirent_version %d, highest version %d -> updating dirent\n", |
253 | "highest version %d -> updating dirent\n", | 261 | __func__, |
254 | je32_to_cpu(rd->version), f->highest_version)); | 262 | je32_to_cpu(rd->version), f->highest_version); |
255 | rd->version = cpu_to_je32(++f->highest_version); | 263 | rd->version = cpu_to_je32(++f->highest_version); |
256 | fd->version = je32_to_cpu(rd->version); | 264 | fd->version = je32_to_cpu(rd->version); |
257 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); | 265 | rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); |
@@ -260,13 +268,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
260 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, | 268 | ret = jffs2_flash_writev(c, vecs, 2, flash_ofs, &retlen, |
261 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); | 269 | (alloc_mode==ALLOC_GC)?0:je32_to_cpu(rd->pino)); |
262 | if (ret || (retlen != sizeof(*rd) + namelen)) { | 270 | if (ret || (retlen != sizeof(*rd) + namelen)) { |
263 | printk(KERN_NOTICE "Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", | 271 | pr_notice("Write of %zd bytes at 0x%08x failed. returned %d, retlen %zd\n", |
264 | sizeof(*rd)+namelen, flash_ofs, ret, retlen); | 272 | sizeof(*rd) + namelen, flash_ofs, ret, retlen); |
265 | /* Mark the space as dirtied */ | 273 | /* Mark the space as dirtied */ |
266 | if (retlen) { | 274 | if (retlen) { |
267 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*rd)+namelen), NULL); | 275 | jffs2_add_physical_node_ref(c, flash_ofs | REF_OBSOLETE, PAD(sizeof(*rd)+namelen), NULL); |
268 | } else { | 276 | } else { |
269 | printk(KERN_NOTICE "Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", flash_ofs); | 277 | pr_notice("Not marking the space at 0x%08x as dirty because the flash driver returned retlen zero\n", |
278 | flash_ofs); | ||
270 | } | 279 | } |
271 | if (!retried) { | 280 | if (!retried) { |
272 | /* Try to reallocate space and retry */ | 281 | /* Try to reallocate space and retry */ |
@@ -275,7 +284,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
275 | 284 | ||
276 | retried = 1; | 285 | retried = 1; |
277 | 286 | ||
278 | D1(printk(KERN_DEBUG "Retrying failed write.\n")); | 287 | jffs2_dbg(1, "Retrying failed write.\n"); |
279 | 288 | ||
280 | jffs2_dbg_acct_sanity_check(c,jeb); | 289 | jffs2_dbg_acct_sanity_check(c,jeb); |
281 | jffs2_dbg_acct_paranoia_check(c, jeb); | 290 | jffs2_dbg_acct_paranoia_check(c, jeb); |
@@ -295,12 +304,14 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff | |||
295 | 304 | ||
296 | if (!ret) { | 305 | if (!ret) { |
297 | flash_ofs = write_ofs(c); | 306 | flash_ofs = write_ofs(c); |
298 | D1(printk(KERN_DEBUG "Allocated space at 0x%08x to retry failed write.\n", flash_ofs)); | 307 | jffs2_dbg(1, "Allocated space at 0x%08x to retry failed write\n", |
308 | flash_ofs); | ||
299 | jffs2_dbg_acct_sanity_check(c,jeb); | 309 | jffs2_dbg_acct_sanity_check(c,jeb); |
300 | jffs2_dbg_acct_paranoia_check(c, jeb); | 310 | jffs2_dbg_acct_paranoia_check(c, jeb); |
301 | goto retry; | 311 | goto retry; |
302 | } | 312 | } |
303 | D1(printk(KERN_DEBUG "Failed to allocate space to retry failed write: %d!\n", ret)); | 313 | jffs2_dbg(1, "Failed to allocate space to retry failed write: %d!\n", |
314 | ret); | ||
304 | } | 315 | } |
305 | /* Release the full_dnode which is now useless, and return */ | 316 | /* Release the full_dnode which is now useless, and return */ |
306 | jffs2_free_full_dirent(fd); | 317 | jffs2_free_full_dirent(fd); |
@@ -333,8 +344,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
333 | int ret = 0; | 344 | int ret = 0; |
334 | uint32_t writtenlen = 0; | 345 | uint32_t writtenlen = 0; |
335 | 346 | ||
336 | D1(printk(KERN_DEBUG "jffs2_write_inode_range(): Ino #%u, ofs 0x%x, len 0x%x\n", | 347 | jffs2_dbg(1, "%s(): Ino #%u, ofs 0x%x, len 0x%x\n", |
337 | f->inocache->ino, offset, writelen)); | 348 | __func__, f->inocache->ino, offset, writelen); |
338 | 349 | ||
339 | while(writelen) { | 350 | while(writelen) { |
340 | struct jffs2_full_dnode *fn; | 351 | struct jffs2_full_dnode *fn; |
@@ -345,12 +356,13 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
345 | int retried = 0; | 356 | int retried = 0; |
346 | 357 | ||
347 | retry: | 358 | retry: |
348 | D2(printk(KERN_DEBUG "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", writelen, offset)); | 359 | jffs2_dbg(2, "jffs2_commit_write() loop: 0x%x to write to 0x%x\n", |
360 | writelen, offset); | ||
349 | 361 | ||
350 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, | 362 | ret = jffs2_reserve_space(c, sizeof(*ri) + JFFS2_MIN_DATA_LEN, |
351 | &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); | 363 | &alloclen, ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); |
352 | if (ret) { | 364 | if (ret) { |
353 | D1(printk(KERN_DEBUG "jffs2_reserve_space returned %d\n", ret)); | 365 | jffs2_dbg(1, "jffs2_reserve_space returned %d\n", ret); |
354 | break; | 366 | break; |
355 | } | 367 | } |
356 | mutex_lock(&f->sem); | 368 | mutex_lock(&f->sem); |
@@ -386,7 +398,7 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
386 | if (!retried) { | 398 | if (!retried) { |
387 | /* Write error to be retried */ | 399 | /* Write error to be retried */ |
388 | retried = 1; | 400 | retried = 1; |
389 | D1(printk(KERN_DEBUG "Retrying node write in jffs2_write_inode_range()\n")); | 401 | jffs2_dbg(1, "Retrying node write in jffs2_write_inode_range()\n"); |
390 | goto retry; | 402 | goto retry; |
391 | } | 403 | } |
392 | break; | 404 | break; |
@@ -399,7 +411,8 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
399 | } | 411 | } |
400 | if (ret) { | 412 | if (ret) { |
401 | /* Eep */ | 413 | /* Eep */ |
402 | D1(printk(KERN_DEBUG "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", ret)); | 414 | jffs2_dbg(1, "Eep. add_full_dnode_to_inode() failed in commit_write, returned %d\n", |
415 | ret); | ||
403 | jffs2_mark_node_obsolete(c, fn->raw); | 416 | jffs2_mark_node_obsolete(c, fn->raw); |
404 | jffs2_free_full_dnode(fn); | 417 | jffs2_free_full_dnode(fn); |
405 | 418 | ||
@@ -410,11 +423,11 @@ int jffs2_write_inode_range(struct jffs2_sb_info *c, struct jffs2_inode_info *f, | |||
410 | mutex_unlock(&f->sem); | 423 | mutex_unlock(&f->sem); |
411 | jffs2_complete_reservation(c); | 424 | jffs2_complete_reservation(c); |
412 | if (!datalen) { | 425 | if (!datalen) { |
413 | printk(KERN_WARNING "Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); | 426 | pr_warn("Eep. We didn't actually write any data in jffs2_write_inode_range()\n"); |
414 | ret = -EIO; | 427 | ret = -EIO; |
415 | break; | 428 | break; |
416 | } | 429 | } |
417 | D1(printk(KERN_DEBUG "increasing writtenlen by %d\n", datalen)); | 430 | jffs2_dbg(1, "increasing writtenlen by %d\n", datalen); |
418 | writtenlen += datalen; | 431 | writtenlen += datalen; |
419 | offset += datalen; | 432 | offset += datalen; |
420 | writelen -= datalen; | 433 | writelen -= datalen; |
@@ -439,7 +452,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
439 | */ | 452 | */ |
440 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, | 453 | ret = jffs2_reserve_space(c, sizeof(*ri), &alloclen, ALLOC_NORMAL, |
441 | JFFS2_SUMMARY_INODE_SIZE); | 454 | JFFS2_SUMMARY_INODE_SIZE); |
442 | D1(printk(KERN_DEBUG "jffs2_do_create(): reserved 0x%x bytes\n", alloclen)); | 455 | jffs2_dbg(1, "%s(): reserved 0x%x bytes\n", __func__, alloclen); |
443 | if (ret) | 456 | if (ret) |
444 | return ret; | 457 | return ret; |
445 | 458 | ||
@@ -450,11 +463,11 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
450 | 463 | ||
451 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); | 464 | fn = jffs2_write_dnode(c, f, ri, NULL, 0, ALLOC_NORMAL); |
452 | 465 | ||
453 | D1(printk(KERN_DEBUG "jffs2_do_create created file with mode 0x%x\n", | 466 | jffs2_dbg(1, "jffs2_do_create created file with mode 0x%x\n", |
454 | jemode_to_cpu(ri->mode))); | 467 | jemode_to_cpu(ri->mode)); |
455 | 468 | ||
456 | if (IS_ERR(fn)) { | 469 | if (IS_ERR(fn)) { |
457 | D1(printk(KERN_DEBUG "jffs2_write_dnode() failed\n")); | 470 | jffs2_dbg(1, "jffs2_write_dnode() failed\n"); |
458 | /* Eeek. Wave bye bye */ | 471 | /* Eeek. Wave bye bye */ |
459 | mutex_unlock(&f->sem); | 472 | mutex_unlock(&f->sem); |
460 | jffs2_complete_reservation(c); | 473 | jffs2_complete_reservation(c); |
@@ -480,7 +493,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
480 | 493 | ||
481 | if (ret) { | 494 | if (ret) { |
482 | /* Eep. */ | 495 | /* Eep. */ |
483 | D1(printk(KERN_DEBUG "jffs2_reserve_space() for dirent failed\n")); | 496 | jffs2_dbg(1, "jffs2_reserve_space() for dirent failed\n"); |
484 | return ret; | 497 | return ret; |
485 | } | 498 | } |
486 | 499 | ||
@@ -597,8 +610,8 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
597 | !memcmp(fd->name, name, namelen) && | 610 | !memcmp(fd->name, name, namelen) && |
598 | !fd->name[namelen]) { | 611 | !fd->name[namelen]) { |
599 | 612 | ||
600 | D1(printk(KERN_DEBUG "Marking old dirent node (ino #%u) @%08x obsolete\n", | 613 | jffs2_dbg(1, "Marking old dirent node (ino #%u) @%08x obsolete\n", |
601 | fd->ino, ref_offset(fd->raw))); | 614 | fd->ino, ref_offset(fd->raw)); |
602 | jffs2_mark_node_obsolete(c, fd->raw); | 615 | jffs2_mark_node_obsolete(c, fd->raw); |
603 | /* We don't want to remove it from the list immediately, | 616 | /* We don't want to remove it from the list immediately, |
604 | because that screws up getdents()/seek() semantics even | 617 | because that screws up getdents()/seek() semantics even |
@@ -627,11 +640,13 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, | |||
627 | dead_f->dents = fd->next; | 640 | dead_f->dents = fd->next; |
628 | 641 | ||
629 | if (fd->ino) { | 642 | if (fd->ino) { |
630 | printk(KERN_WARNING "Deleting inode #%u with active dentry \"%s\"->ino #%u\n", | 643 | pr_warn("Deleting inode #%u with active dentry \"%s\"->ino #%u\n", |
631 | dead_f->inocache->ino, fd->name, fd->ino); | 644 | dead_f->inocache->ino, |
645 | fd->name, fd->ino); | ||
632 | } else { | 646 | } else { |
633 | D1(printk(KERN_DEBUG "Removing deletion dirent for \"%s\" from dir ino #%u\n", | 647 | jffs2_dbg(1, "Removing deletion dirent for \"%s\" from dir ino #%u\n", |
634 | fd->name, dead_f->inocache->ino)); | 648 | fd->name, |
649 | dead_f->inocache->ino); | ||
635 | } | 650 | } |
636 | if (fd->raw) | 651 | if (fd->raw) |
637 | jffs2_mark_node_obsolete(c, fd->raw); | 652 | jffs2_mark_node_obsolete(c, fd->raw); |
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c index 3e93cdd19005..b55b803eddcb 100644 --- a/fs/jffs2/xattr.c +++ b/fs/jffs2/xattr.c | |||
@@ -9,6 +9,8 @@ | |||
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
13 | |||
12 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
14 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
diff --git a/fs/romfs/storage.c b/fs/romfs/storage.c index 71e2b4d50a0a..f86f51f99ace 100644 --- a/fs/romfs/storage.c +++ b/fs/romfs/storage.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #endif | 19 | #endif |
20 | 20 | ||
21 | #ifdef CONFIG_ROMFS_ON_MTD | 21 | #ifdef CONFIG_ROMFS_ON_MTD |
22 | #define ROMFS_MTD_READ(sb, ...) ((sb)->s_mtd->read((sb)->s_mtd, ##__VA_ARGS__)) | 22 | #define ROMFS_MTD_READ(sb, ...) mtd_read((sb)->s_mtd, ##__VA_ARGS__) |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * read data from an romfs image on an MTD device | 25 | * read data from an romfs image on an MTD device |