[PATCH 29/45] writeback: move i_wb_list emptiness test into inode_wb_list_del() from its caller

From: Tejun Heo
Date: Tue Jan 06 2015 - 16:27:35 EST


inode_wb_list_del() has one caller, evict(), which tests whether
inode->i_wb_list is empty before invoking the function. With cgroup
writeback support, an inode may belong to multiple bdi_writeback's
rendering this test incorrect or at least insufficient. This patch
moves the test into inode_wb_list_del() so that later patches can
update the logic in the function proper.

This does add a function call and jump when a clean inode is being
evicted but this shouldn't be anything noticeable and if it ever is
making that part an inline logic in fs/internal.h is easy.

This patch is pure code reorganization.

Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Cc: Jan Kara <jack@xxxxxxx>
---
fs/fs-writeback.c | 3 +++
fs/inode.c | 4 +---
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 4094d30..0fcdfe9 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -510,6 +510,9 @@ void inode_wb_list_del(struct inode *inode)
struct backing_dev_info *bdi = inode_to_bdi(inode);
struct bdi_writeback *wb = &bdi->wb;

+ if (list_empty(&inode->i_wb_list))
+ return;
+
spin_lock(&wb->list_lock);
inode_wb_list_del_locked(inode, wb);
spin_unlock(&wb->list_lock);
diff --git a/fs/inode.c b/fs/inode.c
index aa149e7..7fbfc00 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -536,9 +536,7 @@ static void evict(struct inode *inode)
BUG_ON(!(inode->i_state & I_FREEING));
BUG_ON(!list_empty(&inode->i_lru));

- if (!list_empty(&inode->i_wb_list))
- inode_wb_list_del(inode);
-
+ inode_wb_list_del(inode);
inode_sb_list_del(inode);

/*
--
2.1.0

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