[PATCH] writeback: requeue_io_wait() when I_SYNC is set

From: Jan Kara
Date: Thu Oct 20 2011 - 19:15:43 EST


If writeback skips inode because it is already under writeback (I_SYNC flag is
set), we can now use requeue_io_wait() instead of requeue_io() and remove
special busyloop prevention in wb_writeback().

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
fs/fs-writeback.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 89b9b70..4e5cae0 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -14,6 +14,7 @@
*/

#include <linux/kernel.h>
+#include <linux/ratelimit.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
@@ -391,7 +392,7 @@ writeback_single_inode(struct inode *inode, struct bdi_writeback *wb,
* completed a full scan of b_io.
*/
if (wbc->sync_mode != WB_SYNC_ALL) {
- requeue_io(inode, wb);
+ requeue_io_wait(inode, wb);
trace_writeback_single_inode_requeue(inode, wbc,
nr_to_write);
return 0;
@@ -725,7 +726,6 @@ static long wb_writeback(struct bdi_writeback *wb,
unsigned long wb_start = jiffies;
long nr_pages = work->nr_pages;
unsigned long oldest_jif;
- struct inode *inode;
long progress;
long total_progress = 0;

@@ -791,17 +791,14 @@ static long wb_writeback(struct bdi_writeback *wb,
if (list_empty(&wb->b_more_io))
break;
/*
- * Nothing written. Wait for some inode to
- * become available for writeback. Otherwise
- * we'll just busyloop.
+ * Nothing written but some inodes were moved to b_more_io.
+ * This should not happen as we can easily busyloop.
*/
- if (!list_empty(&wb->b_more_io)) {
- trace_writeback_wait(wb->bdi, work);
- inode = wb_inode(wb->b_more_io.prev);
- spin_lock(&inode->i_lock);
- inode_wait_for_writeback(inode, wb);
- spin_unlock(&inode->i_lock);
- }
+ pr_warn_ratelimited("mm: Possible busyloop in data writeback "
+ "(bdi %s nr_pages %ld sync_mode %d kupdate %d "
+ "background %d)\n",
+ wb->bdi->name, work->nr_pages, work->sync_mode,
+ work->for_kupdate, work->for_background);
}
spin_unlock(&wb->list_lock);

--
1.7.1


--XsQoSWH+UP9D9v3l--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/