diff --git a/src/common/misc/server-config.c b/src/common/misc/server-config.c index 322dbe1..43cfd6a 100644 --- a/src/common/misc/server-config.c +++ b/src/common/misc/server-config.c @@ -125,6 +125,8 @@ static DOTCONF_CB(get_osd_type); static DOTCONF_CB(get_osd_dir_type); static DOTCONF_CB(get_create_type); static DOTCONF_CB(get_member_attr_type); +static DOTCONF_CB(get_eco_type); +static DOTCONF_CB(get_eco_num); static DOTCONF_CB(get_small_file_size); static DOTCONF_CB(directio_thread_num); static DOTCONF_CB(directio_ops_per_queue); @@ -1020,6 +1022,16 @@ static const configoption_t options[] = * Specifies if getting member attributes is enabled or not */ { "MemberAttr", ARG_STR, get_member_attr_type, NULL, CTX_DEFAULTS, "no" }, + + /* + * Specifies if energy saving mode is enabled or not + */ + { "EnergySaving", ARG_STR, get_eco_type, NULL, CTX_DEFAULTS, "no" }, + + /* + * Specifies how many nodes are going to be used in energy saving mode + */ + { "NumECOnodes", ARG_INT, get_eco_num, NULL, CTX_DEFAULTS, 0 }, /* Specifies the size of the small file transition point */ {"SmallFileSize", ARG_INT, get_small_file_size, NULL, CTX_FILESYSTEM, NULL}, @@ -3004,10 +3016,34 @@ static DOTCONF_CB(get_member_attr_type) else if (!strcmp(str, "yes")) config->member_attr = GET_MEMBER_ATTR; else - ret = "get_member_attr_type: unknown FileSystem PostCreate option\n"; + ret = "get_member_attr_type: unknown FileSystem MemberAttr option\n"; + return ret; +} + +static DOTCONF_CB(get_eco_type) +{ + const char *str = cmd->data.str; + struct server_configuration_s *config = cmd->context; + const char *ret = NULL; + + if (!strcmp(str, "no")) + config->energysaving = NO_ENERGY_SAVING; + else if (!strcmp(str, "yes")) + config->energysaving = ENERGY_SAVING; + else + ret = "get_eco_type: unknown FileSystem EnergySaving option\n"; return ret; } +static DOTCONF_CB(get_eco_num) +{ + struct server_configuration_s *config = cmd->context; + + config->econumnodes = cmd->data.value; + + return NULL; +} + static DOTCONF_CB(get_osd_type) { const char *str = cmd->data.str; @@ -4242,6 +4278,46 @@ static char *get_handle_range_str( return ret; } +char *assign_io_servers( + struct server_configuration_s *config_s, + struct filesystem_configuration_s *fs) +{ + char *ret = (char *)0; + PINT_llist *cur = NULL; + struct host_handle_mapping_s *cur_h_mapping = NULL; + int num_io_servers = 0; + gossip_err("%d\n", config_s->econumnodes); + + if (config_s && config_s->host_id && fs) + { + cur = fs->data_handle_ranges; + while(cur) + { + cur_h_mapping = PINT_llist_head(cur); + if (!cur_h_mapping) + { + break; + } + assert(cur_h_mapping->alias_mapping); + assert(cur_h_mapping->alias_mapping->host_alias); + assert(cur_h_mapping->handle_range); + + num_io_servers++; + + cur = PINT_llist_next(cur); + } + } + + if (config_s->econumnodes > num_io_servers) + { + gossip_err("Turning off energy saving mode\n"); + config_s->econumnodes = 0; + config_s->energysaving = 0; + } + + return ret; +} + /* returns 1 if the specified configuration object is valid (i.e. contains values that make sense); 0 otherwise diff --git a/src/common/misc/server-config.h b/src/common/misc/server-config.h index c53f877..c79df27 100644 --- a/src/common/misc/server-config.h +++ b/src/common/misc/server-config.h @@ -224,6 +224,13 @@ typedef struct server_configuration_s NO_MEMBER_ATTR, /* fetch attributes of a single object at once */ GET_MEMBER_ATTR, /* fetch attributes of all the objects that are members of a collection */ } member_attr; + + enum { + NO_ENERGY_SAVING, /* fetch attributes of a single object at once */ + ENERGY_SAVING, /* fetch attributes of all the objects that are members of a collection */ + } energysaving; + + int econumnodes; void *private_data; } server_configuration_s; @@ -276,6 +283,10 @@ char *PINT_config_get_data_handle_range_str( char *PINT_config_get_merged_handle_range_str( struct server_configuration_s *config_s, struct filesystem_configuration_s *fs); + +char *assign_io_servers( + struct server_configuration_s *config_s, + struct filesystem_configuration_s *fs); int PINT_config_is_valid_configuration( struct server_configuration_s *config_s); diff --git a/src/server/pvfs2-server.c b/src/server/pvfs2-server.c index c1a3244..60a427e 100644 --- a/src/server/pvfs2-server.c +++ b/src/server/pvfs2-server.c @@ -905,6 +905,11 @@ static int server_initialize_subsystems( PINT_config_get_merged_handle_range_str( &server_config, cur_fs); + if(server_config.energysaving) + { + assign_io_servers(&server_config, cur_fs); + } + /* * error out if we're not configured to house either a meta or * data handle range at all.