diff options
author | Dan Lambright <dlambrig@redhat.com> | 2015-09-02 09:17:52 -0400 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-09-03 04:52:17 -0700 |
commit | 3050e26c1b733f722dd8dc17718f0c075c079fcf (patch) | |
tree | 69b1d082d2001a6d5c518b245b60f3351f55437c /xlators/cluster/dht/src/tier.c | |
parent | b1cd5cb8a857ed3a95eab95179378283c8d41763 (diff) |
cluster/tier: avoid filling /var/run with tiering files
This is a backport of 11931.
> We failed to delete old promote/demote workfiles in /var/run.
> This fix removes the <pid> postfix so there will be only a
> single pair of files.
> Change-Id: Ib9aafe7b4a9d4b0c05cf03a94cc1057a423a27d2
> BUG: 1253970
> Signed-off-by: Dan Lambright <dlambrig@redhat.com>
> Reviewed-on: http://review.gluster.org/11931
Change-Id: Id9fb843a5ce553a79fc9f5809f84af9d317b1d3e
BUG: 1259360
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-on: http://review.gluster.org/12092
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/tier.c')
-rw-r--r-- | xlators/cluster/dht/src/tier.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index e996c22ea1d..3e3688861cc 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -1091,6 +1091,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) { @@ -1160,22 +1161,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 " |