It might check if the cluster numbers are same between source entry
and target directory.
This checks if newdir is the move target itself.
Example:
mv /mnt/dir0 /mnt/dir0/foo
However, this check is not enough.
We need to check newdir and all ancestors.
Example:
mv /mnt/dir0 /mnt/dir0/dir1/foo
mv /mnt/dir0 /mnt/dir0/dir1/dir2/foo
...
This is probably a taboo for all layered filesystems.
Could you let me know what code you mentioned?
Or do you mean the codes on vfs?
You can find in do_renameat2(). --- around 'fs/namei.c:4440'
If the destination ancestors are itself, our driver will not be called.
I think, of course, vfs has been doing that.
So that code is unnecessary in normal situations.
That code comes from the old exfat implementation.
And as far as I understand, it seems to check once more "the cluster number"
even though it comes through vfs so that it tries detecting abnormal of on-disk.
Anyway, I agonized if it is really needed.
In conclusion, old code could be eliminated and your patch looks reasonable.