diff options
author | Dan Lambright <dlambrig@redhat.com> | 2015-06-27 06:31:53 -0400 |
---|---|---|
committer | Dan Lambright <dlambrig@redhat.com> | 2015-06-27 18:11:00 -0700 |
commit | 3da1a1cf339da77e47f71b245d4cac3f9dc1da38 (patch) | |
tree | 8fd176c995973ac067c04ad3e092c590e7ef000f /xlators/features/changetimerecorder/src/ctr-helper.h | |
parent | fc786da206f5851729a1cde6fbf6897bed9bcb3b (diff) |
tier/ctr: Ignore creation of T file and Ctr Lookup heal improvememnts
This is a back port of 11334
1) Ignore creation of T file in ctr_mknod
2) Ignore lookup for T file in ctr_lookup
3) Ctr_lookup:
a. If the gfid and pgfid in empty dont record
b. Decreased log level for multiple heal attempts
c. Inode/File heal happens after an expiry period, which is configurable.
d. Hardlink heal happens after an expiry period, which is configurable.
> Change-Id: Id8eb5092e78beaec22d05f5283645081619e2452
> BUG: 1235269
> Signed-off-by: Joseph Fernandes <josferna@redhat.com>
> Reviewed-on: http://review.gluster.org/11334
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
> Reviewed-by: Dan Lambright <dlambrig@redhat.com>
> Tested-by: Dan Lambright <dlambrig@redhat.com>
Change-Id: Ia28a5cf975e41d318906f707deca447aaa35630f
BUG: 1236288
Signed-off-by: Dan Lambright <dlambrig@redhat.com>
Reviewed-on: http://review.gluster.org/11446
Reviewed-by: Joseph Fernandes
Tested-by: Joseph Fernandes
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/features/changetimerecorder/src/ctr-helper.h')
-rw-r--r-- | xlators/features/changetimerecorder/src/ctr-helper.h | 108 |
1 files changed, 104 insertions, 4 deletions
diff --git a/xlators/features/changetimerecorder/src/ctr-helper.h b/xlators/features/changetimerecorder/src/ctr-helper.h index a3df9716eaa..82a0c8bc93c 100644 --- a/xlators/features/changetimerecorder/src/ctr-helper.h +++ b/xlators/features/changetimerecorder/src/ctr-helper.h @@ -31,6 +31,9 @@ #include "ctr-xlator-ctx.h" #include "ctr-messages.h" +#define CTR_DEFAULT_HARDLINK_EXP_PERIOD 300 /* Five mins */ +#define CTR_DEFAULT_INODE_EXP_PERIOD 300 /* Five mins */ + /*CTR Xlator Private structure*/ typedef struct gf_ctr_private { gf_boolean_t enabled; @@ -43,6 +46,8 @@ typedef struct gf_ctr_private { gfdb_db_type_t gfdb_db_type; gfdb_sync_type_t gfdb_sync_type; gfdb_conn_node_t *_db_conn; + uint64_t ctr_hardlink_heal_expire_period; + uint64_t ctr_inode_heal_expire_period; } gf_ctr_private_t; @@ -472,19 +477,91 @@ out: /******************************* Hard link function ***************************/ -static inline int +static inline gf_boolean_t +__is_inode_expired (ctr_xlator_ctx_t *ctr_xlator_ctx, + gf_ctr_private_t *_priv, + gfdb_time_t *current_time) +{ + gf_boolean_t ret = _gf_false; + uint64_t time_diff = 0; + + GF_ASSERT (ctr_xlator_ctx); + GF_ASSERT (_priv); + GF_ASSERT (current_time); + + time_diff = current_time->tv_sec - + ctr_xlator_ctx->inode_heal_period; + + ret = (time_diff >= _priv->ctr_inode_heal_expire_period) ? + _gf_true : _gf_false; + return ret; +} + +static inline gf_boolean_t +__is_hardlink_expired (ctr_hard_link_t *ctr_hard_link, + gf_ctr_private_t *_priv, + gfdb_time_t *current_time) +{ + gf_boolean_t ret = _gf_false; + uint64_t time_diff = 0; + + GF_ASSERT (ctr_hard_link); + GF_ASSERT (_priv); + GF_ASSERT (current_time); + + time_diff = current_time->tv_sec - + ctr_hard_link->hardlink_heal_period; + + ret = ret || (time_diff >= _priv->ctr_hardlink_heal_expire_period) ? + _gf_true : _gf_false; + + return ret; +} + + +/* Return values of heal*/ +typedef enum ctr_heal_ret_val { + CTR_CTX_ERROR = -1, + /* No healing required */ + CTR_TRY_NO_HEAL = 0, + /* Try healing hard link */ + CTR_TRY_HARDLINK_HEAL = 1, + /* Try healing inode */ + CTR_TRY_INODE_HEAL = 2, +} ctr_heal_ret_val_t; + + + +/** + * @brief Function to add hard link to the inode context variable. + * The inode context maintainences a in-memory list. This is used + * smart healing of database. + * @param frame of the FOP + * @param this is the Xlator instant + * @param inode + * @return Return ctr_heal_ret_val_t + */ + +static inline ctr_heal_ret_val_t add_hard_link_ctx (call_frame_t *frame, xlator_t *this, inode_t *inode) { + ctr_heal_ret_val_t ret_val = CTR_TRY_NO_HEAL; int ret = -1; gf_ctr_local_t *ctr_local = NULL; ctr_xlator_ctx_t *ctr_xlator_ctx = NULL; ctr_hard_link_t *ctr_hard_link = NULL; + gf_ctr_private_t *_priv = NULL; + gfdb_time_t current_time = {0}; + GF_ASSERT (frame); GF_ASSERT (this); GF_ASSERT (inode); + GF_ASSERT (this->private); + + _priv = this->private; ctr_local = frame->local; if (!ctr_local) { @@ -509,7 +586,29 @@ add_hard_link_ctx (call_frame_t *frame, CTR_DB_REC(ctr_local).file_name); /* if there then ignore */ if (ctr_hard_link) { - ret = 1; + + ret = gettimeofday (¤t_time, NULL); + if (ret == -1) { + gf_log (this->name, GF_LOG_ERROR, + "Failed to get current time"); + ret_val = CTR_CTX_ERROR; + goto unlock; + } + + if (__is_hardlink_expired (ctr_hard_link, + _priv, ¤t_time)) { + ctr_hard_link->hardlink_heal_period = + current_time.tv_sec; + ret_val = ret_val | CTR_TRY_HARDLINK_HEAL; + } + + if (__is_inode_expired (ctr_xlator_ctx, + _priv, ¤t_time)) { + ctr_xlator_ctx->inode_heal_period = + current_time.tv_sec; + ret_val = ret_val | CTR_TRY_INODE_HEAL; + } + goto unlock; } @@ -521,14 +620,15 @@ add_hard_link_ctx (call_frame_t *frame, gf_msg (this->name, GF_LOG_ERROR, 0, CTR_MSG_ADD_HARDLINK_TO_CTR_INODE_CONTEXT_FAILED, "Failed to add hardlink to the ctr inode context"); + ret_val = CTR_CTX_ERROR; goto unlock; } - ret = 0; + ret_val = CTR_TRY_NO_HEAL; unlock: UNLOCK (&ctr_xlator_ctx->lock); out: - return ret; + return ret_val; } static inline int |