From: Josef Bacik <[email protected]> We will drop the inode and re-look it up to do defrag with auto defrag, which means we could lose the encryption policy.
Auto defrag needs to be reworked to just hold onto the inode for scheduling later so we don't lose the context. For now just disable it if the file is encrypted. Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Daniel Vacek <[email protected]> --- v5: https://lore.kernel.org/linux-btrfs/b717912bf88797b3044a3c2724b59b1ecc17ea78.1706116485.git.jo...@toxicpanda.com/ * No changes since. --- fs/btrfs/defrag.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index f64c0502cef9..cd6ea6e5d3ea 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -126,6 +126,14 @@ void btrfs_add_inode_defrag(struct btrfs_inode *inode, u32 extent_thresh) if (!need_auto_defrag(fs_info)) return; + /* + * Since we have to read the inode at defrag time disable auto defrag + * for encrypted inodes until we have code to read the parent and load + * the encryption context. + */ + if (IS_ENCRYPTED(&inode->vfs_inode)) + return; + if (test_bit(BTRFS_INODE_IN_DEFRAG, &inode->runtime_flags)) return; -- 2.51.0
