Ah, I think I understand where my confusion is. Am I correct that you are separating the use of "lfs migrate -m N" to mean "migrate parent directory with all inodes to new MDT 'N'" and "lfs migrate -m N -c -1" to mean the new "split parent directory but leave inodes in place" code that you are working on? I think that "migrate" should generally mean "move inodes to new MDT", while "MDT auto split" should not move existing inodes since that will change inode numbers/locks and could cause problems. I think it is useful to have the meaning of "lfs migrate -m N -c C" for directories be similar to "lfs migrate -i N -c C" for regular files, where "N = -1" means "pick the target index for me" and "C = -1" means "stripe over all targets".
Being able to specify "split directory now" is important for testing, but maybe a different command like "lfs setstripe -c <dir>" on the existing directory is the right command for splitting the directory to have a different number of stripes? For stripe_count=1 directories it is possible to add any kind of hash function to the existing directory, so "crush" would be preferred, and then setting the number of stripes would just migrate the names without affecting the inodes?
I also agree that a simple implementation of "lfs migrate -m -1" might not pick the best MDTs, but users (other than you and me) are even less likely to pick the best MDTs. That means that the implementation of "-m -1" needs to be smart enough that it picks good MDTs when possible.
It should be possible to disable MDTs for new directory creation (similar to "lfs set_param osp.$fsname-OST0000.max_create_count=0" for OSTs) so that the MDS does not put new directories on that MDT. That will allow an MDT to be emptied out with a command like "lfs find -type d -m N | lfs migrate -m -1" without the user having to specify the target for every directory.
Also, when the user is doing MDT balancing, the use of "lfs migrate -m -1" needs to move some directories and inodes to the empty MDTs instead of just splitting existing directories onto new MDTs and not moving any inodes, otherwise the full MDT will not be any less full. Maybe this can be done by weighting the current MDT higher than other MDTs but not keep all directories/inodes on the original MDT (e.g. using qos_mdt_prio_free)?
Landed for 2.15