Whamcloud - gitweb
LU-16374 ldiskfs: round-up enc file size 10/49410/6
authorSebastien Buisson <sbuisson@ddn.com>
Wed, 14 Dec 2022 17:21:14 +0000 (18:21 +0100)
committerOleg Drokin <green@whamcloud.com>
Tue, 21 Mar 2023 23:14:18 +0000 (23:14 +0000)
When accessing encrypted files on targets mounted as ldiskfs, the
sizes must be rounded up to the next encryption block size. This is
required in order to read or write full encryption blocks.

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I6d08a2eb34f0dff864891a4e3e77977688412ec8
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49410
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
29 files changed:
ldiskfs/Makefile.in
ldiskfs/kernel_patches/patches/rhel7.9/ext4-encdata.patch [new file with mode: 0644]
ldiskfs/kernel_patches/patches/rhel8/ext4-encdata.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.8.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.9.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.2.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.3.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.4.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.5.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.6.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.7.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series
ldiskfs/kernel_patches/series/ldiskfs-5.10.0-ml.series
ldiskfs/kernel_patches/series/ldiskfs-5.11.0-40-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.3.18-sles15sp3.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.0-42-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.0-66-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.0-80-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.0-90-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.136-ml.series
ldiskfs/kernel_patches/series/ldiskfs-5.4.21-ml.series
ldiskfs/kernel_patches/series/ldiskfs-5.8.0-53-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.8.0-63-ubuntu20.series
ldiskfs/kernel_patches/series/ldiskfs-5.8.0-ml.series
ldiskfs/kernel_patches/series/ldiskfs-5.9.0-ml.series

index 3ce6566..77a39b8 100644 (file)
@@ -16,7 +16,7 @@ else
 backfs_sources := $(filter-out %.mod.c %/inode-test.c,$(wildcard @EXT4_SRC_DIR@/*.c))
 endif
 
-new_sources := mmp.c htree_lock.c critical_encode.h
+new_sources := mmp.c htree_lock.c critical_encode.h encdata.h
 new_headers :=
 
 ldiskfs_patched_sources := $(notdir $(backfs_sources) $(backfs_headers)) $(new_sources) $(new_headers)
diff --git a/ldiskfs/kernel_patches/patches/rhel7.9/ext4-encdata.patch b/ldiskfs/kernel_patches/patches/rhel7.9/ext4-encdata.patch
new file mode 100644 (file)
index 0000000..c2a1c68
--- /dev/null
@@ -0,0 +1,43 @@
+diff -wur /dev/null b/fs/ext4/encdata.h
+--- /dev/null
++++ b/fs/ext4/encdata.h
+@@ -0,0 +1,16 @@
++/*
++ *  encdata.h
++ *
++ *  Copyright (c) 2022 Whamcloud
++ */
++
++#ifndef _ENCDATA_H
++#define _ENCDATA_H
++
++/* Define a fixed 4096-byte encryption unit size */
++/* Must be identical to LUSTRE_ENCRYPTION_UNIT_SIZE */
++#define EXT4_ENCRYPTION_BLOCKBITS 12
++#define EXT4_ENCRYPTION_UNIT_SIZE ((size_t)1 << EXT4_ENCRYPTION_BLOCKBITS)
++#define EXT4_ENCRYPTION_MASK      (~(EXT4_ENCRYPTION_UNIT_SIZE - 1))
++
++#endif /* _ENCDATA_H */
+diff -wur a/fs/ext4/inode.c b/fs/ext4/inode.c
+--- a/fs/ext4/inode.c
++++ b/fs/ext4/inode.c
+@@ -45,6 +45,7 @@
+ #include "xattr.h"
+ #include "acl.h"
+ #include "truncate.h"
++#include "encdata.h"
+ #include <trace/events/ext4.h>
+@@ -5069,6 +5070,11 @@ int ext4_getattr(struct vfsmount *mnt
+       inode = dentry->d_inode;
+       generic_fillattr(inode, stat);
++
++      if (EXT4_I(inode)->i_flags & EXT4_ENCRYPT_FL &&
++          unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)))
++              stat->size = round_up(stat->size,
++                                    EXT4_ENCRYPTION_UNIT_SIZE);
+
+       /*
+        * If there is inline data in the inode, the inode will normally not
diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-encdata.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-encdata.patch
new file mode 100644 (file)
index 0000000..d80ec4c
--- /dev/null
@@ -0,0 +1,44 @@
+diff -wur /dev/null b/fs/ext4/encdata.h
+--- /dev/null
++++ b/fs/ext4/encdata.h
+@@ -0,0 +1,16 @@
++/*
++ *  encdata.h
++ *
++ *  Copyright (c) 2022 Whamcloud
++ */
++
++#ifndef _ENCDATA_H
++#define _ENCDATA_H
++
++/* Define a fixed 4096-byte encryption unit size */
++/* Must be identical to LUSTRE_ENCRYPTION_UNIT_SIZE */
++#define EXT4_ENCRYPTION_BLOCKBITS 12
++#define EXT4_ENCRYPTION_UNIT_SIZE ((size_t)1 << EXT4_ENCRYPTION_BLOCKBITS)
++#define EXT4_ENCRYPTION_MASK      (~(EXT4_ENCRYPTION_UNIT_SIZE - 1))
++
++#endif /* _ENCDATA_H */
+diff -wur a/fs/ext4/inode.c b/fs/ext4/inode.c
+--- a/fs/ext4/inode.c
++++ b/fs/ext4/inode.c
+@@ -45,6 +45,7 @@
+ #include "xattr.h"
+ #include "acl.h"
+ #include "truncate.h"
++#include "encdata.h"
+ #include <trace/events/ext4.h>
+@@ -5769,6 +5770,12 @@ int ext4_getattr(const struct path *p
+                                 STATX_ATTR_NODUMP);
+       generic_fillattr(inode, stat);
++
++      if (flags & EXT4_ENCRYPT_FL &&
++          unlikely(!IS_LUSTRE_MOUNT(inode->i_sb)))
++              stat->size = round_up(stat->size,
++                                    EXT4_ENCRYPTION_UNIT_SIZE);
++
+       return 0;
+ }
index 1e5079f..524f08b 100644 (file)
@@ -53,3 +53,4 @@ rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 rhel7.6/ext4-projid-xattrs.patch
 rhel7.9/ext4-enc-flag.patch
 rhel7.9/ext4-filename-encode.patch
+rhel7.9/ext4-encdata.patch
index ebf4be8..00e6a03 100644 (file)
@@ -53,3 +53,4 @@ rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 rhel7.6/ext4-projid-xattrs.patch
 rhel7.9/ext4-enc-flag.patch
 rhel7.9/ext4-filename-encode.patch
+rhel7.9/ext4-encdata.patch
index 28726f8..280e48c 100644 (file)
@@ -46,3 +46,4 @@ rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 rhel7.6/ext4-projid-xattrs.patch
 rhel7.9/ext4-enc-flag.patch
 rhel7.9/ext4-filename-encode.patch
+rhel7.9/ext4-encdata.patch
index a07d728..17c4b3a 100644 (file)
@@ -46,3 +46,4 @@ rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 rhel7.6/ext4-projid-xattrs.patch
 rhel7.9/ext4-enc-flag.patch
 rhel7.9/ext4-filename-encode.patch
+rhel7.9/ext4-encdata.patch
index e1fa7c4..12ffab2 100644 (file)
@@ -31,3 +31,4 @@ base/ext4-projid-xattrs.patch
 rhel8/linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-filename-encode.patch
+rhel8/ext4-encdata.patch
index f884a28..f992e68 100644 (file)
@@ -31,3 +31,4 @@ base/ext4-projid-xattrs.patch
 rhel8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-filename-encode.patch
+rhel8/ext4-encdata.patch
index fd3d026..b9acdf7 100644 (file)
@@ -31,3 +31,4 @@ base/ext4-projid-xattrs.patch
 rhel8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-filename-encode.patch
+rhel8/ext4-encdata.patch
index 4cf9472..4040ac7 100644 (file)
@@ -33,3 +33,4 @@ base/ext4-delayed-iput.patch
 rhel8.5/ext4-filename-encode.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
 rhel8.4/ext4-optimize-find_delayed_extent.patch
+rhel8/ext4-encdata.patch
index a4237d2..139fa46 100644 (file)
@@ -33,3 +33,4 @@ base/ext4-delayed-iput.patch
 rhel8.5/ext4-filename-encode.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
 rhel8.4/ext4-optimize-find_delayed_extent.patch
+rhel8/ext4-encdata.patch
index a4237d2..139fa46 100644 (file)
@@ -33,3 +33,4 @@ base/ext4-delayed-iput.patch
 rhel8.5/ext4-filename-encode.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
 rhel8.4/ext4-optimize-find_delayed_extent.patch
+rhel8/ext4-encdata.patch
index 1cdea2b..f4e0397 100644 (file)
@@ -32,3 +32,4 @@ rhel8.5/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8.7/ext4-filename-encode.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 56a2ca3..ce4eac9 100644 (file)
@@ -33,3 +33,4 @@ ubuntu18/ext4-projid-xattrs.patch
 rhel8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-filename-encode.patch
+rhel8/ext4-encdata.patch
index 7a2cfa0..c9cddab 100644 (file)
@@ -32,3 +32,4 @@ linux-5.8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 linux-5.10/ext4-fiemap-kernel-data.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 7b0a8df..f89b93c 100644 (file)
@@ -32,3 +32,4 @@ linux-5.8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 linux-5.10/ext4-fiemap-kernel-data.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 4307894..7c650b0 100644 (file)
@@ -31,3 +31,4 @@ rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 base/ext4-projid-xattrs.patch
 linux-5.8/ext4-enc-flag.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 1bbc6ad..8458a5b 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 0a34613..0fb9961 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 444a084..1fb67e6 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index b478f85..ce35f3e 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 61646ee..a15776a 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 1ef4ab4..6d2ff66 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 1bbc6ad..8458a5b 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.4/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 5a3d93b..1099df1 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index b33bddc..cbccba0 100644 (file)
@@ -32,3 +32,4 @@ base/ext4-projid-xattrs.patch
 linux-5.8/ext4-enc-flag.patch
 base/ext4-delayed-iput.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index a1579a5..73aec00 100644 (file)
@@ -31,3 +31,4 @@ rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 base/ext4-projid-xattrs.patch
 linux-5.8/ext4-enc-flag.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch
index 9257052..a3360a8 100644 (file)
@@ -30,3 +30,4 @@ rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch
 base/ext4-projid-xattrs.patch
 linux-5.8/ext4-enc-flag.patch
 rhel8/ext4-old_ea_inodes_handling_fix.patch
+rhel8/ext4-encdata.patch