diff options
author | Christoph Hellwig <hch@lst.de> | 2010-06-19 17:08:22 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:23:06 -0400 |
commit | 082439004b31adc146e96e5f1c574dd2b57dcd93 (patch) | |
tree | 19ef2ccab9588c2aa77d0b09c2bae760b23ae110 /fs | |
parent | c1955ce32fdb0877b7a1b22feb2669358f65be76 (diff) |
writeback: merge bdi_writeback_task and bdi_start_fn
Move all code for the writeback thread into fs/fs-writeback.c instead of
splitting it over two functions in two files.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fs-writeback.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index d67989b8ba44..c8471b3ddccf 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
@@ -775,12 +775,36 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) | |||
775 | * Handle writeback of dirty data for the device backed by this bdi. Also | 775 | * Handle writeback of dirty data for the device backed by this bdi. Also |
776 | * wakes up periodically and does kupdated style flushing. | 776 | * wakes up periodically and does kupdated style flushing. |
777 | */ | 777 | */ |
778 | int bdi_writeback_task(struct bdi_writeback *wb) | 778 | int bdi_writeback_thread(void *data) |
779 | { | 779 | { |
780 | struct bdi_writeback *wb = data; | ||
781 | struct backing_dev_info *bdi = wb->bdi; | ||
780 | unsigned long last_active = jiffies; | 782 | unsigned long last_active = jiffies; |
781 | unsigned long wait_jiffies = -1UL; | 783 | unsigned long wait_jiffies = -1UL; |
782 | long pages_written; | 784 | long pages_written; |
783 | 785 | ||
786 | /* | ||
787 | * Add us to the active bdi_list | ||
788 | */ | ||
789 | spin_lock_bh(&bdi_lock); | ||
790 | list_add_rcu(&bdi->bdi_list, &bdi_list); | ||
791 | spin_unlock_bh(&bdi_lock); | ||
792 | |||
793 | current->flags |= PF_FLUSHER | PF_SWAPWRITE; | ||
794 | set_freezable(); | ||
795 | |||
796 | /* | ||
797 | * Our parent may run at a different priority, just set us to normal | ||
798 | */ | ||
799 | set_user_nice(current, 0); | ||
800 | |||
801 | /* | ||
802 | * Clear pending bit and wakeup anybody waiting to tear us down | ||
803 | */ | ||
804 | clear_bit(BDI_pending, &bdi->state); | ||
805 | smp_mb__after_clear_bit(); | ||
806 | wake_up_bit(&bdi->state, BDI_pending); | ||
807 | |||
784 | while (!kthread_should_stop()) { | 808 | while (!kthread_should_stop()) { |
785 | pages_written = wb_do_writeback(wb, 0); | 809 | pages_written = wb_do_writeback(wb, 0); |
786 | 810 | ||
@@ -813,9 +837,18 @@ int bdi_writeback_task(struct bdi_writeback *wb) | |||
813 | try_to_freeze(); | 837 | try_to_freeze(); |
814 | } | 838 | } |
815 | 839 | ||
840 | wb->task = NULL; | ||
841 | |||
842 | /* | ||
843 | * Flush any work that raced with us exiting. No new work | ||
844 | * will be added, since this bdi isn't discoverable anymore. | ||
845 | */ | ||
846 | if (!list_empty(&bdi->work_list)) | ||
847 | wb_do_writeback(wb, 1); | ||
816 | return 0; | 848 | return 0; |
817 | } | 849 | } |
818 | 850 | ||
851 | |||
819 | /* | 852 | /* |
820 | * Start writeback of `nr_pages' pages. If `nr_pages' is zero, write back | 853 | * Start writeback of `nr_pages' pages. If `nr_pages' is zero, write back |
821 | * the whole world. | 854 | * the whole world. |