Skip to content

Commit 505a666

Browse files
committed
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>
1 parent 0ba13fd commit 505a666

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/fs-writeback.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,12 +1546,15 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
15461546
.range_cyclic = 1,
15471547
.reason = reason,
15481548
};
1549+
struct blk_plug plug;
15491550

1551+
blk_start_plug(&plug);
15501552
spin_lock(&wb->list_lock);
15511553
if (list_empty(&wb->b_io))
15521554
queue_io(wb, &work);
15531555
__writeback_inodes_wb(wb, &work);
15541556
spin_unlock(&wb->list_lock);
1557+
blk_finish_plug(&plug);
15551558

15561559
return nr_pages - work.nr_pages;
15571560
}
@@ -1579,10 +1582,12 @@ static long wb_writeback(struct bdi_writeback *wb,
15791582
unsigned long oldest_jif;
15801583
struct inode *inode;
15811584
long progress;
1585+
struct blk_plug plug;
15821586

15831587
oldest_jif = jiffies;
15841588
work->older_than_this = &oldest_jif;
15851589

1590+
blk_start_plug(&plug);
15861591
spin_lock(&wb->list_lock);
15871592
for (;;) {
15881593
/*
@@ -1662,6 +1667,7 @@ static long wb_writeback(struct bdi_writeback *wb,
16621667
}
16631668
}
16641669
spin_unlock(&wb->list_lock);
1670+
blk_finish_plug(&plug);
16651671

16661672
return nr_pages - work->nr_pages;
16671673
}

0 commit comments

Comments
 (0)