diff options
Diffstat (limited to 'xlators/cluster/dht/src')
| -rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 30 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-helper.c | 21 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 4 | ||||
| -rw-r--r-- | xlators/cluster/dht/src/tier.c | 6 | 
4 files changed, 34 insertions, 27 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 8a7b4bf5ff5..c7c7fbf22ba 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -4335,23 +4335,28 @@ fill_layout_info (dht_layout_t *layout, char *buf)          }  } -void +static void  dht_fill_pathinfo_xattr (xlator_t *this, dht_local_t *local,                           char *xattr_buf, int32_t alloc_len,                           int flag, char *layout_buf)  { -        if (flag && local->xattr_val) -                snprintf (xattr_buf, alloc_len, +        if (flag) { +                if (local->xattr_val) { +                        snprintf (xattr_buf, alloc_len,                            "((<"DHT_PATHINFO_HEADER"%s> %s) (%s-layout %s))",                            this->name, local->xattr_val, this->name,                            layout_buf); -        else if (local->xattr_val) +                } else { +                        snprintf (xattr_buf, alloc_len, "(%s-layout %s)", +                          this->name, layout_buf); +                } +        } else if (local->xattr_val) {                  snprintf (xattr_buf, alloc_len,                            "(<"DHT_PATHINFO_HEADER"%s> %s)",                            this->name, local->xattr_val); -        else if (flag) -                snprintf (xattr_buf, alloc_len, "(%s-layout %s)", -                          this->name, layout_buf); +        } else { +                xattr_buf[0] = '\0'; +        }  }  int @@ -4360,7 +4365,6 @@ dht_vgetxattr_alloc_and_fill (dht_local_t *local, dict_t *xattr, xlator_t *this,  {          int      ret       = -1;          char    *value     = NULL; -        int32_t  plen      = 0;          ret = dict_get_str (xattr, local->xsel, &value);          if (ret) { @@ -4375,16 +4379,17 @@ dht_vgetxattr_alloc_and_fill (dht_local_t *local, dict_t *xattr, xlator_t *this,          local->alloc_len += strlen(value);          if (!local->xattr_val) { -                local->alloc_len += (strlen (DHT_PATHINFO_HEADER) + 10); -                local->xattr_val = GF_CALLOC (local->alloc_len, sizeof (char), +                local->alloc_len += sizeof (DHT_PATHINFO_HEADER) + 10; +                local->xattr_val = GF_MALLOC (local->alloc_len,                                                gf_common_mt_char);                  if (!local->xattr_val) {                          ret = -1;                          goto out;                  } +                local->xattr_val[0] = '\0';          } -        plen = strlen (local->xattr_val); +        int plen = strlen (local->xattr_val);          if (plen) {                  /* extra byte(s) for \0 to be safe */                  local->alloc_len += (plen + 2); @@ -4436,8 +4441,7 @@ dht_vgetxattr_fill_and_set (dht_local_t *local, dict_t **dict, xlator_t *this,          local->alloc_len += (2 * strlen (this->name))                  + strlen (layout_buf)                  + 40; -        xattr_buf = GF_CALLOC (local->alloc_len, sizeof (char), -                               gf_common_mt_char); +        xattr_buf = GF_MALLOC (local->alloc_len, gf_common_mt_char);          if (!xattr_buf)                  goto out; diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index fc67a45c7ce..8bd3f564221 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -622,6 +622,9 @@ dht_filter_loc_subvol_key (xlator_t *this, loc_t *loc, loc_t *new_loc,          xlator_list_t *trav      = NULL;          char           key[1024] = {0,};          int            ret       = 0; /* not found */ +        int            keylen    = 0; +        int            name_len  = 0; +        int            path_len  = 0;          /* Why do other tasks if first required 'char' itself is not there */          if (!new_loc || !loc || !loc->name || !strchr (loc->name, '@')) { @@ -631,24 +634,24 @@ dht_filter_loc_subvol_key (xlator_t *this, loc_t *loc, loc_t *new_loc,          trav = this->children;          while (trav) { -                snprintf (key, sizeof (key), "*@%s:%s", this->name, trav->xlator->name); +                keylen = snprintf (key, sizeof (key), "*@%s:%s", this->name, trav->xlator->name);                  if (fnmatch (key, loc->name, FNM_NOESCAPE) == 0) { -                        new_name = GF_CALLOC(strlen (loc->name), -                                             sizeof (char), +                        name_len = strlen (loc->name); +                        new_name = GF_MALLOC(name_len,                                               gf_common_mt_char);                          if (!new_name)                                  goto out;                          if (fnmatch (key, loc->path, FNM_NOESCAPE) == 0) { -                                new_path = GF_CALLOC(strlen (loc->path), -                                                     sizeof (char), +                                path_len = strlen (loc->path); +                                new_path = GF_MALLOC(path_len,                                                       gf_common_mt_char);                                  if (!new_path)                                          goto out; -                                strncpy (new_path, loc->path, (strlen (loc->path) - -                                                               strlen (key) + 1)); +                                strncpy (new_path, loc->path, (path_len - +                                                               keylen + 1));                          } -                        strncpy (new_name, loc->name, (strlen (loc->name) - -                                                       strlen (key) + 1)); +                        strncpy (new_name, loc->name, (name_len - +                                                       keylen + 1));                          if (new_loc) {                                  new_loc->path   = ((new_path) ? new_path: diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index 97b98e01451..6d9d4e693ff 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -201,8 +201,8 @@ dht_layouts_init (xlator_t *this, dht_conf_t *conf)          if (!conf)                  goto out; -        conf->file_layouts = GF_CALLOC (conf->subvolume_cnt, -                                        sizeof (dht_layout_t *), +        conf->file_layouts = GF_MALLOC (conf->subvolume_cnt +                                        * sizeof (dht_layout_t *),                                          gf_dht_mt_dht_layout_t);          if (!conf->file_layouts) {                  goto out; diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c index 13ce7f4fb2b..63eb65be302 100644 --- a/xlators/cluster/dht/src/tier.c +++ b/xlators/cluster/dht/src/tier.c @@ -74,8 +74,8 @@ qfile_array_new (ssize_t array_size)                  goto out;          } -        qfile_array->fd_array = GF_CALLOC (array_size, sizeof (int), -                                        gf_dht_mt_int32_t); +        qfile_array->fd_array = GF_MALLOC (array_size * sizeof (int), +                                           gf_dht_mt_int32_t);          if (!qfile_array->fd_array) {                  gf_msg ("tier", GF_LOG_ERROR, 0, DHT_MSG_LOG_TIER_ERROR,                          "Failed to allocate memory for " @@ -2157,7 +2157,7 @@ tier_get_bricklist (xlator_t *xl, struct list_head *local_bricklist_head)                                   brickname);                          local_brick->brick_db_path = -                                GF_CALLOC (PATH_MAX, 1, gf_common_mt_char); +                                GF_MALLOC (PATH_MAX, gf_common_mt_char);                          if (!local_brick->brick_db_path) {                                  gf_msg ("tier", GF_LOG_ERROR, 0,                                          DHT_MSG_LOG_TIER_STATUS,  | 
