Merge pull request #1303 from gaul/rename/use_cache

Relink cache stats file atomically via rename
This commit is contained in:
Takeshi Nakatani 2020-06-01 00:10:33 +09:00 committed by GitHub
commit 0cb057dadd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1531,13 +1531,9 @@ bool FdEntity::RenamePath(const string& newpath, string& fentmapkey)
return false;
}
// link and unlink cache file
if(-1 == link(cachepath.c_str(), newcachepath.c_str())){
S3FS_PRN_ERR("failed to link old cache path(%s) to new cache path(%s) by errno(%d).", cachepath.c_str(), newcachepath.c_str(), errno);
return false;
}
if(-1 == unlink(cachepath.c_str())){
S3FS_PRN_ERR("failed to unlink old cache path(%s) by errno(%d).", cachepath.c_str(), errno);
// rename cache file
if(-1 == rename(cachepath.c_str(), newcachepath.c_str())){
S3FS_PRN_ERR("failed to rename old cache path(%s) to new cache path(%s) by errno(%d).", cachepath.c_str(), newcachepath.c_str(), errno);
return false;
}