Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Daniel Vacek <neelx@suse.com>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: Daniel Vacek <neelx@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Omar Sandoval <osandov@osandov.com>,
	Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Subject: [PATCH v7 1/6] btrfs: disable various operations on encrypted inodes
Date: Tue, 18 Nov 2025 17:08:38 +0100	[thread overview]
Message-ID: <20251118160845.3006733-2-neelx@suse.com> (raw)
In-Reply-To: <20251118160845.3006733-1-neelx@suse.com>

From: Omar Sandoval <osandov@osandov.com>

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 <osandov@osandov.com>
Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Daniel Vacek <neelx@suse.com>
---
v5 was 'Reviewed-by: Boris Burkov <boris@bur.io>' but the rebase changed
the code a bit so dropping.
https://lore.kernel.org/linux-btrfs/20240124195303.GC1789919@zen.localdomain/
---
 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_inode *inode,
 	if (size < i_size_read(&inode->vfs_inode))
 		return false;
 
+	/* Encrypted file cannot be inlined. */
+	if (IS_ENCRYPTED(&inode->vfs_inode))
+		return false;
+
 	return true;
 }
 
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
 
 #include <linux/blkdev.h>
+#include <linux/fscrypt.h>
 #include <linux/iversion.h>
 #include "ctree.h"
 #include "fs.h"
@@ -789,6 +790,12 @@ static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
 		ASSERT(inode_in->vfs_inode.i_sb == inode_out->vfs_inode.i_sb);
 	}
 
+	/*
+	 * Can only reflink encrypted files if both files are encrypted.
+	 */
+	if (IS_ENCRYPTED(&inode_in->vfs_inode) != IS_ENCRYPTED(&inode_out->vfs_inode))
+		return -EINVAL;
+
 	/* Don't make the dst file partly checksummed */
 	if ((inode_in->flags & BTRFS_INODE_NODATASUM) !=
 	    (inode_out->flags & BTRFS_INODE_NODATASUM)) {
-- 
2.51.0


  reply	other threads:[~2025-11-18 16:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-18 16:08 [PATCH v8 0/6] btrfs: add fscrypt support, PART 1 Daniel Vacek
2025-11-18 16:08 ` Daniel Vacek [this message]
2025-11-18 16:08 ` [PATCH v7 2/6] btrfs: disable verity on encrypted inodes Daniel Vacek
2025-11-18 16:08 ` [PATCH v7 3/6] btrfs: add orig_logical to btrfs_bio Daniel Vacek
2025-11-18 16:08 ` [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission Daniel Vacek
2025-11-19 10:07   ` Johannes Thumshirn
2025-11-19 10:13     ` Johannes Thumshirn
2025-11-19 12:08       ` David Sterba
2025-11-18 16:08 ` [PATCH v7 5/6] btrfs: move inode_to_path higher in backref.c Daniel Vacek
2025-11-19 10:10   ` Johannes Thumshirn
2025-11-19 12:21   ` Filipe Manana
2025-11-19 12:49     ` David Sterba
2025-11-18 16:08 ` [PATCH v7 6/6] btrfs: don't search back for dir inode item in INO_LOOKUP_USER Daniel Vacek
2025-11-19 10:16   ` Johannes Thumshirn
2025-11-19  8:23 ` [PATCH v8 0/6] btrfs: add fscrypt support, PART 1 Christoph Hellwig
2025-11-19  8:59   ` David Sterba
2025-11-19  9:06     ` Christoph Hellwig
2025-11-19 11:16       ` David Sterba
2025-11-19 12:16 ` David Sterba
2025-11-19 14:09   ` Daniel Vacek
  -- strict thread matches above, loose matches on Subject: below --
2025-11-18 16:00 [PATCH v7 0/7] " Daniel Vacek
2025-11-18 16:00 ` [PATCH v7 1/6] btrfs: disable various operations on encrypted inodes Daniel Vacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251118160845.3006733-2-neelx@suse.com \
    --to=neelx@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=osandov@osandov.com \
    --cc=sweettea-kernel@dorminy.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox