From mboxrd@z Thu Jan 1 00:00:00 1970 From: Josef Bacik Subject: [PATCH 7/8] writeback: periodically trim the writeback list Date: Tue, 23 Jun 2015 20:24:01 -0700 Message-ID: <1435116242-27495-8-git-send-email-jbacik@fb.com> References: <1435116242-27495-1-git-send-email-jbacik@fb.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Dave Chinner To: , , , , , Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39977 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932233AbbFXDYj (ORCPT ); Tue, 23 Jun 2015 23:24:39 -0400 In-Reply-To: <1435116242-27495-1-git-send-email-jbacik@fb.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Dave Chinner 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 Signed-off-by: Josef Bacik Reviewed-by: Jan Kara Tested-by: Dave Chinner --- fs/fs-writeback.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 5c005ad..a2cd363 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1060,6 +1060,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; @@ -1076,6 +1093,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(); -- 2.1.0