Skip to content

Commit 111b812

Browse files
konisakpm00
authored andcommitted
nilfs2: determine empty node blocks as corrupted
Due to the nature of b-trees, nilfs2 itself and admin tools such as mkfs.nilfs2 will never create an intermediate b-tree node block with 0 child nodes, nor will they delete (key, pointer)-entries that would result in such a state. However, it is possible that a b-tree node block is corrupted on the backing device and is read with 0 child nodes. Because operation is not guaranteed if the number of child nodes is 0 for intermediate node blocks other than the root node, modify nilfs_btree_node_broken(), which performs sanity checks when reading a b-tree node block, so that such cases will be judged as metadata corruption. Link: https://lkml.kernel.org/r/[email protected] Fixes: 17c76b0 ("nilfs2: B-tree based block mapping") Signed-off-by: Ryusuke Konishi <[email protected]> Cc: Lizhi Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 9403001 commit 111b812

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/nilfs2/btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
350350
if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN ||
351351
level >= NILFS_BTREE_LEVEL_MAX ||
352352
(flags & NILFS_BTREE_NODE_ROOT) ||
353-
nchildren < 0 ||
353+
nchildren <= 0 ||
354354
nchildren > NILFS_BTREE_NODE_NCHILDREN_MAX(size))) {
355355
nilfs_crit(inode->i_sb,
356356
"bad btree node (ino=%lu, blocknr=%llu): level = %d, flags = 0x%x, nchildren = %d",

0 commit comments

Comments
 (0)