Description of problem: rename a dir1 to another existing dir2 cause dir1 glusterfs link file in .glusterfs/xx/xx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx disappear Version-Release number of selected component (if applicable): glusterfs7.0 How reproducible: Steps to Reproduce: 1> Mkdir dir1 dir2 2> Touch some files in both dir1 and dir2 3> Rename dir1 dir2 * //this will fail with “rename: dir1: rename to dir2 failed: Directory not empty” 4> Check the glusterfs link file in .glusterfs/xx/xx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx this file will disappear Actual results: Expected results: glusterfs link file should not disappear. Additional info: this issue is permanent in glusterfs7.0, very easy to reproduce.
This problem is permanent. From my investigation, for both glusterfs3.12.15 and glusterfs7.0 the root cause seems to be the posix_rename of glusterfsd side firstly unlink the glusterfs link (in posix_handle_unset) and then it fails in sys_rename(since the target already exists), then it does not restore the glusterfs link( file link 1d6febd3-875c-4879-a370-c4828e0052c3 in .glusterfs/1d/6f directory). I think the correct practice should be either restore the deleted glusterfs link file after sys_rename fail or change to firstly call sys_rename then delete the glusterfs link( I test this and seems with my code change this problem is gone). I would like your opinion on this issue, this issue is permanent, you can try in your own env. Thanks! following is the reproduce steps: 1> Mkdir dir1 dir2 2> Touch some files in both dir1 and dir2 3> Rename dir1 dir2 * //this will fail with “rename: dir1: rename to dir2 failed: Directory not empty” 4> Check the glusterfs link file in .glusterfs/xx/xx/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx this file will disappear 5> Ls dir1 when dht is enabled in glusterfs3.12 ls command fails to show dir1 contents enclosed is my test patch, with my patch there is no such issue.
Created attachment 1646749 [details] patch for ls dir return empty after rename dir to another existing dir firstly sys_rename, only remove glusterfs metadata( glusterfs gfid link file) when sys_rename has been successfully executed.
Could you send the patch for review on gerrit please?
The patch workflow is @ https://docs.gluster.org/en/latest/Developer-guide/Simplified-Development-Workflow/ but I think you already have sent patches before. :-)
https://review.gluster.org/#/c/glusterfs/+/23918/ please help to check
REVIEW: https://review.gluster.org/23918 (put sys_rename ahead of deleting gfid link) posted (#8) for review on master by None
This bug is moved to https://github.com/gluster/glusterfs/issues/1014, and will be tracked there from now on. Visit GitHub issues URL for further details
The needinfo request[s] on this closed bug have been removed as they have been unresolved for 1000 days