From nobody Tue Dec 2 02:42:59 2025 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 C8F79369984 for ; Tue, 18 Nov 2025 16:01:09 +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=1763481671; cv=none; b=AFKtRcbeWl0irlkzKD1aQTAkoLqjdvkWLrhvy3IFVQAHNtOsaTy/6coqLuK5k2a07TZn76Lqqh6qoDU4Cxsg3k6y5FDIMBINqVLuuNKzeMtWEQyLTQFAQRrCaXLSnPXsnZwcnW2f+2DIltOvlpzo6IJYzYreCfHaNkzGCqPMask= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763481671; c=relaxed/simple; bh=eQaGiBGI7QDJGR9sw+SddJxeZY7/xSEdUXr+OnfvMe4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y9J+8sGUVjAoDicy2jxwRRpZrhGZ2GUphXn4MX4J4HZ81WhA8G8RaHrwANb3+54J1rqBj3/vYSta6nKuvNyIrlOYkBiYo0c3ZwhY3/Uzq5c8SlxfpU2OKFvSnjFYKaPaJKAiYyo4O/M6prftpdOWrW+phREu3Glf1ZAmvB2qsQQ= 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 B5DA22121F; Tue, 18 Nov 2025 16:01:00 +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 994DF3EA61; Tue, 18 Nov 2025 16:01:00 +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 AK/qJDyYHGkSWgAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:01:00 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Omar Sandoval , Sweet Tea Dorminy , Daniel Vacek Subject: [PATCH v7 1/6] btrfs: disable various operations on encrypted inodes Date: Tue, 18 Nov 2025 17:00:36 +0100 Message-ID: <20251118160043.3005684-2-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160043.3005684-1-neelx@suse.com> References: <20251118160043.3005684-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: B5DA22121F 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)[]; TAGGED_RCPT(0.00)[] Content-Type: text/plain; charset="utf-8" From: Omar Sandoval Initially, only normal data extents will be encrypted. This change forbids various other bits: - allows reflinking only if both inodes have the same encryption status - disable inline data on encrypted inodes Signed-off-by: Omar Sandoval Signed-off-by: Sweet Tea Dorminy Signed-off-by: Josef Bacik Signed-off-by: Daniel Vacek -- v5 was 'Reviewed-by: Boris Burkov ' but the rebase changed the code a bit so dropping. https://lore.kernel.org/linux-btrfs/20240124195303.GC1789919@zen.localdomai= n/ Signed-off-by: Daniel Vacek --- fs/btrfs/inode.c | 4 ++++ fs/btrfs/reflink.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f71a5f7f55b9..8e13117eca16 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -592,6 +592,10 @@ static bool can_cow_file_range_inline(struct btrfs_ino= de *inode, if (size < i_size_read(&inode->vfs_inode)) return false; =20 + /* Encrypted file cannot be inlined. */ + if (IS_ENCRYPTED(&inode->vfs_inode)) + return false; + return true; } =20 diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 775a32a7953a..3c9c570d6493 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 =20 #include +#include #include #include "ctree.h" #include "fs.h" @@ -789,6 +790,12 @@ static int btrfs_remap_file_range_prep(struct file *fi= le_in, loff_t pos_in, ASSERT(inode_in->vfs_inode.i_sb =3D=3D inode_out->vfs_inode.i_sb); } =20 + /* + * Can only reflink encrypted files if both files are encrypted. + */ + if (IS_ENCRYPTED(&inode_in->vfs_inode) !=3D IS_ENCRYPTED(&inode_out->vfs_= inode)) + return -EINVAL; + /* Don't make the dst file partly checksummed */ if ((inode_in->flags & BTRFS_INODE_NODATASUM) !=3D (inode_out->flags & BTRFS_INODE_NODATASUM)) { --=20 2.51.0