diff options
author | shishir gowda <shishirng@gluster.com> | 2011-04-14 05:11:33 +0000 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2011-05-31 21:53:59 -0700 |
commit | 0d2d861849a3b066eac676ebed4e16accdfe8598 (patch) | |
tree | 46845464af66310163e83c62a1fae0b168d95cf6 /xlators | |
parent | dd476eb4678df02ff22f9aa7db7453f857721c42 (diff) |
DHT:first_up_subvol should be the one up the longest
Signed-off-by: shishir gowda <shishirng@gluster.com>
Signed-off-by: Anand Avati <avati@gluster.com>
BUG: 2684 (Dir missing from mount point)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2684
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 10 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-common.h | 1 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-helper.c | 12 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-mem-types.h | 1 |
4 files changed, 20 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 8fa93fa07..cd2985002 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -4992,6 +4992,11 @@ dht_init_subvolumes (xlator_t *this, dht_conf_t *conf) return -1; } + conf->subvol_up_time = GF_CALLOC (cnt, sizeof (time_t), + gf_dht_mt_subvol_time); + if (!conf->subvol_up_time) { + return -1; + } return 0; } @@ -5008,7 +5013,7 @@ dht_notify (xlator_t *this, int event, void *data, ...) int had_heard_from_all = 0; int have_heard_from_all = 0; - + struct timeval time = {0,}; conf = this->private; if (!conf) @@ -5042,10 +5047,12 @@ dht_notify (xlator_t *this, int event, void *data, ...) break; } + gettimeofday (&time, NULL); LOCK (&conf->subvolume_lock); { conf->subvolume_status[cnt] = 1; conf->last_event[cnt] = event; + conf->subvol_up_time[cnt] = time.tv_sec; } UNLOCK (&conf->subvolume_lock); @@ -5089,6 +5096,7 @@ dht_notify (xlator_t *this, int event, void *data, ...) { conf->subvolume_status[cnt] = 0; conf->last_event[cnt] = event; + conf->subvol_up_time[cnt] = 0; } UNLOCK (&conf->subvolume_lock); diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h index 99b626c16..95c20af1f 100644 --- a/xlators/cluster/dht/src/dht-common.h +++ b/xlators/cluster/dht/src/dht-common.h @@ -170,6 +170,7 @@ struct dht_conf { gf_boolean_t use_readdirp; char vol_uuid[UUID_SIZE + 1]; gf_boolean_t assert_no_child_down; + time_t *subvol_up_time; }; typedef struct dht_conf dht_conf_t; diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index cd57b9ea0..42c6d025f 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -268,6 +268,7 @@ dht_first_up_subvol (xlator_t *this) dht_conf_t *conf = NULL; xlator_t *child = NULL; int i = 0; + time_t time = 0; conf = this->private; if (!conf) @@ -276,9 +277,14 @@ dht_first_up_subvol (xlator_t *this) LOCK (&conf->subvolume_lock); { for (i = 0; i < conf->subvolume_cnt; i++) { - if (conf->subvolume_status[i]) { - child = conf->subvolumes[i]; - break; + if (conf->subvol_up_time[i]) { + if (!time) { + time = conf->subvol_up_time[i]; + child = conf->subvolumes[i]; + } else if (time > conf->subvol_up_time[i]) { + time = conf->subvol_up_time[i]; + child = conf->subvolumes[i]; + } } } } diff --git a/xlators/cluster/dht/src/dht-mem-types.h b/xlators/cluster/dht/src/dht-mem-types.h index af31c8b07..38bd3de15 100644 --- a/xlators/cluster/dht/src/dht-mem-types.h +++ b/xlators/cluster/dht/src/dht-mem-types.h @@ -35,6 +35,7 @@ enum gf_dht_mem_types_ { gf_switch_mt_dht_du_t, gf_switch_mt_switch_sched_array, gf_switch_mt_switch_struct, + gf_dht_mt_subvol_time, gf_dht_mt_end }; #endif |