[PATCH 7/8] writeback: periodically trim the writeback list

From: Josef Bacik
Date: Fri Mar 20 2015 - 13:15:32 EST


From: Dave Chinner <dchinner@xxxxxxxxxx>

Inodes are removed lazily from the bdi writeback list, so in the
absence of sync(2) work inodes will build up on the bdi writback
list even though they are no longer under IO. Use the periodic
kupdate work check to remove inodes no longer under IO from the
writeback list.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
Signed-off-by: Josef Bacik <jbacik@xxxxxx>
Reviewed-by: Jan Kara <jack@xxxxxxx>
---
fs/fs-writeback.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 82b0f43..aa0de0f 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1037,6 +1037,23 @@ static long wb_check_background_flush(struct bdi_writeback *wb)
return 0;
}

+/*
+ * clean out writeback list for all inodes that don't have IO in progress
+ */
+static void wb_trim_writeback_list(struct bdi_writeback *wb)
+{
+ struct inode *inode;
+ struct inode *tmp;
+
+ spin_lock(&wb->list_lock);
+ list_for_each_entry_safe(inode, tmp, &wb->b_writeback, i_wb_list) {
+ if (!mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))
+ list_del_init(&inode->i_wb_list);
+ }
+ spin_unlock(&wb->list_lock);
+
+}
+
static long wb_check_old_data_flush(struct bdi_writeback *wb)
{
unsigned long expired;
@@ -1053,6 +1070,8 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
if (time_before(jiffies, expired))
return 0;

+ wb_trim_writeback_list(wb);
+
wb->last_old_flush = jiffies;
nr_pages = get_nr_dirty_pages();

--
1.8.3.1

--
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/