diff options
Diffstat (limited to 'fs/fs-writeback.c')
| -rw-r--r-- | fs/fs-writeback.c | 81 |
1 files changed, 32 insertions, 49 deletions
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 2f76c4a081a2..7d9d06ba184b 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c | |||
| @@ -68,7 +68,7 @@ int nr_pdflush_threads; | |||
| 68 | */ | 68 | */ |
| 69 | int writeback_in_progress(struct backing_dev_info *bdi) | 69 | int writeback_in_progress(struct backing_dev_info *bdi) |
| 70 | { | 70 | { |
| 71 | return !list_empty(&bdi->work_list); | 71 | return test_bit(BDI_writeback_running, &bdi->state); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static void bdi_queue_work(struct backing_dev_info *bdi, | 74 | static void bdi_queue_work(struct backing_dev_info *bdi, |
| @@ -249,10 +249,18 @@ static void move_expired_inodes(struct list_head *delaying_queue, | |||
| 249 | 249 | ||
| 250 | /* | 250 | /* |
| 251 | * Queue all expired dirty inodes for io, eldest first. | 251 | * Queue all expired dirty inodes for io, eldest first. |
| 252 | * Before | ||
| 253 | * newly dirtied b_dirty b_io b_more_io | ||
| 254 | * =============> gf edc BA | ||
| 255 | * After | ||
| 256 | * newly dirtied b_dirty b_io b_more_io | ||
| 257 | * =============> g fBAedc | ||
| 258 | * | | ||
| 259 | * +--> dequeue for IO | ||
| 252 | */ | 260 | */ |
| 253 | static void queue_io(struct bdi_writeback *wb, unsigned long *older_than_this) | 261 | static void queue_io(struct bdi_writeback *wb, unsigned long *older_than_this) |
| 254 | { | 262 | { |
| 255 | list_splice_init(&wb->b_more_io, wb->b_io.prev); | 263 | list_splice_init(&wb->b_more_io, &wb->b_io); |
| 256 | move_expired_inodes(&wb->b_dirty, &wb->b_io, older_than_this); | 264 | move_expired_inodes(&wb->b_dirty, &wb->b_io, older_than_this); |
| 257 | } | 265 | } |
| 258 | 266 | ||
| @@ -363,62 +371,35 @@ writeback_single_inode(struct inode *inode, struct writeback_control *wbc) | |||
| 363 | spin_lock(&inode_lock); | 371 | spin_lock(&inode_lock); |
| 364 | inode->i_state &= ~I_SYNC; | 372 | inode->i_state &= ~I_SYNC; |
| 365 | if (!(inode->i_state & I_FREEING)) { | 373 | if (!(inode->i_state & I_FREEING)) { |
| 366 | if ((inode->i_state & I_DIRTY_PAGES) && wbc->for_kupdate) { | 374 | if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { |
| 367 | /* | ||
| 368 | * More pages get dirtied by a fast dirtier. | ||
| 369 | */ | ||
| 370 | goto select_queue; | ||
| 371 | } else if (inode->i_state & I_DIRTY) { | ||
| 372 | /* | ||
| 373 | * At least XFS will redirty the inode during the | ||
| 374 | * writeback (delalloc) and on io completion (isize). | ||
| 375 | */ | ||
| 376 | redirty_tail(inode); | ||
| 377 | } else if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { | ||
| 378 | /* | 375 | /* |
| 379 | * We didn't write back all the pages. nfs_writepages() | 376 | * We didn't write back all the pages. nfs_writepages() |
| 380 | * sometimes bales out without doing anything. Redirty | 377 | * sometimes bales out without doing anything. |
| 381 | * the inode; Move it from b_io onto b_more_io/b_dirty. | ||
| 382 | */ | 378 | */ |
| 383 | /* | 379 | inode->i_state |= I_DIRTY_PAGES; |
| 384 | * akpm: if the caller was the kupdate function we put | 380 | if (wbc->nr_to_write <= 0) { |
| 385 | * this inode at the head of b_dirty so it gets first | ||
| 386 | * consideration. Otherwise, move it to the tail, for | ||
| 387 | * the reasons described there. I'm not really sure | ||
| 388 | * how much sense this makes. Presumably I had a good | ||
| 389 | * reasons for doing it this way, and I'd rather not | ||
| 390 | * muck with it at present. | ||
| 391 | */ | ||
| 392 | if (wbc->for_kupdate) { | ||
| 393 | /* | 381 | /* |
| 394 | * For the kupdate function we move the inode | 382 | * slice used up: queue for next turn |
| 395 | * to b_more_io so it will get more writeout as | ||
| 396 | * soon as the queue becomes uncongested. | ||
| 397 | */ | 383 | */ |
| 398 | inode->i_state |= I_DIRTY_PAGES; | 384 | requeue_io(inode); |
| 399 | select_queue: | ||
| 400 | if (wbc->nr_to_write <= 0) { | ||
| 401 | /* | ||
| 402 | * slice used up: queue for next turn | ||
| 403 | */ | ||
| 404 | requeue_io(inode); | ||
| 405 | } else { | ||
| 406 | /* | ||
| 407 | * somehow blocked: retry later | ||
| 408 | */ | ||
| 409 | redirty_tail(inode); | ||
| 410 | } | ||
| 411 | } else { | 385 | } else { |
| 412 | /* | 386 | /* |
| 413 | * Otherwise fully redirty the inode so that | 387 | * Writeback blocked by something other than |
| 414 | * other inodes on this superblock will get some | 388 | * congestion. Delay the inode for some time to |
| 415 | * writeout. Otherwise heavy writing to one | 389 | * avoid spinning on the CPU (100% iowait) |
| 416 | * file would indefinitely suspend writeout of | 390 | * retrying writeback of the dirty page/inode |
| 417 | * all the other files. | 391 | * that cannot be performed immediately. |
| 418 | */ | 392 | */ |
| 419 | inode->i_state |= I_DIRTY_PAGES; | ||
| 420 | redirty_tail(inode); | 393 | redirty_tail(inode); |
| 421 | } | 394 | } |
| 395 | } else if (inode->i_state & I_DIRTY) { | ||
| 396 | /* | ||
| 397 | * Filesystems can dirty the inode during writeback | ||
| 398 | * operations, such as delayed allocation during | ||
| 399 | * submission or metadata updates after data IO | ||
| 400 | * completion. | ||
| 401 | */ | ||
| 402 | redirty_tail(inode); | ||
| 422 | } else if (atomic_read(&inode->i_count)) { | 403 | } else if (atomic_read(&inode->i_count)) { |
| 423 | /* | 404 | /* |
| 424 | * The inode is clean, inuse | 405 | * The inode is clean, inuse |
| @@ -590,7 +571,7 @@ static inline bool over_bground_thresh(void) | |||
| 590 | { | 571 | { |
| 591 | unsigned long background_thresh, dirty_thresh; | 572 | unsigned long background_thresh, dirty_thresh; |
| 592 | 573 | ||
| 593 | get_dirty_limits(&background_thresh, &dirty_thresh, NULL, NULL); | 574 | global_dirty_limits(&background_thresh, &dirty_thresh); |
| 594 | 575 | ||
| 595 | return (global_page_state(NR_FILE_DIRTY) + | 576 | return (global_page_state(NR_FILE_DIRTY) + |
| 596 | global_page_state(NR_UNSTABLE_NFS) >= background_thresh); | 577 | global_page_state(NR_UNSTABLE_NFS) >= background_thresh); |
| @@ -759,6 +740,7 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) | |||
| 759 | struct wb_writeback_work *work; | 740 | struct wb_writeback_work *work; |
| 760 | long wrote = 0; | 741 | long wrote = 0; |
| 761 | 742 | ||
| 743 | set_bit(BDI_writeback_running, &wb->bdi->state); | ||
| 762 | while ((work = get_next_work_item(bdi)) != NULL) { | 744 | while ((work = get_next_work_item(bdi)) != NULL) { |
| 763 | /* | 745 | /* |
| 764 | * Override sync mode, in case we must wait for completion | 746 | * Override sync mode, in case we must wait for completion |
| @@ -785,6 +767,7 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) | |||
| 785 | * Check for periodic writeback, kupdated() style | 767 | * Check for periodic writeback, kupdated() style |
| 786 | */ | 768 | */ |
| 787 | wrote += wb_check_old_data_flush(wb); | 769 | wrote += wb_check_old_data_flush(wb); |
| 770 | clear_bit(BDI_writeback_running, &wb->bdi->state); | ||
| 788 | 771 | ||
| 789 | return wrote; | 772 | return wrote; |
| 790 | } | 773 | } |
