Skip to content

Commit

Permalink
added CONFIG_CONCURRENT_DISK_OPS support back
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii committed Dec 3, 2011
1 parent 8631d91 commit a34b5f9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
29 changes: 16 additions & 13 deletions node/handlers.c
Expand Up @@ -904,17 +904,19 @@ static int init (void)
} }
} }


#define GET_VAR_INT(var,name) \ #define GET_VAR_INT(var,name,def) \
s = getConfString(configFiles, 2, name); \ s = getConfString(configFiles, 2, name); \
if (s){ \ if (s){ \
var = atoi(s);\ var = atoi(s);\
free (s);\ free (s);\
} } else { \
GET_VAR_INT(nc_state.config_max_mem, CONFIG_MAX_MEM); var = def; \
GET_VAR_INT(nc_state.config_max_cores, CONFIG_MAX_CORES); }
GET_VAR_INT(nc_state.save_instance_files, CONFIG_SAVE_INSTANCES); GET_VAR_INT(nc_state.config_max_mem, CONFIG_MAX_MEM, 0);
int disable_injection = 0; GET_VAR_INT(nc_state.config_max_cores, CONFIG_MAX_CORES, 0);
GET_VAR_INT(disable_injection, CONFIG_DISABLE_KEY_INJECTION); GET_VAR_INT(nc_state.save_instance_files, CONFIG_SAVE_INSTANCES, 0);
GET_VAR_INT(nc_state.concurrent_disk_ops, CONFIG_CONCURRENT_DISK_OPS, 1);
int disable_injection; GET_VAR_INT(disable_injection, CONFIG_DISABLE_KEY_INJECTION, 0);
nc_state.do_inject_key = !disable_injection; nc_state.do_inject_key = !disable_injection;
strcpy(nc_state.admin_user_id, EUCALYPTUS_ADMIN); strcpy(nc_state.admin_user_id, EUCALYPTUS_ADMIN);


Expand Down Expand Up @@ -986,10 +988,10 @@ static int init (void)
long long cache_bs_reserved_mb = cache_meta.blocks_limit ? ((cache_meta.blocks_locked + cache_meta.blocks_unlocked) / 2048) : 0; long long cache_bs_reserved_mb = cache_meta.blocks_limit ? ((cache_meta.blocks_locked + cache_meta.blocks_unlocked) / 2048) : 0;


// look up configuration file settings for work and cache size // look up configuration file settings for work and cache size
long long conf_work_size_mb = -1; GET_VAR_INT(conf_work_size_mb, CONFIG_NC_WORK_SIZE); long long conf_work_size_mb; GET_VAR_INT(conf_work_size_mb, CONFIG_NC_WORK_SIZE, -1);
long long conf_cache_size_mb = -1; GET_VAR_INT(conf_cache_size_mb, CONFIG_NC_CACHE_SIZE); long long conf_cache_size_mb; GET_VAR_INT(conf_cache_size_mb, CONFIG_NC_CACHE_SIZE, -1);
{ // accommodate legacy MAX_DISK setting by converting it { // accommodate legacy MAX_DISK setting by converting it
int max_disk_gb = -1; GET_VAR_INT(max_disk_gb, CONFIG_MAX_DISK); int max_disk_gb; GET_VAR_INT(max_disk_gb, CONFIG_MAX_DISK, -1);
if (max_disk_gb != -1) { if (max_disk_gb != -1) {
if (conf_work_size_mb == -1) { if (conf_work_size_mb == -1) {
logprintfl (EUCAWARN, "warning: using deprecated setting %s for the new setting %s\n", CONFIG_MAX_DISK, CONFIG_NC_WORK_SIZE); logprintfl (EUCAWARN, "warning: using deprecated setting %s for the new setting %s\n", CONFIG_MAX_DISK, CONFIG_NC_WORK_SIZE);
Expand Down Expand Up @@ -1121,9 +1123,9 @@ static int init (void)
// only load virtio config for kvm // only load virtio config for kvm
if (!strncmp("kvm", hypervisor, CHAR_BUFFER_SIZE) || if (!strncmp("kvm", hypervisor, CHAR_BUFFER_SIZE) ||
!strncmp("KVM", hypervisor, CHAR_BUFFER_SIZE)) { !strncmp("KVM", hypervisor, CHAR_BUFFER_SIZE)) {
GET_VAR_INT(nc_state.config_use_virtio_net, CONFIG_USE_VIRTIO_NET); GET_VAR_INT(nc_state.config_use_virtio_net, CONFIG_USE_VIRTIO_NET, 0);
GET_VAR_INT(nc_state.config_use_virtio_disk, CONFIG_USE_VIRTIO_DISK); GET_VAR_INT(nc_state.config_use_virtio_disk, CONFIG_USE_VIRTIO_DISK, 0);
GET_VAR_INT(nc_state.config_use_virtio_root, CONFIG_USE_VIRTIO_ROOT); GET_VAR_INT(nc_state.config_use_virtio_root, CONFIG_USE_VIRTIO_ROOT, 0);
} }
free (hypervisor); free (hypervisor);


Expand All @@ -1147,6 +1149,7 @@ static int init (void)
logprintfl(EUCAINFO, "physical memory available for instances: %lldMB\n", nc_state.mem_max); logprintfl(EUCAINFO, "physical memory available for instances: %lldMB\n", nc_state.mem_max);
logprintfl(EUCAINFO, "virtual cpu cores available for instances: %lld\n", nc_state.cores_max); logprintfl(EUCAINFO, "virtual cpu cores available for instances: %lld\n", nc_state.cores_max);



// adopt running instances // adopt running instances
adopt_instances(); adopt_instances();


Expand Down
1 change: 1 addition & 0 deletions node/handlers.h
Expand Up @@ -87,6 +87,7 @@ struct nc_state_t {
virConnectPtr conn; virConnectPtr conn;
boolean convert_to_disk; boolean convert_to_disk;
boolean do_inject_key; boolean do_inject_key;
int concurrent_disk_ops;
// defined max // defined max
long long config_max_mem; long long config_max_mem;
long long config_max_cores; long long config_max_cores;
Expand Down
25 changes: 22 additions & 3 deletions storage/backing.c
Expand Up @@ -84,6 +84,7 @@
#include "backing.h" #include "backing.h"
#include "iscsi.h" #include "iscsi.h"
#include "vbr.h" #include "vbr.h"
#include "ipc.h" // sem


#define CACHE_TIMEOUT_USEC 1000000LL*60*60*2 #define CACHE_TIMEOUT_USEC 1000000LL*60*60*2
#define STORE_TIMEOUT_USEC 1000000LL*60*2 #define STORE_TIMEOUT_USEC 1000000LL*60*2
Expand All @@ -93,6 +94,8 @@
static char instances_path [MAX_PATH]; static char instances_path [MAX_PATH];
static blobstore * cache_bs = NULL; static blobstore * cache_bs = NULL;
static blobstore * work_bs; static blobstore * work_bs;
static sem * disk_sem = NULL;

extern struct nc_state_t nc_state; extern struct nc_state_t nc_state;


static void bs_errors (const char * msg) { static void bs_errors (const char * msg) {
Expand Down Expand Up @@ -172,6 +175,13 @@ int init_backing_store (const char * conf_instances_path, unsigned int conf_work
return ERROR; return ERROR;
} }


// set the initial value of the semaphore to the number of
// disk-intensive operations that can run in parallel on this node
if (nc_state.concurrent_disk_ops && (disk_sem = sem_alloc (nc_state.concurrent_disk_ops, "mutex")) == NULL) {
logprintfl (EUCAERROR, "failed to create and initialize disk semaphore\n");
return ERROR;
}

return OK; return OK;
} }


Expand Down Expand Up @@ -347,12 +357,21 @@ int create_instance_backing (ncInstance * instance)
TRUE, // make working copy of runtime-modifiable files TRUE, // make working copy of runtime-modifiable files
(instance->do_inject_key)?(instance->keyName):(NULL), // the SSH key (instance->do_inject_key)?(instance->keyName):(NULL), // the SSH key
instance->instanceId); // ID is for logging instance->instanceId); // ID is for logging
if (sentinel == NULL || if (sentinel == NULL) {
art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC) != OK) { // download/create/combine the dependencies
logprintfl (EUCAERROR, "[%s] error: failed to prepare backing for instance\n", instance->instanceId); logprintfl (EUCAERROR, "[%s] error: failed to prepare backing for instance\n", instance->instanceId);
goto out; goto out;
} }


sem_p (disk_sem);
// download/create/combine the dependencies
int rc = art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC);
sem_v (disk_sem);

if (rc != OK) {
logprintfl (EUCAERROR, "[%s] error: failed to implement backing for instance\n", instance->instanceId);
goto out;
}

if (save_instance_struct (instance)) // update instance checkpoint now that the struct got updated if (save_instance_struct (instance)) // update instance checkpoint now that the struct got updated
goto out; goto out;


Expand Down

0 comments on commit a34b5f9

Please sign in to comment.