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 <shaun.tancheff@hpe.com>
Change-Id: I87e9c792b5240820bfd3a7268e477970ebac8465
Reviewed-on: https://review.whamcloud.com/37556
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
--- /dev/null
+From 3950e714298eca5bfd4955202c70b390f6f6c679 Mon Sep 17 00:00:00 2001
+From: Shaun Tancheff <shaun.tancheff@hpe.com>
+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
+
--- /dev/null
+From ead0a400ed5f3621b2450a5da61c2295a224e002 Mon Sep 17 00:00:00 2001
+From: Shaun Tancheff <shaun.tancheff@hpe.com>
+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
+
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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);
!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;
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;
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));