summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-04-12 04:12:00 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-04-12 19:18:03 +0530
commitecead44b5c8d1215e7c398ca1132a4b0b11a44bb (patch)
tree01bdbf9c7ae83f90487ab6442c6016d117aa1a02 /xlators
parente00bdb4a323b60ced500df59071d2a940b976ae9 (diff)
in dht, initialize the free available space properly, so the first few creates are not confused.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-common.c3
-rw-r--r--xlators/cluster/dht/src/dht-common.h1
-rw-r--r--xlators/cluster/dht/src/dht-diskusage.c51
3 files changed, 52 insertions, 3 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index e68b268df..b2d2a0d9f 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 b6959d86d..303cf9cb1 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 330e93699..795574661 100644
--- a/xlators/cluster/dht/src/dht-diskusage.c
+++ b/xlators/cluster/dht/src/dht-diskusage.c
@@ -70,6 +70,49 @@ dht_du_info_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
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)
{
int i = 0;
@@ -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;