Overall I think this looks like a reasonable restructuring, and it works in a few manual tests of existing hardlinks on my system. Until #8879 goes in, we can't really add tests for this.
Hirokazu, do you want to commit this since you came up with it?