an 2036 19:58:57 GMT ETag: "790704a8fc74ca16a7b396eb5ac2dfdcc25b811e" /* Copyright (c) 2006-2009 Z RESEARCH, Inc. This file is part of GlusterFS. GlusterFS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. GlusterFS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include #include "scheduler.h" #include "common-utils.h" struct nufa_sched_struct { xlator_t *xl; struct timeval last_stat_fetch; int64_t free_disk; int32_t refresh_interval; unsigned char eligible; }; struct nufa_struct { struct nufa_sched_struct *array; struct timeval last_stat_fetch; int32_t *local_array; /* Used to keep the index of the local xlators */ int32_t local_xl_index; /* index in the above array */ int32_t local_xl_count; /* Count of the local subvolumes */ uint32_t refresh_interval; uint32_t min_free_disk; gf_lock_t nufa_lock; int32_t child_count; int32_t sched_index; }; #define NUFA_LIMITS_MIN_FREE_DISK_DEFAULT 15 #define NUFA_REFRESH_INTERVAL_DEFAULT 30 static int32_t nufa_init (xlator_t *xl) { int32_t index = 0; data_t *local_name = NULL; data_t *data = NULL; xlator_list_t *trav_xl = xl->children; struct nufa_struct *nufa_buf = NULL; nufa_buf = CALLOC (1, sizeof (struct nufa_struct)); ERR_ABORT (nufa_buf); data = dict_get (xl->options, "scheduler.limits.min-free-disk"); if (data) { if (gf_string2percent (data->data, &nufa_buf->min_free_disk) != 0) { gf_log ("nufa", GF_LOG_ERROR, "invalid number format \"%s\" of " "\"option scheduler.limits.min-free-disk\"", data->data); return -1; } if (nufa_buf->min_free_disk >= 100) { gf_log ("nufa", GF_LOG_ERROR, "check \"option scheduler.limits.min-free-disk" "\", it should be percentage value"); return -1; } } else { gf_log ("nufa", GF_LOG_WARNING, "No option for limit min-free-disk given, " "defaulting it to 15%%"); nufa_buf->min_free_disk = NUFA_LIMITS_MIN_FREE_DISK_DEFAULT; } data = dict_get (xl->options, "scheduler.refresh-interval"); if (data != NULL) { if (gf_string2time (data->data, &nufa_buf->refresh_interval) != 0) { gf_log ("nufa", GF_LOG_ERROR, "invalid number format \"%s\" of " "\"option scheduler.refresh-interval\"", data->data); return -1; } } else { gf_log ("nufa", GF_LOG_WARNING, "No option for scheduler.refresh-interval given, " "defaulting it to 30"); nufa_buf->refresh_interval = NUFA_REFRESH_INTERVAL_DEFAULT; } /* Get the array built */ while (trav_xl) { index++; trav_xl = trav_xl->next; } nufa_buf->child_count = index; nufa_buf->sched_index = 0; nufa_buf->array = CALLOC (index, sizeof (struct nufa_sched_struct)); ERR_ABORT (nufa_buf->array); nufa_buf->local_array = CALLOC (index, sizeof (int32_t)); ERR_ABORT (nufa_buf->array); trav_xl = xl->children; local_name = dict_get (xl->options, "scheduler.local-volume-name"); if (!local_name) { /* Error */ gf_log ("nufa", GF_LOG_ERROR, "No 'loc