diff options
| author | Kaushal M <kaushal@gluster.com> | 2011-10-31 12:33:50 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2011-10-31 05:52:51 -0700 | 
| commit | 2379475bda40de6349e94506e0c7ea9386c9b514 (patch) | |
| tree | 389befdb8520de603ad206d4015cd5bb773f12d3 | |
| parent | e5d1f3ce842c7a3e7d3f86304b22b0e31141a2f3 (diff) | |
cluster/afr : Fix self-heal of special files
Fixes self-heal of special files like device files, fifo files, socket files
etc. Does it by doing the following:
* Prevent setting of pending data xattr on a special file during entry self-heal
  when a new file is created.
* Allow data self-heal to be started on all file types other than directories.
  During data self-heal, for special files just erase pending xattrs, if those
  xattrs were set by previous releases of glusterfs.
Change-Id: I1a36670b7287292d579b53852e25cdd452d55605
BUG: 3525
Reviewed-on: http://review.gluster.com/647
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com>
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 28 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 7 | ||||
| -rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-metadata.c | 13 | 
3 files changed, 37 insertions, 11 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 11d6745b446..5bd5edd668b 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -843,6 +843,26 @@ out:          return read_child;  } +int +afr_sh_data_special_file_fix (call_frame_t *frame, xlator_t *this) +{ +        afr_private_t   *priv = NULL; +        afr_self_heal_t *sh = NULL; +        afr_local_t     *local = NULL; +        int             i = 0; + +        local = frame->local; +        sh = &local->self_heal; +        priv = this->private; + +        for (i = 0; i < priv->child_count; i++) +                if (1 == local->child_up[i]) +                        sh->success[i] = 1; + +        afr_sh_data_erase_pending (frame, this); + +        return 0; +}  int  afr_sh_data_fstat_cbk (call_frame_t *frame, void *cookie, @@ -877,7 +897,13 @@ afr_sh_data_fstat_cbk (call_frame_t *frame, void *cookie,          call_count = afr_frame_return (frame);          if (call_count == 0) { -                afr_sh_data_fix (frame, this); +                /* Previous versions of glusterfs might have set +                 * the pending data xattrs which need to be erased +                 */ +                if (IA_ISREG (buf->ia_type)) +                        afr_sh_data_fix (frame, this); +                else +                        afr_sh_data_special_file_fix (frame, this);          }          return 0; diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index e32b507631a..21b248f496c 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -1097,14 +1097,19 @@ afr_sh_entry_impunge_newfile_cbk (call_frame_t *impunge_frame, void *cookie,                  gf_log (this->name, GF_LOG_ERROR, "Out of memory");                  goto out;          } +        /* Pending data xattrs shouldn't be set for special files +         */          idx = afr_index_for_transaction_type (AFR_METADATA_TRANSACTION);          pending_array[idx] = hton32 (1);          if (IA_ISDIR (stbuf->ia_type))                  idx = afr_index_for_transaction_type (AFR_ENTRY_TRANSACTION); -        else +        else if (IA_ISREG (stbuf->ia_type))                  idx = afr_index_for_transaction_type (AFR_DATA_TRANSACTION); +        else +                goto cont;          pending_array[idx] = hton32 (1); +cont:          ret = dict_set_dynptr (xattr, priv->pending_key[child_index],                                     pending_array, 3 * sizeof (int32_t));          if (ret < 0) { diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c index af2f76d94f9..5727209c58e 100644 --- a/xlators/cluster/afr/src/afr-self-heal-metadata.c +++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c @@ -82,14 +82,6 @@ afr_sh_metadata_done (call_frame_t *frame, xlator_t *this)                  sh->op_failed = 1;                  sh->completion_cbk (frame, this);          } else { -                if (IA_ISREG (sh->type)) { -                        gf_log (this->name, GF_LOG_DEBUG, -                                "proceeding to data check on %s", -                                local->loc.path); -                        afr_self_heal_data (frame, this); -                        return 0; -                } -                  if (IA_ISDIR (sh->type)) {                          gf_log (this->name, GF_LOG_DEBUG,                                  "proceeding to entry check on %s", @@ -97,7 +89,10 @@ afr_sh_metadata_done (call_frame_t *frame, xlator_t *this)                          afr_self_heal_entry (frame, this);                          return 0;                  } -                sh->completion_cbk (frame, this); +                gf_log (this->name, GF_LOG_DEBUG, +                        "proceeding to data check on %s", +                        local->loc.path); +                afr_self_heal_data (frame, this);          }          return 0;  | 
