1 ext4: enforce online defrag restriction for encrypted files
3 From: Eric Whitney <enwlinux@gmail.com>
5 Online defragging of encrypted files is not currently implemented.
6 However, the move extent ioctl can still return successfully when
7 called. For example, this occurs when xfstest ext4/020 is run on an
8 encrypted file system, resulting in a corrupted test file and a
9 corresponding test failure.
11 Until the proper functionality is implemented, fail the move extent
12 ioctl if either the original or donor file is encrypted.
14 Cc: stable@vger.kernel.org
15 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
16 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18 fs/ext4/move_extent.c | 7 +++++++
19 1 file changed, 7 insertions(+)
21 diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
22 index a920c5d..6fc14de 100644
23 --- a/fs/ext4/move_extent.c
24 +++ b/fs/ext4/move_extent.c
25 @@ -598,6 +598,13 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk,
29 + if (ext4_encrypted_inode(orig_inode) ||
30 + ext4_encrypted_inode(donor_inode)) {
31 + ext4_msg(orig_inode->i_sb, KERN_ERR,
32 + "Online defrag not supported for encrypted files");
36 /* Protect orig and donor inodes against a truncate */
37 lock_two_nondirectories(orig_inode, donor_inode);