12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/kernel.h>
16 #include <linux/compiler.h>
17 #include <linux/sched.h>
34 jffs2_dbg(1,
"rpsize %u, dirty_size %u, free_size %u, "
35 "erasing_size %u, unchecked_size %u, "
36 "nr_erasing_blocks %u, avail %u, resrv %u\n",
80 minsize =
PAD(minsize);
82 jffs2_dbg(1,
"%s(): Requested 0x%x bytes\n", __func__, minsize);
85 jffs2_dbg(1,
"%s(): alloc sem got\n", __func__);
116 if (dirty < c->nospc_dirty_size) {
118 jffs2_dbg(1,
"%s(): Low on dirty space to GC, but it's a deletion. Allowing...\n",
122 jffs2_dbg(1,
"dirty size 0x%08x + unchecked_size 0x%08x < nospc_dirty_size 0x%08x, returning -ENOSPC\n",
143 jffs2_dbg(1,
"%s(): Low on possibly available space, but it's a deletion. Allowing...\n",
148 jffs2_dbg(1,
"max. available size 0x%08x < blocksneeded * sector_size 0x%08x, returning -ENOSPC\n",
157 jffs2_dbg(1,
"Triggering GC pass. nr_free_blocks %d, nr_erasing_blocks %d, free_size 0x%08x, dirty_size 0x%08x, wasted_size 0x%08x, used_size 0x%08x, erasing_size 0x%08x, bad_size 0x%08x (total 0x%08x of 0x%08x)\n",
177 jffs2_dbg(1,
"%s waiting for erase to complete\n",
196 ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
198 jffs2_dbg(1,
"%s(): ret is %d\n", __func__, ret);
215 minsize =
PAD(minsize);
217 jffs2_dbg(1,
"%s(): Requested 0x%x bytes\n", __func__, minsize);
221 ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
223 jffs2_dbg(1,
"%s(): looping, ret is %d\n",
241 jffs2_dbg(1,
"%s(): Erase block at 0x%08x has already been placed in a list\n",
252 jffs2_dbg(1,
"Adding full erase block at 0x%08x to very_dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
257 jffs2_dbg(1,
"Adding full erase block at 0x%08x to dirty_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
263 jffs2_dbg(1,
"Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
290 jffs2_dbg(1,
"%s(): Triggering erase of erasable block at 0x%08x\n",
296 jffs2_dbg(1,
"%s(): Flushing write buffer\n",
309 pr_crit(
"Argh. No free space left for GC. nr_erasing_blocks is %d. nr_free_blocks is %d. (erasableempty: %s, erasingempty: %s, erasependingempty: %s)\n",
335 #ifdef CONFIG_JFFS2_FS_WRITEBUFFER
337 if (!(c->wbuf_ofs % c->
sector_size) && !c->wbuf_len)
338 c->wbuf_ofs = 0xffffffff;
341 jffs2_dbg(1,
"%s(): new nextblock = 0x%08x\n",
364 "summary->size=%d , sumsize=%d\n",
366 c->
summary->sum_size, sumsize);
371 if (jeb && (
PAD(minsize) +
PAD(c->
summary->sum_size + sumsize +
395 jffs2_close_nextblock(c, jeb);
409 jffs2_dbg(1,
"%s(): Flushing write buffer\n",
438 jffs2_close_nextblock(c, jeb);
445 ret = jffs2_find_nextblock(c);
452 pr_warn(
"Eep. Block 0x%08x taken from free_list had free_size of 0x%08x!!\n",
474 jffs2_dbg(1,
"%s(): Giving 0x%x bytes at 0x%x\n",
501 jffs2_dbg(1,
"%s(): Node at 0x%x(%d), size 0x%x\n",
502 __func__, ofs & ~3, ofs & 3, len);
509 pr_warn(
"argh. node added in wrong place at 0x%08x(%d)\n",
515 pr_cont(
", expected at %08x\n",
526 jffs2_dbg(1,
"Adding full erase block at 0x%08x to clean_list (free 0x%08x, dirty 0x%08x, used 0x%08x\n",
550 jffs2_dbg(1,
"jffs2_complete_reservation()\n");
563 jffs2_dbg(1,
"%p is on list at %p\n", obj, head);
581 pr_notice(
"EEEEEK. jffs2_mark_node_obsolete called with NULL node\n");
585 jffs2_dbg(1,
"%s(): called with already obsolete node at 0x%08x\n",
591 pr_notice(
"raw node at 0x%08x is off the end of device!\n",
614 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",
619 jffs2_dbg(1,
"Obsoleting previously unchecked node at 0x%08x of len %x\n",
625 pr_notice(
"raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n",
630 jffs2_dbg(1,
"Obsoleting node at 0x%08x of len %#x: ",
639 addedsize = freed_len;
646 jffs2_dbg(1,
"Leaving block at %08x on the bad_used_list\n",
650 jffs2_dbg(1,
"Converting %d bytes of wasted space to dirty in block at %08x\n",
682 jffs2_dbg(2,
"Not moving nextblock 0x%08x to dirty/erase_pending list\n",
686 jffs2_dbg(1,
"gcblock at 0x%08x completely dirtied. Clearing gcblock...\n",
690 jffs2_dbg(1,
"Eraseblock at 0x%08x completely dirtied. Removing from (dirty?) list...\n",
695 jffs2_dbg(1,
"...and adding to erasable_pending_wbuf_list\n");
701 jffs2_dbg(1,
"...and adding to erase_pending_list\n");
708 jffs2_dbg(1,
"...and adding to erasable_list\n");
713 }
else if (jeb == c->
gcblock) {
714 jffs2_dbg(2,
"Not moving gcblock 0x%08x to dirty_list\n",
717 jffs2_dbg(1,
"Eraseblock at 0x%08x is freshly dirtied. Removing from clean list...\n",
720 jffs2_dbg(1,
"...and adding to dirty_list\n");
724 jffs2_dbg(1,
"Eraseblock at 0x%08x is now very dirty. Removing from dirty list...\n",
727 jffs2_dbg(1,
"...and adding to very_dirty_list\n");
730 jffs2_dbg(1,
"Eraseblock at 0x%08x not moved anywhere. (free 0x%08x, dirty 0x%08x, used 0x%08x)\n",
748 jffs2_dbg(1,
"obliterating obsoleted node at 0x%08x\n",
752 pr_warn(
"Read error reading from obsoleted node at 0x%08x: %d\n",
756 if (retlen !=
sizeof(
n)) {
757 pr_warn(
"Short read from obsoleted node at 0x%08x: %zd\n",
762 pr_warn(
"Node totlen on flash (0x%08x) != totlen from node ref (0x%08x)\n",
767 jffs2_dbg(1,
"Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n",
775 pr_warn(
"Write error in obliterating obsoleted node at 0x%08x: %d\n",
779 if (retlen !=
sizeof(
n)) {
780 pr_warn(
"Short write in obliterating obsoleted node at 0x%08x: %zd\n",
795 if (ref->next_in_ino) {
801 ic = jffs2_raw_ref_to_ic(ref);
802 for (p = &ic->
nodes; (*p) != ref; p = &((*p)->next_in_ino))
806 ref->next_in_ino =
NULL;
809 #ifdef CONFIG_JFFS2_FS_XATTR
833 int nr_very_dirty = 0;
841 jffs2_dbg(1,
"jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n",
870 jffs2_dbg(1,
"%s(): nr_free_blocks %d, nr_erasing_blocks %d, dirty_size 0x%x, vdirty_blocks %d: %s\n",
872 c->
dirty_size, nr_very_dirty, ret ?
"yes" :
"no");