Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 208340
b: refs/heads/master
c: adf3924
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy authored and Jens Axboe committed Aug 7, 2010
1 parent 54d9248 commit ea28571
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecd584030da67ede1bf17955746a6ce834d9fc6b
refs/heads/master: adf392407076b85816d48714fb8eeaedb2157884
69 changes: 39 additions & 30 deletions trunk/mm/backing-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,12 @@ static int bdi_forker_thread(void *ptr)
set_user_nice(current, 0);

for (;;) {
bool fork = false;
struct task_struct *task;
struct backing_dev_info *bdi;
enum {
NO_ACTION, /* Nothing to do */
FORK_THREAD, /* Fork bdi thread */
} action = NO_ACTION;

/*
* Temporary measure, we want to make sure we don't see
Expand All @@ -348,56 +351,62 @@ static int bdi_forker_thread(void *ptr)
* a thread registered. If so, set that up.
*/
list_for_each_entry(bdi, &bdi_list, bdi_list) {
if (!bdi_cap_writeback_dirty(bdi))
continue;
if (bdi->wb.task)
continue;
if (list_empty(&bdi->work_list) &&
!bdi_has_dirty_io(bdi))
bool have_dirty_io;

if (!bdi_cap_writeback_dirty(bdi) ||
bdi_cap_flush_forker(bdi))
continue;

WARN(!test_bit(BDI_registered, &bdi->state),
"bdi %p/%s is not registered!\n", bdi, bdi->name);

fork = true;
have_dirty_io = !list_empty(&bdi->work_list) ||
wb_has_dirty_io(&bdi->wb);

/*
* Set the pending bit - if someone will try to
* unregister this bdi - it'll wait on this bit.
* If the bdi has work to do, but the thread does not
* exist - create it.
*/
set_bit(BDI_pending, &bdi->state);
break;
if (!bdi->wb.task && have_dirty_io) {
/*
* Set the pending bit - if someone will try to
* unregister this bdi - it'll wait on this bit.
*/
set_bit(BDI_pending, &bdi->state);
action = FORK_THREAD;
break;
}
}
spin_unlock_bh(&bdi_lock);

/* Keep working if default bdi still has things to do */
if (!list_empty(&me->bdi->work_list))
__set_current_state(TASK_RUNNING);

if (!fork) {
unsigned long wait;
switch (action) {
case FORK_THREAD:
__set_current_state(TASK_RUNNING);
task = kthread_run(bdi_writeback_thread, &bdi->wb, "flush-%s",
dev_name(bdi->dev));
if (IS_ERR(task)) {
/*
* If thread creation fails, force writeout of
* the bdi from the thread.
*/
bdi_flush_io(bdi);
} else
bdi->wb.task = task;
break;

wait = msecs_to_jiffies(dirty_writeback_interval * 10);
if (wait)
schedule_timeout(wait);
case NO_ACTION:
if (dirty_writeback_interval)
schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
else
schedule();
try_to_freeze();
/* Back to the main loop */
continue;
}

__set_current_state(TASK_RUNNING);

task = kthread_run(bdi_writeback_thread, &bdi->wb, "flush-%s",
dev_name(bdi->dev));
if (IS_ERR(task)) {
/*
* If thread creation fails, force writeout of the bdi
* from the thread.
*/
bdi_flush_io(bdi);
} else
bdi->wb.task = task;
}

return 0;
Expand Down

0 comments on commit ea28571

Please sign in to comment.