diff options
Diffstat (limited to 'xlators')
| -rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 32 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 38 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal.h | 6 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 24 | ||||
| -rw-r--r-- | xlators/debug/trace/src/trace.c | 18 | ||||
| -rw-r--r-- | xlators/features/changelog/src/changelog-helpers.c | 31 | ||||
| -rw-r--r-- | xlators/features/upcall/src/upcall-internal.c | 1 | ||||
| -rw-r--r-- | xlators/nfs/server/src/mount3.c | 10 |
8 files changed, 115 insertions, 45 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index fb3318da36a..ebadba99a05 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -668,14 +668,17 @@ afr_set_split_brain_choice (int ret, call_frame_t *frame, void *opaque) gf_boolean_t timer_reset = _gf_false; int old_spb_choice = -1; - if (ret) - goto out; - frame = data->frame; loc = data->loc; this = frame->this; priv = this->private; + if (ret) { + op_errno = -ret; + ret = -1; + goto out; + } + delta.tv_sec = priv->spb_choice_timeout; delta.tv_nsec = 0; @@ -5880,6 +5883,12 @@ afr_is_split_brain (call_frame_t *frame, xlator_t *this, inode_t *inode, if (ret) goto out; + if (!afr_can_decide_split_brain_source_sinks (replies, + priv->child_count)) { + ret = -EAGAIN; + goto out; + } + ret = _afr_is_split_brain (frame, this, replies, AFR_DATA_TRANSACTION, d_spb); if (ret) @@ -5932,6 +5941,13 @@ afr_get_split_brain_status (void *opaque) if (!inode) goto out; + dict = dict_new (); + if (!dict) { + op_errno = ENOMEM; + ret = -1; + goto out; + } + /* Calculation for string length : * (child_count X length of child-name) + strlen (" Choices :") * child-name consists of : @@ -5945,13 +5961,9 @@ afr_get_split_brain_status (void *opaque) &m_spb); if (ret) { op_errno = -ret; - ret = -1; - goto out; - } - - dict = dict_new (); - if (!dict) { - op_errno = ENOMEM; + if (ret == -EAGAIN) + ret = dict_set_str (dict, GF_AFR_SBRAIN_STATUS, + SBRAIN_HEAL_NO_GO_MSG); ret = -1; goto out; } diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 40cfd01f4e9..c11ca11fdd9 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -472,6 +472,19 @@ afr_dict_contains_heal_op (call_frame_t *frame) return _gf_true; } +gf_boolean_t +afr_can_decide_split_brain_source_sinks (struct afr_reply *replies, + int child_count) +{ + int i = 0; + + for (i = 0; i < child_count; i++) + if (replies[i].valid != 1 || replies[i].op_ret != 0) + return _gf_false; + + return _gf_true; +} + int afr_mark_split_brain_source_sinks_by_heal_op (call_frame_t *frame, xlator_t *this, unsigned char *sources, @@ -510,6 +523,14 @@ afr_mark_split_brain_source_sinks_by_heal_op (call_frame_t *frame, } xdata_rsp = local->xdata_rsp; + if (!afr_can_decide_split_brain_source_sinks (replies, + priv->child_count)) { + ret = dict_set_str (xdata_rsp, "sh-fail-msg", + SBRAIN_HEAL_NO_GO_MSG); + ret = -1; + goto out; + } + for (i = 0 ; i < priv->child_count; i++) if (locked_on[i]) sources[i] = 1; @@ -748,26 +769,35 @@ afr_sh_get_fav_by_policy (xlator_t *this, struct afr_reply *replies, int fav_child = -1; priv = this->private; + if (!afr_can_decide_split_brain_source_sinks (replies, + priv->child_count)) { + return -1; + } + switch (priv->fav_child_policy) { case AFR_FAV_CHILD_BY_SIZE: fav_child = afr_sh_fav_by_size (this, replies, inode); - if (policy_str && fav_child >= 0) + if (policy_str && fav_child >= 0) { *policy_str = "SIZE"; + } break; case AFR_FAV_CHILD_BY_CTIME: fav_child = afr_sh_fav_by_ctime (this, replies, inode); - if (policy_str && fav_child >= 0) + if (policy_str && fav_child >= 0) { *policy_str = "CTIME"; + } break; case AFR_FAV_CHILD_BY_MTIME: fav_child = afr_sh_fav_by_mtime (this, replies, inode); - if (policy_str && fav_child >= 0) + if (policy_str && fav_child >= 0) { *policy_str = "MTIME"; + } break; case AFR_FAV_CHILD_BY_MAJORITY: fav_child = afr_sh_fav_by_majority (this, replies, inode); - if (policy_str && fav_child >= 0) + if (policy_str && fav_child >= 0) { *policy_str = "MAJORITY"; + } break; case AFR_FAV_CHILD_NONE: default: diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index 500227abe24..a33905033cc 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -81,7 +81,8 @@ #define IA_EQUAL(f,s,field) (memcmp (&(f.ia_##field), &(s.ia_##field), sizeof (s.ia_##field)) == 0) - +#define SBRAIN_HEAL_NO_GO_MSG "Failed to obtain replies from all bricks of "\ + "the replica (are they up?). Cannot resolve split-brain." int afr_selfheal (xlator_t *this, uuid_t gfid); @@ -220,6 +221,9 @@ afr_mark_active_sinks (xlator_t *this, unsigned char *sources, gf_boolean_t afr_dict_contains_heal_op (call_frame_t *frame); +gf_boolean_t +afr_can_decide_split_brain_source_sinks (struct afr_reply *replies, + int child_count); int afr_mark_split_brain_source_sinks (call_frame_t *frame, xlator_t *this, inode_t *inode, diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index ebc8a9c2492..ffd8bac9e4f 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -1835,32 +1835,8 @@ rebalance_task (void *data) static int rebalance_task_completion (int op_ret, call_frame_t *sync_frame, void *data) { - int ret = -1; - uint64_t layout_int = 0; - dht_layout_t *layout = 0; - xlator_t *this = NULL; - dht_local_t *local = NULL; int32_t op_errno = EINVAL; - this = THIS; - local = sync_frame->local; - - if (!op_ret) { - /* Make sure we have valid 'layout' in inode ctx - after the operation */ - ret = inode_ctx_del (local->loc.inode, this, &layout_int); - if (!ret && layout_int) { - layout = (dht_layout_t *)(long)layout_int; - dht_layout_unref (this, layout); - } - - ret = dht_layout_preset (this, local->rebalance.target_node, - local->loc.inode); - if (ret) - gf_log (this->name, GF_LOG_WARNING, - "%s: failed to set inode ctx", local->loc.path); - } - if (op_ret == -1) { /* Failure of migration process, mostly due to write process. as we can't preserve the exact errno, lets say there was diff --git a/xlators/debug/trace/src/trace.c b/xlators/debug/trace/src/trace.c index 03e92184dcd..555147aec47 100644 --- a/xlators/debug/trace/src/trace.c +++ b/xlators/debug/trace/src/trace.c @@ -294,14 +294,17 @@ trace_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, gf_dirent_t *buf, dict_t *xdata) { - trace_conf_t *conf = NULL; + int count = 0; + char statstr[4096] = {0,}; + char string[4096] = {0,}; + trace_conf_t *conf = NULL; + gf_dirent_t *entry = NULL; conf = this->private; if (!conf->log_file && !conf->log_history) goto out; if (trace_fop_names[GF_FOP_READDIRP].enabled) { - char string[4096] = {0,}; snprintf (string, sizeof (string), "%"PRId64" : gfid=%s op_ret=%d, op_errno=%d", frame->root->unique, uuid_utoa (frame->local), @@ -309,6 +312,17 @@ trace_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, LOG_ELEMENT (conf, string); } + if (op_ret < 0) + goto out; + + list_for_each_entry (entry, &buf->list, list) { + count++; + TRACE_STAT_TO_STR (&entry->d_stat, statstr); + snprintf (string, sizeof (string), "entry no. %d, pargfid=%s, " + "bname=%s *buf {%s}", count, uuid_utoa (frame->local), + entry->d_name, statstr); + LOG_ELEMENT (conf, string); + } out: TRACE_STACK_UNWIND (readdirp, frame, op_ret, op_errno, buf, xdata); diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index 0cb68587e57..5c47f5e0303 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -620,7 +620,10 @@ htime_open (xlator_t *this, unsigned long min_ts = 0; unsigned long max_ts = 0; unsigned long total = 0; + unsigned long total1 = 0; ssize_t size = 0; + struct stat stat_buf = {0,}; + unsigned long record_len = 0; CHANGELOG_FILL_HTIME_DIR(priv->changelog_dir, ht_dir_path); @@ -681,6 +684,16 @@ htime_open (xlator_t *this, /* save this htime_fd in priv->htime_fd */ priv->htime_fd = ht_file_fd; + ret = sys_fstat (ht_file_fd, &stat_buf); + if (ret < 0) { + gf_msg (this->name, GF_LOG_ERROR, errno, + CHANGELOG_MSG_HTIME_ERROR, + "unable to stat htime file: %s", + ht_file_path); + ret = -1; + goto out; + } + /* Initialize rollover-number in priv to current number */ size = sys_fgetxattr (ht_file_fd, HTIME_KEY, x_value, sizeof (x_value)); if (size < 0) { @@ -693,11 +706,27 @@ htime_open (xlator_t *this, } sscanf (x_value, "%lu:%lu", &max_ts, &total); + + /* 22 = 1(/) + 20(CHANGELOG.TIMESTAMP) + 1(\x00) */ + record_len = strlen(priv->changelog_dir) + 22; + total1 = stat_buf.st_size/record_len; + if (total != total1) { + gf_msg (this->name, GF_LOG_INFO, 0, + CHANGELOG_MSG_TOTAL_LOG_INFO, + "Mismatch of changelog count. " + "INIT CASE: XATTR TOTAL: %lu, SIZE TOTAL: %lu", + total, total1); + } + gf_msg (this->name, GF_LOG_INFO, 0, CHANGELOG_MSG_TOTAL_LOG_INFO, "INIT CASE: MIN: %lu, MAX: %lu," " TOTAL CHANGELOGS: %lu", min_ts, max_ts, total); - priv->rollover_count = total + 1; + + if (total < total1) + priv->rollover_count = total1 + 1; + else + priv->rollover_count = total + 1; out: if (ht_dir_fd != -1) diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index 66cbddf5fa9..37fc3dbc35a 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -204,6 +204,7 @@ __upcall_inode_ctx_set (inode_t *inode, xlator_t *this) if (ret) { gf_log (this->name, GF_LOG_DEBUG, "failed to set inode ctx (%p)", inode); + GF_FREE (inode_ctx); goto out; } diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index bff7e0669ff..57d1874c79a 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -2544,8 +2544,6 @@ __mnt3svc_umountall (struct mount3_state *ms) GF_FREE (me); } - dict_unref (ms->mountdict); - return 0; } @@ -3939,7 +3937,13 @@ mnt3svc_deinit (xlator_t *nfsx) mnt3_auth_params_deinit (mstate->auth_params); /* Unmount everything and clear mountdict */ - mnt3svc_umountall (mstate); + LOCK (&mstate->mountlock); + { + __mnt3svc_umountall (mstate); + dict_unref (mstate->mountdict); + } + UNLOCK (&mstate->mountlock); + } rpcsvc_program_t * |
