diff --git a/HISTORY b/HISTORY index 91f548f..b18be82 100644 --- a/HISTORY +++ b/HISTORY @@ -1,4 +1,7 @@ +Version 6.9.2 2022-11-28 + * space size such as total_mb and free_mb use int64_t instead of int + Version 6.9.1 2022-11-25 * bugfixed: clear task extra data correctly when the connection broken diff --git a/client/tracker_client.h b/client/tracker_client.h index 93f0b99..bfe76a6 100644 --- a/client/tracker_client.h +++ b/client/tracker_client.h @@ -26,8 +26,8 @@ typedef struct char src_id[FDFS_STORAGE_ID_MAX_SIZE]; //src storage id char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE]; //http domain name char version[FDFS_VERSION_SIZE]; - int total_mb; //total disk storage in MB - int free_mb; //free disk storage in MB + int64_t total_mb; //total disk storage in MB + int64_t free_mb; //free disk storage in MB int upload_priority; //upload priority time_t join_time; //storage join timestamp (create timestamp) time_t up_time; //storage service started timestamp diff --git a/storage/storage_dump.c b/storage/storage_dump.c index a0bac08..b97a93f 100644 --- a/storage/storage_dump.c +++ b/storage/storage_dump.c @@ -111,7 +111,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize) "g_trunk_file_size=%d\n" "g_store_path_mode=%d\n" "storage_reserved_mb=%s\n" - "g_avg_storage_reserved_mb=%d\n" + "g_avg_storage_reserved_mb=%"PRId64"\n" "g_store_path_index=%d\n" "g_current_trunk_file_id=%d\n" "g_trunk_sync_thread_count=%d\n" @@ -243,7 +243,7 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize) { total_len += snprintf(buff + total_len, buffSize - total_len, "\tg_fdfs_store_paths.paths[%d]=%s, " \ - "total=%d MB, free=%d MB\n", i, \ + "total=%"PRId64" MB, free=%"PRId64" MB\n", i, \ g_fdfs_store_paths.paths[i].path, \ g_fdfs_store_paths.paths[i].total_mb, \ g_fdfs_store_paths.paths[i].free_mb); diff --git a/storage/storage_service.c b/storage/storage_service.c index 67847bf..3f830b3 100644 --- a/storage/storage_service.c +++ b/storage/storage_service.c @@ -4368,7 +4368,7 @@ static int storage_upload_file(struct fast_task_info *pTask, bool bAppenderFile) { logError("file: "__FILE__", line: %d, " \ "no space to upload file, " - "free space: %d MB is too small, file bytes: " \ + "free space: %"PRId64" MB is too small, file bytes: " \ "%"PRId64", reserved space: %s", \ __LINE__, g_fdfs_store_paths.paths[store_path_index].\ free_mb, file_bytes, \ @@ -5222,7 +5222,7 @@ static int storage_upload_slave_file(struct fast_task_info *pTask) { logError("file: "__FILE__", line: %d, " \ "no space to upload file, " - "free space: %d MB is too small, file bytes: " \ + "free space: %"PRId64" MB is too small, file bytes: " \ "%"PRId64", reserved space: %s", __LINE__,\ g_fdfs_store_paths.paths[store_path_index].free_mb, \ file_bytes, fdfs_storage_reserved_space_to_string_ex(\ diff --git a/storage/tracker_client_thread.c b/storage/tracker_client_thread.c index 84e882b..fccc948 100644 --- a/storage/tracker_client_thread.c +++ b/storage/tracker_client_thread.c @@ -2246,7 +2246,7 @@ static int tracker_report_df_stat(ConnectionInfo *pTrackerServer, if (g_store_path_mode == FDFS_STORE_PATH_LOAD_BALANCE) { - int max_free_mb; + int64_t max_free_mb; /* find the max free space path */ max_free_mb = 0; diff --git a/storage/trunk_mgr/trunk_mem.c b/storage/trunk_mgr/trunk_mem.c index 193a473..162c17d 100644 --- a/storage/trunk_mgr/trunk_mem.c +++ b/storage/trunk_mgr/trunk_mem.c @@ -50,7 +50,7 @@ int g_trunk_file_size = 0; int g_store_path_mode = FDFS_STORE_PATH_ROUND_ROBIN; FDFSStorageReservedSpace g_storage_reserved_space = { TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB}; -int g_avg_storage_reserved_mb = FDFS_DEF_STORAGE_RESERVED_MB; +int64_t g_avg_storage_reserved_mb = FDFS_DEF_STORAGE_RESERVED_MB; int g_store_path_index = 0; volatile int g_current_trunk_file_id = 0; TimeInfo g_trunk_create_file_time_base = {0, 0}; diff --git a/storage/trunk_mgr/trunk_mem.h b/storage/trunk_mgr/trunk_mem.h index bed9650..e1fbb59 100644 --- a/storage/trunk_mgr/trunk_mem.h +++ b/storage/trunk_mgr/trunk_mem.h @@ -43,7 +43,7 @@ extern int g_trunk_alloc_alignment_size; //the alignment size for trunk alloc extern int g_trunk_file_size; //the trunk file size, such as 64MB extern int g_store_path_mode; //store which path mode, fetch from tracker extern FDFSStorageReservedSpace g_storage_reserved_space; //fetch from tracker -extern int g_avg_storage_reserved_mb; //calc by above var: g_storage_reserved_mb +extern int64_t g_avg_storage_reserved_mb; //calc by above var: g_storage_reserved_mb extern int g_store_path_index; //store to which path extern volatile int g_current_trunk_file_id; //current trunk file id extern TimeInfo g_trunk_create_file_time_base; diff --git a/storage/trunk_mgr/trunk_shared.h b/storage/trunk_mgr/trunk_shared.h index c845c15..93b6e21 100644 --- a/storage/trunk_mgr/trunk_shared.h +++ b/storage/trunk_mgr/trunk_shared.h @@ -50,8 +50,8 @@ typedef struct { - int total_mb; //total spaces - int free_mb; //free spaces + int64_t total_mb; //total spaces + int64_t free_mb; //free spaces int path_len; //the length of store path char *path; //file store path char *mark; //path mark to avoid confusion diff --git a/tracker/fdfs_shared_func.c b/tracker/fdfs_shared_func.c index 9f64948..ad964fe 100644 --- a/tracker/fdfs_shared_func.c +++ b/tracker/fdfs_shared_func.c @@ -222,8 +222,7 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext, if (*(pReservedSpaceStr + len - 1) == '%') { char *endptr; - pStorageReservedSpace->flag = \ - TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO; + pStorageReservedSpace->flag = TRACKER_STORAGE_RESERVED_SPACE_FLAG_RATIO; endptr = NULL; *(pReservedSpaceStr + len - 1) = '\0'; pStorageReservedSpace->rs.ratio = \ @@ -261,41 +260,40 @@ int fdfs_parse_storage_reserved_space(IniContext *pIniContext, return 0; } -const char *fdfs_storage_reserved_space_to_string(FDFSStorageReservedSpace \ +const char *fdfs_storage_reserved_space_to_string(FDFSStorageReservedSpace *pStorageReservedSpace, char *buff) { - if (pStorageReservedSpace->flag == \ + if (pStorageReservedSpace->flag == TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB) { - sprintf(buff, "%dMB", pStorageReservedSpace->rs.mb); + sprintf(buff, "%"PRId64"MB", pStorageReservedSpace->rs.mb); } else { - sprintf(buff, "%.2f%%", 100.00 * \ - pStorageReservedSpace->rs.ratio); + sprintf(buff, "%.2f%%", 100.00 * pStorageReservedSpace->rs.ratio); } return buff; } -const char *fdfs_storage_reserved_space_to_string_ex(const bool flag, \ - const int space_mb, const int total_mb, const double space_ratio, \ - char *buff) +const char *fdfs_storage_reserved_space_to_string_ex(const bool flag, + const int64_t space_mb, const int64_t total_mb, + const double space_ratio, char *buff) { if (flag == TRACKER_STORAGE_RESERVED_SPACE_FLAG_MB) { - sprintf(buff, "%d MB", space_mb); + sprintf(buff, "%"PRId64" MB", space_mb); } else { - sprintf(buff, "%d MB(%.2f%%)", (int)(total_mb * space_ratio), \ + sprintf(buff, "%"PRId64" MB(%.2f%%)", (int64_t)(total_mb * space_ratio), 100.00 * space_ratio); } return buff; } -int fdfs_get_storage_reserved_space_mb(const int total_mb, \ +int64_t fdfs_get_storage_reserved_space_mb(const int64_t total_mb, FDFSStorageReservedSpace *pStorageReservedSpace) { if (pStorageReservedSpace->flag == \ @@ -305,7 +303,7 @@ int fdfs_get_storage_reserved_space_mb(const int total_mb, \ } else { - return (int)(total_mb * pStorageReservedSpace->rs.ratio); + return (int64_t)(total_mb * pStorageReservedSpace->rs.ratio); } } @@ -363,7 +361,7 @@ bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \ } bool fdfs_check_reserved_space_path(const int64_t total_mb, \ - const int64_t free_mb, const int avg_mb, \ + const int64_t free_mb, const int64_t avg_mb, \ FDFSStorageReservedSpace *pStorageReservedSpace) { if (pStorageReservedSpace->flag == \ diff --git a/tracker/fdfs_shared_func.h b/tracker/fdfs_shared_func.h index aced559..7a10b5f 100644 --- a/tracker/fdfs_shared_func.h +++ b/tracker/fdfs_shared_func.h @@ -35,17 +35,17 @@ extern "C" { int fdfs_get_tracker_leader_index_ex(TrackerServerGroup *pServerGroup, \ const char *leaderIp, const int leaderPort); -int fdfs_parse_storage_reserved_space(IniContext *pIniContext, \ +int fdfs_parse_storage_reserved_space(IniContext *pIniContext, FDFSStorageReservedSpace *pStorageReservedSpace); -const char *fdfs_storage_reserved_space_to_string(FDFSStorageReservedSpace \ +const char *fdfs_storage_reserved_space_to_string(FDFSStorageReservedSpace *pStorageReservedSpace, char *buff); -const char *fdfs_storage_reserved_space_to_string_ex(const bool flag, \ - const int space_mb, const int total_mb, const double space_ratio, \ - char *buff); +const char *fdfs_storage_reserved_space_to_string_ex(const bool flag, + const int64_t space_mb, const int64_t total_mb, + const double space_ratio, char *buff); -int fdfs_get_storage_reserved_space_mb(const int total_mb, \ +int64_t fdfs_get_storage_reserved_space_mb(const int64_t total_mb, FDFSStorageReservedSpace *pStorageReservedSpace); bool fdfs_check_reserved_space(FDFSGroupInfo *pGroup, \ @@ -55,7 +55,7 @@ bool fdfs_check_reserved_space_trunk(FDFSGroupInfo *pGroup, \ FDFSStorageReservedSpace *pStorageReservedSpace); bool fdfs_check_reserved_space_path(const int64_t total_mb, \ - const int64_t free_mb, const int avg_mb, \ + const int64_t free_mb, const int64_t avg_mb, \ FDFSStorageReservedSpace *pStorageReservedSpace); int fdfs_connection_pool_init(const char *config_filename, \ diff --git a/tracker/tracker_service.c b/tracker/tracker_service.c index e3e00a6..6520c58 100644 --- a/tracker/tracker_service.c +++ b/tracker/tracker_service.c @@ -2435,7 +2435,7 @@ static int tracker_deal_service_query_storage( \ char *p; bool bHaveActiveServer; int write_path_index; - int avg_reserved_mb; + int64_t avg_reserved_mb; if (cmd == TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE || cmd == TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ALL) diff --git a/tracker/tracker_types.h b/tracker/tracker_types.h index 9b5ada9..dd67adc 100644 --- a/tracker/tracker_types.h +++ b/tracker/tracker_types.h @@ -459,7 +459,7 @@ typedef struct typedef struct { char flag; union { - int mb; + int64_t mb; double ratio; } rs; } FDFSStorageReservedSpace;