~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to fs/jffs2/nodemgmt.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno, Martin Michlmayr
  • Date: 2011-04-06 13:53:30 UTC
  • mfrom: (43.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110406135330-wjufxhd0tvn3zx4z
Tags: 2.6.38-3
[ Ben Hutchings ]
* [ppc64] Add to linux-tools package architectures (Closes: #620124)
* [amd64] Save cr4 to mmu_cr4_features at boot time (Closes: #620284)
* appletalk: Fix bugs introduced when removing use of BKL
* ALSA: Fix yet another race in disconnection
* cciss: Fix lost command issue
* ath9k: Fix kernel panic in AR2427
* ses: Avoid kernel panic when lun 0 is not mapped
* PCI/ACPI: Report ASPM support to BIOS if not disabled from command line

[ Aurelien Jarno ]
* rtlwifi: fix build when PCI is not enabled.

[ Martin Michlmayr ]
* rtlwifi: Eliminate udelay calls with too large values (Closes: #620204)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 */
11
11
 
12
12
#include <linux/kernel.h>
13
 
#include <linux/slab.h>
14
13
#include <linux/mtd/mtd.h>
15
14
#include <linux/compiler.h>
16
15
#include <linux/sched.h> /* For cond_resched() */
117
116
 
118
117
                        ret = jffs2_garbage_collect_pass(c);
119
118
 
120
 
                        if (ret == -EAGAIN)
121
 
                                jffs2_erase_pending_blocks(c, 1);
122
 
                        else if (ret)
 
119
                        if (ret == -EAGAIN) {
 
120
                                spin_lock(&c->erase_completion_lock);
 
121
                                if (c->nr_erasing_blocks &&
 
122
                                    list_empty(&c->erase_pending_list) &&
 
123
                                    list_empty(&c->erase_complete_list)) {
 
124
                                        DECLARE_WAITQUEUE(wait, current);
 
125
                                        set_current_state(TASK_UNINTERRUPTIBLE);
 
126
                                        add_wait_queue(&c->erase_wait, &wait);
 
127
                                        D1(printk(KERN_DEBUG "%s waiting for erase to complete\n", __func__));
 
128
                                        spin_unlock(&c->erase_completion_lock);
 
129
 
 
130
                                        schedule();
 
131
                                } else
 
132
                                        spin_unlock(&c->erase_completion_lock);
 
133
                        } else if (ret)
123
134
                                return ret;
124
135
 
125
136
                        cond_resched();
218
229
                        ejeb = list_entry(c->erasable_list.next, struct jffs2_eraseblock, list);
219
230
                        list_move_tail(&ejeb->list, &c->erase_pending_list);
220
231
                        c->nr_erasing_blocks++;
221
 
                        jffs2_erase_pending_trigger(c);
 
232
                        jffs2_garbage_collect_trigger(c);
222
233
                        D1(printk(KERN_DEBUG "jffs2_find_nextblock: Triggering erase of erasable block at 0x%08x\n",
223
234
                                  ejeb->offset));
224
235
                }
470
481
void jffs2_complete_reservation(struct jffs2_sb_info *c)
471
482
{
472
483
        D1(printk(KERN_DEBUG "jffs2_complete_reservation()\n"));
 
484
        spin_lock(&c->erase_completion_lock);
473
485
        jffs2_garbage_collect_trigger(c);
 
486
        spin_unlock(&c->erase_completion_lock);
474
487
        mutex_unlock(&c->alloc_sem);
475
488
}
476
489
 
612
625
                                D1(printk(KERN_DEBUG "...and adding to erase_pending_list\n"));
613
626
                                list_add_tail(&jeb->list, &c->erase_pending_list);
614
627
                                c->nr_erasing_blocks++;
615
 
                                jffs2_erase_pending_trigger(c);
 
628
                                jffs2_garbage_collect_trigger(c);
616
629
                        } else {
617
630
                                /* Sometimes, however, we leave it elsewhere so it doesn't get
618
631
                                   immediately reused, and we spread the load a bit. */
733
746
        int nr_very_dirty = 0;
734
747
        struct jffs2_eraseblock *jeb;
735
748
 
 
749
        if (!list_empty(&c->erase_complete_list) ||
 
750
            !list_empty(&c->erase_pending_list))
 
751
                return 1;
 
752
 
736
753
        if (c->unchecked_size) {
737
754
                D1(printk(KERN_DEBUG "jffs2_thread_should_wake(): unchecked_size %d, checked_ino #%d\n",
738
755
                          c->unchecked_size, c->checked_ino));