From nobody Mon Feb 9 11:28:39 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 252573538BF for ; Wed, 12 Nov 2025 19:36:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762976213; cv=none; b=mV3Rghw2e0kl5qzrGGNFdrtX+mRF09Y2DM/PST5gXY+UOsVRKgy/LgkF5nHEr2bip62FkzbOqKCPIaF/5FnH3gnBjkK0io/gYr0L4bRvK7+kF2lDP/WRJHl0G1/PDNgZG2YGP3kqXiJHvM84HVKOWTvh2appPNsrCYPBiCwtYFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762976213; c=relaxed/simple; bh=Qq4Tp00GXzNvEm9j0Ogoy9B+mJlCtDLzO+gAdCsskZk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AXU0lCba6Xxx4oAlEO67Alr4Qx+2eCi4zPj+5USulGAIVIvWfGKGMKFCJ7/R3a28ONHSAErj273itsNxRNY+TeaP6JWLw/GJXcgRRxQObhTSsovzgGd/MUcs3lZJnpwcBE6DPx/nWj8k5GgQzrPY08fem4/eZkL1V+Zzq8oyvlg= 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.131 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-out2.suse.de (Postfix) with ESMTPS id BF7CE1F7BD; Wed, 12 Nov 2025 19:36:42 +0000 (UTC) Authentication-Results: smtp-out2.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 A8A2D3EA61; Wed, 12 Nov 2025 19:36:42 +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 0NyiKMrhFGm+YgAAD6G6ig (envelope-from ); Wed, 12 Nov 2025 19:36:42 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 4/8] btrfs: add orig_logical to btrfs_bio Date: Wed, 12 Nov 2025 20:36:04 +0100 Message-ID: <20251112193611.2536093-5-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251112193611.2536093-1-neelx@suse.com> References: <20251112193611.2536093-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: BF7CE1F7BD 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)[] Content-Type: text/plain; charset="utf-8" From: Josef Bacik When checksumming the encrypted bio on writes we need to know which logical address this checksum is for. At the point where we get the encrypted bio the bi_sector is the physical location on the target disk, so we need to save the original logical offset in the btrfs_bio. Then we can use this when csum'ing the bio instead of the bio->iter.bi_sector. Signed-off-by: Josef Bacik --- No code changes other than context since v5. --- fs/btrfs/bio.c | 10 ++++++++++ fs/btrfs/bio.h | 2 ++ fs/btrfs/file-item.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index a69174b2b6b6..aba452dd9904 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -94,6 +94,8 @@ static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_= info *fs_info, if (bbio_has_ordered_extent(bbio)) { refcount_inc(&orig_bbio->ordered->refs); bbio->ordered =3D orig_bbio->ordered; + bbio->orig_logical =3D orig_bbio->orig_logical; + orig_bbio->orig_logical +=3D map_length; } bbio->csum_search_commit_root =3D orig_bbio->csum_search_commit_root; atomic_inc(&orig_bbio->pending_ios); @@ -726,6 +728,14 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio,= int mirror_num) goto end_bbio; } =20 + /* + * For fscrypt writes we will get the encrypted bio after we've + * remapped our bio to the physical disk location, so we need to + * save the original bytenr so we know what we're checksumming. + */ + if (bio_op(bio) =3D=3D REQ_OP_WRITE && is_data_bbio(bbio)) + bbio->orig_logical =3D logical; + map_length =3D min(map_length, length); if (use_append) map_length =3D btrfs_append_map_length(bbio, map_length); diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h index c5a6c66d51a0..5015e327dbd9 100644 --- a/fs/btrfs/bio.h +++ b/fs/btrfs/bio.h @@ -52,6 +52,7 @@ struct btrfs_bio { * - pointer to the checksums for this bio * - original physical address from the allocator * (for zone append only) + * - original logical address, used for checksumming fscrypt bios. */ struct { struct btrfs_ordered_extent *ordered; @@ -61,6 +62,7 @@ struct btrfs_bio { struct bio *csum_bio; struct bvec_iter csum_saved_iter; u64 orig_physical; + u64 orig_logical; }; =20 /* For metadata reads: parentness verification. */ diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 474949074da8..d2ecd26727ac 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -812,7 +812,7 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, struct b= io *bio, bool async) if (!sums) return -ENOMEM; =20 - sums->logical =3D bio->bi_iter.bi_sector << SECTOR_SHIFT; + sums->logical =3D bbio->orig_logical; sums->len =3D bio->bi_iter.bi_size; INIT_LIST_HEAD(&sums->list); bbio->sums =3D sums; --=20 2.51.0