I have submitted a patch from Dmitry Ivanov that seems to address this issue, by detecting whether a directory is striped using XATTR_NAME_LMV and if so, using mdd_parent_fid() to obtain the real parent FID for use in the generated changelog record:
# git describe
v2_15_56-1-g80258995e4
# lfs mkdir -i -1 -c 2 /mnt/lustre/testdir0
# lctl get_param mdd.*.changelog_striped_dir_real_pfid
mdd.lustre-MDT0000.changelog_striped_dir_real_pfid=0
mdd.lustre-MDT0001.changelog_striped_dir_real_pfid=0
# lfs getdirstripe /mnt/lustre/testdir0
lmv_stripe_count: 2 lmv_stripe_offset: 0 lmv_hash_type: crush
mdtidx FID[seq:oid:ver]
0 [0x200000400:0x2:0x0]
1 [0x240000401:0x2:0x0]
# lfs path2fid /mnt/lustre/testdir0
[0x200000402:0x1:0x0]
# touch /mnt/lustre/testdir0/testfile0
# lfs changelog lustre-MDT0000; lfs changelog lustre-MDT0001
...
2 01CREAT 21:46:35.984819711 2023.06.14 0x0 t=[0x200000402:0x2:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo p=[0x200000400:0x2:0x0] testfile0
3 11CLOSE 21:46:36.028827790 2023.06.14 0x42 t=[0x200000402:0x2:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo
# lctl set_param mdd.*.changelog_striped_dir_real_pfid=1
mdd.lustre-MDT0000.changelog_striped_dir_real_pfid=1
mdd.lustre-MDT0001.changelog_striped_dir_real_pfid=1
# lctl get_param mdd.*.changelog_striped_dir_real_pfid
mdd.lustre-MDT0000.changelog_striped_dir_real_pfid=1
mdd.lustre-MDT0001.changelog_striped_dir_real_pfid=1
# touch /mnt/lustre/testdir0/testfile1
# lfs changelog lustre-MDT0000; lfs changelog lustre-MDT0001
...
2 01CREAT 21:46:35.984819711 2023.06.14 0x0 t=[0x200000402:0x2:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo p=[0x200000400:0x2:0x0] testfile0
3 11CLOSE 21:46:36.028827790 2023.06.14 0x42 t=[0x200000402:0x2:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo
4 01CREAT 21:47:08.772277807 2023.06.14 0x0 t=[0x200000402:0x3:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo p=[0x200000402:0x1:0x0] testfile1
5 11CLOSE 21:47:08.831376478 2023.06.14 0x42 t=[0x200000402:0x3:0x0] j=touch.0 ef=0xf u=0:0 nid=0@lo
Sergey Cheremencev had shown that this patch can result in an increased number of cross-MDT RPCs, so the added functionality needs to be explicitly enabled by setting the changelog_striped_dir_real_pfid tunable and is disabled by default. There have been some discussions re the possibility of avoiding the extra cross-MDT RPCs by obtaining the real parent fid from the parent's REMOTE_PARENT_DIR entry's linkEA, but Vitaly reckoned this would still require some RPCs in cases where the parent's fid is in a different MDT. Unfortunately, I am not sure if this is accurate and/or if we could add any additional information to the REMOTE_PARENT_DIR entries to use them for avoiding the extra RPCs in this case?
Landed for 2.16