mds: wrongly treat symlink inode as normal file/dir when symlink inode is stale on kcephfs
This issue should happen on kcephfs only. My kernel version is 3.10.94. I think it might also happen on other 3.x versions.
Steps to reproduce on kcephfs:
1. Create a symlink to a directory, both are on kcephfs.
2. Use opendir/readdir function to open/read this symlink. It will succeed at this time.
3. Wait for some time or just umount cephfs and remount it for quick validation.
4. Just Use opendir/readdir function to open/read this symlink again without any other ops before opendir. Now it will fail.
The root cause is that after some time, this symlink's inode lease will be invalid (function: ceph_d_revalidate). When accessing this inode next time, kcephfs uses atomic_open on it and send related req to MDS. MDS treats this inode as a file but its flag is O_DIRECTORY, so MDS return EINVAL to client. Similar reason when using umounting/remounting for valication.
The fix could be checking if this indoe is symlink on MDS side for atomic_open. If it is, MSD could return this inode's info to client, then client could fill this inode with correct info and set inode's iop to symlink iops. Then kernel will retry on this symlink.
#2 Updated by Zhi Zhang over 5 years ago
I have tried to backport Yan's following patch, which can only resolve this issue when symlink dentry is invalid, but can't fully resolve it if umounting/remounting cephfs again.
So I made above change on MDS side, which can resolve both cases.