writeback: plug writeback in wb_writeback() and writeback_inodes_wb()

We had to revert the pluggin in writeback_sb_inodes() because the
wb->list_lock is held, but we could easily plug at a higher level before
taking that lock, and unplug after releasing it. This does that.

Chris will run performance numbers, just to verify that this approach is
comparable to the alternative (we could just drop and re-take the lock
around the blk_finish_plug() rather than these two commits.

I'd have preferred waiting for actual performance numbers before picking
one approach over the other, but I don't want to release rc1 with the
known "sleeping function called from invalid context" issue, so I'll
pick this cleanup version for now. But if the numbers show that we
really want to plug just at the writeback_sb_inodes() level, and we
should just play ugly games with the spinlock, we'll switch to that.

Cc: Chris Mason <clm@fb.com>
Cc: Josef Bacik <jbacik@fb.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Neil Brown <neilb@suse.de>
Cc: Jan Kara <jack@suse.cz>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Changed files
+6
fs
+6
fs/fs-writeback.c
··· 1546 .range_cyclic = 1, 1547 .reason = reason, 1548 }; 1549 1550 spin_lock(&wb->list_lock); 1551 if (list_empty(&wb->b_io)) 1552 queue_io(wb, &work); 1553 __writeback_inodes_wb(wb, &work); 1554 spin_unlock(&wb->list_lock); 1555 1556 return nr_pages - work.nr_pages; 1557 } ··· 1582 unsigned long oldest_jif; 1583 struct inode *inode; 1584 long progress; 1585 1586 oldest_jif = jiffies; 1587 work->older_than_this = &oldest_jif; 1588 1589 spin_lock(&wb->list_lock); 1590 for (;;) { 1591 /* ··· 1667 } 1668 } 1669 spin_unlock(&wb->list_lock); 1670 1671 return nr_pages - work->nr_pages; 1672 }
··· 1546 .range_cyclic = 1, 1547 .reason = reason, 1548 }; 1549 + struct blk_plug plug; 1550 1551 + blk_start_plug(&plug); 1552 spin_lock(&wb->list_lock); 1553 if (list_empty(&wb->b_io)) 1554 queue_io(wb, &work); 1555 __writeback_inodes_wb(wb, &work); 1556 spin_unlock(&wb->list_lock); 1557 + blk_finish_plug(&plug); 1558 1559 return nr_pages - work.nr_pages; 1560 } ··· 1579 unsigned long oldest_jif; 1580 struct inode *inode; 1581 long progress; 1582 + struct blk_plug plug; 1583 1584 oldest_jif = jiffies; 1585 work->older_than_this = &oldest_jif; 1586 1587 + blk_start_plug(&plug); 1588 spin_lock(&wb->list_lock); 1589 for (;;) { 1590 /* ··· 1662 } 1663 } 1664 spin_unlock(&wb->list_lock); 1665 + blk_finish_plug(&plug); 1666 1667 return nr_pages - work->nr_pages; 1668 }