From: Shaun Tancheff Date: Thu, 10 Dec 2020 16:31:51 +0000 (-0600) Subject: LU-13239 ldiskfs: pass inode timestamps at initial creation X-Git-Tag: 2.14.51~96 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5bb641fa61175fd0fe63e830219d88304b5162c3 LU-13239 ldiskfs: pass inode timestamps at initial creation A previous patch https://github.com/Cray/lustre/commit/6d4fb6694 "LUS-4880 osd-ldiskfs: pass uid/gid/xtime directly to ldiskfs" was intended to be ported to upstream lustre but was lost. The patch https://review.whamcloud.com/34685/ "LU-12151 osd-ldiskfs: pass owner down rather than transfer it" passed the inode UID and GID down to ldiskfs at inode allocation time to avoid the overhead of transferring quota from the inode (initially created as root) over to the actual user of the file. The two patches differed slightly in that the LUS-4880 included passing the a/m/ctimes from osd-ldiskfs to ldiskfs at inode creation time avoids overhead of setting the timestamps afterward. Benchmarks using MDTEST: mdtest -f 32 -l 32 -n 16384 -i 5 -p 120 -t -u -v -d mdtest master patched Operation Mean Std Dev Mean Std Dev --------- ---- ------- ---- ------- Directory creation: 17008.593 72.700 17099.863 155.461 Directory stat : 170513.269 1456.002 170105.207 2349.934 Directory removal : 80796.147 2633.832 84480.222 892.536 File creation : 39227.419 7014.539 40429.900 6643.868 File stat : 101761.395 2979.802 103818.800 1146.689 File read : 86583.370 871.982 85725.254 965.862 File removal : 74923.504 761.048 75075.180 723.966 Tree creation : 588.570 244.534 608.332 123.939 Tree removal : 39.874 1.873 44.357 2.350 This patch also reorganizes the ldiskfs patch series in order to accommodate struct iattr being added to ldiskfs_create_inode. All supported server platforms RHEL 7.5+, SUSE 12+ and ubuntu 18+ are affected. HPE-bug-id: LUS-7378, LUS-4880, LUS-8042, LUS-9157, LUS-8772, LUS-8769 Signed-off-by: Shaun Tancheff Change-Id: I87e9c792b5240820bfd3a7268e477970ebac8465 Reviewed-on: https://review.whamcloud.com/37556 Reviewed-by: Petros Koutoupis Tested-by: jenkins Tested-by: Maloo Reviewed-by: Jian Yu Reviewed-by: Wang Shilong Reviewed-by: Oleg Drokin --- diff --git a/ldiskfs/kernel_patches/patches/rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch b/ldiskfs/kernel_patches/patches/rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch new file mode 100644 index 0000000..50c2e16 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch @@ -0,0 +1,105 @@ +From 3950e714298eca5bfd4955202c70b390f6f6c679 Mon Sep 17 00:00:00 2001 +From: Shaun Tancheff +Date: Wed, 2 Dec 2020 13:23:45 -0600 +Subject: [PATCH] ext4 ialloc uid gid and pass owner down + +pass inode timestamps at initial creation +--- + fs/ext4/ext4.h | 9 +++++---- + fs/ext4/ialloc.c | 12 +++++++++++- + fs/ext4/namei.c | 13 +++++++++++-- + 3 files changed, 27 insertions(+), 7 deletions(-) + +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h +index 3228967..f1446e2 100644 +--- a/fs/ext4/ext4.h ++++ b/fs/ext4/ext4.h +@@ -2331,15 +2331,16 @@ extern int ext4fs_dirhash(const char *name, int len, struct + extern struct inode *__ext4_new_inode(handle_t *, struct inode *, umode_t, + const struct qstr *qstr, __u32 goal, + uid_t *owner, int handle_type, +- unsigned int line_no, int nblocks); ++ unsigned int line_no, int nblocks, ++ struct iattr *iattr); + + #define ext4_new_inode(handle, dir, mode, qstr, goal, owner) \ + __ext4_new_inode((handle), (dir), (mode), (qstr), (goal), (owner), \ +- 0, 0, 0) ++ 0, 0, 0, NULL) + #define ext4_new_inode_start_handle(dir, mode, qstr, goal, owner, \ + type, nblocks) \ + __ext4_new_inode(NULL, (dir), (mode), (qstr), (goal), (owner), \ +- (type), __LINE__, (nblocks)) ++ (type), __LINE__, (nblocks), NULL) + + + extern void ext4_free_inode(handle_t *, struct inode *); +@@ -2463,7 +2464,7 @@ extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, + __u32 start_minor_hash, __u32 *next_hash); + extern struct inode *ext4_create_inode(handle_t *handle, + struct inode *dir, int mode, +- uid_t *owner); ++ struct iattr *iattr); + extern int ext4_delete_entry(handle_t *handle, struct inode * dir, + struct ext4_dir_entry_2 *de_del, + struct buffer_head *bh); +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c +index 844e06b..a8ab19b 100644 +--- a/fs/ext4/ialloc.c ++++ b/fs/ext4/ialloc.c +@@ -698,7 +698,8 @@ next: + struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, + umode_t mode, const struct qstr *qstr, + __u32 goal, uid_t *owner, int handle_type, +- unsigned int line_no, int nblocks) ++ unsigned int line_no, int nblocks, ++ struct iattr *iattr) + { + struct super_block *sb; + struct buffer_head *inode_bitmap_bh = NULL; +@@ -1029,6 +1030,15 @@ got: + if (err) + goto fail_drop; + ++ if (iattr) { ++ if (iattr->ia_valid & ATTR_CTIME) ++ inode->i_ctime = iattr->ia_ctime; ++ if (iattr->ia_valid & ATTR_MTIME) ++ inode->i_mtime = iattr->ia_mtime; ++ if (iattr->ia_valid & ATTR_ATIME) ++ inode->i_atime = iattr->ia_atime; ++ } ++ + err = ext4_init_acl(handle, inode, dir); + if (err) + goto fail_free_drop; +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index 81c2bfb..59a6f82 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -2895,11 +2895,20 @@ static int ext4_add_nondir(handle_t *handle, + /* Return locked inode, then the caller can modify the inode's states/flags + * before others finding it. The caller should unlock the inode by itself. */ + struct inode *ext4_create_inode(handle_t *handle, struct inode *dir, int mode, +- uid_t *owner) ++ struct iattr *iattr) + { + struct inode *inode; ++ uid_t owner[2] = {0, 0}; ++ ++ if (iattr) { ++ if (iattr->ia_valid & ATTR_UID) ++ owner[0] = from_kuid(&init_user_ns, iattr->ia_uid); ++ if (iattr->ia_valid & ATTR_GID) ++ owner[1] = from_kgid(&init_user_ns, iattr->ia_gid); ++ } ++ inode = __ext4_new_inode(handle, dir, mode, NULL, 0, owner, ++ 0, 0, 0, iattr); + +- inode = ext4_new_inode(handle, dir, mode, NULL, 0, owner); + if (!IS_ERR(inode)) { + if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) { + #ifdef CONFIG_LDISKFS_FS_XATTR +-- +2.25.1 + diff --git a/ldiskfs/kernel_patches/patches/rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch b/ldiskfs/kernel_patches/patches/rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch new file mode 100644 index 0000000..0fbddc5 --- /dev/null +++ b/ldiskfs/kernel_patches/patches/rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch @@ -0,0 +1,103 @@ +From ead0a400ed5f3621b2450a5da61c2295a224e002 Mon Sep 17 00:00:00 2001 +From: Shaun Tancheff +Date: Wed, 2 Dec 2020 13:02:37 -0600 +Subject: [PATCH] ext4 ialloc uid gid and pass owner down + +pass inode timestamps at initial creation +--- + fs/ext4/ext4.h | 8 ++++---- + fs/ext4/ialloc.c | 11 ++++++++++- + fs/ext4/namei.c | 13 +++++++++++-- + 3 files changed, 25 insertions(+), 7 deletions(-) + +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h +index f2ed50c..548bb43 100644 +--- a/fs/ext4/ext4.h ++++ b/fs/ext4/ext4.h +@@ -2549,15 +2549,15 @@ extern struct inode *__ext4_new_inode(handle_t *, struct inode *, umode_t, + const struct qstr *qstr, __u32 goal, + uid_t *owner, __u32 i_flags, + int handle_type, unsigned int line_no, +- int nblocks); ++ int nblocks, struct iattr *iattr); + + #define ext4_new_inode(handle, dir, mode, qstr, goal, owner, i_flags) \ + __ext4_new_inode((handle), (dir), (mode), (qstr), (goal), (owner), \ +- i_flags, 0, 0, 0) ++ i_flags, 0, 0, 0, NULL) + #define ext4_new_inode_start_handle(dir, mode, qstr, goal, owner, \ + type, nblocks) \ + __ext4_new_inode(NULL, (dir), (mode), (qstr), (goal), (owner), \ +- 0, (type), __LINE__, (nblocks)) ++ 0, (type), __LINE__, (nblocks), NULL) + + + extern void ext4_free_inode(handle_t *, struct inode *); +@@ -2695,7 +2695,7 @@ extern int ext4_orphan_add(handle_t *, struct inode *); + extern int ext4_orphan_del(handle_t *, struct inode *); + extern struct inode *ext4_create_inode(handle_t *handle, + struct inode *dir, int mode, +- uid_t *owner); ++ struct iattr *iattr); + extern int ext4_delete_entry(handle_t *handle, struct inode * dir, + struct ext4_dir_entry_2 *de_del, + struct buffer_head *bh); +diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c +index e771142..364fb49 100644 +--- a/fs/ext4/ialloc.c ++++ b/fs/ext4/ialloc.c +@@ -744,7 +744,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, + umode_t mode, const struct qstr *qstr, + __u32 goal, uid_t *owner, __u32 i_flags, + int handle_type, unsigned int line_no, +- int nblocks) ++ int nblocks, struct iattr *iattr) + { + struct super_block *sb; + struct buffer_head *inode_bitmap_bh = NULL; +@@ -1143,6 +1143,15 @@ got: + if (err) + goto fail_drop; + ++ if (iattr) { ++ if (iattr->ia_valid & ATTR_CTIME) ++ inode->i_ctime = iattr->ia_ctime; ++ if (iattr->ia_valid & ATTR_MTIME) ++ inode->i_mtime = iattr->ia_mtime; ++ if (iattr->ia_valid & ATTR_ATIME) ++ inode->i_atime = iattr->ia_atime; ++ } ++ + /* + * Since the encryption xattr will always be unique, create it first so + * that it's less likely to end up in an external xattr block and +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index 5d03e3a..dbb5a61 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -3029,11 +3029,20 @@ static int ext4_add_nondir(handle_t *handle, + /* Return locked inode, then the caller can modify the inode's states/flags + * before others finding it. The caller should unlock the inode by itself. */ + struct inode *ext4_create_inode(handle_t *handle, struct inode *dir, int mode, +- uid_t *owner) ++ struct iattr *iattr) + { + struct inode *inode; ++ uid_t owner[2] = {0, 0}; + +- inode = ext4_new_inode(handle, dir, mode, NULL, 0, owner, 0); ++ if (iattr) { ++ if (iattr->ia_valid & ATTR_UID) ++ owner[0] = from_kuid(&init_user_ns, iattr->ia_uid); ++ if (iattr->ia_valid & ATTR_GID) ++ owner[1] = from_kgid(&init_user_ns, iattr->ia_gid); ++ } ++ ++ inode = __ext4_new_inode(handle, dir, mode, NULL, 0, owner, 0, ++ 0, 0, 0, iattr); + if (!IS_ERR(inode)) { + if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) { + #ifdef CONFIG_LDISKFS_FS_XATTR +-- +2.25.1 + diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series index ad0d05a..d051d3b 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series @@ -49,3 +49,4 @@ rhel7.6/ext4-cleanup-flag-definitions-for-extent-status-tree.patch rhel7.6/ext4-introduce-aging-to-extent-status-tree.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch rhel7.6/ext4-dquot-commit-speedup.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series index 88c5369..da4cf53 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series @@ -49,3 +49,4 @@ rhel7.6/ext4-cleanup-flag-definitions-for-extent-status-tree.patch rhel7.6/ext4-introduce-aging-to-extent-status-tree.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch rhel7.6/ext4-dquot-commit-speedup.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.8.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.8.series index 8ee2757..8178924 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.8.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.8.series @@ -42,3 +42,4 @@ rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7.7/ext4-mballoc-prefetch.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch rhel7.6/ext4-dquot-commit-speedup.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.9.series b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.9.series index e3e094e..dceb035 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.9.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.9.series @@ -42,3 +42,4 @@ rhel7.6/ext4-mballoc-skip-uninit-groups-cr0.patch rhel7.7/ext4-mballoc-prefetch.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch rhel7.6/ext4-dquot-commit-speedup.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15-22.series b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15-22.series index 97219b3..a4c776c 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15-22.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15-22.series @@ -26,3 +26,4 @@ rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.6/ext4-export-orphan-add.patch suse15/ext4-export-mb-stream-allocator-variables.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15.series b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15.series index 3f7a3f8..b7bb0f6 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15.series @@ -26,3 +26,4 @@ rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.6/ext4-export-orphan-add.patch suse15/ext4-export-mb-stream-allocator-variables.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1-7.series b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1-7.series index 97219b3..a4c776c 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1-7.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1-7.series @@ -26,3 +26,4 @@ rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.6/ext4-export-orphan-add.patch suse15/ext4-export-mb-stream-allocator-variables.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1.series b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1.series index fc12701..2fc137d 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.12-sles15sp1.series @@ -26,3 +26,4 @@ rhel7.6/ext4-optimize-ext4_find_delalloc_range-in-nodelalloc.patch rhel7.6/ext4-export-orphan-add.patch suse15/ext4-export-mb-stream-allocator-variables.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series index cee3584..ee17a3e 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series @@ -23,3 +23,4 @@ rhel7.6/ext4-export-orphan-add.patch rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel7.7/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series index 327749a..e4800b8 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series @@ -24,3 +24,4 @@ rhel7.6/ext4-mmp-dont-mark-bh-dirty.patch ubuntu18/ext4-include-terminating-u32-in-size-of-xattr-entries-when-expanding-inodes.patch suse15/ext4-export-mb-stream-allocator-variables.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series index b21f8e2..e18f0d9 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.1.series @@ -26,3 +26,4 @@ rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch rhel8.1/ext4-mballoc-prefetch.patch rhel8/ext4-xattr-disable-credits-check.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.2.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.2.series index fb46704..9c53636 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.2.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.2.series @@ -26,3 +26,4 @@ rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch rhel8.1/ext4-mballoc-prefetch.patch rhel8/ext4-xattr-disable-credits-check.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.3.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.3.series index 512ff36..b92964a 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.3.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.3.series @@ -26,3 +26,4 @@ rhel8/ext4-mballoc-skip-uninit-groups-cr0.patch rhel8.1/ext4-mballoc-prefetch.patch rhel8.3/ext4-xattr-disable-credits-check.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series index a59cc33a..9f91efd 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series @@ -28,3 +28,4 @@ rhel8/ext4-mballoc-prefetch.patch rhel8/ext4-xattr-disable-credits-check.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch base/ext4-reset-exts-for-gcc10.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series b/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series index a8315e4..76cfc98 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series @@ -24,3 +24,4 @@ rhel8/ext4-export-mb-stream-allocator-variables.patch ubuntu19/ext4-iget-with-flags.patch rhel8/ext4-simple-blockalloc.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-42-ubuntu20.series b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-42-ubuntu20.series index 0e439de..ca3f98f 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-42-ubuntu20.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-42-ubuntu20.series @@ -26,3 +26,4 @@ linux-5.4/export-ext4fs-dirhash-helper.patch linux-5.4/ext4-misc.patch rhel8/ext4-simple-blockalloc.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series index 571d739..0a71c7f 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.4.0-ml.series @@ -26,3 +26,4 @@ linux-5.4/export-ext4fs-dirhash-helper.patch linux-5.4/ext4-misc.patch rhel8/ext4-simple-blockalloc.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/ldiskfs/kernel_patches/series/ldiskfs-5.4.21-ml.series b/ldiskfs/kernel_patches/series/ldiskfs-5.4.21-ml.series index 0e439de..ca3f98f 100644 --- a/ldiskfs/kernel_patches/series/ldiskfs-5.4.21-ml.series +++ b/ldiskfs/kernel_patches/series/ldiskfs-5.4.21-ml.series @@ -26,3 +26,4 @@ linux-5.4/export-ext4fs-dirhash-helper.patch linux-5.4/ext4-misc.patch rhel8/ext4-simple-blockalloc.patch base/ext4-no-max-dir-size-limit-for-iam-objects.patch +rhel8/ext4-ialloc-uid-gid-and-pass-owner-down.patch diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 300d090..97fceb3 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -3226,12 +3226,21 @@ static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj, struct osd_thandle *oth; struct dt_object *parent = NULL; struct inode *inode; - uid_t owner[2] = {0, 0}; + struct iattr iattr = { + .ia_valid = ATTR_UID | ATTR_GID | + ATTR_CTIME | ATTR_MTIME | ATTR_ATIME, + .ia_ctime.tv_sec = attr->la_ctime, + .ia_mtime.tv_sec = attr->la_mtime, + .ia_atime.tv_sec = attr->la_atime, + .ia_uid = GLOBAL_ROOT_UID, + .ia_gid = GLOBAL_ROOT_GID, + }; + const struct osd_timespec omit = { .tv_nsec = UTIME_OMIT }; if (attr->la_valid & LA_UID) - owner[0] = attr->la_uid; + iattr.ia_uid = make_kuid(&init_user_ns, attr->la_uid); if (attr->la_valid & LA_GID) - owner[1] = attr->la_gid; + iattr.ia_gid = make_kgid(&init_user_ns, attr->la_gid); LINVRNT(osd_invariant(obj)); LASSERT(obj->oo_inode == NULL); @@ -3251,10 +3260,18 @@ static int osd_mkfile(struct osd_thread_info *info, struct osd_object *obj, !dt_object_remote(hint->dah_parent)) parent = hint->dah_parent; + /* if a time component is not valid set it to UTIME_OMIT */ + if (!(attr->la_valid & LA_CTIME)) + iattr.ia_ctime = omit; + if (!(attr->la_valid & LA_MTIME)) + iattr.ia_mtime = omit; + if (!(attr->la_valid & LA_ATIME)) + iattr.ia_atime = omit; + inode = ldiskfs_create_inode(oth->ot_handle, parent ? osd_dt_obj(parent)->oo_inode : osd_sb(osd)->s_root->d_inode, - mode, owner); + mode, &iattr); if (!IS_ERR(inode)) { /* Do not update file c/mtime in ldiskfs. */ inode->i_flags |= S_NOCMTIME; @@ -3945,7 +3962,15 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, struct osd_thread_info *info = osd_oti_get(env); struct inode *local; struct osd_thandle *oh; - uid_t own[2] = {0, 0}; + struct iattr iattr = { + .ia_valid = ATTR_UID | ATTR_GID | + ATTR_CTIME | ATTR_MTIME | ATTR_ATIME, + .ia_ctime.tv_nsec = UTIME_OMIT, + .ia_mtime.tv_nsec = UTIME_OMIT, + .ia_atime.tv_nsec = UTIME_OMIT, + .ia_uid = GLOBAL_ROOT_UID, + .ia_gid = GLOBAL_ROOT_GID, + }; int rc; ENTRY; @@ -3954,7 +3979,8 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env, oh = container_of(th, struct osd_thandle, ot_super); LASSERT(oh->ot_handle->h_transaction != NULL); - local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, type, own); + local = ldiskfs_create_inode(oh->ot_handle, pobj->oo_inode, + type, &iattr); if (IS_ERR(local)) { CERROR("%s: create local error %d\n", osd_name(osd), (int)PTR_ERR(local));