Do not fail updating directory when removing old-style object(ref #658)

This commit is contained in:
Takeshi Nakatani 2017-10-15 05:03:44 +00:00
parent 21cf1d64e5
commit 41206fa0e2

View File

@ -138,6 +138,7 @@ static s3fs_log_level set_s3fs_log_level(s3fs_log_level level);
static s3fs_log_level bumpup_s3fs_log_level(void);
static bool is_special_name_folder_object(const char* path);
static int chk_dir_object_type(const char* path, string& newpath, string& nowpath, string& nowcache, headers_t* pmeta = NULL, int* pDirType = NULL);
static int remove_old_type_dir(const string& path, int dirtype);
static int get_object_attribute(const char* path, struct stat* pstbuf, headers_t* pmeta = NULL, bool overcheck = true, bool* pisforce = NULL, bool add_no_truncate_cache = false);
static int check_object_access(const char* path, int mask, struct stat* pstbuf);
static int check_object_owner(const char* path, struct stat* pstbuf);
@ -391,6 +392,21 @@ static int chk_dir_object_type(const char* path, string& newpath, string& nowpat
return result;
}
static int remove_old_type_dir(const string& path, int dirtype)
{
if(IS_RMTYPEDIR(dirtype)){
S3fsCurl s3fscurl;
int result = s3fscurl.DeleteRequest(path.c_str());
if(0 != result && -ENOENT != result){
return result;
}
// succeed removing or not found the directory
}else{
// nothing to do
}
return 0;
}
//
// Get object attributes with stat cache.
// This function is base for s3fs_getattr().
@ -1547,12 +1563,9 @@ static int s3fs_chmod(const char* path, mode_t mode)
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -1625,12 +1638,9 @@ static int s3fs_chmod_nocopy(const char* path, mode_t mode)
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -1710,12 +1720,9 @@ static int s3fs_chown(const char* path, uid_t uid, gid_t gid)
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -1784,12 +1791,9 @@ static int s3fs_chown_nocopy(const char* path, uid_t uid, gid_t gid)
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -1866,12 +1870,9 @@ static int s3fs_utimens(const char* path, const struct timespec ts[2])
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -1934,12 +1935,9 @@ static int s3fs_utimens_nocopy(const char* path, const struct timespec ts[2])
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -3066,12 +3064,9 @@ static int s3fs_setxattr(const char* path, const char* name, const char* value,
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")
@ -3314,13 +3309,9 @@ static int s3fs_removexattr(const char* path, const char* name)
// Need to remove old dir("dir" etc) and make new dir("dir/")
// At first, remove directory old object
if(IS_RMTYPEDIR(nDirType)){
S3fsCurl s3fscurl;
if(0 != (result = s3fscurl.DeleteRequest(strpath.c_str()))){
free_xattrs(xattrs);
if(0 != (result = remove_old_type_dir(strpath, nDirType))){
return result;
}
}
StatCache::getStatCacheData()->DelStat(nowcache);
// Make new directory object("dir/")