Skip to content

Commit b4b8be0

Browse files
adam900710kdave
authored andcommitted
btrfs: add an ASSERT() to catch ordered extents without datasum
Inside btrfs_finish_one_ordered(), there are only very limited situations where the OE has no checksum: - The OE is completely truncated or error happened In that case no file extent is going to be inserted. - The inode has NODATASUM flag - The inode belongs to data reloc tree Add an ASSERT() using the last two cases, which will help us to catch problems described in commit 18de34d ("btrfs: truncate ordered extent when skipping writeback past i_size"), and prevent future similar cases. Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3604a8b commit b4b8be0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

fs/btrfs/inode.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3282,6 +3282,21 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
32823282
goto out;
32833283
}
32843284

3285+
/*
3286+
* If we have no data checksum, either the OE is:
3287+
* - Fully truncated
3288+
* Those ones won't reach here.
3289+
*
3290+
* - No data checksum
3291+
*
3292+
* - Belongs to data reloc inode
3293+
* Which doesn't have csum attached to OE, but cloned
3294+
* from original chunk.
3295+
*/
3296+
if (list_empty(&ordered_extent->list))
3297+
ASSERT(inode->flags & BTRFS_INODE_NODATASUM ||
3298+
btrfs_is_data_reloc_root(inode->root));
3299+
32853300
ret = add_pending_csums(trans, &ordered_extent->list);
32863301
if (unlikely(ret)) {
32873302
btrfs_abort_transaction(trans, ret);

0 commit comments

Comments
 (0)