From ecead44b5c8d1215e7c398ca1132a4b0b11a44bb Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Sun, 12 Apr 2009 04:12:00 -0700 Subject: in dht, initialize the free available space properly, so the first few creates are not confused. Signed-off-by: Anand V. Avati --- xlators/cluster/dht/src/dht-common.c | 3 ++ xlators/cluster/dht/src/dht-common.h | 1 + xlators/cluster/dht/src/dht-diskusage.c | 51 +++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) (limited to 'xlators/cluster/dht/src') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index e68b268df30..b2d2a0d9f46 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -3649,6 +3649,9 @@ dht_notify (xlator_t *this, int event, void *data, ...) } UNLOCK (&conf->subvolume_lock); + /* one of the node came back up, do a stat update */ + dht_get_du_info_for_subvol (this, cnt); + break; case GF_EVENT_CHILD_DOWN: diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index b6959d86d14..303cf9cb131 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -234,5 +234,6 @@ int dht_get_du_info (call_frame_t *frame, xlator_t *this, loc_t *loc); int dht_is_subvol_filled (xlator_t *this, xlator_t *subvol); xlator_t *dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol); +int dht_get_du_info_for_subvol (xlator_t *this, int subvol_idx); #endif /* _DHT_H */ diff --git a/xlators/cluster/dht/src/dht-diskusage.c b/xlators/cluster/dht/src/dht-diskusage.c index 330e93699d7..795574661e7 100644 --- a/xlators/cluster/dht/src/dht-diskusage.c +++ b/xlators/cluster/dht/src/dht-diskusage.c @@ -69,6 +69,49 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie, xlator_t *this, return 0; } +int +dht_get_du_info_for_subvol (xlator_t *this, int subvol_idx) +{ + dht_conf_t *conf = NULL; + call_frame_t *statfs_frame = NULL; + dht_local_t *statfs_local = NULL; + call_pool_t *pool = NULL; + + conf = this->private; + pool = this->ctx->pool; + + statfs_frame = create_frame (this, pool); + if (!statfs_frame) { + gf_log (this->name, GF_LOG_ERROR, + "memory allocation failed :("); + goto err; + } + + statfs_local = dht_local_init (statfs_frame); + if (!statfs_local) { + gf_log (this->name, GF_LOG_ERROR, + "memory allocation failed :("); + goto err; + } + + loc_t tmp_loc = { .inode = NULL, + .path = "/", + }; + + statfs_local->call_cnt = 1; + STACK_WIND (statfs_frame, dht_du_info_cbk, + conf->subvolumes[subvol_idx], + conf->subvolumes[subvol_idx]->fops->statfs, + &tmp_loc); + + return 0; + err: + if (statfs_frame) + DHT_STACK_DESTROY (statfs_frame); + + return -1; +} + int dht_get_du_info (call_frame_t *frame, xlator_t *this, loc_t *loc) { @@ -103,6 +146,7 @@ dht_get_du_info (call_frame_t *frame, xlator_t *this, loc_t *loc) .path = "/", }; + statfs_local->call_cnt = conf->subvolume_cnt; for (i = 0; i < conf->subvolume_cnt; i++) { STACK_WIND (statfs_frame, dht_du_info_cbk, conf->subvolumes[i], @@ -148,8 +192,9 @@ dht_is_subvol_filled (xlator_t *this, xlator_t *subvol) if (!(conf->du_stats[i].log++ % GF_UNIVERSAL_ANSWER)) { gf_log (this->name, GF_LOG_CRITICAL, "disk space on subvolume '%s' is getting " - "full(%f), consider adding more nodes", - subvol->name, conf->du_stats[i].avail_percent); + "full (%.2f %%), consider adding more nodes", + subvol->name, + (100 - conf->du_stats[i].avail_percent)); } } @@ -180,7 +225,7 @@ dht_free_disk_available_subvol (xlator_t *this, xlator_t *subvol) if (avail_subvol == subvol) { gf_log (this->name, GF_LOG_CRITICAL, - "no node has enough free space :O"); + "no node has enough free space to schedule create"); } return avail_subvol; -- cgit