diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 6d7ae2bc..157a0b70 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -2082,6 +2082,25 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_path *path, } } + /* + * Extra check for compressed extents: + * Btrfs doesn't allow NODATASUM and compressed extent co-exist, thus + * all compressed extents should have a checksum. + */ + if (compressed && csum_found < search_len) { + error( +"root %llu EXTENT_DATA[%llu %llu] compressed extent must have csum, but only %llu bytes have, expect %llu", + root->objectid, fkey.objectid, fkey.offset, csum_found, + search_len); + err |= CSUM_ITEM_MISSING; + } + if (compressed && nodatasum) { + error( +"root %llu EXTENT_DATA[%llu %llu] is compressed, but inode flag doesn't allow it", + root->objectid, fkey.objectid, fkey.offset); + err |= FILE_EXTENT_ERROR; + } + /* Check EXTENT_DATA hole */ if (!no_holes && *end != fkey.offset) { if (repair)