Rename temp-files under lock to prevent metadata reads while renaming