[LU-11739] Don't inherit default layout from root for new subdirectories Created: 07/Dec/18  Updated: 20/Oct/20  Resolved: 04/Oct/19

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.12.0, Lustre 2.10.6
Fix Version/s: Lustre 2.13.0, Lustre 2.10.7, Lustre 2.12.4

Type: Improvement Priority: Critical
Reporter: Andreas Dilger Assignee: Jian Yu
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by LU-12433 subdir under ROOT should honor ROOT d... Resolved
Related
is related to LU-11875 "lfs find" does not return directorie... Open
is related to LU-11995 sanity test_65n returned 127 Resolved
is related to LU-9982 Clients striping from mapped FID in n... Open
is related to LU-12643 PFL layout don't inherit correctly fr... Open
is related to LU-11656 "lfs getstripe" on directory does not... Resolved
is related to LU-11920 memory leak in lod_lds_buf_get() Resolved
Rank (Obsolete): 9223372036854775807

 Description   

There is no need to inherit the default directory layout from the root directory when subdirectories are created therein. This consumes xattr space on the subdirectories, and makes it more complex to change the filesystem default layout in the future.

Instead, it should be possible to check if the parent directory is the root directory and not copy the default layout xattr to the new subdirectory.



 Comments   
Comment by Jian Yu [ 31/Dec/18 ]

The change needs to be made in lod_ah_init() in lustre/lod/lod_object.c. I'm creating the patch.

Comment by Gerrit Updater [ 03/Jan/19 ]

Jian Yu (yujian@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/33956
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: a55f947c5a70ba6eb9fab077683dafbf1049a788

Comment by Andreas Dilger [ 08/Jan/19 ]

In all cases, new subdirectories under root should not explicitly inherit the file layout from the root (we cannot specify the default file layout at the same time the directory is created, so your 1b) case above cannot happen, unless the default file layout is explicitly specified after the directory is created).

This avoids the case where the filesystem-wide default layout is set on the root directory of a new filesystem, and then every subdirectory created in the filesystem explicitly inherits this filesystem-wide layout. Then, if the filesystem-wide "default" layout changes, none of the new files created use this new default because every parent directory already has an old explicitly inherited layout that is being used instead.

We need the explicit inheritance behaviour for subdirectories because we can't walk the whole directory tree on every file create to find if some parent-of-parent has a default file layout that we should be inheriting. However, we should consider whether an explicit layout should be inherited from a parent directory that is exactly the same as the filesystem default layout? On the plus side, always inheriting the parent layout avoids some overhead to compare an explicit parent directory layout against the filesystem-wide default layout. On the minus side, this continues the issue that currently exists with explicitly-inherited default layouts. If we don't explicitly inherit a layout from the parent that matches the filesystem-wide default, it would slowly improve existing filesystems by preventing the spread of explicit-but-fs-default layouts.

In such cases, it might make sense to add a tunable to control the "inherit filesystem-wide default file layout from parent" behaviour (e.g. lod.*.stripe_inherit_default or similar, but default the tunable to be off (which is IMHO the better long-term solution), and allow it to be enabled if this is the wrong choice for some reason.

Comment by Jian Yu [ 13/Jan/19 ]

Hi Andreas,

Before adding the implementation of lod.*.stripe_inherit_default, I did some tests to verify patch https://review.whamcloud.com/33956. Here are the test results:

# getfattr -n trusted.lov /mnt/lustre
/mnt/lustre: trusted.lov: No such attribute

# mkdir /mnt/lustre/olddir
# getfattr -n trusted.lov /mnt/lustre/olddir
/mnt/lustre/olddir: trusted.lov: No such attribute

# lfs setstripe -S 8M /mnt/lustre
# getfattr -n trusted.lov /mnt/lustre
getfattr: Removing leading '/' from absolute path names
# file: mnt/lustre
trusted.lov=0s0AvRCwEAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAA//8=

# mkdir /mnt/lustre/newdir
# getfattr -n trusted.lov /mnt/lustre/newdir
/mnt/lustre/newdir: trusted.lov: No such attribute                <------ newdir didn't inherit root directory default layout

# lfs setstripe -p pool /mnt/lustre
# getfattr -n trusted.lov /mnt/lustre
getfattr: Removing leading '/' from absolute path names
# file: mnt/lustre
trusted.lov=0s0AvTCwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//9wb29sAAAAAAAAAAAAAAAA

# mkdir /mnt/lustre/newdir_pool
# getfattr -n trusted.lov /mnt/lustre/newdir_pool
/mnt/lustre/newdir_pool: trusted.lov: No such attribute       <------ newdir_pool didn't inherit root directory default layout

# lfs setstripe -S 4M -p pool /mnt/lustre/newdir_pool
# getfattr -n trusted.lov /mnt/lustre/newdir_pool
getfattr: Removing leading '/' from absolute path names
# file: mnt/lustre/newdir_pool
trusted.lov=0s0AvTCwEAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAA//9wb29sAAAAAAAAAAAAAAAA

# mkdir /mnt/lustre/newdir_pool/subdir
# getfattr -n trusted.lov /mnt/lustre/newdir_pool/subdir
getfattr: Removing leading '/' from absolute path names
# file: mnt/lustre/newdir_pool/subdir
trusted.lov=0s0AvTCwEAAAAEAAAAAAAAAAEEAAACAAAAAABAAAAA//9wb29sAAAAAAAAAAAAAAAA  <------ subdir inherited non-root parent directory default layout

Could you please take a look at the above test results to see if they are as expected? Thank you.

Comment by Andreas Dilger [ 13/Jan/19 ]

Yes, I think this looks correct.

Comment by Patrick Farrell (Inactive) [ 22/Jan/19 ]

There are references here to some sort of file system wide default layout.  I wasn't aware that was a possibility - Is there (or could someone give  ) a quick explanation of that and how to interact with it?  I just thought you had directory level defaults (optionally set by users/admins) and built-in system defaults (defined in the code).

Comment by Andreas Dilger [ 22/Jan/19 ]

The old-style "filesystem wide" plain defaults (used in case everything else fails) are stored in the lov_descriptor for the filesystem from the mkfs.lustre --param lov.stripesize and similar options. They can also be set via lctl conf_param on the MGS.

However, for quite a few releases, the more common interface for setting the filesystem-wide default is to use "lfs setstripe" as root to set a default layout on the root directory of the filesystem. This allows complex default layouts (e.g. pools, PFL, FLR, etc) to be set for the filesystem.

This is mentioned in the man page for lfs-setstripe.1:

DESCRIPTION
       The lfs setstripe command is used to create a new file in
       a Lustre filesystem with the specified layout, or to specify
       the default layout for new files created in directory, or
       anywhere in the filesystem if directory is the filesystem root
       and no other layout takes precedence.

       Files with composite layouts allow different STRIPE_OPTIONS to
       be specified for non-overlapping extents of the file.  Files
       will inherit options not explicitly specified on the command
       line either from the default layout on the parent directory, or
       from the filesystem-wide default.  The default layout set on a
       directory will be copied to any new subdirectories created within
       that directory at the time they are created.

However, I note that this text needs to be updated to reflect that the filesystem default layout will not be explicitly copied to subdirectories under the root directory and their children to ensure that the filesystem default layout continues to be applied to those directories if the default is changed.

Comment by Patrick Farrell (Inactive) [ 22/Jan/19 ]

Thanks, Andreas - Nice to have the background here.

Comment by Jinshan Xiong [ 26/Jan/19 ]

I think system-wide default layout needs a new way of definition. For example, we can use one bit in the layout to specify that a directory should apply system default layout(like a layout pointer).

This patch makes root directory different from the other directories, which seems confusing from my point of view.

Comment by Andreas Dilger [ 27/Jan/19 ]

Actually, it isn't really different than other directories in that they do inherit the layout from the parent, they just don't make a copy. That avoids copying the current default layout all the way from the root directory down to all the subdirectories and then if the default changes there are a thousand copies of the old default around the filesystem.

Comment by Gerrit Updater [ 30/Jan/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/33956/
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 0a988cae95f99fee1a9c0d489ce00d0954d2a68e

Comment by Gerrit Updater [ 30/Jan/19 ]

Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/34135
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: 2c55161aab2c6ed7cd0cf25b6d6b27a27bc9b932

Comment by Gerrit Updater [ 30/Jan/19 ]

Jian Yu (yujian@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/34139
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: b2_10
Current Patch Set: 1
Commit: 79cbd455b9d33d5942328046fbf62b0e7f83b73d

Comment by Peter Jones [ 30/Jan/19 ]

Landed for 2.13

Comment by Gerrit Updater [ 23/Feb/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/34139/
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: b2_10
Current Patch Set:
Commit: ff53b1a267feee05094414e6eb4b4cd75033e1e6

Comment by Gerrit Updater [ 19/Mar/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/34135/
Subject: LU-11739 lod: don't inherit default layout from root directory
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: 6ceb90a2461e2724121a6c26434e11bcb31c9f43

Comment by Lai Siyao [ 09/May/19 ]

This patch looks wrong to me: in lod_ah_init(), if parent directory is ROOT, it skips reading default layout, which means subdirs under ROOT don't follow default layout, while in my understanding it need to read default layout anyway, and then use it to decide child layout, but it doesn't inherit this default layout (by clearing it after use).

Comment by Andreas Dilger [ 18/May/19 ]

Lai, could you please put your comments in the form of a test case, to verify if this is working or broken. If it is broken, then we can use your patch to verify it is working when it is fixed.

Comment by Lai Siyao [ 22/May/19 ]

Okay, I'll work on it after vacation.

Comment by Gerrit Updater [ 12/Jun/19 ]

Lai Siyao (lai.siyao@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/35204
Subject: LU-11739 lod: subdir under ROOT should honor default layout
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 3a615a0fbd184015e2aea4e5a02015f054a4698b

Comment by Andreas Dilger [ 30/Sep/19 ]

There is a patch that has not been landed yet.

Comment by Gerrit Updater [ 04/Oct/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/35204/
Subject: LU-11739 lod: subdir under ROOT should honor default layout
Project: fs/lustre-release
Branch: master
Current Patch Set:
Commit: 693fb63ac777eab426f1b618316a5649534759ad

Comment by Peter Jones [ 04/Oct/19 ]

Landed for 2.13

Comment by Gerrit Updater [ 04/Oct/19 ]

Minh Diep (mdiep@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/36370
Subject: LU-11739 lod: subdir under ROOT should honor default layout
Project: fs/lustre-release
Branch: b2_12
Current Patch Set: 1
Commit: ba7427ac4dfbee42e34ba3b1b6a9a7b33e8c89dc

Comment by Gerrit Updater [ 21/Nov/19 ]

Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36370/
Subject: LU-11739 lod: subdir under ROOT should honor default layout
Project: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: a53869aa31ceee700215520e5267b155a0f59d46

Generated at Sat Feb 10 02:46:30 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.