From 092cc95ddc7af7d99bb362e790cf52c296c25bb8 Mon Sep 17 00:00:00 2001 From: Dan Lambright Date: Sun, 2 Aug 2015 15:17:30 +0100 Subject: cluster/tier: avoid filling /var/run with tiering files We failed to delete old promote/demote workfiles in /var/run. This fix removes the postfix so there will be only a single pair of files. Change-Id: Ib9aafe7b4a9d4b0c05cf03a94cc1057a423a27d2 BUG: 1253970 Signed-off-by: Dan Lambright Reviewed-on: http://review.gluster.org/11931 Tested-by: Gluster Build System Tested-by: NetBSD Build System Reviewed-by: N Balachandran --- xlators/cluster/dht/src/tier.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index d47932df5c0..7563ec7f20b 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1104,6 +1104,7 @@ tier_init (xlator_t *this) int freq = 0; dht_conf_t *conf = NULL; gf_defrag_info_t *defrag = NULL; + char *voldir = NULL; ret = dht_init(this); if (ret) { @@ -1173,22 +1174,45 @@ tier_init (xlator_t *this) defrag->read_freq_threshold = freq; - ret = gf_asprintf(&promotion_qfile, "%s/%s-%d", + ret = gf_asprintf(&voldir, "%s/%s", DEFAULT_VAR_RUN_DIRECTORY, + this->name); + if (ret < 0) + goto out; + + ret = mkdir_p(voldir, 0777, _gf_true); + if (ret == -1 && errno != EEXIST) { + gf_msg(this->name, GF_LOG_ERROR, 0, + DHT_MSG_LOG_TIER_ERROR, + "tier_init failed"); + + GF_FREE(voldir); + goto out; + } + + GF_FREE(voldir); + + ret = gf_asprintf(&promotion_qfile, "%s/%s/%s-%s", + DEFAULT_VAR_RUN_DIRECTORY, + this->name, PROMOTION_QFILE, - getpid()); + this->name); if (ret < 0) goto out; - ret = gf_asprintf(&demotion_qfile, "%s/%s-%d", + ret = gf_asprintf(&demotion_qfile, "%s/%s/%s-%s", DEFAULT_VAR_RUN_DIRECTORY, + this->name, DEMOTION_QFILE, - getpid()); + this->name); if (ret < 0) { GF_FREE(promotion_qfile); goto out; } + unlink(promotion_qfile); + unlink(demotion_qfile); + gf_msg(this->name, GF_LOG_INFO, 0, DHT_MSG_LOG_TIER_STATUS, "Promote/demote frequency %d/%d " -- cgit