Skip to contentSkip to conversation

nilfs2: skip blocks with no bmap entry in nilfs_ioctl_mark_blocks_dirty()

PATCH New Junjie Cao 1 participant 1 message Mar 19

Subsystems (2)
lore
Share & tools
lore

Junjie Cao

author
#0 lore raw

PATCH 1/1 nilfs2: skip blocks with no bmap entry in nilfs_ioctl_mark_blocks_dirty()

In nilfs_ioctl_mark_blocks_dirty(), called during garbage collection, nilfs_bmap_lookup_at_level() may return -ENOENT when a block no longer exists in the DAT bmap. In that case the code sets bd_blocknr to 0 but falls through to the liveness check that compares bd_blocknr against bd_oblocknr. If bd_oblocknr also happens to be 0, the descriptor is incorrectly treated as live and the code attempts to get or mark the non-existent block, triggering a WARN_ON.

Fix this by adding a continue statement so that a block descriptor is immediately skipped when its bmap lookup returns -ENOENT, since there is no block in the DAT to mark dirty.

---
 fs/nilfs2/ioctl.c | 1 +
 1 file changed, 1 insertion(+)
fs/nilfs2/ioctl.c +1 -0
index 1bfe8a2..d71a0a5 100644
@@ -744,6 +744,7 @@ static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs,
 		if (ret < 0) {
 			if (ret != -ENOENT)
 				return ret;
 			bdescs[i].bd_blocknr = 0;
+			continue;
 		}
 		if (bdescs[i].bd_blocknr != bdescs[i].bd_oblocknr)

/* skip dead block */

Signature · 1 line
2.43.0