Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nilfs2: do not propagate ENOENT error from nilfs_btree_propagate()

In preparation for writing logs, in nilfs_btree_propagate(), which makes
parent and ancestor node blocks dirty starting from a modified data block
or b-tree node block, if the starting block does not belong to the b-tree,
i.e. is isolated, nilfs_btree_do_lookup() called within the function
fails with -ENOENT.

In this case, even though -ENOENT is an internal code, it is propagated to
the log writer via nilfs_bmap_propagate() and may be erroneously returned
to system calls such as fsync().

Fix this issue by changing the error code to -EINVAL in this case, and
having the bmap layer detect metadata corruption and convert the error
code appropriately.

Link: https://lkml.kernel.org/r/20250428173808.6452-3-konishi.ryusuke@gmail.com
Fixes: 1f5abe7e7dbc ("nilfs2: replace BUG_ON and BUG calls triggerable from ioctl")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: Wentao Liang <vulab@iscas.ac.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Ryusuke Konishi and committed by
Andrew Morton
8e39fbb1 f43f0242

+3 -1
+3 -1
fs/nilfs2/btree.c
··· 2102 2102 2103 2103 ret = nilfs_btree_do_lookup(btree, path, key, NULL, level + 1, 0); 2104 2104 if (ret < 0) { 2105 - if (unlikely(ret == -ENOENT)) 2105 + if (unlikely(ret == -ENOENT)) { 2106 2106 nilfs_crit(btree->b_inode->i_sb, 2107 2107 "writing node/leaf block does not appear in b-tree (ino=%lu) at key=%llu, level=%d", 2108 2108 btree->b_inode->i_ino, 2109 2109 (unsigned long long)key, level); 2110 + ret = -EINVAL; 2111 + } 2110 2112 goto out; 2111 2113 } 2112 2114