Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added CONFIG_CONCURRENT_DISK_OPS support back

  • Loading branch information...
commit a34b5f9d23f3e24d602f719178447df6ee0c1a04 1 parent 8631d91
@dmitrii dmitrii authored
Showing with 39 additions and 16 deletions.
  1. +16 −13 node/handlers.c
  2. +1 −0  node/handlers.h
  3. +22 −3 storage/backing.c
View
29 node/handlers.c
@@ -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); \
if (s){ \
var = atoi(s);\
free (s);\
- }
- GET_VAR_INT(nc_state.config_max_mem, CONFIG_MAX_MEM);
- GET_VAR_INT(nc_state.config_max_cores, CONFIG_MAX_CORES);
- GET_VAR_INT(nc_state.save_instance_files, CONFIG_SAVE_INSTANCES);
- int disable_injection = 0;
- GET_VAR_INT(disable_injection, CONFIG_DISABLE_KEY_INJECTION);
+ } else { \
+ var = def; \
+ }
+ GET_VAR_INT(nc_state.config_max_mem, CONFIG_MAX_MEM, 0);
+ GET_VAR_INT(nc_state.config_max_cores, CONFIG_MAX_CORES, 0);
+ 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;
strcpy(nc_state.admin_user_id, EUCALYPTUS_ADMIN);
@@ -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;
// 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_cache_size_mb = -1; GET_VAR_INT(conf_cache_size_mb, CONFIG_NC_CACHE_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; GET_VAR_INT(conf_cache_size_mb, CONFIG_NC_CACHE_SIZE, -1);
{ // 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 (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);
@@ -1121,9 +1123,9 @@ static int init (void)
// only load virtio config for kvm
if (!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_disk, CONFIG_USE_VIRTIO_DISK);
- GET_VAR_INT(nc_state.config_use_virtio_root, CONFIG_USE_VIRTIO_ROOT);
+ 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, 0);
+ GET_VAR_INT(nc_state.config_use_virtio_root, CONFIG_USE_VIRTIO_ROOT, 0);
}
free (hypervisor);
@@ -1147,6 +1149,7 @@ static int init (void)
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);
+
// adopt running instances
adopt_instances();
View
1  node/handlers.h
@@ -87,6 +87,7 @@ struct nc_state_t {
virConnectPtr conn;
boolean convert_to_disk;
boolean do_inject_key;
+ int concurrent_disk_ops;
// defined max
long long config_max_mem;
long long config_max_cores;
View
25 storage/backing.c
@@ -84,6 +84,7 @@
#include "backing.h"
#include "iscsi.h"
#include "vbr.h"
+#include "ipc.h" // sem
#define CACHE_TIMEOUT_USEC 1000000LL*60*60*2
#define STORE_TIMEOUT_USEC 1000000LL*60*2
@@ -93,6 +94,8 @@
static char instances_path [MAX_PATH];
static blobstore * cache_bs = NULL;
static blobstore * work_bs;
+static sem * disk_sem = NULL;
+
extern struct nc_state_t nc_state;
static void bs_errors (const char * msg) {
@@ -172,6 +175,13 @@ int init_backing_store (const char * conf_instances_path, unsigned int conf_work
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;
}
@@ -347,12 +357,21 @@ int create_instance_backing (ncInstance * instance)
TRUE, // make working copy of runtime-modifiable files
(instance->do_inject_key)?(instance->keyName):(NULL), // the SSH key
instance->instanceId); // ID is for logging
- if (sentinel == NULL ||
- art_implement_tree (sentinel, work_bs, cache_bs, work_prefix, INSTANCE_PREP_TIMEOUT_USEC) != OK) { // download/create/combine the dependencies
+ if (sentinel == NULL) {
logprintfl (EUCAERROR, "[%s] error: failed to prepare backing for instance\n", instance->instanceId);
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
goto out;
Please sign in to comment.
Something went wrong with that request. Please try again.