flexnbd status: display mirror->max_bytes_per_second as mirror_speed_limit

This commit is contained in:
nick
2013-08-14 13:30:25 +01:00
parent b73081e417
commit 385c9027db
3 changed files with 23 additions and 5 deletions

View File

@@ -28,14 +28,10 @@ struct status * status_create( struct server * serve )
status->migration_duration = 0; status->migration_duration = 0;
} }
status->migration_duration /= 1000; status->migration_duration /= 1000;
status->migration_speed = serve->mirror->all_dirty / ( status->migration_duration + 1 ); status->migration_speed = serve->mirror->all_dirty / ( status->migration_duration + 1 );
status->migration_speed_limit = serve->mirror->max_bytes_per_second;
} }
server_unlock_start_mirror( serve ); server_unlock_start_mirror( serve );
return status; return status;
@@ -63,6 +59,9 @@ int status_write( struct status * status, int fd )
PRINT_UINT64( pass_clean_bytes ); PRINT_UINT64( pass_clean_bytes );
PRINT_UINT64( migration_speed ); PRINT_UINT64( migration_speed );
PRINT_UINT64( migration_duration ); PRINT_UINT64( migration_duration );
if ( status->migration_speed_limit < UINT64_MAX ) {
PRINT_UINT64( migration_speed_limit );
};
} }
dprintf(fd, "\n"); dprintf(fd, "\n");

View File

@@ -80,6 +80,7 @@ struct status {
uint64_t migration_duration; uint64_t migration_duration;
uint64_t migration_speed; uint64_t migration_speed;
uint64_t migration_speed_limit;
}; };
/** Create a status object for the given server. */ /** Create a status object for the given server. */

View File

@@ -125,6 +125,7 @@ START_TEST( test_gets_migration_statistics )
server->mirror->this_pass_clean = 2048; server->mirror->this_pass_clean = 2048;
server->mirror->this_pass_dirty = 4096; server->mirror->this_pass_dirty = 4096;
server->mirror->all_dirty = 16384; server->mirror->all_dirty = 16384;
server->mirror->max_bytes_per_second = 32768;
/* we have a bit of a time dependency here */ /* we have a bit of a time dependency here */
server->mirror->migration_started = monotonic_time_ms(); server->mirror->migration_started = monotonic_time_ms();
@@ -146,6 +147,8 @@ START_TEST( test_gets_migration_statistics )
"migration_speed not calculated correctly" "migration_speed not calculated correctly"
); );
fail_unless( 32768 == status->migration_speed_limit, "migration_speed_limit not read" );
status_destroy( status ); status_destroy( status );
destroy_mock_server( server ); destroy_mock_server( server );
@@ -285,6 +288,7 @@ START_TEST( test_renders_migration_statistics )
status.pass_clean_bytes = 4096; status.pass_clean_bytes = 4096;
status.migration_duration = 8; status.migration_duration = 8;
status.migration_speed = 40000000; status.migration_speed = 40000000;
status.migration_speed_limit = 40000001;
status_write( &status, fds[1] ); status_write( &status, fds[1] );
@@ -300,6 +304,8 @@ START_TEST( test_renders_migration_statistics )
fail_if( NULL != found, "migration_duration output when not migrating" ); fail_if( NULL != found, "migration_duration output when not migrating" );
found = strstr( buf, "migration_speed" ); found = strstr( buf, "migration_speed" );
fail_if( NULL != found, "migration_speed output when not migrating" ); fail_if( NULL != found, "migration_speed output when not migrating" );
found = strstr( buf, "migration_speed_limit" );
fail_if( NULL != found, "migration_speed_limit output when not migrating" );
status.is_mirroring = 1; status.is_mirroring = 1;
status_write( &status, fds[1] ); status_write( &status, fds[1] );
@@ -314,6 +320,18 @@ START_TEST( test_renders_migration_statistics )
fail_if( NULL == found, "migration_duration not output when migrating" ); fail_if( NULL == found, "migration_duration not output when migrating" );
found = strstr( buf, "migration_speed=40000000" ); found = strstr( buf, "migration_speed=40000000" );
fail_if( NULL == found, "migration_speed not output when migrating" ); fail_if( NULL == found, "migration_speed not output when migrating" );
found = strstr( buf, "migration_speed_limit=40000001" );
fail_if( NULL == found, "migration_speed_limit not output when migrating" );
status.migration_speed_limit = UINT64_MAX;
status_write( &status, fds[1] );
fail_unless( read_until_newline( fds[0], buf, 1024 ) > 0,
"Couldn't read the result" );
found = strstr( buf, "migration_speed_limit" );
fail_if( NULL != found, "migration_speed_limit output when no migration limit was set" );
} }
END_TEST END_TEST