Skip to content
Snippets Groups Projects
Commit e2f3f2b2 authored by Eric Whitney's avatar Eric Whitney Committed by Nick Desaulniers
Browse files

UPSTREAM: ext4: enforce online defrag restriction for encrypted files


commit 14fbd4aa613bd5110556c281799ce36dc6f3ba97 upstream.

Online defragging of encrypted files is not currently implemented.
However, the move extent ioctl can still return successfully when
called.  For example, this occurs when xfstest ext4/020 is run on an
encrypted file system, resulting in a corrupted test file and a
corresponding test failure.

Until the proper functionality is implemented, fail the move extent
ioctl if either the original or donor file is encrypted.

Bug: 38276297
Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 76a8f17e)
Change-Id: Ifaa55e8b4acc07a93a246ded4c233250cfbc2aac
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent e12f1f1c
Branches
Tags
No related merge requests found
...@@ -601,6 +601,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk, ...@@ -601,6 +601,14 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
ext4_should_journal_data(donor_inode)) { ext4_should_journal_data(donor_inode)) {
return -EINVAL; return -EINVAL;
} }
if (ext4_encrypted_inode(orig_inode) ||
ext4_encrypted_inode(donor_inode)) {
ext4_msg(orig_inode->i_sb, KERN_ERR,
"Online defrag not supported for encrypted files");
return -EOPNOTSUPP;
}
/* Protect orig and donor inodes against a truncate */ /* Protect orig and donor inodes against a truncate */
lock_two_nondirectories(orig_inode, donor_inode); lock_two_nondirectories(orig_inode, donor_inode);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment