Hi Andreas,
As per your suggestions, fetching default layout for a directory will be done in lfs_getstripe()->...->cb_getstripe(). If get_lmd_info() returns -ENODATA for a directory that does not have trusted.lov xattr, cb_getstripe() should get the lov_user_md data from ROOT FID, and then print the layout information in llapi_lov_dump_user_lmm().
One solution would be to special-case the [FID_SEQ_ROOT, FID_OID_ROOT, 0] lookup in the directory in ioctl(IOC_MDC_GETFILESTRIPE) to convert this ioctl onto the actual ROOT FID, since this is out of the critical code path, and is unlikely to cause any problems for existing files. It should treat -ENOENT as -ENODATA, in case it is running on an old client that does not have this feature, and it will just keep the same behaviour as today.
That will probably involve taking the core of ll_lov_getstripe_ea_info() into a separate helper function that allows passing the ROOT FID, while the original ll_lov_getstripe_ea_info() gets the FID from inode.
One upcoming issue with explicitly using the ROOT FID is that this will complicate things is the patch https://review.whamcloud.com/28972 "LU-9982 lustre: Clients striping from mapped FID in nodemap", since that feature will allow clients to inherit layouts from a non-ROOT directory based on their nodemap. In that case, it might make sense to handle the ROOT FID getstripe to be mapped to the nodemap root layout (if set) so that the "lfs getstripe" output is consistent.
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37072/
Subject:
LU-11656llite: fetch default layout for a directoryProject: fs/lustre-release
Branch: b2_12
Current Patch Set:
Commit: ca373442fc15a6dc77dcce36e91847c58ac45c03