bcache: only clear BTREE_NODE_dirty bit when it is set
authorColy Li <colyli@suse.de>
Fri, 28 Jun 2019 11:59:55 +0000 (19:59 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Sep 2019 06:22:23 +0000 (08:22 +0200)
commit7989a5026fd12c7208448b66c51402a65a8a7f16
tree4ce0d4dddbbb85e5f72a238d9d338017dc3d42a8
parent652993a5aae5ffa1d59188058c07e8f0e5d2461f
bcache: only clear BTREE_NODE_dirty bit when it is set

[ Upstream commit e5ec5f4765ada9c75fb3eee93a6e72f0e50599d5 ]

In bch_btree_cache_free() and btree_node_free(), BTREE_NODE_dirty is
always set no matter btree node is dirty or not. The code looks like
this,
if (btree_node_dirty(b))
btree_complete_write(b, btree_current_write(b));
clear_bit(BTREE_NODE_dirty, &b->flags);

Indeed if btree_node_dirty(b) returns false, it means BTREE_NODE_dirty
bit is cleared, then it is unnecessary to clear the bit again.

This patch only clears BTREE_NODE_dirty when btree_node_dirty(b) is
true (the bit is set), to save a few CPU cycles.

Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/bcache/btree.c