From nobody Mon Feb 9 10:12:43 2026 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 A1CAF4418F0 for ; Fri, 6 Feb 2026 18:25:06 +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=1770402306; cv=none; b=putuQITv0QLImQebuSV7Q1/6l4ndp0Aap7VfjX5RwLRwbEqMucmZVafVZ5t9EWbxhdSOlJ0EKFeFiAXpdtox7W0UlpeQH2Nvt97fZOH5CMcID9G6w6UfX9gwl0NLBzkSZBGLvkNFz+Kf9Mj27PmUvCUYky/fXtRoptjsurybx48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770402306; c=relaxed/simple; bh=FBy99Pni9ZqUQJCWFn5hJAPFNmk7nOaxxWnDwn8nPjA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=utABwe9b9GquayTnC+7zNZoPtqNIXmVLrzOoWSHqWccsHJh+N/P+HguLL5j4gTFQeDhFtabggJS4rCnEGCUU55KzKToCUkha9XUuYjlzB6mhWZ2JW1QPA2EnPoMFI7onT3oEmHdt5XwrOzs55stgd3V917hFYc88gsK5KIBbQAs= 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; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=dgnhT86q; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=dgnhT86q; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="dgnhT86q"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="dgnhT86q" Received: from imap1.dmz-prg2.suse.org (unknown [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 95C6C3E74C; Fri, 6 Feb 2026 18:24:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770402253; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HiR3m+n+8ALmEnGsv/bKdMO09KbAjSFNZ63G9sqGBN0=; b=dgnhT86qpk1BBbJ6q5dy6D/4ZkkJHYXxV3PLkgBqWX4UmuDUlm2DpPFzNGcax/QzCwibmV dRNlHH5U34MGyGsm4n0aj+soJxXwdxqjki6oMot27IsaBYyIYCYPyKd6FHYVlyyYe8kBiy Xob5nXnLwfMXiMjS1tnVP+R/vR5VYZQ= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1770402253; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HiR3m+n+8ALmEnGsv/bKdMO09KbAjSFNZ63G9sqGBN0=; b=dgnhT86qpk1BBbJ6q5dy6D/4ZkkJHYXxV3PLkgBqWX4UmuDUlm2DpPFzNGcax/QzCwibmV dRNlHH5U34MGyGsm4n0aj+soJxXwdxqjki6oMot27IsaBYyIYCYPyKd6FHYVlyyYe8kBiy Xob5nXnLwfMXiMjS1tnVP+R/vR5VYZQ= 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 6B23C3EA63; Fri, 6 Feb 2026 18:24:13 +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 +N+uGc0xhmkTCQAAD6G6ig (envelope-from ); Fri, 06 Feb 2026 18:24:13 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , Eric Biggers , "Theodore Y. Ts'o" , Jaegeuk Kim , Jens Axboe , David Sterba Cc: linux-block@vger.kernel.org, Daniel Vacek , linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 30/43] btrfs: add a bio argument to btrfs_csum_one_bio Date: Fri, 6 Feb 2026 19:23:02 +0100 Message-ID: <20260206182336.1397715-31-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206182336.1397715-1-neelx@suse.com> References: <20260206182336.1397715-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-Spam-Score: -6.80 X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,suse.com:email,toxicpanda.com:email]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCPT_COUNT_TWELVE(0.00)[12]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; R_RATELIMIT(0.00)[to_ip_from(RLdafymbgddseoxkryad1wgu8n)]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" From: Josef Bacik We only ever needed the bbio in btrfs_csum_one_bio, since that has the bio embedded in it. However with encryption we'll have a different bio with the encrypted data in it, and the original bbio. Update btrfs_csum_one_bio to take the bio we're going to csum as an argument, which will allow us to csum the encrypted bio and stuff the csums into the corresponding bbio to be used later when the IO completes. Signed-off-by: Josef Bacik Signed-off-by: Daniel Vacek --- v5: https://lore.kernel.org/linux-btrfs/595a2e46dae3d18bceb5dfa60ac3ae23760= fc800.1706116485.git.josef@toxicpanda.com/ * Adapted for async csums. For writes we have to stick with sync csums. Otherwise fscrypt would have to hand us the bounced bio instead of releasing it. Though that is not implemented yet. --- fs/btrfs/bio.c | 4 ++-- fs/btrfs/bio.h | 1 + fs/btrfs/file-item.c | 13 ++++++------- fs/btrfs/file-item.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 0a69e09bfe28..487dd9267fd7 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -592,9 +592,9 @@ static int btrfs_bio_csum(struct btrfs_bio *bbio) if (bbio->bio.bi_opf & REQ_META) return btree_csum_one_bio(bbio); #ifdef CONFIG_BTRFS_EXPERIMENTAL - return btrfs_csum_one_bio(bbio, true); + return btrfs_csum_one_bio(bbio, &bbio->bio, true); #else - return btrfs_csum_one_bio(bbio, false); + return btrfs_csum_one_bio(bbio, &bbio->bio, false); #endif } =20 diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h index 303ed6c7103d..43f7544029ac 100644 --- a/fs/btrfs/bio.h +++ b/fs/btrfs/bio.h @@ -59,6 +59,7 @@ struct btrfs_bio { struct btrfs_ordered_sum *sums; struct work_struct csum_work; struct completion csum_done; + struct bio *csum_bio; struct bvec_iter csum_saved_iter; u64 orig_physical; u64 orig_logical; diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 08dc78295707..ef0b6faf3de0 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -764,11 +764,10 @@ int btrfs_lookup_csums_bitmap(struct btrfs_root *root= , struct btrfs_path *path, return ret; } =20 -static void csum_one_bio(struct btrfs_bio *bbio, struct bvec_iter *src) +static void csum_one_bio(struct btrfs_bio *bbio, struct bio *bio, struct b= vec_iter *src) { struct btrfs_inode *inode =3D bbio->inode; struct btrfs_fs_info *fs_info =3D inode->root->fs_info; - struct bio *bio =3D &bbio->bio; struct btrfs_ordered_sum *sums =3D bbio->sums; struct bvec_iter iter =3D *src; phys_addr_t paddr; @@ -796,19 +795,18 @@ static void csum_one_bio_work(struct work_struct *wor= k) =20 ASSERT(btrfs_op(&bbio->bio) =3D=3D BTRFS_MAP_WRITE); ASSERT(bbio->async_csum =3D=3D true); - csum_one_bio(bbio, &bbio->csum_saved_iter); + csum_one_bio(bbio, bbio->csum_bio, &bbio->csum_saved_iter); complete(&bbio->csum_done); } =20 /* * Calculate checksums of the data contained inside a bio. */ -int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async) +int btrfs_csum_one_bio(struct btrfs_bio *bbio, struct bio *bio, bool async) { struct btrfs_ordered_extent *ordered =3D bbio->ordered; struct btrfs_inode *inode =3D bbio->inode; struct btrfs_fs_info *fs_info =3D inode->root->fs_info; - struct bio *bio =3D &bbio->bio; struct btrfs_ordered_sum *sums; unsigned nofs_flag; =20 @@ -827,12 +825,13 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool a= sync) btrfs_add_ordered_sum(ordered, sums); =20 if (!async) { - csum_one_bio(bbio, &bbio->bio.bi_iter); + csum_one_bio(bbio, bio, &bio->bi_iter); return 0; } init_completion(&bbio->csum_done); bbio->async_csum =3D true; - bbio->csum_saved_iter =3D bbio->bio.bi_iter; + bbio->csum_bio =3D bio; + bbio->csum_saved_iter =3D bio->bi_iter; INIT_WORK(&bbio->csum_work, csum_one_bio_work); schedule_work(&bbio->csum_work); return 0; diff --git a/fs/btrfs/file-item.h b/fs/btrfs/file-item.h index 5645c5e3abdb..d16fd2144552 100644 --- a/fs/btrfs/file-item.h +++ b/fs/btrfs/file-item.h @@ -64,7 +64,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *t= rans, int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct btrfs_ordered_sum *sums); -int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async); +int btrfs_csum_one_bio(struct btrfs_bio *bbio, struct bio *bio, bool async= ); int btrfs_alloc_dummy_sum(struct btrfs_bio *bbio); int btrfs_lookup_csums_range(struct btrfs_root *root, u64 start, u64 end, struct list_head *list, int search_commit, --=20 2.51.0