control/mirror: Use uint64_t and strtoull to get max_Bps into the mirror
This commit is contained in:
@@ -319,7 +319,7 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
|
|||||||
struct flexnbd * flexnbd = client->flexnbd;
|
struct flexnbd * flexnbd = client->flexnbd;
|
||||||
union mysockaddr *connect_to = xmalloc( sizeof( union mysockaddr ) );
|
union mysockaddr *connect_to = xmalloc( sizeof( union mysockaddr ) );
|
||||||
union mysockaddr *connect_from = NULL;
|
union mysockaddr *connect_from = NULL;
|
||||||
uint64_t max_Bps = 0;
|
uint64_t max_Bps = UINT64_MAX;
|
||||||
int action_at_finish;
|
int action_at_finish;
|
||||||
int raw_port;
|
int raw_port;
|
||||||
|
|
||||||
@@ -367,7 +367,15 @@ int control_mirror(struct control_client* client, int linesc, char** lines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (linesc > 4) {
|
if (linesc > 4) {
|
||||||
max_Bps = atoi(lines[4]);
|
errno = 0;
|
||||||
|
max_Bps = strtoull( lines[4], NULL, 10 );
|
||||||
|
if ( errno == ERANGE ) {
|
||||||
|
write_socket( "1: max_bps out of range" );
|
||||||
|
return -1;
|
||||||
|
} else if ( errno != 0 ) {
|
||||||
|
write_socket( "1: max_bps couldn't be parsed" );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
10
src/mirror.c
10
src/mirror.c
@@ -82,8 +82,8 @@ struct mirror_ctrl {
|
|||||||
struct mirror * mirror_alloc(
|
struct mirror * mirror_alloc(
|
||||||
union mysockaddr * connect_to,
|
union mysockaddr * connect_to,
|
||||||
union mysockaddr * connect_from,
|
union mysockaddr * connect_from,
|
||||||
int max_Bps,
|
uint64_t max_Bps,
|
||||||
int action_at_finish,
|
enum mirror_finish_action action_at_finish,
|
||||||
struct mbox * commit_signal)
|
struct mbox * commit_signal)
|
||||||
{
|
{
|
||||||
struct mirror * mirror;
|
struct mirror * mirror;
|
||||||
@@ -178,7 +178,7 @@ struct mirror * mirror_create(
|
|||||||
const char * filename,
|
const char * filename,
|
||||||
union mysockaddr * connect_to,
|
union mysockaddr * connect_to,
|
||||||
union mysockaddr * connect_from,
|
union mysockaddr * connect_from,
|
||||||
int max_Bps,
|
uint64_t max_Bps,
|
||||||
int action_at_finish,
|
int action_at_finish,
|
||||||
struct mbox * commit_signal)
|
struct mbox * commit_signal)
|
||||||
{
|
{
|
||||||
@@ -816,8 +816,8 @@ struct mirror_super * mirror_super_create(
|
|||||||
const char * filename,
|
const char * filename,
|
||||||
union mysockaddr * connect_to,
|
union mysockaddr * connect_to,
|
||||||
union mysockaddr * connect_from,
|
union mysockaddr * connect_from,
|
||||||
int max_Bps,
|
uint64_t max_Bps,
|
||||||
int action_at_finish,
|
enum mirror_finish_action action_at_finish,
|
||||||
struct mbox * state_mbox)
|
struct mbox * state_mbox)
|
||||||
{
|
{
|
||||||
struct mirror_super * super = xmalloc( sizeof( struct mirror_super) );
|
struct mirror_super * super = xmalloc( sizeof( struct mirror_super) );
|
||||||
|
@@ -73,7 +73,7 @@ struct mirror {
|
|||||||
|
|
||||||
/* Not used yet. Will be a limiter, used to restrict migration speed.
|
/* Not used yet. Will be a limiter, used to restrict migration speed.
|
||||||
* only dirty bytes (those going over the network) will be considered */
|
* only dirty bytes (those going over the network) will be considered */
|
||||||
off64_t max_bytes_per_second;
|
uint64_t max_bytes_per_second;
|
||||||
|
|
||||||
enum mirror_finish_action action_at_finish;
|
enum mirror_finish_action action_at_finish;
|
||||||
|
|
||||||
@@ -124,8 +124,8 @@ struct mirror_super * mirror_super_create(
|
|||||||
const char * filename,
|
const char * filename,
|
||||||
union mysockaddr * connect_to,
|
union mysockaddr * connect_to,
|
||||||
union mysockaddr * connect_from,
|
union mysockaddr * connect_from,
|
||||||
int max_Bps,
|
uint64_t max_Bps,
|
||||||
int action_at_finish,
|
enum mirror_finish_action action_at_finish,
|
||||||
struct mbox * state_mbox
|
struct mbox * state_mbox
|
||||||
);
|
);
|
||||||
void * mirror_super_runner( void * serve_uncast );
|
void * mirror_super_runner( void * serve_uncast );
|
||||||
|
Reference in New Issue
Block a user