Commit c5444198ca210498e8ac0ba121b4cd3537aa12f7

Authored by Christoph Hellwig
Committed by Jens Axboe
1 parent b8c2f3474f

writeback: simplify and split bdi_start_writeback

bdi_start_writeback now never gets a superblock passed, so we can just remove
that case.  And to further untangle the code and flatten the call stack
split it into two trivial helpers for it's two callers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>

Showing 3 changed files with 24 additions and 17 deletions Side-by-side Diff

... ... @@ -200,7 +200,6 @@
200 200 /**
201 201 * bdi_start_writeback - start writeback
202 202 * @bdi: the backing device to write from
203   - * @sb: write inodes from this super_block
204 203 * @nr_pages: the number of pages to write
205 204 *
206 205 * Description:
207 206  
208 207  
209 208  
... ... @@ -209,25 +208,34 @@
209 208 * completion. Caller need not hold sb s_umount semaphore.
210 209 *
211 210 */
212   -void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
213   - long nr_pages)
  211 +void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages)
214 212 {
215 213 struct wb_writeback_args args = {
216   - .sb = sb,
217 214 .sync_mode = WB_SYNC_NONE,
218 215 .nr_pages = nr_pages,
219 216 .range_cyclic = 1,
220 217 };
221 218  
222   - /*
223   - * We treat @nr_pages=0 as the special case to do background writeback,
224   - * ie. to sync pages until the background dirty threshold is reached.
225   - */
226   - if (!nr_pages) {
227   - args.nr_pages = LONG_MAX;
228   - args.for_background = 1;
229   - }
  219 + bdi_alloc_queue_work(bdi, &args);
  220 +}
230 221  
  222 +/**
  223 + * bdi_start_background_writeback - start background writeback
  224 + * @bdi: the backing device to write from
  225 + *
  226 + * Description:
  227 + * This does WB_SYNC_NONE background writeback. The IO is only
  228 + * started when this function returns, we make no guarentees on
  229 + * completion. Caller need not hold sb s_umount semaphore.
  230 + */
  231 +void bdi_start_background_writeback(struct backing_dev_info *bdi)
  232 +{
  233 + struct wb_writeback_args args = {
  234 + .sync_mode = WB_SYNC_NONE,
  235 + .nr_pages = LONG_MAX,
  236 + .for_background = 1,
  237 + .range_cyclic = 1,
  238 + };
231 239 bdi_alloc_queue_work(bdi, &args);
232 240 }
233 241  
include/linux/backing-dev.h
... ... @@ -105,8 +105,8 @@
105 105 int bdi_register_dev(struct backing_dev_info *bdi, dev_t dev);
106 106 void bdi_unregister(struct backing_dev_info *bdi);
107 107 int bdi_setup_and_register(struct backing_dev_info *, char *, unsigned int);
108   -void bdi_start_writeback(struct backing_dev_info *bdi, struct super_block *sb,
109   - long nr_pages);
  108 +void bdi_start_writeback(struct backing_dev_info *bdi, long nr_pages);
  109 +void bdi_start_background_writeback(struct backing_dev_info *bdi);
110 110 int bdi_writeback_task(struct bdi_writeback *wb);
111 111 int bdi_has_dirty_io(struct backing_dev_info *bdi);
112 112 void bdi_arm_supers_timer(void);
... ... @@ -597,7 +597,7 @@
597 597 (!laptop_mode && ((global_page_state(NR_FILE_DIRTY)
598 598 + global_page_state(NR_UNSTABLE_NFS))
599 599 > background_thresh)))
600   - bdi_start_writeback(bdi, NULL, 0);
  600 + bdi_start_background_writeback(bdi);
601 601 }
602 602  
603 603 void set_page_dirty_balance(struct page *page, int page_mkwrite)
604 604  
... ... @@ -705,9 +705,8 @@
705 705 * We want to write everything out, not just down to the dirty
706 706 * threshold
707 707 */
708   -
709 708 if (bdi_has_dirty_io(&q->backing_dev_info))
710   - bdi_start_writeback(&q->backing_dev_info, NULL, nr_pages);
  709 + bdi_start_writeback(&q->backing_dev_info, nr_pages);
711 710 }
712 711  
713 712 /*