code refine: extent struct FDFSStorePathInfo

v6.03_dev
YuQing 2019-11-17 19:21:55 +08:00
parent 1ac2ced873
commit af4f0754e4
13 changed files with 155 additions and 162 deletions

View File

@ -1,5 +1,5 @@
Version 6.03 2019-11-16 Version 6.03 2019-11-17
* dual IPs support two different types of inner (intranet) IPs * dual IPs support two different types of inner (intranet) IPs
* storage server request tracker server to change it's status * storage server request tracker server to change it's status
to that of tracker leader when the storage server found to that of tracker leader when the storage server found
@ -7,6 +7,8 @@ Version 6.03 2019-11-16
* bugfix: fdfs_monitor fix get index of the specified tracker server * bugfix: fdfs_monitor fix get index of the specified tracker server
* storage server write to data_init_flag and mark file safely * storage server write to data_init_flag and mark file safely
(write to temp file then rename) (write to temp file then rename)
* code refine: combine g_fdfs_store_paths and g_path_space_list,
and extent struct FDFSStorePathInfo
NOTE: the tracker and storage server must upgrade together NOTE: the tracker and storage server must upgrade together

View File

@ -30,6 +30,7 @@
#include "tracker_types.h" #include "tracker_types.h"
#include "tracker_proto.h" #include "tracker_proto.h"
#include "storage_global.h" #include "storage_global.h"
#include "trunk_mgr/trunk_shared.h"
#include "storage_func.h" #include "storage_func.h"
#include "storage_sync.h" #include "storage_sync.h"
#include "tracker_client.h" #include "tracker_client.h"
@ -65,7 +66,7 @@ static int storage_do_fetch_binlog(ConnectionInfo *pSrcStorage, \
int64_t file_bytes; int64_t file_bytes;
int result; int result;
pBasePath = g_fdfs_store_paths.paths[store_path_index]; pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
recovery_get_binlog_filename(pBasePath, full_binlog_filename); recovery_get_binlog_filename(pBasePath, full_binlog_filename);
memset(out_buff, 0, sizeof(out_buff)); memset(out_buff, 0, sizeof(out_buff));
@ -534,7 +535,7 @@ static int recovery_download_file_to_local(StorageBinLogRecord *pRecord,
{ {
bTrunkFile = false; bTrunkFile = false;
sprintf(local_filename, "%s/data/%s", sprintf(local_filename, "%s/data/%s",
g_fdfs_store_paths.paths[pRecord->store_path_index], g_fdfs_store_paths.paths[pRecord->store_path_index].path,
pRecord->true_filename); pRecord->true_filename);
} }
@ -684,7 +685,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
break; break;
} }
sprintf(local_filename, "%s/data/%s", \ sprintf(local_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
record.true_filename); record.true_filename);
if ((result=storage_split_filename_ex( \ if ((result=storage_split_filename_ex( \
@ -695,7 +696,7 @@ static int storage_do_recovery(const char *pBasePath, StorageBinLogReader *pRead
break; break;
} }
sprintf(src_filename, "%s/data/%s", \ sprintf(src_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
record.true_filename); record.true_filename);
if (symlink(src_filename, local_filename) == 0) if (symlink(src_filename, local_filename) == 0)
{ {
@ -916,7 +917,7 @@ static int storage_do_split_trunk_binlog(const int store_path_index,
int record_length; int record_length;
int result; int result;
pBasePath = g_fdfs_store_paths.paths[store_path_index]; pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
recovery_get_full_filename(pBasePath, \ recovery_get_full_filename(pBasePath, \
RECOVERY_BINLOG_FILENAME".tmp", tmpFullFilename); RECOVERY_BINLOG_FILENAME".tmp", tmpFullFilename);
fp = fopen(tmpFullFilename, "w"); fp = fopen(tmpFullFilename, "w");
@ -1087,7 +1088,7 @@ static int storage_disk_recovery_split_trunk_binlog(const int store_path_index)
StorageBinLogReader reader; StorageBinLogReader reader;
int result; int result;
pBasePath = g_fdfs_store_paths.paths[store_path_index]; pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
if ((result=recovery_reader_init(pBasePath, &reader)) != 0) if ((result=recovery_reader_init(pBasePath, &reader)) != 0)
{ {
storage_reader_destroy(&reader); storage_reader_destroy(&reader);
@ -1107,7 +1108,7 @@ int storage_disk_recovery_start(const int store_path_index)
int result; int result;
char *pBasePath; char *pBasePath;
pBasePath = g_fdfs_store_paths.paths[store_path_index]; pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
if ((result=recovery_init_mark_file(pBasePath, false)) != 0) if ((result=recovery_init_mark_file(pBasePath, false)) != 0)
{ {
return result; return result;

View File

@ -246,9 +246,9 @@ static int fdfs_dump_global_vars(char *buff, const int buffSize)
total_len += snprintf(buff + total_len, buffSize - total_len, total_len += snprintf(buff + total_len, buffSize - total_len,
"\tg_fdfs_store_paths.paths[%d]=%s, " \ "\tg_fdfs_store_paths.paths[%d]=%s, " \
"total=%d MB, free=%d MB\n", i, \ "total=%d MB, free=%d MB\n", i, \
g_fdfs_store_paths.paths[i], \ g_fdfs_store_paths.paths[i].path, \
g_path_space_list[i].total_mb, \ g_fdfs_store_paths.paths[i].total_mb, \
g_path_space_list[i].free_mb); g_fdfs_store_paths.paths[i].free_mb);
} }
if (total_len < buffSize - 1) if (total_len < buffSize - 1)

View File

@ -842,7 +842,7 @@ static int storage_check_and_make_data_dirs()
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
if ((result=storage_make_data_dirs(g_fdfs_store_paths.paths[i], \ if ((result=storage_make_data_dirs(g_fdfs_store_paths.paths[i].path,
&pathCreated)) != 0) &pathCreated)) != 0)
{ {
return result; return result;
@ -856,7 +856,7 @@ static int storage_check_and_make_data_dirs()
} }
} }
result = storage_disk_recovery_restore(g_fdfs_store_paths.paths[i]); result = storage_disk_recovery_restore(g_fdfs_store_paths.paths[i].path);
if (result == EAGAIN) //need to re-fetch binlog if (result == EAGAIN) //need to re-fetch binlog
{ {
if ((result=storage_disk_recovery_start(i)) != 0) if ((result=storage_disk_recovery_start(i)) != 0)
@ -864,7 +864,7 @@ static int storage_check_and_make_data_dirs()
return result; return result;
} }
result=storage_disk_recovery_restore(g_fdfs_store_paths.paths[i]); result=storage_disk_recovery_restore(g_fdfs_store_paths.paths[i].path);
} }
if (result != 0) if (result != 0)
@ -1024,7 +1024,6 @@ static int init_fsync_pthread_cond()
static int storage_load_paths(IniContext *pItemContext) static int storage_load_paths(IniContext *pItemContext)
{ {
int result; int result;
int bytes;
result = storage_load_paths_from_conf_file(pItemContext); result = storage_load_paths_from_conf_file(pItemContext);
if (result != 0) if (result != 0)
@ -1032,16 +1031,6 @@ static int storage_load_paths(IniContext *pItemContext)
return result; return result;
} }
bytes = sizeof(FDFSStorePathInfo) * g_fdfs_store_paths.count;
g_path_space_list = (FDFSStorePathInfo *)malloc(bytes);
if (g_path_space_list == NULL)
{
logError("file: "__FILE__", line: %d, " \
"malloc %d bytes fail, errno: %d, error info: %s", \
__LINE__, bytes, errno, STRERROR(errno));
return errno != 0 ? errno : ENOMEM;
}
memset(g_path_space_list, 0, bytes);
return 0; return 0;
} }
@ -1996,10 +1985,10 @@ int storage_func_destroy()
{ {
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
if (g_fdfs_store_paths.paths[i] != NULL) if (g_fdfs_store_paths.paths[i].path != NULL)
{ {
free(g_fdfs_store_paths.paths[i]); free(g_fdfs_store_paths.paths[i].path);
g_fdfs_store_paths.paths[i] = NULL; g_fdfs_store_paths.paths[i].path = NULL;
} }
} }
@ -2185,7 +2174,7 @@ int storage_logic_to_local_full_filename(const char *logic_filename,
} }
snprintf(full_filename, filename_size, "%s/data/%s", snprintf(full_filename, filename_size, "%s/data/%s",
g_fdfs_store_paths.paths[*store_path_index], true_filename); g_fdfs_store_paths.paths[*store_path_index].path, true_filename);
return 0; return 0;
} }

View File

@ -15,7 +15,6 @@
#include "storage_global.h" #include "storage_global.h"
volatile bool g_continue_flag = true; volatile bool g_continue_flag = true;
FDFSStorePathInfo *g_path_space_list = NULL;
int g_subdir_count_per_path = DEFAULT_DATA_DIR_COUNT_PER_PATH; int g_subdir_count_per_path = DEFAULT_DATA_DIR_COUNT_PER_PATH;
int g_server_port = FDFS_STORAGE_SERVER_DEF_PORT; int g_server_port = FDFS_STORAGE_SERVER_DEF_PORT;

View File

@ -21,7 +21,6 @@
#include "client_global.h" #include "client_global.h"
#include "fdht_types.h" #include "fdht_types.h"
#include "fastcommon/local_ip_func.h" #include "fastcommon/local_ip_func.h"
#include "trunk_shared.h"
#ifdef WITH_HTTPD #ifdef WITH_HTTPD
#include "fdfs_http_shared.h" #include "fdfs_http_shared.h"
@ -51,12 +50,6 @@ typedef struct
int last_sync_src_timestamp; int last_sync_src_timestamp;
} FDFSStorageServer; } FDFSStorageServer;
typedef struct
{
int total_mb; //total spaces
int free_mb; //free spaces
} FDFSStorePathInfo;
typedef struct typedef struct
{ {
signed char my_status; //my status from tracker server signed char my_status; //my status from tracker server
@ -68,8 +61,6 @@ typedef struct
extern volatile bool g_continue_flag; extern volatile bool g_continue_flag;
extern FDFSStorePathInfo *g_path_space_list;
/* subdirs under store path, g_subdir_count * g_subdir_count 2 level subdirs */ /* subdirs under store path, g_subdir_count * g_subdir_count 2 level subdirs */
extern int g_subdir_count_per_path; extern int g_subdir_count_per_path;

View File

@ -789,7 +789,7 @@ static int storage_do_delete_meta_file(struct fast_task_info *pTask)
} }
sprintf(meta_filename, "%s/data/%s"FDFS_STORAGE_META_FILE_EXT, \ sprintf(meta_filename, "%s/data/%s"FDFS_STORAGE_META_FILE_EXT, \
g_fdfs_store_paths.paths[store_path_index], true_filename); g_fdfs_store_paths.paths[store_path_index].path, true_filename);
} }
else else
{ {
@ -1022,7 +1022,7 @@ static int storage_do_delete_meta_file(struct fast_task_info *pTask)
else else
{ {
sprintf(pFileContext->filename, "%s/data/%s", \ sprintf(pFileContext->filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
true_filename); true_filename);
} }
@ -2012,15 +2012,15 @@ int storage_get_storage_path_index(int *store_path_index)
*store_path_index = 0; *store_path_index = 0;
} }
if (!storage_check_reserved_space_path(g_path_space_list \ if (!storage_check_reserved_space_path(g_fdfs_store_paths.paths \
[*store_path_index].total_mb, g_path_space_list \ [*store_path_index].total_mb, g_fdfs_store_paths.paths \
[*store_path_index].free_mb, g_avg_storage_reserved_mb)) [*store_path_index].free_mb, g_avg_storage_reserved_mb))
{ {
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
if (storage_check_reserved_space_path( \ if (storage_check_reserved_space_path( \
g_path_space_list[i].total_mb, \ g_fdfs_store_paths.paths[i].total_mb, \
g_path_space_list[i].free_mb, \ g_fdfs_store_paths.paths[i].free_mb, \
g_avg_storage_reserved_mb)) g_avg_storage_reserved_mb))
{ {
*store_path_index = i; *store_path_index = i;
@ -2240,7 +2240,7 @@ static int storage_get_filename(StorageClientInfo *pClientInfo,
} }
sprintf(full_filename, "%s/data/%s", sprintf(full_filename, "%s/data/%s",
g_fdfs_store_paths.paths[store_path_index], filename); g_fdfs_store_paths.paths[store_path_index].path, filename);
if (!fileExists(full_filename)) if (!fileExists(full_filename))
{ {
break; break;
@ -2499,7 +2499,7 @@ static int storage_service_upload_file_done(struct fast_task_info *pTask)
} }
snprintf(pFileContext->filename, sizeof(pFileContext->filename), \ snprintf(pFileContext->filename, sizeof(pFileContext->filename), \
"%s/data/%s", g_fdfs_store_paths.paths[master_store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[master_store_path_index].path, \
filename); filename);
sprintf(pFileContext->fname2log, \ sprintf(pFileContext->fname2log, \
"%c"FDFS_STORAGE_DATA_DIR_FORMAT"/%s", \ "%c"FDFS_STORAGE_DATA_DIR_FORMAT"/%s", \
@ -2878,12 +2878,12 @@ static int storage_service_do_create_link(struct fast_task_info *pTask, \
else else
{ {
sprintf(full_filename, "%s/data/%s", \ sprintf(full_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
filename); filename);
} }
sprintf(src_full_filename, "%s/data/%s", \ sprintf(src_full_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
pSrcFileInfo->src_true_filename); pSrcFileInfo->src_true_filename);
if (symlink(src_full_filename, full_filename) != 0) if (symlink(src_full_filename, full_filename) != 0)
{ {
@ -3337,7 +3337,7 @@ static int storage_server_set_metadata(struct fast_task_info *pTask)
pFileContext->timestamp2log = g_current_time; pFileContext->timestamp2log = g_current_time;
sprintf(pFileContext->filename, "%s/data/%s%s", \ sprintf(pFileContext->filename, "%s/data/%s%s", \
g_fdfs_store_paths.paths[store_path_index], true_filename, \ g_fdfs_store_paths.paths[store_path_index].path, true_filename, \
FDFS_STORAGE_META_FILE_EXT); FDFS_STORAGE_META_FILE_EXT);
sprintf(pFileContext->fname2log,"%s%s", \ sprintf(pFileContext->fname2log,"%s%s", \
filename, FDFS_STORAGE_META_FILE_EXT); filename, FDFS_STORAGE_META_FILE_EXT);
@ -3595,7 +3595,7 @@ static int query_file_info_deal_response(struct fast_task_info *pTask,
snprintf(pFileContext->fname2log, sizeof(pFileContext->fname2log), snprintf(pFileContext->fname2log, sizeof(pFileContext->fname2log),
"%s", filename); "%s", filename);
snprintf(pFileContext->filename, sizeof(pFileContext->filename), snprintf(pFileContext->filename, sizeof(pFileContext->filename),
"%s/data/%s", g_fdfs_store_paths.paths[store_path_index], "%s/data/%s", g_fdfs_store_paths.paths[store_path_index].path,
true_filename); true_filename);
return push_calc_crc32_to_dio_queue(pTask, return push_calc_crc32_to_dio_queue(pTask,
@ -3772,7 +3772,7 @@ static int storage_server_query_file_info(struct fast_task_info *pTask)
{ {
char full_filename[MAX_PATH_SIZE + 128]; char full_filename[MAX_PATH_SIZE + 128];
sprintf(full_filename, "%s/data/%s", sprintf(full_filename, "%s/data/%s",
g_fdfs_store_paths.paths[store_path_index], g_fdfs_store_paths.paths[store_path_index].path,
true_filename); true_filename);
if ((len=readlink(full_filename, src_filename, \ if ((len=readlink(full_filename, src_filename, \
sizeof(src_filename))) < 0) sizeof(src_filename))) < 0)
@ -4156,7 +4156,6 @@ static int storage_server_fetch_one_path_binlog_dealer( \
char *pBasePath; char *pBasePath;
int result; int result;
int record_len; int record_len;
int base_path_len;
int len; int len;
int store_path_index; int store_path_index;
struct stat stat_buf; struct stat stat_buf;
@ -4180,8 +4179,7 @@ static int storage_server_fetch_one_path_binlog_dealer( \
store_path_index = pFileContext->extra_info.upload.trunk_info. \ store_path_index = pFileContext->extra_info.upload.trunk_info. \
path.store_path_index; path.store_path_index;
pBasePath = g_fdfs_store_paths.paths[store_path_index]; pBasePath = g_fdfs_store_paths.paths[store_path_index].path;
base_path_len = strlen(pBasePath);
pOutBuff = pTask->data; pOutBuff = pTask->data;
bLast = false; bLast = false;
@ -4202,7 +4200,8 @@ static int storage_server_fetch_one_path_binlog_dealer( \
break; break;
} }
if (g_fdfs_store_paths.paths[record.store_path_index] != pBasePath) if (g_fdfs_store_paths.paths[record.store_path_index].
path != pBasePath)
{ {
continue; continue;
} }
@ -4231,7 +4230,7 @@ static int storage_server_fetch_one_path_binlog_dealer( \
else else
{ {
snprintf(full_filename, sizeof(full_filename), "%s/data/%s", snprintf(full_filename, sizeof(full_filename), "%s/data/%s",
g_fdfs_store_paths.paths[record.store_path_index], g_fdfs_store_paths.paths[record.store_path_index].path,
record.true_filename); record.true_filename);
if (lstat(full_filename, &stat_buf) != 0) if (lstat(full_filename, &stat_buf) != 0)
{ {
@ -4326,7 +4325,7 @@ static int storage_server_fetch_one_path_binlog_dealer( \
break; break;
} }
if (len <= base_path_len) if (len <= g_fdfs_store_paths.paths[store_path_index].path_len)
{ {
logWarning("file: "__FILE__", line: %d, " \ logWarning("file: "__FILE__", line: %d, " \
"invalid symbol link file: %s, " \ "invalid symbol link file: %s, " \
@ -4346,11 +4345,11 @@ static int storage_server_fetch_one_path_binlog_dealer( \
} }
//full filename format: ${base_path}/data/filename //full filename format: ${base_path}/data/filename
pOutBuff += sprintf(pOutBuff, "%d %c %s %s/%s\n", \ pOutBuff += sprintf(pOutBuff, "%d %c %s %s/%s\n",
(int)record.timestamp, \ (int)record.timestamp,
record.op_type, record.filename, \ record.op_type, record.filename,
diskLogicPath, \ diskLogicPath, src_filename + g_fdfs_store_paths.
src_filename + base_path_len + 6); paths[store_path_index].path_len + 6);
} }
if (pTask->size - (pOutBuff - pTask->data) < if (pTask->size - (pOutBuff - pTask->data) <
@ -4663,8 +4662,8 @@ static int storage_upload_file(struct fast_task_info *pTask, bool bAppenderFile)
{ {
char reserved_space_str[32]; char reserved_space_str[32];
if (!storage_check_reserved_space_path(g_path_space_list \ if (!storage_check_reserved_space_path(g_fdfs_store_paths.paths \
[store_path_index].total_mb, g_path_space_list \ [store_path_index].total_mb, g_fdfs_store_paths.paths \
[store_path_index].free_mb - (file_bytes/FDFS_ONE_MB), \ [store_path_index].free_mb - (file_bytes/FDFS_ONE_MB), \
g_avg_storage_reserved_mb)) g_avg_storage_reserved_mb))
{ {
@ -4672,12 +4671,12 @@ static int storage_upload_file(struct fast_task_info *pTask, bool bAppenderFile)
"no space to upload file, " "no space to upload file, "
"free space: %d MB is too small, file bytes: " \ "free space: %d MB is too small, file bytes: " \
"%"PRId64", reserved space: %s", \ "%"PRId64", reserved space: %s", \
__LINE__, g_path_space_list[store_path_index].\ __LINE__, g_fdfs_store_paths.paths[store_path_index].\
free_mb, file_bytes, \ free_mb, file_bytes, \
fdfs_storage_reserved_space_to_string_ex( \ fdfs_storage_reserved_space_to_string_ex( \
g_storage_reserved_space.flag, \ g_storage_reserved_space.flag, \
g_avg_storage_reserved_mb, \ g_avg_storage_reserved_mb, \
g_path_space_list[store_path_index]. \ g_fdfs_store_paths.paths[store_path_index]. \
total_mb, g_storage_reserved_space.rs.ratio,\ total_mb, g_storage_reserved_space.rs.ratio,\
reserved_space_str)); reserved_space_str));
return ENOSPC; return ENOSPC;
@ -4758,7 +4757,7 @@ static int storage_server_check_appender_file(struct fast_task_info *pTask,
} }
snprintf(pFileContext->filename, sizeof(pFileContext->filename), snprintf(pFileContext->filename, sizeof(pFileContext->filename),
"%s/data/%s", g_fdfs_store_paths.paths[*store_path_index], "%s/data/%s", g_fdfs_store_paths.paths[*store_path_index].path,
true_filename); true_filename);
if (lstat(pFileContext->filename, stat_buf) == 0) if (lstat(pFileContext->filename, stat_buf) == 0)
{ {
@ -5517,8 +5516,8 @@ static int storage_upload_slave_file(struct fast_task_info *pTask)
return result; return result;
} }
if (!storage_check_reserved_space_path(g_path_space_list \ if (!storage_check_reserved_space_path(g_fdfs_store_paths.paths \
[store_path_index].total_mb, g_path_space_list \ [store_path_index].total_mb, g_fdfs_store_paths.paths \
[store_path_index].free_mb - (file_bytes / FDFS_ONE_MB), \ [store_path_index].free_mb - (file_bytes / FDFS_ONE_MB), \
g_avg_storage_reserved_mb)) g_avg_storage_reserved_mb))
{ {
@ -5526,11 +5525,11 @@ static int storage_upload_slave_file(struct fast_task_info *pTask)
"no space to upload file, " "no space to upload file, "
"free space: %d MB is too small, file bytes: " \ "free space: %d MB is too small, file bytes: " \
"%"PRId64", reserved space: %s", __LINE__,\ "%"PRId64", reserved space: %s", __LINE__,\
g_path_space_list[store_path_index].free_mb, \ g_fdfs_store_paths.paths[store_path_index].free_mb, \
file_bytes, fdfs_storage_reserved_space_to_string_ex(\ file_bytes, fdfs_storage_reserved_space_to_string_ex(\
g_storage_reserved_space.flag, \ g_storage_reserved_space.flag, \
g_avg_storage_reserved_mb, \ g_avg_storage_reserved_mb, \
g_path_space_list[store_path_index].total_mb, \ g_fdfs_store_paths.paths[store_path_index].total_mb, \
g_storage_reserved_space.rs.ratio, \ g_storage_reserved_space.rs.ratio, \
reserved_space_str)); reserved_space_str));
return ENOSPC; return ENOSPC;
@ -5573,7 +5572,7 @@ static int storage_upload_slave_file(struct fast_task_info *pTask)
} }
snprintf(pFileContext->filename, sizeof(pFileContext->filename), \ snprintf(pFileContext->filename, sizeof(pFileContext->filename), \
"%s/data/%s", g_fdfs_store_paths.paths[store_path_index], filename); "%s/data/%s", g_fdfs_store_paths.paths[store_path_index].path, filename);
if (fileExists(pFileContext->filename)) if (fileExists(pFileContext->filename))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
@ -5871,7 +5870,7 @@ static int storage_sync_copy_file(struct fast_task_info *pTask, \
sprintf(pFileContext->filename, "%s/data/.cp" \ sprintf(pFileContext->filename, "%s/data/.cp" \
"%"PRId64".tmp", \ "%"PRId64".tmp", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
temp_file_sequence++); temp_file_sequence++);
pthread_mutex_unlock(&g_storage_thread_lock); pthread_mutex_unlock(&g_storage_thread_lock);
@ -6732,11 +6731,11 @@ static int storage_do_sync_link_file(struct fast_task_info *pTask)
else else
{ {
snprintf(pFileContext->filename, sizeof(pFileContext->filename), \ snprintf(pFileContext->filename, sizeof(pFileContext->filename), \
"%s/data/%s", g_fdfs_store_paths.paths[dest_store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[dest_store_path_index].path, \
dest_true_filename); dest_true_filename);
snprintf(src_full_filename, sizeof(src_full_filename), \ snprintf(src_full_filename, sizeof(src_full_filename), \
"%s/data/%s", g_fdfs_store_paths.paths[src_store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[src_store_path_index].path, \
src_true_filename); src_true_filename);
if (symlink(src_full_filename, pFileContext->filename) != 0) if (symlink(src_full_filename, pFileContext->filename) != 0)
{ {
@ -7106,7 +7105,7 @@ static int storage_server_get_metadata(struct fast_task_info *pTask)
} }
sprintf(pFileContext->filename, "%s/data/%s%s", \ sprintf(pFileContext->filename, "%s/data/%s%s", \
g_fdfs_store_paths.paths[store_path_index], \ g_fdfs_store_paths.paths[store_path_index].path, \
true_filename, FDFS_STORAGE_META_FILE_EXT); true_filename, FDFS_STORAGE_META_FILE_EXT);
if (lstat(pFileContext->filename, &stat_buf) == 0) if (lstat(pFileContext->filename, &stat_buf) == 0)
{ {
@ -7308,7 +7307,7 @@ static int storage_server_download_file(struct fast_task_info *pTask)
else else
{ {
sprintf(pFileContext->filename, "%s/data/%s", \ sprintf(pFileContext->filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], true_filename); g_fdfs_store_paths.paths[store_path_index].path, true_filename);
} }
pFileContext->calc_crc32 = false; pFileContext->calc_crc32 = false;
@ -7560,7 +7559,7 @@ static int storage_sync_delete_file(struct fast_task_info *pTask)
{ {
pClientInfo->deal_func = dio_delete_normal_file; pClientInfo->deal_func = dio_delete_normal_file;
sprintf(pFileContext->filename, "%s/data/%s", \ sprintf(pFileContext->filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], true_filename); g_fdfs_store_paths.paths[store_path_index].path, true_filename);
} }
strcpy(pFileContext->fname2log, filename); strcpy(pFileContext->fname2log, filename);
@ -7695,7 +7694,7 @@ static int storage_server_delete_file(struct fast_task_info *pTask)
{ {
pClientInfo->deal_func = dio_delete_normal_file; pClientInfo->deal_func = dio_delete_normal_file;
sprintf(pFileContext->filename, "%s/data/%s", \ sprintf(pFileContext->filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], true_filename); g_fdfs_store_paths.paths[store_path_index].path, true_filename);
} }
if ((pFileContext->extra_info.upload.file_type & _FILE_TYPE_LINK) && \ if ((pFileContext->extra_info.upload.file_type & _FILE_TYPE_LINK) && \
@ -7706,12 +7705,11 @@ static int storage_server_delete_file(struct fast_task_info *pTask)
char src_fname2log[128]; char src_fname2log[128];
char *src_true_filename; char *src_true_filename;
int src_filename_len; int src_filename_len;
int base_path_len;
int src_store_path_index; int src_store_path_index;
int i; int i;
sprintf(full_filename, "%s/data/%s", \ sprintf(full_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[store_path_index], true_filename); g_fdfs_store_paths.paths[store_path_index].path, true_filename);
do do
{ {
if ((src_filename_len=readlink(full_filename, \ if ((src_filename_len=readlink(full_filename, \
@ -7742,11 +7740,11 @@ static int storage_server_delete_file(struct fast_task_info *pTask)
return result; return result;
} }
base_path_len = strlen(g_fdfs_store_paths.paths \ if (src_filename_len > g_fdfs_store_paths.paths
[store_path_index]); [store_path_index].path_len && memcmp(
if (src_filename_len > base_path_len && memcmp( \ src_filename, g_fdfs_store_paths.paths
src_filename, g_fdfs_store_paths.paths \ [store_path_index].path, g_fdfs_store_paths.
[store_path_index], base_path_len) == 0) paths[store_path_index].path_len) == 0)
{ {
src_store_path_index = store_path_index; src_store_path_index = store_path_index;
} }
@ -7755,10 +7753,9 @@ static int storage_server_delete_file(struct fast_task_info *pTask)
src_store_path_index = -1; src_store_path_index = -1;
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
base_path_len = strlen(g_fdfs_store_paths.paths[i]); if (src_filename_len > g_fdfs_store_paths.paths[i].path_len &&
if (src_filename_len > base_path_len && \ memcmp(src_filename, g_fdfs_store_paths.paths
memcmp(src_filename, g_fdfs_store_paths.paths\ [i].path, g_fdfs_store_paths.paths[i].path_len) == 0)
[i], base_path_len) == 0)
{ {
src_store_path_index = i; src_store_path_index = i;
break; break;
@ -7774,7 +7771,8 @@ static int storage_server_delete_file(struct fast_task_info *pTask)
} }
} }
src_true_filename = src_filename + (base_path_len + \ src_true_filename = src_filename + (g_fdfs_store_paths.
paths[src_store_path_index].path_len +
(sizeof("/data/") -1)); (sizeof("/data/") -1));
snprintf(src_fname2log, sizeof(src_fname2log), \ snprintf(src_fname2log, sizeof(src_fname2log), \
"%c"FDFS_STORAGE_DATA_DIR_FORMAT"/%s", \ "%c"FDFS_STORAGE_DATA_DIR_FORMAT"/%s", \
@ -7916,7 +7914,7 @@ static int storage_create_link_core(struct fast_task_info *pTask, \
} }
snprintf(full_filename, sizeof(full_filename), \ snprintf(full_filename, sizeof(full_filename), \
"%s/data/%s", g_fdfs_store_paths.paths[store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[store_path_index].path, \
filename); filename);
if (fileExists(full_filename)) if (fileExists(full_filename))
{ {

View File

@ -185,7 +185,7 @@ static int storage_sync_copy_file(ConnectionInfo *pStorageServer, \
{ {
file_offset = 0; file_offset = 0;
sprintf(full_filename, "%s/data/%s", \ sprintf(full_filename, "%s/data/%s", \
g_fdfs_store_paths.paths[pRecord->store_path_index], \ g_fdfs_store_paths.paths[pRecord->store_path_index].path, \
pRecord->true_filename); pRecord->true_filename);
} }
@ -350,7 +350,7 @@ static int storage_sync_modify_file(ConnectionInfo *pStorageServer, \
} }
snprintf(full_filename, sizeof(full_filename), \ snprintf(full_filename, sizeof(full_filename), \
"%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index].path, \
pRecord->true_filename); pRecord->true_filename);
if (lstat(full_filename, &stat_buf) != 0) if (lstat(full_filename, &stat_buf) != 0)
{ {
@ -520,7 +520,7 @@ static int storage_sync_truncate_file(ConnectionInfo *pStorageServer, \
} }
snprintf(full_filename, sizeof(full_filename), \ snprintf(full_filename, sizeof(full_filename), \
"%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index].path, \
pRecord->true_filename); pRecord->true_filename);
if (lstat(full_filename, &stat_buf) != 0) if (lstat(full_filename, &stat_buf) != 0)
{ {
@ -841,7 +841,7 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
int src_filename_len; int src_filename_len;
snprintf(full_filename, sizeof(full_filename), \ snprintf(full_filename, sizeof(full_filename), \
"%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index], \ "%s/data/%s", g_fdfs_store_paths.paths[pRecord->store_path_index].path, \
pRecord->true_filename); pRecord->true_filename);
src_filename_len = readlink(full_filename, src_full_filename, \ src_filename_len = readlink(full_filename, src_full_filename, \
sizeof(src_full_filename) - 1); sizeof(src_full_filename) - 1);
@ -884,7 +884,7 @@ static int storage_sync_link_file(ConnectionInfo *pStorageServer, \
src_path_index++) src_path_index++)
{ {
if (strcmp(src_full_filename, \ if (strcmp(src_full_filename, \
g_fdfs_store_paths.paths[src_path_index]) == 0) g_fdfs_store_paths.paths[src_path_index].path) == 0)
{ {
break; break;
} }
@ -998,7 +998,7 @@ static int storage_sync_rename_file(ConnectionInfo *pStorageServer,
} }
snprintf(full_filename, sizeof(full_filename), "%s/data/%s", snprintf(full_filename, sizeof(full_filename), "%s/data/%s",
g_fdfs_store_paths.paths[pRecord->store_path_index], g_fdfs_store_paths.paths[pRecord->store_path_index].path,
pRecord->true_filename); pRecord->true_filename);
if (lstat(full_filename, &stat_buf) != 0) if (lstat(full_filename, &stat_buf) != 0)
{ {

View File

@ -2203,7 +2203,7 @@ static int tracker_report_df_stat(ConnectionInfo *pTrackerServer,
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
if (statvfs(g_fdfs_store_paths.paths[i], &sbuf) != 0) if (statvfs(g_fdfs_store_paths.paths[i].path, &sbuf) != 0)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"call statfs fail, errno: %d, error info: %s.",\ "call statfs fail, errno: %d, error info: %s.",\
@ -2216,12 +2216,12 @@ static int tracker_report_df_stat(ConnectionInfo *pTrackerServer,
return errno != 0 ? errno : EACCES; return errno != 0 ? errno : EACCES;
} }
g_path_space_list[i].total_mb = ((int64_t)(sbuf.f_blocks) * \ g_fdfs_store_paths.paths[i].total_mb = ((int64_t)(sbuf.f_blocks) * \
sbuf.f_frsize) / FDFS_ONE_MB; sbuf.f_frsize) / FDFS_ONE_MB;
g_path_space_list[i].free_mb = ((int64_t)(sbuf.f_bavail) * \ g_fdfs_store_paths.paths[i].free_mb = ((int64_t)(sbuf.f_bavail) * \
sbuf.f_frsize) / FDFS_ONE_MB; sbuf.f_frsize) / FDFS_ONE_MB;
long2buff(g_path_space_list[i].total_mb, pStatBuff->sz_total_mb); long2buff(g_fdfs_store_paths.paths[i].total_mb, pStatBuff->sz_total_mb);
long2buff(g_path_space_list[i].free_mb, pStatBuff->sz_free_mb); long2buff(g_fdfs_store_paths.paths[i].free_mb, pStatBuff->sz_free_mb);
pStatBuff++; pStatBuff++;
} }
@ -2235,12 +2235,12 @@ static int tracker_report_df_stat(ConnectionInfo *pTrackerServer,
store_path_index = -1; store_path_index = -1;
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
if (g_path_space_list[i].free_mb > \ if (g_fdfs_store_paths.paths[i].free_mb > \
g_avg_storage_reserved_mb \ g_avg_storage_reserved_mb \
&& g_path_space_list[i].free_mb > max_free_mb) && g_fdfs_store_paths.paths[i].free_mb > max_free_mb)
{ {
store_path_index = i; store_path_index = i;
max_free_mb = g_path_space_list[i].free_mb; max_free_mb = g_fdfs_store_paths.paths[i].free_mb;
} }
} }
if (g_store_path_index != store_path_index) if (g_store_path_index != store_path_index)

View File

@ -1953,8 +1953,8 @@ int trunk_create_trunk_file_advance(void *args)
free_mb_sum = 0; free_mb_sum = 0;
for (i=0; i<g_fdfs_store_paths.count; i++) for (i=0; i<g_fdfs_store_paths.count; i++)
{ {
total_mb_sum += g_path_space_list[i].total_mb; total_mb_sum += g_fdfs_store_paths.paths[i].total_mb;
free_mb_sum += g_path_space_list[i].free_mb; free_mb_sum += g_fdfs_store_paths.paths[i].free_mb;
} }
if (!storage_check_reserved_space_path(total_mb_sum, free_mb_sum \ if (!storage_check_reserved_space_path(total_mb_sum, free_mb_sum \

View File

@ -32,46 +32,47 @@ void trunk_shared_init()
base64_init_ex(&g_fdfs_base64_context, 0, '-', '_', '.'); base64_init_ex(&g_fdfs_base64_context, 0, '-', '_', '.');
} }
char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \ FDFSStorePathInfo *storage_load_paths_from_conf_file_ex(
const char *szSectionName, const bool bUseBasePath, \ IniContext *pItemContext, const char *szSectionName,
int *path_count, int *err_no) const bool bUseBasePath, int *path_count, int *err_no)
{ {
char item_name[64]; char item_name[64];
char **store_paths; FDFSStorePathInfo *store_paths;
char *pPath; char *pPath;
int bytes;
int i; int i;
*path_count = iniGetIntValue(szSectionName, "store_path_count", *path_count = iniGetIntValue(szSectionName, "store_path_count",
pItemContext, 1); pItemContext, 1);
if (*path_count <= 0) if (*path_count <= 0)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"store_path_count: %d is invalid!", \ "store_path_count: %d is invalid!",
__LINE__, *path_count); __LINE__, *path_count);
*err_no = EINVAL; *err_no = EINVAL;
return NULL; return NULL;
} }
store_paths = (char **)malloc(sizeof(char *) * (*path_count)); bytes = sizeof(FDFSStorePathInfo) * (*path_count);
store_paths = (FDFSStorePathInfo *)malloc(bytes);
if (store_paths == NULL) if (store_paths == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"malloc %d bytes fail, " \ "malloc %d bytes fail, "
"errno: %d, error info: %s", \ "errno: %d, error info: %s", __LINE__,
__LINE__, (int)sizeof(char *) * (*path_count), \ bytes, errno, STRERROR(errno));
errno, STRERROR(errno));
*err_no = errno != 0 ? errno : ENOMEM; *err_no = errno != 0 ? errno : ENOMEM;
return NULL; return NULL;
} }
memset(store_paths, 0, sizeof(char *) * (*path_count)); memset(store_paths, 0, bytes);
pPath = iniGetStrValue(szSectionName, "store_path0", pItemContext); pPath = iniGetStrValue(szSectionName, "store_path0", pItemContext);
if (pPath == NULL) if (pPath == NULL)
{ {
if (!bUseBasePath) if (!bUseBasePath)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"conf file must have item " \ "conf file must have item "
"\"store_path0\"!", __LINE__); "\"store_path0\"!", __LINE__);
*err_no = ENOENT; *err_no = ENOENT;
free(store_paths); free(store_paths);
@ -80,13 +81,15 @@ char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \
pPath = g_fdfs_base_path; pPath = g_fdfs_base_path;
} }
store_paths[0] = strdup(pPath);
if (store_paths[0] == NULL) store_paths[0].path_len = strlen(pPath);
store_paths[0].path = strdup(pPath);
if (store_paths[0].path == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"malloc %d bytes fail, " \ "malloc %d bytes fail, "
"errno: %d, error info: %s", \ "errno: %d, error info: %s",
__LINE__, (int)strlen(pPath), \ __LINE__, (int)strlen(pPath),
errno, STRERROR(errno)); errno, STRERROR(errno));
*err_no = errno != 0 ? errno : ENOMEM; *err_no = errno != 0 ? errno : ENOMEM;
free(store_paths); free(store_paths);
@ -97,12 +100,12 @@ char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \
for (i=1; i<*path_count; i++) for (i=1; i<*path_count; i++)
{ {
sprintf(item_name, "store_path%d", i); sprintf(item_name, "store_path%d", i);
pPath = iniGetStrValue(szSectionName, item_name, \ pPath = iniGetStrValue(szSectionName, item_name,
pItemContext); pItemContext);
if (pPath == NULL) if (pPath == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"conf file must have item \"%s\"!", \ "conf file must have item \"%s\"!",
__LINE__, item_name); __LINE__, item_name);
*err_no = ENOENT; *err_no = ENOENT;
break; break;
@ -111,24 +114,25 @@ char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \
chopPath(pPath); chopPath(pPath);
if (!fileExists(pPath)) if (!fileExists(pPath))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"\"%s\" can't be accessed, " \ "\"%s\" can't be accessed, "
"errno: %d, error info: %s", __LINE__, \ "errno: %d, error info: %s", __LINE__,
pPath, errno, STRERROR(errno)); pPath, errno, STRERROR(errno));
*err_no = errno != 0 ? errno : ENOENT; *err_no = errno != 0 ? errno : ENOENT;
break; break;
} }
if (!isDir(pPath)) if (!isDir(pPath))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"\"%s\" is not a directory!", \ "\"%s\" is not a directory!",
__LINE__, pPath); __LINE__, pPath);
*err_no = ENOTDIR; *err_no = ENOTDIR;
break; break;
} }
store_paths[i] = strdup(pPath); store_paths[i].path_len = strlen(pPath);
if (store_paths[i] == NULL) store_paths[i].path = strdup(pPath);
if (store_paths[i].path == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"malloc %d bytes fail, " \ "malloc %d bytes fail, " \
@ -143,9 +147,9 @@ char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \
{ {
for (i=0; i<*path_count; i++) for (i=0; i<*path_count; i++)
{ {
if (store_paths[i] != NULL) if (store_paths[i].path != NULL)
{ {
free(store_paths[i]); free(store_paths[i].path);
} }
} }
free(store_paths); free(store_paths);
@ -163,7 +167,7 @@ int storage_load_paths_from_conf_file(IniContext *pItemContext)
pPath = iniGetStrValue(NULL, "base_path", pItemContext); pPath = iniGetStrValue(NULL, "base_path", pItemContext);
if (pPath == NULL) if (pPath == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"conf file must have item \"base_path\"!", __LINE__); "conf file must have item \"base_path\"!", __LINE__);
return ENOENT; return ENOENT;
} }
@ -172,20 +176,20 @@ int storage_load_paths_from_conf_file(IniContext *pItemContext)
chopPath(g_fdfs_base_path); chopPath(g_fdfs_base_path);
if (!fileExists(g_fdfs_base_path)) if (!fileExists(g_fdfs_base_path))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"\"%s\" can't be accessed, error info: %s", \ "\"%s\" can't be accessed, error info: %s",
__LINE__, STRERROR(errno), g_fdfs_base_path); __LINE__, STRERROR(errno), g_fdfs_base_path);
return errno != 0 ? errno : ENOENT; return errno != 0 ? errno : ENOENT;
} }
if (!isDir(g_fdfs_base_path)) if (!isDir(g_fdfs_base_path))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"\"%s\" is not a directory!", \ "\"%s\" is not a directory!",
__LINE__, g_fdfs_base_path); __LINE__, g_fdfs_base_path);
return ENOTDIR; return ENOTDIR;
} }
g_fdfs_store_paths.paths = storage_load_paths_from_conf_file_ex( \ g_fdfs_store_paths.paths = storage_load_paths_from_conf_file_ex(
pItemContext, NULL, true, &g_fdfs_store_paths.count, &result); pItemContext, NULL, true, &g_fdfs_store_paths.count, &result);
return result; return result;
@ -259,7 +263,7 @@ int storage_split_filename(const char *logic_filename, \
SPLIT_FILENAME_BODY(logic_filename, filename_len, true_filename, \ SPLIT_FILENAME_BODY(logic_filename, filename_len, true_filename, \
store_path_index, true); store_path_index, true);
*ppStorePath = g_fdfs_store_paths.paths[store_path_index]; *ppStorePath = g_fdfs_store_paths.paths[store_path_index].path;
return 0; return 0;
} }
@ -325,7 +329,7 @@ char *trunk_get_full_filename_ex(const FDFSStorePaths *pStorePaths, \
char short_filename[64]; char short_filename[64];
char *pStorePath; char *pStorePath;
pStorePath = pStorePaths->paths[pTrunkInfo->path.store_path_index]; pStorePath = pStorePaths->paths[pTrunkInfo->path.store_path_index].path;
TRUNK_GET_FILENAME(pTrunkInfo->file.id, short_filename); TRUNK_GET_FILENAME(pTrunkInfo->file.id, short_filename);
snprintf(full_filename, buff_size, \ snprintf(full_filename, buff_size, \
@ -547,7 +551,7 @@ int trunk_file_do_lstat_func_ex(const FDFSStorePaths *pStorePaths, \
if (filename_len != FDFS_TRUNK_FILENAME_LENGTH) //not trunk file if (filename_len != FDFS_TRUNK_FILENAME_LENGTH) //not trunk file
{ {
snprintf(full_filename, sizeof(full_filename), "%s/data/%s", \ snprintf(full_filename, sizeof(full_filename), "%s/data/%s", \
pStorePaths->paths[store_path_index], true_filename); pStorePaths->paths[store_path_index].path, true_filename);
if (stat_func == FDFS_STAT_FUNC_STAT) if (stat_func == FDFS_STAT_FUNC_STAT)
{ {
@ -576,7 +580,7 @@ int trunk_file_do_lstat_func_ex(const FDFSStorePaths *pStorePaths, \
if (!IS_TRUNK_FILE(file_size)) //slave file if (!IS_TRUNK_FILE(file_size)) //slave file
{ {
snprintf(full_filename, sizeof(full_filename), "%s/data/%s", \ snprintf(full_filename, sizeof(full_filename), "%s/data/%s", \
pStorePaths->paths[store_path_index], true_filename); pStorePaths->paths[store_path_index].path, true_filename);
if (stat_func == FDFS_STAT_FUNC_STAT) if (stat_func == FDFS_STAT_FUNC_STAT)
{ {

View File

@ -48,6 +48,20 @@
#define TRUNK_GET_FILENAME(file_id, filename) \ #define TRUNK_GET_FILENAME(file_id, filename) \
sprintf(filename, "%06d", file_id) sprintf(filename, "%06d", file_id)
typedef struct
{
int total_mb; //total spaces
int free_mb; //free spaces
int path_len; //the length of store path
char *path; //file store path
char *mark; //path mark to avoid confusion
} FDFSStorePathInfo;
typedef struct {
int count; //store path count
FDFSStorePathInfo *paths; //file store paths
} FDFSStorePaths;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -84,9 +98,9 @@ typedef struct tagFDFSTrunkFullInfo {
FDFSTrunkFileInfo file; FDFSTrunkFileInfo file;
} FDFSTrunkFullInfo; } FDFSTrunkFullInfo;
char **storage_load_paths_from_conf_file_ex(IniContext *pItemContext, \ FDFSStorePathInfo *storage_load_paths_from_conf_file_ex(
const char *szSectionName, const bool bUseBasePath, \ IniContext *pItemContext, const char *szSectionName,
int *path_count, int *err_no); const bool bUseBasePath, int *path_count, int *err_no);
int storage_load_paths_from_conf_file(IniContext *pItemContext); int storage_load_paths_from_conf_file(IniContext *pItemContext);
void trunk_shared_init(); void trunk_shared_init();

View File

@ -464,11 +464,6 @@ typedef struct {
} rs; } rs;
} FDFSStorageReservedSpace; } FDFSStorageReservedSpace;
typedef struct {
int count; //store path count
char **paths; //file store paths
} FDFSStorePaths;
typedef struct { typedef struct {
TrackerServerInfo *pTrackerServer; TrackerServerInfo *pTrackerServer;
int running_time; //running seconds, more means higher weight int running_time; //running seconds, more means higher weight