I don't think it makes sense to wait for dir restripe, since that will be at least one release away, and will only balance large directories. Being able to balance small directories on a regular basis is more important for regular usage. I don't think it makes sense to limit space-hashed directories to only be used on ROOT, since they can be very useful for e.g. top-level user directories (to distribute their files across MDTs).
I think the main issue is if new subdirectories below a space-hash directory are always created as striped:
/*
* "space" hash type can only be set in default LMV, child use
* FNV_1A_64 in case it's striped.
*/
if (lo->ldo_dir_hash_type == LMV_HASH_TYPE_SPACE)
lo->ldo_dir_hash_type = LMV_HASH_TYPE_FNV_1A_64;
I think it makes sense to move the lum_stripe_count check into lod_striping_from_default() so lum_stripe_count=0 or lum_stripe_count=1 would create a plain subdirectory, otherwise, the directory would be created with the specified parameters in lmv_user_md_v1., which makes the code more clear:
} else if (lds->lds_dir_def_striping_set && S_ISDIR(mode)) {
:
:
if (lo->ldo_dir_stripe_count <= 1) {
lo->ldo_dir_hash_type = LMV_HASH_TYPE_NONE;
lo->ldo_dir_stripe_count = 0;
}
/*
* "space" hash type can only be set in default LMV, child use
* FNV_1A_64 in case it's striped.
*/
if (lo->ldo_dir_hash_type == LMV_HASH_TYPE_SPACE)
lo->ldo_dir_hash_type = LMV_HASH_TYPE_FNV_1A_64;
However, this only allows setting the hash type to FNV_1A_64, which may be limiting in the future.
One option would be to change lum_hash_type to be like LOV_PATTERN_* and have a 16-bit mask in the high bits and a 16-bit type, and put LMV_HASH_FLAG_SPACE in the mask part, and let the low bits store LMV_HASH_TYPE_FNV_1A_64 or LMV_HASH_TYPE_ALL_CHARS or LMV_HASH_TYPE_UNKNOWN (which should be renamed to LMV_HASH_TYPE_NONE) to indicate what type of subdirectory should be created.
For the inherited layout, the lum_hash_type would be inherited if lum_inherit_count > 0 and cleared once lum_inherit_count == 0 to only create plain directories below that.
This was largely implemented in patch https://review.whamcloud.com/44090 "
LU-14792llite: enable filesystem-wide default LMV" using "lum_stripe_offset = -1" and remote 1-stripe directories to do space balancing.LMV_HASH_TYPE_SPACE was renamed to LMV_HASH_FLAG_SPACE in patch https://review.whamcloud.com/35318 "
LU-11213uapi: change 'space' hash type to hash flag" and removed entirely in patch https://review.whamcloud.com/35825 "LU-12624lod: alloc dir stripes by QoS"