btrfs-progs: check: skip shared node or leaf check for low_memory mode
authorWang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Wed, 24 Aug 2016 07:49:17 +0000 (15:49 +0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 14 Dec 2016 14:06:33 +0000 (15:06 +0100)
commit5e2dc770471bc8ff394e70ff5af0dbec1bf0f705
treeb668452f7669c9815b46fcb92b9353c6a8f2a248
parentd1e8227ceb5adb8c3a40b0ab31d4787e400fd0df
btrfs-progs: check: skip shared node or leaf check for low_memory mode

The basic idea is simple. Assume a middle tree node A is shared and
its referencing fs/file tree root ids are 5, 258 and 260, then we
only check node A in the tree who has the smallest root id. That means
in this case, when checking root tree(5), we check inode A, for root
tree 258 and 260, we can just skip it.

Notice even with this patch, we still may visit a shared node or leaf
multiple times. This happens when a inode metadata occupies multiple
leaves.

                 leaf_A     leaf_B
When checking inode item in leaf_A, assume inode[512] have file extents
in leaf_B, and leaf_B is shared. In the case, for inode[512], we must
visit leaf_B to have inode item checked. After finishing inode[512] check,
here we walk down tree root to leaf_B to check whether node or leaf
is shared, if some node or leaf is shared, we can just skip it and below
nodes or leaf's check.

I also fill a disk partition with linux source codes and create 3
snapshots in it. Before this patch, it averagely took 46s to finish one
btrfsck execution, with this patch, it averagely took 15s.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-check.c