From nobody Mon Feb 9 12:15:42 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 F1C3643E490 for ; Fri, 6 Feb 2026 18:25:40 +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=1770402341; cv=none; b=PAuiV18pL2wNqY7Nyu2MkjYVsMq8Z8YA9PVvmsu3AT5K4a+lGGoQcFdEIXhzja7Ue3f7pcH5PJ62j835qufsMu0PzO+spXjZLVNLgjRt+O66Rdg/uQC2Uq3tuTo79sYO2D+HcGIF+i1DjbM2EYsVZMm6r+O1t4OY+Xg7dqxALcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770402341; c=relaxed/simple; bh=fZxW8wexZZ7fyQehWlyzdfCe9GH5o7H4GiTaE8gAS1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SOcxSr2TaYqK9VxwvkFdN4seOieoCLw7pynPYxX6RpTgCierPjJKOuZKVRnQbjWjLRVtTY3SHOfHuTE+tzOjFIMULvL7DRj/OtMyRAcHrCCXK5Ink5+Gx3F9mRd3d6UXz2EI1wGE4w963POZe8DYKGH/xkf+qWWvXObf82d+f+U= 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 69D0A3E745; Fri, 6 Feb 2026 18:24:19 +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 3F3A63EA63; Fri, 6 Feb 2026 18:24:19 +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 SJfzDtMxhmkTCQAAD6G6ig (envelope-from ); Fri, 06 Feb 2026 18:24:19 +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 40/43] btrfs: support encryption with log replay Date: Fri, 6 Feb 2026 19:23:12 +0100 Message-ID: <20260206182336.1397715-41-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-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Score: -4.00 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Rspamd-Queue-Id: 69D0A3E745 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Flag: NO Content-Type: text/plain; charset="utf-8" From: Josef Bacik Log replay needs a few tweaks in order to make sure everything works with encryption. 1. Copy in the fscrypt context if we find one in the log. 2. Set NEEDS_FULL_SYNC when we update the inode context so all of the items are copied into the log at fsync time. This makes replay of encrypted files work properly. Signed-off-by: Josef Bacik Signed-off-by: Daniel Vacek --- v5: https://lore.kernel.org/linux-btrfs/d1ada7ac632c2ab554a840c7ba29b53a93b= 9855f.1706116485.git.josef@toxicpanda.com/ * Adapted to the redesigned encryption context storing. - No need to specially handle the extent item now. It is not any different to before and the new context items are simply copied. --- fs/btrfs/fscrypt.c | 1 + fs/btrfs/tree-log.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/fscrypt.c b/fs/btrfs/fscrypt.c index bcb86cbaa171..cbdeaa75a868 100644 --- a/fs/btrfs/fscrypt.c +++ b/fs/btrfs/fscrypt.c @@ -145,6 +145,7 @@ static int btrfs_fscrypt_set_context(struct inode *inod= e, const void *ctx, goto out_err; } =20 + set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags); leaf =3D path->nodes[0]; ptr =3D btrfs_item_ptr_offset(leaf, path->slots[0]); =20 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 0d01e31a4592..fa75531f9633 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c @@ -2922,7 +2922,9 @@ static int replay_one_buffer(struct extent_buffer *eb, continue; =20 /* these keys are simply copied */ - if (wc->log_key.type =3D=3D BTRFS_XATTR_ITEM_KEY) { + if (wc->log_key.type =3D=3D BTRFS_XATTR_ITEM_KEY || + wc->log_key.type =3D=3D BTRFS_FSCRYPT_INODE_CTX_KEY || + wc->log_key.type =3D=3D BTRFS_FSCRYPT_CTX_KEY) { ret =3D overwrite_item(wc); if (ret) break; --=20 2.51.0