Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0132F326D58 for ; Wed, 15 Oct 2025 12:12:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760530359; cv=none; b=KB3HUPfsahpC/SStBwBcDiiA7JuPvR67vv1ru0jMdPQxW681pOlyB284/d1ySVAenvjMZ/R3Yuycd5/fv+htJpX1coP0pIUTBVka1VkFdo7Ii4OuRitvVWLQt+lzaahm6UhSHUvauzI7Q5s8NLLL/zUM6b4taftSZQv0Cv/tX4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760530359; c=relaxed/simple; bh=tvZH9Nut3Mi4hlMimbFBYrPw6C0bJvHR78PUcjzY7SQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XV4y3kBaFor6ZM5KTHJPSb5/IrCINpCnem2f1rPB4xZ0iJkJQzxDZekqPkHHraD1pJETHsZcUYEQsXFfGoxRCZQij3xHARyKxMFpEzlxTKePAd17Y/DY1ebM/PijnG2iCZQr5kqK78cDg7W5mL2B46+OnrI4p/DjeCVLnpkfbeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 23FDD3385B; Wed, 15 Oct 2025 12:12:03 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 11B9013AE4; Wed, 15 Oct 2025 12:12:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eI3iA5OP72i2fAAAD6G6ig (envelope-from ); Wed, 15 Oct 2025 12:12:03 +0000 From: Daniel Vacek To: David Sterba Cc: linux-btrfs@vger.kernel.org, Daniel Vacek , Josef Bacik , Sweet Tea Dorminy Subject: [PATCH 7/8] btrfs-progs: check: update inline extent length checking Date: Wed, 15 Oct 2025 14:11:55 +0200 Message-ID: <20251015121157.1348124-8-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015121157.1348124-1-neelx@suse.com> References: <20251015121157.1348124-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 23FDD3385B X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] From: Sweet Tea Dorminy As part of the encryption changes, encrypted inline file extents record their actual data length in ram_bytes, like compressed inline file extents, while the item's length records the actual size. As such, encrypted inline extents must be treated like compressed ones for inode length consistency checking. Signed-off-by: Sweet Tea Dorminy --- check/main.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/check/main.c b/check/main.c index d3d65854..e2ce277c 100644 --- a/check/main.c +++ b/check/main.c @@ -1721,7 +1721,7 @@ static int process_file_extent(struct btrfs_root *root, u64 mask = gfs_info->sectorsize - 1; u32 max_inline_size = min_t(u32, gfs_info->sectorsize, BTRFS_MAX_INLINE_DATA_SIZE(gfs_info)); - u8 compression; + u8 compression, encryption; int extent_type; int ret; @@ -1746,25 +1746,25 @@ static int process_file_extent(struct btrfs_root *root, fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item); extent_type = btrfs_file_extent_type(eb, fi); compression = btrfs_file_extent_compression(eb, fi); + encryption = btrfs_file_extent_encryption(eb, fi); if (extent_type == BTRFS_FILE_EXTENT_INLINE) { - num_bytes = btrfs_file_extent_ram_bytes(eb, fi); - if (num_bytes == 0) + u64 num_decoded_bytes = btrfs_file_extent_ram_bytes(eb, fi); + u64 num_disk_bytes = btrfs_file_extent_inline_item_len(eb, slot); + if (num_decoded_bytes == 0) rec->errors |= I_ERR_BAD_FILE_EXTENT; - if (compression) { - if (btrfs_file_extent_inline_item_len(eb, slot) > - max_inline_size || - num_bytes > gfs_info->sectorsize) + if (compression || encryption) { + if (num_disk_bytes > max_inline_size || + num_decoded_bytes > gfs_info->sectorsize) rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE; } else { - if (num_bytes > max_inline_size) + if (num_decoded_bytes > max_inline_size) rec->errors |= I_ERR_FILE_EXTENT_TOO_LARGE; - if (btrfs_file_extent_inline_item_len(eb, slot) != - num_bytes) + if (num_disk_bytes != num_decoded_bytes) rec->errors |= I_ERR_INLINE_RAM_BYTES_WRONG; } - rec->found_size += num_bytes; - num_bytes = (num_bytes + mask) & ~mask; + rec->found_size += num_decoded_bytes; + num_bytes = (num_decoded_bytes + mask) & ~mask; } else if (extent_type == BTRFS_FILE_EXTENT_REG || extent_type == BTRFS_FILE_EXTENT_PREALLOC) { num_bytes = btrfs_file_extent_num_bytes(eb, fi); -- 2.51.0