Skip to content

Commit 5a042aa

Browse files
jankaraJens Axboe
authored andcommitted
mm: Cleanup clearing of BDI_pending bit in bdi_forker_thread()
bdi_forker_thread() clears BDI_pending bit at the end of the main loop. However clearing of this bit must not be done in some cases which is handled by calling 'continue' from switch statement. That's kind of unusual construct and without a good reason so change the function into more intuitive code flow. CC: Wu Fengguang <[email protected]> CC: Andrew Morton <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 56ebdaf commit 5a042aa

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

mm/backing-dev.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,17 @@ static unsigned long bdi_longest_inactive(void)
359359
return max(5UL * 60 * HZ, interval);
360360
}
361361

362+
/*
363+
* Clear pending bit and wakeup anybody waiting for flusher thread creation or
364+
* shutdown
365+
*/
366+
static void bdi_clear_pending(struct backing_dev_info *bdi)
367+
{
368+
clear_bit(BDI_pending, &bdi->state);
369+
smp_mb__after_clear_bit();
370+
wake_up_bit(&bdi->state, BDI_pending);
371+
}
372+
362373
static int bdi_forker_thread(void *ptr)
363374
{
364375
struct bdi_writeback *me = ptr;
@@ -469,11 +480,13 @@ static int bdi_forker_thread(void *ptr)
469480
spin_unlock_bh(&bdi->wb_lock);
470481
wake_up_process(task);
471482
}
483+
bdi_clear_pending(bdi);
472484
break;
473485

474486
case KILL_THREAD:
475487
__set_current_state(TASK_RUNNING);
476488
kthread_stop(task);
489+
bdi_clear_pending(bdi);
477490
break;
478491

479492
case NO_ACTION:
@@ -489,16 +502,8 @@ static int bdi_forker_thread(void *ptr)
489502
else
490503
schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
491504
try_to_freeze();
492-
/* Back to the main loop */
493-
continue;
505+
break;
494506
}
495-
496-
/*
497-
* Clear pending bit and wakeup anybody waiting to tear us down.
498-
*/
499-
clear_bit(BDI_pending, &bdi->state);
500-
smp_mb__after_clear_bit();
501-
wake_up_bit(&bdi->state, BDI_pending);
502507
}
503508

504509
return 0;

0 commit comments

Comments
 (0)