flexnbd status: Add current migration pass to the status output if we're migrating

This commit is contained in:
nick
2013-07-08 09:58:31 +01:00
parent 55b452ebef
commit f556f298b1
5 changed files with 85 additions and 6 deletions

View File

@@ -347,13 +347,14 @@ void mirror_run( struct server *serve )
NULLCHECK( serve );
NULLCHECK( serve->mirror );
int pass;
struct mirror* m = serve->mirror;
uint64_t written;
info("Starting mirror" );
for (pass=0; pass < mirror_maximum_passes-1; pass++) {
for (m->pass=0; m->pass < mirror_maximum_passes-1; m->pass++) {
debug("mirror start pass=%d", pass);
debug("mirror start pass=%d", m->pass);
if ( !mirror_pass( serve, 0, &written ) ){
debug("Failed mirror pass state is %d", mirror_get_state( serve->mirror ) );
debug("pass failed, giving up");

View File

@@ -69,7 +69,7 @@ struct mirror {
const char * filename;
off64_t max_bytes_per_second;
enum mirror_finish_action action_at_finish;
char *mapped;
struct bitset_mapping *dirty_map;
@@ -79,6 +79,9 @@ struct mirror {
* and checking the remote size, whether successful or not.
*/
struct mbox * commit_signal;
/* The current mirror pass. We put this here so status can query it */
int pass;
};
@@ -106,3 +109,4 @@ struct mirror_super * mirror_super_create(
);
void * mirror_super_runner( void * serve_uncast );
#endif

View File

@@ -11,6 +11,11 @@ struct status * status_create( struct server * serve )
status->pid = getpid();
status->has_control = serve->success;
status->is_mirroring = NULL != serve->mirror;
if ( status->is_mirroring ) {
status->migration_pass = serve->mirror->pass;
}
return status;
}
@@ -26,6 +31,11 @@ int status_write( struct status * status, int fd )
PRINT_INT( pid );
PRINT_BOOL( is_mirroring );
PRINT_BOOL( has_control );
if ( status->is_mirroring ) {
PRINT_INT( migration_pass );
}
dprintf(fd, "\n");
return 1;
}
@@ -36,3 +46,4 @@ void status_destroy( struct status * status )
NULLCHECK( status );
free( status );
}

View File

@@ -32,8 +32,17 @@
* or "serve" mode. It will become true when a server in "serve"
* mode starts a migration, and will become false again when the
* migration terminates, successfully or not.
* If the server is currently in "listen" mode, this will never b
* If the server is currently in "listen" mode, this will never be
* true.
*
* If is_migrating is true, then a number of other attributes may appear,
* relating to the progress of the migration.
*
* migration_pass:
* When migrating, we perform a number of passes over the file. This indicates
* the current pass.
*
*
*/
@@ -46,6 +55,7 @@ struct status {
pid_t pid;
int has_control;
int is_mirroring;
int migration_pass;
};
/** Create a status object for the given server. */
@@ -60,3 +70,4 @@ void status_destroy( struct status * );
#endif