specify the storage server ID for NAT network

pull/687/head
YuQing 2023-12-10 15:12:20 +08:00
parent 47759f2cf7
commit 48fb05dbb2
18 changed files with 196 additions and 92 deletions

View File

@ -1,6 +1,8 @@
Version 6.11.0 2023-12-05 Version 6.11.0 2023-12-10
* support IPv6, config item: address_family in tracker.conf and storage.conf * support IPv6, config item: address_family in tracker.conf and storage.conf
use libfastcommon V1.71 and libserverframe 1.2.1
* storage.conf can specify the storage server ID for NAT network
Version 6.10.0 2023-09-07 Version 6.10.0 2023-09-07
* use libfastcommon V1.70 and libserverframe 1.2.0 * use libfastcommon V1.70 and libserverframe 1.2.0

View File

@ -11,7 +11,7 @@ Chinese language: http://www.fastken.com/
# command lines as: # command lines as:
git clone https://github.com/happyfish100/libfastcommon.git git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon; git checkout V1.0.70 cd libfastcommon; git checkout V1.0.71
./make.sh clean && ./make.sh && ./make.sh install ./make.sh clean && ./make.sh && ./make.sh install
@ -21,7 +21,7 @@ Chinese language: http://www.fastken.com/
# command lines as: # command lines as:
git clone https://github.com/happyfish100/libserverframe.git git clone https://github.com/happyfish100/libserverframe.git
cd libserverframe; git checkout V1.2.0 cd libserverframe; git checkout V1.2.1
./make.sh clean && ./make.sh && ./make.sh install ./make.sh clean && ./make.sh && ./make.sh install
# step 3. download fastdfs source codes and install it, # step 3. download fastdfs source codes and install it,
@ -30,7 +30,7 @@ Chinese language: http://www.fastken.com/
# command lines as: # command lines as:
git clone https://github.com/happyfish100/fastdfs.git git clone https://github.com/happyfish100/fastdfs.git
cd fastdfs; git checkout V6.10.0 cd fastdfs; git checkout V6.11.0
./make.sh clean && ./make.sh && ./make.sh install ./make.sh clean && ./make.sh && ./make.sh install

View File

@ -38,8 +38,21 @@ port = 23000
## auto: auto detect by bind_addr, IPv4 first then IPv6 when bind_addr is empty ## auto: auto detect by bind_addr, IPv4 first then IPv6 when bind_addr is empty
## both: IPv4 and IPv6 dual stacks ## both: IPv4 and IPv6 dual stacks
# default value is auto # default value is auto
# since V6.11
address_family = auto address_family = auto
# specify the storage server ID for NAT network
# NOT set or commented for auto set by the local ip addresses
# since V6.11
#
# NOTE:
## * this paramter is valid only when use_storage_id and trust_storage_server_id
## in tracker.conf set to true
## * the storage server id must exist in storage_ids.conf
#server_id =
# connect timeout in seconds # connect timeout in seconds
# default value is 30 # default value is 30
# Note: in the intranet network (LAN), 2 seconds is enough. # Note: in the intranet network (LAN), 2 seconds is enough.

View File

@ -29,6 +29,7 @@ port = 22122
# id_type_in_filename MUST set to id when IPv6 enabled # id_type_in_filename MUST set to id when IPv6 enabled
# #
# default value is auto # default value is auto
# since V6.11
address_family = auto address_family = auto
# connect timeout in seconds # connect timeout in seconds
@ -286,6 +287,13 @@ storage_ids_filename = storage_ids.conf
# since V4.03 # since V4.03
id_type_in_filename = id id_type_in_filename = id
# if trust the storage server ID sent by the storage server
# this paramter is valid only when use_storage_id set to true
# default value is true
# since V6.11
trust_storage_server_id = true
# if store slave file use symbol link # if store slave file use symbol link
# default value is false # default value is false
# since V4.01 # since V4.01

View File

@ -219,7 +219,32 @@ static int storage_get_group_name_from_tracker()
return result; return result;
} }
static int tracker_get_my_server_id() static int get_my_server_id_by_local_ip()
{
FDFSStorageIdInfo *idInfo;
const char *ip_addr;
ip_addr = get_first_local_ip();
while (ip_addr != NULL) {
if ((idInfo=fdfs_get_storage_id_by_ip(g_group_name,
ip_addr)) != NULL)
{
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str),
"%s", idInfo->id);
return 0;
}
ip_addr = get_next_local_ip(ip_addr);
}
logError("file: "__FILE__", line: %d, "
"can't find my server id by local ip address, "
"local ip count: %d", __LINE__, g_local_host_ip_count);
return ENOENT;
}
static int tracker_get_my_server_id(const char *conf_filename,
const char *server_id_in_conf)
{ {
struct in_addr ipv4_addr; struct in_addr ipv4_addr;
struct in6_addr ipv6_addr; struct in6_addr ipv6_addr;
@ -241,7 +266,7 @@ static int tracker_get_my_server_id()
if (!flag) if (!flag)
{ {
logError("file: "__FILE__", line: %d, " logWarning("file: "__FILE__", line: %d, "
"call inet_pton for ip: %s fail", "call inet_pton for ip: %s fail",
__LINE__, g_tracker_client_ip.ips[0].address); __LINE__, g_tracker_client_ip.ips[0].address);
g_server_id_in_filename = INADDR_NONE; g_server_id_in_filename = INADDR_NONE;
@ -252,6 +277,24 @@ static int tracker_get_my_server_id()
ConnectionInfo *pTrackerServer; ConnectionInfo *pTrackerServer;
int result; int result;
if (g_trust_storage_server_id) {
if (server_id_in_conf == NULL) {
if ((result=get_my_server_id_by_local_ip()) != 0) {
return result;
}
} else if (*server_id_in_conf != '\0') {
if (!fdfs_is_server_id_valid(server_id_in_conf)) {
logError("file: "__FILE__", line: %d, "
"config file: %s, server_id: %s is invalid",
__LINE__, conf_filename, server_id_in_conf);
return EINVAL;
}
snprintf(g_my_server_id_str, sizeof(g_my_server_id_str),
"%s", server_id_in_conf);
}
}
if (*g_my_server_id_str == '\0') {
pTrackerServer = tracker_get_connection(); pTrackerServer = tracker_get_connection();
if (pTrackerServer == NULL) if (pTrackerServer == NULL)
{ {
@ -265,6 +308,7 @@ static int tracker_get_my_server_id()
if (result != 0) if (result != 0)
{ {
return result; return result;
}
} }
if (g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID) if (g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID)
@ -1431,6 +1475,7 @@ int storage_func_init(const char *filename)
char *pIfAliasPrefix; char *pIfAliasPrefix;
char *pHttpDomain; char *pHttpDomain;
char *pRotateAccessLogSize; char *pRotateAccessLogSize;
char *server_id_in_conf;
IniContext iniContext; IniContext iniContext;
SFContextIniConfig config; SFContextIniConfig config;
int result; int result;
@ -1949,6 +1994,9 @@ int storage_func_init(const char *filename)
break; break;
} }
server_id_in_conf = iniGetStrValue(NULL,
"server_id", &iniContext);
#ifdef WITH_HTTPD #ifdef WITH_HTTPD
{ {
char *pHttpTrunkSize; char *pHttpTrunkSize;
@ -2097,7 +2145,16 @@ int storage_func_init(const char *filename)
return result; return result;
} }
if ((result=tracker_get_my_server_id()) != 0) if (g_use_storage_id)
{
if ((result=fdfs_get_storage_ids_from_tracker_group(
&g_tracker_group)) != 0)
{
return result;
}
}
if ((result=tracker_get_my_server_id(filename, server_id_in_conf)) != 0)
{ {
logCrit("file: "__FILE__", line: %d, " \ logCrit("file: "__FILE__", line: %d, " \
"get my server id from tracker server fail, " \ "get my server id from tracker server fail, " \
@ -2106,15 +2163,6 @@ int storage_func_init(const char *filename)
return result; return result;
} }
if (g_use_storage_id)
{
if ((result=fdfs_get_storage_ids_from_tracker_group( \
&g_tracker_group)) != 0)
{
return result;
}
}
if ((result=storage_check_ip_changed()) != 0) if ((result=storage_check_ip_changed()) != 0)
{ {
return result; return result;

View File

@ -74,6 +74,7 @@ bool g_use_access_log = false; //if log to access log
bool g_rotate_access_log = false; //if rotate the access log every day bool g_rotate_access_log = false; //if rotate the access log every day
bool g_compress_old_access_log = false; //if compress the old access log bool g_compress_old_access_log = false; //if compress the old access log
bool g_use_storage_id = false; //identify storage by ID instead of IP address bool g_use_storage_id = false; //identify storage by ID instead of IP address
bool g_trust_storage_server_id = false;
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
bool g_store_slave_file_use_link = false; //if store slave file use symbol link bool g_store_slave_file_use_link = false; //if store slave file use symbol link

View File

@ -103,6 +103,7 @@ extern LogContext g_access_log_context;
extern in_addr_64_t g_server_id_in_filename; extern in_addr_64_t g_server_id_in_filename;
extern bool g_store_slave_file_use_link; //if store slave file use symbol link extern bool g_store_slave_file_use_link; //if store slave file use symbol link
extern bool g_use_storage_id; //identify storage by ID instead of IP address extern bool g_use_storage_id; //identify storage by ID instead of IP address
extern bool g_trust_storage_server_id;
extern byte g_id_type_in_filename; //id type of the storage server in the filename extern byte g_id_type_in_filename; //id type of the storage server in the filename
extern bool g_use_access_log; //if log to access log extern bool g_use_access_log; //if log to access log
extern bool g_rotate_access_log; //if rotate the access log every day extern bool g_rotate_access_log; //if rotate the access log every day

View File

@ -179,6 +179,8 @@ int storage_get_params_from_tracker()
{ {
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
} }
g_trust_storage_server_id = iniGetBoolValue(NULL,
"trust_storage_server_id", &iniContext, false);
iniFreeContext(&iniContext); iniFreeContext(&iniContext);
@ -194,6 +196,7 @@ int storage_get_params_from_tracker()
logInfo("file: "__FILE__", line: %d, " logInfo("file: "__FILE__", line: %d, "
"use_storage_id=%d, " "use_storage_id=%d, "
"id_type_in_filename=%s, " "id_type_in_filename=%s, "
"trust_storage_server_id=%d, "
"storage_ip_changed_auto_adjust=%d, " "storage_ip_changed_auto_adjust=%d, "
"store_path=%d, " "store_path=%d, "
"reserved_storage_space=%s, " "reserved_storage_space=%s, "
@ -217,6 +220,7 @@ int storage_get_params_from_tracker()
"store_slave_file_use_link=%d", "store_slave_file_use_link=%d",
__LINE__, g_use_storage_id, __LINE__, g_use_storage_id,
g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID ? "id" : "ip", g_id_type_in_filename == FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
g_trust_storage_server_id,
g_storage_ip_changed_auto_adjust, g_storage_ip_changed_auto_adjust,
g_store_path_mode, fdfs_storage_reserved_space_to_string( g_store_path_mode, fdfs_storage_reserved_space_to_string(
&g_storage_reserved_space, reserved_space_str), &g_storage_reserved_space, reserved_space_str),

View File

@ -2027,6 +2027,9 @@ int tracker_report_join(ConnectionInfo *pTrackerServer, \
long2buff(g_sf_global_vars.up_time, pReqBody->up_time); long2buff(g_sf_global_vars.up_time, pReqBody->up_time);
pReqBody->init_flag = sync_old_done ? 0 : 1; pReqBody->init_flag = sync_old_done ? 0 : 1;
strcpy(pReqBody->current_tracker_ip, pTrackerServer->ip_addr); strcpy(pReqBody->current_tracker_ip, pTrackerServer->ip_addr);
if (g_use_storage_id) {
strcpy(pReqBody->storage_id, g_my_server_id_str);
}
memset(&targetServer, 0, sizeof(targetServer)); memset(&targetServer, 0, sizeof(targetServer));
pTargetServer = &targetServer; pTargetServer = &targetServer;

View File

@ -489,9 +489,9 @@ int fdfs_load_storage_ids(char *content, const char *pStorageIdsFilename)
if (!fdfs_is_server_id_valid(id)) if (!fdfs_is_server_id_valid(id))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"invalid server id: \"%s\", " \ "invalid server id: \"%s\", "
"which must be a none zero start " \ "which must be a none zero start "
"integer, such as 100001", __LINE__, id); "integer, such as 100001", __LINE__, id);
result = EINVAL; result = EINVAL;
break; break;

View File

@ -99,12 +99,12 @@ static int tracker_load_store_lookup(const char *filename, \
} }
static int tracker_load_storage_id_info(const char *config_filename, static int tracker_load_storage_id_info(const char *config_filename,
IniContext *pItemContext) IniContext *iniContext)
{ {
char *pIdType; char *pIdType;
g_use_storage_id = iniGetBoolValue(NULL, "use_storage_id", \ g_use_storage_id = iniGetBoolValue(NULL, "use_storage_id",
pItemContext, false); iniContext, false);
if (!g_use_storage_id) if (!g_use_storage_id)
{ {
if (SF_G_IPV6_ENABLED) if (SF_G_IPV6_ENABLED)
@ -118,7 +118,7 @@ static int tracker_load_storage_id_info(const char *config_filename,
return 0; return 0;
} }
pIdType = iniGetStrValue(NULL, "id_type_in_filename", pItemContext); pIdType = iniGetStrValue(NULL, "id_type_in_filename", iniContext);
if (pIdType != NULL && strcasecmp(pIdType, "id") == 0) if (pIdType != NULL && strcasecmp(pIdType, "id") == 0)
{ {
g_id_type_in_filename = FDFS_ID_TYPE_SERVER_ID; g_id_type_in_filename = FDFS_ID_TYPE_SERVER_ID;
@ -135,7 +135,9 @@ static int tracker_load_storage_id_info(const char *config_filename,
g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS;
} }
return fdfs_load_storage_ids_from_file(config_filename, pItemContext); g_trust_storage_server_id = iniGetBoolValue(NULL,
"trust_storage_server_id", iniContext, true);
return fdfs_load_storage_ids_from_file(config_filename, iniContext);
} }
int tracker_load_from_conf_file(const char *filename) int tracker_load_from_conf_file(const char *filename)
@ -534,6 +536,7 @@ int tracker_load_from_conf_file(const char *filename)
"trunk_binlog_max_backups=%d, " "trunk_binlog_max_backups=%d, "
"use_storage_id=%d, " "use_storage_id=%d, "
"id_type_in_filename=%s, " "id_type_in_filename=%s, "
"trust_storage_server_id=%d, "
"storage_id/ip_count=%d / %d, " "storage_id/ip_count=%d / %d, "
"store_slave_file_use_link=%d, " "store_slave_file_use_link=%d, "
"use_connection_pool=%d, " "use_connection_pool=%d, "
@ -569,6 +572,7 @@ int tracker_load_from_conf_file(const char *filename)
g_trunk_binlog_max_backups, g_trunk_binlog_max_backups,
g_use_storage_id, g_id_type_in_filename == g_use_storage_id, g_id_type_in_filename ==
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip", FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
g_trust_storage_server_id,
g_storage_ids_by_id.count, g_storage_ids_by_ip.count, g_storage_ids_by_id.count, g_storage_ids_by_ip.count,
g_store_slave_file_use_link, g_store_slave_file_use_link,
g_use_connection_pool, g_connection_pool_max_idle_time); g_use_connection_pool, g_connection_pool_max_idle_time);

View File

@ -21,6 +21,7 @@ in_addr_64_t *g_allow_ip_addrs = NULL;
bool g_storage_ip_changed_auto_adjust = true; bool g_storage_ip_changed_auto_adjust = true;
bool g_use_storage_id = false; //if use storage ID instead of IP address bool g_use_storage_id = false; //if use storage ID instead of IP address
bool g_trust_storage_server_id = true;
byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename byte g_id_type_in_filename = FDFS_ID_TYPE_IP_ADDRESS; //id type of the storage server in the filename
int g_storage_sync_file_max_delay = DEFAULT_STORAGE_SYNC_FILE_MAX_DELAY; int g_storage_sync_file_max_delay = DEFAULT_STORAGE_SYNC_FILE_MAX_DELAY;

View File

@ -47,6 +47,7 @@ extern in_addr_64_t *g_allow_ip_addrs; /* sorted array, asc order */
extern bool g_storage_ip_changed_auto_adjust; extern bool g_storage_ip_changed_auto_adjust;
extern bool g_use_storage_id; //identify storage by ID instead of IP address extern bool g_use_storage_id; //identify storage by ID instead of IP address
extern bool g_trust_storage_server_id;
extern byte g_id_type_in_filename; //id type of the storage server in the filename extern byte g_id_type_in_filename; //id type of the storage server in the filename
extern int g_storage_sync_file_max_delay; extern int g_storage_sync_file_max_delay;

View File

@ -3568,8 +3568,8 @@ static int tracker_mem_add_storage(TrackerClientInfo *pClientInfo,
FDFSStorageDetail *pStorageServer; FDFSStorageDetail *pStorageServer;
pStorageServer = NULL; pStorageServer = NULL;
result = _tracker_mem_add_storage(pClientInfo->pGroup, \ result = _tracker_mem_add_storage(pClientInfo->pGroup,
&pStorageServer, id, ip_addr, bNeedSleep, \ &pStorageServer, id, ip_addr, bNeedSleep,
bNeedLock, bInserted); bNeedLock, bInserted);
if (result == 0) if (result == 0)
{ {
@ -4408,8 +4408,8 @@ static int tracker_mem_get_sys_files_from_others(FDFSStorageJoinBody *pJoinBody,
return tracker_open_changlog_file(); return tracker_open_changlog_file();
} }
int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo,
const char *ip_addr, FDFSStorageJoinBody *pJoinBody, \ const char *ip_addr, FDFSStorageJoinBody *pJoinBody,
const bool bNeedSleep) const bool bNeedSleep)
{ {
int result; int result;
@ -4418,7 +4418,6 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
FDFSStorageDetail *pStorageServer; FDFSStorageDetail *pStorageServer;
FDFSStorageDetail **ppServer; FDFSStorageDetail **ppServer;
FDFSStorageDetail **ppEnd; FDFSStorageDetail **ppEnd;
FDFSStorageIdInfo *pStorageIdInfo;
FDFSStorageId storage_id; FDFSStorageId storage_id;
tracker_mem_file_lock(); tracker_mem_file_lock();
@ -4489,7 +4488,7 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
tracker_mem_file_unlock(); tracker_mem_file_unlock();
if ((result=tracker_mem_add_group_ex(&g_groups, pClientInfo, \ if ((result=tracker_mem_add_group_ex(&g_groups, pClientInfo,
pJoinBody->group_name, bNeedSleep, &bGroupInserted)) != 0) pJoinBody->group_name, bNeedSleep, &bGroupInserted)) != 0)
{ {
return result; return result;
@ -4504,22 +4503,37 @@ int tracker_mem_add_group_and_storage(TrackerClientInfo *pClientInfo, \
} }
if (g_use_storage_id) if (g_use_storage_id)
{
FDFSStorageIdInfo *pStorageIdInfo;
if (g_trust_storage_server_id && *(pJoinBody->storage_id) != '\0')
{
pStorageIdInfo = fdfs_get_storage_by_id(pJoinBody->storage_id);
if (pStorageIdInfo == NULL)
{
logError("file: "__FILE__", line: %d, "
"get storage id info fail, storage id: %s",
__LINE__, pJoinBody->storage_id);
return ENOENT;
}
}
else
{ {
pStorageIdInfo = fdfs_get_storage_id_by_ip( pStorageIdInfo = fdfs_get_storage_id_by_ip(
pClientInfo->pGroup->group_name, ip_addr); pClientInfo->pGroup->group_name, ip_addr);
if (pStorageIdInfo == NULL) if (pStorageIdInfo == NULL)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"get storage id info fail, group_name: %s, " \ "get storage id info fail, group_name: %s, "
"storage ip: %s", __LINE__, \ "storage ip: %s", __LINE__,
pClientInfo->pGroup->group_name, ip_addr); pClientInfo->pGroup->group_name, ip_addr);
return ENOENT; return ENOENT;
}
} }
storage_id.ptr = pStorageIdInfo->id; storage_id.ptr = pStorageIdInfo->id;
} }
else else
{ {
pStorageIdInfo = NULL;
// 当IP地址为IPv6时其storage_id值为IP地址的short code // 当IP地址为IPv6时其storage_id值为IP地址的short code
if (is_ipv6_addr(ip_addr)) if (is_ipv6_addr(ip_addr))
{ {

View File

@ -592,7 +592,7 @@ void tracker_disconnect_server_no_pool(TrackerServerInfo *pServerInfo)
} }
} }
static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer,
char *buff, const int buff_size) char *buff, const int buff_size)
{ {
char out_buff[sizeof(TrackerHeader)]; char out_buff[sizeof(TrackerHeader)];
@ -603,14 +603,13 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \
memset(out_buff, 0, sizeof(out_buff)); memset(out_buff, 0, sizeof(out_buff));
pHeader = (TrackerHeader *)out_buff; pHeader = (TrackerHeader *)out_buff;
pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_PARAMETER_REQ; pHeader->cmd = TRACKER_PROTO_CMD_STORAGE_PARAMETER_REQ;
if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff, \ if((result=tcpsenddata_nb(pTrackerServer->sock, out_buff,
sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0) sizeof(TrackerHeader), SF_G_NETWORK_TIMEOUT)) != 0)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"tracker server %s:%u, send data fail, " \ "tracker server %s:%u, send data fail, "
"errno: %d, error info: %s.", \ "errno: %d, error info: %s.", __LINE__,
__LINE__, pTrackerServer->ip_addr, \ pTrackerServer->ip_addr, pTrackerServer->port,
pTrackerServer->port, \
result, STRERROR(result)); result, STRERROR(result));
return result; return result;
} }
@ -623,11 +622,11 @@ static int fdfs_do_parameter_req(ConnectionInfo *pTrackerServer, \
if (in_bytes >= buff_size) if (in_bytes >= buff_size)
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, "
"server: %s:%u, recv body bytes: " \ "server: %s:%u, recv body bytes: "
"%"PRId64" exceed max: %d", \ "%"PRId64" exceed max: %d", __LINE__,
__LINE__, pTrackerServer->ip_addr, \ pTrackerServer->ip_addr, pTrackerServer->port,
pTrackerServer->port, in_bytes, buff_size); in_bytes, buff_size);
return ENOSPC; return ENOSPC;
} }

View File

@ -142,6 +142,7 @@ typedef struct
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE]; char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
char init_flag; char init_flag;
signed char status; signed char status;
char storage_id[FDFS_STORAGE_ID_MAX_SIZE]; //since 6.11
char current_tracker_ip[IP_ADDRESS_SIZE]; //current tracker ip address char current_tracker_ip[IP_ADDRESS_SIZE]; //current tracker ip address
char tracker_count[FDFS_PROTO_PKG_LEN_SIZE]; //all tracker server count char tracker_count[FDFS_PROTO_PKG_LEN_SIZE]; //all tracker server count
} TrackerStorageJoinBody; } TrackerStorageJoinBody;

View File

@ -448,6 +448,7 @@ static int tracker_deal_parameter_req(struct fast_task_info *pTask)
body_len = sprintf(pTask->send.ptr->data + sizeof(TrackerHeader), body_len = sprintf(pTask->send.ptr->data + sizeof(TrackerHeader),
"use_storage_id=%d\n" "use_storage_id=%d\n"
"id_type_in_filename=%s\n" "id_type_in_filename=%s\n"
"trust_storage_server_id=%d\n"
"storage_ip_changed_auto_adjust=%d\n" "storage_ip_changed_auto_adjust=%d\n"
"storage_sync_file_max_delay=%d\n" "storage_sync_file_max_delay=%d\n"
"store_path=%d\n" "store_path=%d\n"
@ -472,6 +473,7 @@ static int tracker_deal_parameter_req(struct fast_task_info *pTask)
"store_slave_file_use_link=%d\n", "store_slave_file_use_link=%d\n",
g_use_storage_id, g_id_type_in_filename == g_use_storage_id, g_id_type_in_filename ==
FDFS_ID_TYPE_SERVER_ID ? "id" : "ip", FDFS_ID_TYPE_SERVER_ID ? "id" : "ip",
g_trust_storage_server_id,
g_storage_ip_changed_auto_adjust, g_storage_ip_changed_auto_adjust,
g_storage_sync_file_max_delay, g_groups.store_path, g_storage_sync_file_max_delay, g_groups.store_path,
fdfs_storage_reserved_space_to_string( fdfs_storage_reserved_space_to_string(
@ -1244,7 +1246,7 @@ static int tracker_deal_storage_join(struct fast_task_info *pTask)
pClientInfo = (TrackerClientInfo *)pTask->arg; pClientInfo = (TrackerClientInfo *)pTask->arg;
if (pTask->recv.ptr->length - sizeof(TrackerHeader) < \ if (pTask->recv.ptr->length - sizeof(TrackerHeader) <
sizeof(TrackerStorageJoinBody)) sizeof(TrackerStorageJoinBody))
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
@ -1377,6 +1379,7 @@ static int tracker_deal_storage_join(struct fast_task_info *pTask)
strcpy(joinBody.domain_name, pBody->domain_name); strcpy(joinBody.domain_name, pBody->domain_name);
joinBody.init_flag = pBody->init_flag; joinBody.init_flag = pBody->init_flag;
joinBody.status = pBody->status; joinBody.status = pBody->status;
memcpy(joinBody.storage_id, pBody->storage_id, FDFS_STORAGE_ID_MAX_SIZE);
pBody->current_tracker_ip[IP_ADDRESS_SIZE - 1] = '\0'; pBody->current_tracker_ip[IP_ADDRESS_SIZE - 1] = '\0';

View File

@ -427,6 +427,7 @@ typedef struct
char version[FDFS_VERSION_SIZE]; //storage version char version[FDFS_VERSION_SIZE]; //storage version
char group_name[FDFS_GROUP_NAME_MAX_LEN + 1]; char group_name[FDFS_GROUP_NAME_MAX_LEN + 1];
char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE]; char domain_name[FDFS_DOMAIN_NAME_MAX_SIZE];
char storage_id[FDFS_STORAGE_ID_MAX_SIZE];
char init_flag; char init_flag;
signed char status; signed char status;
int tracker_count; int tracker_count;