void work_queue_resources_measure_locally( struct work_queue_resources *r, const char *disk_path ) { static int gpu_check = 0; UINT64_T avail,total; r->cores.total = load_average_get_cpus(); r->cores.largest = r->cores.smallest = r->cores.total; /* For disk and memory, we compute the total thinking that the worker is * not executing by itself, but that it has to share its resources with * other processes/workers. */ host_disk_info_get(disk_path,&avail,&total); r->disk.total = (avail / (UINT64_T) MEGA) + r->disk.inuse; // Free + whatever we are using. r->disk.largest = r->disk.smallest = r->disk.total; host_memory_info_get(&avail,&total); r->memory.total = (avail / (UINT64_T) MEGA) + r->memory.inuse; // Free + whatever we are using. r->memory.largest = r->memory.smallest = r->memory.total; if(!gpu_check) { r->gpus.total = gpu_info_get(); r->gpus.largest = r->gpus.smallest = r->gpus.total; gpu_check = 1; } r->workers.total = 1; r->workers.largest = r->workers.smallest = r->workers.total; }
static int directory_low_disk( const char *path ) { UINT64_T avail, total; if(host_disk_info_get(path, &avail, &total) >= 0) return avail <= MAKEFLOW_MIN_SPACE; return 0; }
static int directory_low_disk( const char *path, uint64_t size ) { UINT64_T avail, total; if(host_disk_info_get(path, &avail, &total) >= 0) return avail <= size; return 0; }
int check_disk_space_for_filesize(char *path, int64_t file_size, uint64_t disk_avail_threshold) { uint64_t disk_avail, disk_total; if(disk_avail_threshold > 0) { host_disk_info_get(path, &disk_avail, &disk_total); if(file_size > 0) { if((uint64_t)file_size > disk_avail || (disk_avail - file_size) < disk_avail_threshold) { debug(D_DEBUG, "File of size %"PRId64" MB will lower available disk space (%"PRIu64" MB) below threshold (%"PRIu64" MB).\n", file_size/MEGA, disk_avail/MEGA, disk_avail_threshold/MEGA); return 0; } } else { if(disk_avail < disk_avail_threshold) { debug(D_DEBUG, "Available disk space (%"PRIu64" MB) lower than threshold (%"PRIu64" MB).\n", disk_avail/MEGA, disk_avail_threshold/MEGA); return 0; } } } return 1; }