Skip to content

Commit ffbc7fe

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 <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 03406ca commit ffbc7fe

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
@@ -3221,6 +3221,21 @@ int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent)
32213221
goto out;
32223222
}
32233223

3224+
/*
3225+
* If we have no data checksum, either the OE is:
3226+
* - Fully truncated
3227+
* Those ones won't reach here.
3228+
*
3229+
* - No data checksum
3230+
*
3231+
* - Belongs to data reloc inode
3232+
* Which doesn't have csum attached to OE, but cloned
3233+
* from original chunk.
3234+
*/
3235+
if (list_empty(&ordered_extent->list))
3236+
ASSERT(inode->flags & BTRFS_INODE_NODATASUM ||
3237+
btrfs_is_data_reloc_root(inode->root));
3238+
32243239
ret = add_pending_csums(trans, &ordered_extent->list);
32253240
if (unlikely(ret)) {
32263241
btrfs_abort_transaction(trans, ret);

0 commit comments

Comments
 (0)