summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht/src')
-rw-r--r--xlators/cluster/dht/src/dht-common.c15
-rw-r--r--xlators/cluster/dht/src/dht-common.h1
-rw-r--r--xlators/cluster/dht/src/dht-hashfn.c54
-rw-r--r--xlators/cluster/dht/src/dht-messages.h11
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c274
-rw-r--r--xlators/cluster/dht/src/dht-rename.c8
-rw-r--r--xlators/cluster/dht/src/dht-shared.c54
7 files changed, 275 insertions, 142 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 50a948ffe30..a97d03bb055 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -898,8 +898,11 @@ unlock:
dht_layout_set (this, local->inode, layout);
}
- dht_inode_ctx_time_update (local->inode, this,
- &local->stbuf, 1);
+ if (local->inode) {
+ dht_inode_ctx_time_update (local->inode, this,
+ &local->stbuf, 1);
+ }
+
if (local->loc.parent) {
dht_inode_ctx_time_update (local->loc.parent, this,
&local->postparent, 1);
@@ -1313,6 +1316,7 @@ dht_lookup_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = (dht_local_t*)frame->local;
path = local->loc.path;
+ FRAME_SU_UNDO (frame, dht_local_t);
gf_msg (this->name, GF_LOG_INFO, 0,
DHT_MSG_UNLINK_LOOKUP_INFO, "lookup_unlink returned with "
@@ -2006,7 +2010,12 @@ unlock:
loc->path, subvol->name,
(local->hashed_subvol?
local->hashed_subvol->name : "<null>"));
-
+ /* *
+ * These stale files may be created using root
+ * user. Hence deletion will work only with
+ * root.
+ */
+ FRAME_SU_DO (frame, dht_local_t);
STACK_WIND (frame, dht_lookup_unlink_cbk,
subvol, subvol->fops->unlink, loc,
0, dict_req);
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 71b093b20ea..613a9d39816 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -550,6 +550,7 @@ struct dht_conf {
/* lock migration */
gf_boolean_t lock_migration_enabled;
+ gf_lock_t lock;
/* du stats */
uint32_t du_refresh_interval_sec;
diff --git a/xlators/cluster/dht/src/dht-hashfn.c b/xlators/cluster/dht/src/dht-hashfn.c
index 66e3ede736b..f8e614a40aa 100644
--- a/xlators/cluster/dht/src/dht-hashfn.c
+++ b/xlators/cluster/dht/src/dht-hashfn.c
@@ -41,12 +41,16 @@ dht_hash_compute_internal (int type, const char *name, uint32_t *hash_p)
static
gf_boolean_t
-dht_munge_name (const char *original, char *modified, size_t len, regex_t *re)
+dht_munge_name (const char *original, char *modified,
+ size_t len, regex_t *re)
{
- regmatch_t matches[2];
- size_t new_len;
+ regmatch_t matches[2] = {{0}, };
+ size_t new_len = 0;
+ int ret = 0;
- if (regexec(re,original,2,matches,0) != REG_NOMATCH) {
+ ret = regexec(re, original, 2, matches, 0);
+
+ if (ret != REG_NOMATCH) {
if (matches[1].rm_so != -1) {
new_len = matches[1].rm_eo - matches[1].rm_so;
/* Equal would fail due to the NUL at the end. */
@@ -60,7 +64,7 @@ dht_munge_name (const char *original, char *modified, size_t len, regex_t *re)
}
/* This is guaranteed safe because of how the dest was allocated. */
- strcpy(modified,original);
+ strcpy(modified, original);
return _gf_false;
}
@@ -68,28 +72,36 @@ int
dht_hash_compute (xlator_t *this, int type, const char *name, uint32_t *hash_p)
{
char *rsync_friendly_name = NULL;
- dht_conf_t *priv = this->private;
+ dht_conf_t *priv = NULL;
size_t len = 0;
gf_boolean_t munged = _gf_false;
- if (priv->extra_regex_valid) {
- len = strlen(name) + 1;
- rsync_friendly_name = alloca(len);
- munged = dht_munge_name (name, rsync_friendly_name, len,
- &priv->extra_regex);
- }
+ priv = this->private;
- if (!munged && priv->rsync_regex_valid) {
- len = strlen(name) + 1;
- rsync_friendly_name = alloca(len);
- gf_msg_trace (this->name, 0, "trying regex for %s", name);
- munged = dht_munge_name (name, rsync_friendly_name, len,
- &priv->rsync_regex);
- if (munged) {
- gf_msg_debug (this->name, 0,
- "munged down to %s", rsync_friendly_name);
+ LOCK (&priv->lock);
+ {
+ if (priv->extra_regex_valid) {
+ len = strlen(name) + 1;
+ rsync_friendly_name = alloca(len);
+ munged = dht_munge_name (name, rsync_friendly_name, len,
+ &priv->extra_regex);
+ }
+
+ if (!munged && priv->rsync_regex_valid) {
+ len = strlen(name) + 1;
+ rsync_friendly_name = alloca(len);
+ gf_msg_trace (this->name, 0, "trying regex for %s",
+ name);
+ munged = dht_munge_name (name, rsync_friendly_name, len,
+ &priv->rsync_regex);
+ if (munged) {
+ gf_msg_debug (this->name, 0,
+ "munged down to %s",
+ rsync_friendly_name);
+ }
}
}
+ UNLOCK (&priv->lock);
if (!munged) {
rsync_friendly_name = (char *)name;
diff --git a/xlators/cluster/dht/src/dht-messages.h b/xlators/cluster/dht/src/dht-messages.h
index 153f4de0458..30b64eb5711 100644
--- a/xlators/cluster/dht/src/dht-messages.h
+++ b/xlators/cluster/dht/src/dht-messages.h
@@ -40,7 +40,7 @@
*/
#define GLFS_DHT_BASE GLFS_MSGID_COMP_DHT
-#define GLFS_DHT_NUM_MESSAGES 117
+#define GLFS_DHT_NUM_MESSAGES 118
#define GLFS_MSGID_END (GLFS_DHT_BASE + GLFS_DHT_NUM_MESSAGES + 1)
/* Messages with message IDs */
@@ -1072,11 +1072,18 @@
#define DHT_MSG_LOCK_INODE_UNREF_FAILED (GLFS_DHT_BASE + 116)
/*
- * @messageid 109116
+ * @messageid 109117
* @diagnosis
* @recommendedaction None
*/
#define DHT_MSG_ASPRINTF_FAILED (GLFS_DHT_BASE + 117)
+/*
+ * @messageid 109118
+ * @diagnosis
+ * @recommendedaction None
+ */
+#define DHT_MSG_DIR_LOOKUP_FAILED (GLFS_DHT_BASE + 118)
+
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
#endif /* _DHT_MESSAGES_H_ */
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index 7a19b82c4f0..10fd878041e 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -376,6 +376,50 @@ out:
return ret;
}
+
+static int
+__check_file_has_hardlink (xlator_t *this, loc_t *loc,
+ struct iatt *stbuf, dict_t *xattrs, int flags,
+ gf_defrag_info_t *defrag)
+{
+ int ret = 0;
+
+ if (flags == GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS) {
+ ret = 0;
+ return ret;
+ }
+ if (stbuf->ia_nlink > 1) {
+ /* support for decomission */
+ if (flags == GF_DHT_MIGRATE_HARDLINK) {
+ synclock_lock (&defrag->link_lock);
+ ret = gf_defrag_handle_hardlink
+ (this, loc, xattrs, stbuf);
+ synclock_unlock (&defrag->link_lock);
+ /*
+ Returning zero will force the file to be remigrated.
+ Checkout gf_defrag_handle_hardlink for more information.
+ */
+ if (ret && ret != -2) {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "%s: failed to migrate file with link",
+ loc->path);
+ }
+ } else {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_MIGRATE_FILE_FAILED,
+ "Migrate file failed:"
+ "%s: file has hardlinks", loc->path);
+ ret = -ENOTSUP;
+ }
+ }
+
+ return ret;
+}
+
+
+
/*
return values
0 : File will be migrated
@@ -424,40 +468,9 @@ __is_file_migratable (xlator_t *this, loc_t *loc,
}
}
- if (flags == GF_DHT_MIGRATE_HARDLINK_IN_PROGRESS) {
- ret = 0;
- goto out;
- }
-
- if (stbuf->ia_nlink > 1) {
- /* support for decomission */
- if (flags == GF_DHT_MIGRATE_HARDLINK) {
- synclock_lock (&defrag->link_lock);
- ret = gf_defrag_handle_hardlink
- (this, loc, xattrs, stbuf);
- synclock_unlock (&defrag->link_lock);
- /*
- Returning zero will force the file to be remigrated.
- Checkout gf_defrag_handle_hardlink for more information.
- */
- if (ret && ret != -2) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- DHT_MSG_MIGRATE_FILE_FAILED,
- "Migrate file failed:"
- "%s: failed to migrate file with link",
- loc->path);
- }
- } else {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- DHT_MSG_MIGRATE_FILE_FAILED,
- "Migrate file failed:"
- "%s: file has hardlinks", loc->path);
- ret = -ENOTSUP;
- }
- goto out;
- }
-
- ret = 0;
+ /* Check if file has hardlink*/
+ ret = __check_file_has_hardlink (this, loc, stbuf, xattrs,
+ flags, defrag);
out:
return ret;
@@ -1337,8 +1350,13 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
goto out;
}
+ if (xattr_rsp) {
+ /* we no more require this key */
+ dict_del (dict, conf->link_xattr_name);
+ dict_unref (xattr_rsp);
+ }
- ret = syncop_fstat (from, src_fd, &stbuf, NULL, NULL);
+ ret = syncop_fstat (from, src_fd, &stbuf, dict, &xattr_rsp);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, -ret,
DHT_MSG_MIGRATE_FILE_FAILED,
@@ -1348,6 +1366,15 @@ dht_migrate_file (xlator_t *this, loc_t *loc, xlator_t *from, xlator_t *to,
goto out;
}
+ /* Check again if file has hardlink */
+ ret = __check_file_has_hardlink (this, loc, &stbuf, xattr_rsp,
+ flag, defrag);
+ if (ret) {
+ if (ret == -2)
+ ret = 0;
+ goto out;
+ }
+
/* Try to preserve 'holes' while migrating data */
if (stbuf.ia_size > (stbuf.ia_blocks * GF_DISK_SECTOR_SIZE))
file_has_holes = 1;
@@ -2335,6 +2362,7 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
struct dht_container *tmp_container = NULL;
xlator_t *hashed_subvol = NULL;
xlator_t *cached_subvol = NULL;
+ int fop_errno = 0;
if (defrag->defrag_status != GF_DEFRAG_STATUS_STARTED) {
ret = -1;
@@ -2358,11 +2386,11 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
}
if (ret < 0) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_WARNING, -ret,
DHT_MSG_MIGRATE_DATA_FAILED,
- "%s: Migrate data failed: Readdir returned"
- " %s. Aborting migrate-data", loc->path,
- strerror(-ret));
+ "Readdirp failed. Aborting data migration for "
+ "directory: %s", loc->path);
+ fop_errno = -ret;
ret = -1;
goto out;
}
@@ -2494,9 +2522,9 @@ gf_defrag_get_entry (xlator_t *this, int i, struct dht_container **container,
ret = syncop_lookup (this, &entry_loc, NULL, NULL,
NULL, NULL);
if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_WARNING, -ret,
DHT_MSG_MIGRATE_FILE_FAILED,
- "Migrate file failed:%s lookup failed",
+ "lookup failed for file:%s",
entry_loc.path);
if (-ret != ENOENT && -ret != ESTALE) {
@@ -2617,6 +2645,9 @@ out:
if (xattr_rsp)
dict_unref (xattr_rsp);
+
+
+ errno = fop_errno;
return ret;
}
@@ -2642,6 +2673,7 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
int throttle_up = 0;
struct dir_dfmeta *dir_dfmeta = NULL;
int should_commit_hash = 1;
+ int fop_errno = 0;
gf_log (this->name, GF_LOG_INFO, "migrate data called on %s",
loc->path);
@@ -2664,10 +2696,11 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_opendir (this, loc, fd, NULL, NULL);
if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
+ gf_msg (this->name, GF_LOG_WARNING, 0,
DHT_MSG_MIGRATE_DATA_FAILED,
"Migrate data failed: Failed to open dir %s",
loc->path);
+ fop_errno = -ret;
ret = -1;
goto out;
}
@@ -2814,9 +2847,12 @@ gf_defrag_process_dir (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
migrate_data, dir_dfmeta,
xattr_req,
&should_commit_hash);
+
if (ret) {
- gf_log ("DHT", GF_LOG_INFO, "Found critical "
+ fop_errno = errno;
+ gf_log ("this->name", GF_LOG_WARNING, "Found "
"error from gf_defrag_get_entry");
+
ret = -1;
goto out;
}
@@ -2874,6 +2910,7 @@ out:
ret = 2;
}
+ errno = fop_errno;
return ret;
}
int
@@ -3043,7 +3080,6 @@ out:
return ret;
}
-
int
gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
dict_t *fix_layout, dict_t *migrate_data)
@@ -3067,14 +3103,33 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
goto out;
}
-
-
ret = syncop_lookup (this, loc, &iatt, NULL, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Lookup failed on %s",
- loc->path);
- ret = -1;
- goto out;
+ if (strcmp (loc->path, "/") == 0) {
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_DIR_LOOKUP_FAILED,
+ "lookup failed for:%s", loc->path);
+
+ defrag->total_failures++;
+ ret = -1;
+ goto out;
+ }
+
+ if (-ret == ENOENT || -ret == ESTALE) {
+ gf_msg (this->name, GF_LOG_INFO, errno,
+ DHT_MSG_DIR_LOOKUP_FAILED,
+ "Dir:%s renamed or removed. Skipping",
+ loc->path);
+ ret = 0;
+ goto out;
+ } else {
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_DIR_LOOKUP_FAILED,
+ "lookup failed for:%s", loc->path);
+
+ defrag->total_failures++;
+ goto out;
+ }
}
if ((defrag->cmd != GF_DEFRAG_CMD_START_TIER) &&
@@ -3082,18 +3137,24 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = gf_defrag_process_dir (this, defrag, loc, migrate_data);
if (ret && ret != 2) {
- defrag->total_failures++;
+ if (errno == ENOENT || errno == ESTALE) {
+ ret = 0;
+ goto out;
+ } else {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- DHT_MSG_DEFRAG_PROCESS_DIR_FAILED,
- "gf_defrag_process_dir failed for directory: %s"
- , loc->path);
+ defrag->total_failures++;
- if (conf->decommission_in_progress) {
- goto out;
- }
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ DHT_MSG_DEFRAG_PROCESS_DIR_FAILED,
+ "gf_defrag_process_dir failed for "
+ "directory: %s", loc->path);
- should_commit_hash = 0;
+ if (conf->decommission_in_progress) {
+ goto out;
+ }
+
+ should_commit_hash = 0;
+ }
} else if (ret == 2) {
should_commit_hash = 0;
}
@@ -3110,8 +3171,14 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_opendir (this, loc, fd, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s",
- loc->path);
+ if (-ret == ENOENT || -ret == ESTALE) {
+ ret = 0;
+ goto out;
+ }
+
+ gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s, "
+ "err:%d", loc->path, -ret);
+
ret = -1;
goto out;
}
@@ -3123,8 +3190,15 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
{
if (ret < 0) {
- gf_log (this->name, GF_LOG_ERROR, "Readdir returned %s"
- ". Aborting fix-layout",strerror(-ret));
+ if (-ret == ENOENT || -ret == ESTALE) {
+ ret = 0;
+ goto out;
+ }
+
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_READDIR_ERROR, "readdirp failed for "
+ "path %s. Aborting fix-layout", loc->path);
+
ret = -1;
goto out;
}
@@ -3216,43 +3290,63 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
ret = syncop_lookup (this, &entry_loc, &iatt, NULL,
NULL, NULL);
- /*Check whether it is ENOENT or ESTALE*/
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "%s"
- " lookup failed with %d",
- entry_loc.path, -ret);
-
- if (!conf->decommission_in_progress &&
- -ret != ENOENT && -ret != ESTALE) {
- should_commit_hash = 0;
+ if (-ret == ENOENT || -ret == ESTALE) {
+ gf_msg (this->name, GF_LOG_INFO, errno,
+ DHT_MSG_DIR_LOOKUP_FAILED,
+ "Dir:%s renamed or removed. "
+ "Skipping", loc->path);
+ ret = 0;
+ continue;
+ } else {
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_DIR_LOOKUP_FAILED,
+ "lookup failed for:%s",
+ entry_loc.path);
+ defrag->total_failures++;
+ if (conf->decommission_in_progress) {
+ defrag->defrag_status =
+ GF_DEFRAG_STATUS_FAILED;
+ ret = -1;
+ goto out;
+ } else {
+ should_commit_hash = 0;
+ continue;
+ }
}
-
- continue;
}
ret = syncop_setxattr (this, &entry_loc, fix_layout,
0, NULL, NULL);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Setxattr "
- "failed for %s", entry_loc.path);
-
- defrag->total_failures++;
-
- /*Don't go for fix-layout of child subtree if"
- fix-layout failed*/
- if (conf->decommission_in_progress) {
- defrag->defrag_status =
- GF_DEFRAG_STATUS_FAILED;
-
- ret = -1;
-
- goto out;
- } else {
+ if (-ret == ENOENT || -ret == ESTALE) {
+ gf_msg (this->name, GF_LOG_INFO, -ret,
+ DHT_MSG_LAYOUT_FIX_FAILED,
+ "Setxattr failed. Dir %s "
+ "renamed or removed",
+ entry_loc.path);
+ ret = 0;
continue;
+ } else {
+
+ gf_msg (this->name, GF_LOG_ERROR, -ret,
+ DHT_MSG_LAYOUT_FIX_FAILED,
+ "Setxattr failed for %s",
+ entry_loc.path);
+
+ defrag->total_failures++;
+
+ if (conf->decommission_in_progress) {
+ defrag->defrag_status =
+ GF_DEFRAG_STATUS_FAILED;
+ ret = -1;
+ goto out;
+ } else {
+ continue;
+ }
}
}
-
/* A return value of 2 means, either process_dir or
* lookup of a dir failed. Hence, don't commit hash
* for the current directory*/
@@ -3272,8 +3366,6 @@ gf_defrag_fix_layout (xlator_t *this, gf_defrag_info_t *defrag, loc_t *loc,
defrag->defrag_status =
GF_DEFRAG_STATUS_FAILED;
- ret = -1;
-
goto out;
} else {
/* Let's not commit-hash if
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
index 777c63de685..a9ffd1d9fb5 100644
--- a/xlators/cluster/dht/src/dht-rename.c
+++ b/xlators/cluster/dht/src/dht-rename.c
@@ -637,6 +637,7 @@ dht_rename_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
prev = cookie;
+ FRAME_SU_UNDO (frame, dht_local_t);
if (!local) {
gf_msg (this->name, GF_LOG_ERROR, 0,
DHT_MSG_INVALID_VALUE,
@@ -745,7 +746,12 @@ dht_rename_cleanup (call_frame_t *frame)
local->loc2.pargfid) == 0) {
DHT_MARKER_DONT_ACCOUNT(xattr_new);
}
-
+ /* *
+ * The link to file is created using root permission.
+ * Hence deletion should happen using root. Otherwise
+ * it will fail.
+ */
+ FRAME_SU_DO (frame, dht_local_t);
STACK_WIND (frame, dht_rename_unlink_cbk,
src_cached, src_cached->fops->unlink,
&local->loc2, 0, xattr_new);
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index 56bfdedc642..ccbf66b626d 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -336,9 +336,9 @@ out:
}
void
dht_init_regex (xlator_t *this, dict_t *odict, char *name,
- regex_t *re, gf_boolean_t *re_valid)
+ regex_t *re, gf_boolean_t *re_valid, dht_conf_t *conf)
{
- char *temp_str;
+ char *temp_str = NULL;
if (dict_get_str (odict, name, &temp_str) != 0) {
if (strcmp(name,"rsync-hash-regex")) {
@@ -347,25 +347,29 @@ dht_init_regex (xlator_t *this, dict_t *odict, char *name,
temp_str = "^\\.(.+)\\.[^.]+$";
}
- if (*re_valid) {
- regfree(re);
- *re_valid = _gf_false;
- }
+ LOCK (&conf->lock);
+ {
+ if (*re_valid) {
+ regfree(re);
+ *re_valid = _gf_false;
+ }
- if (!strcmp(temp_str,"none")) {
- return;
- }
+ if (!strcmp(temp_str, "none")) {
+ goto unlock;
+ }
- if (regcomp(re,temp_str,REG_EXTENDED) == 0) {
- gf_msg_debug (this->name, 0,
- "using regex %s = %s", name, temp_str);
- *re_valid = _gf_true;
- }
- else {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- DHT_MSG_REGEX_INFO,
- "compiling regex %s failed", temp_str);
+ if (regcomp(re, temp_str, REG_EXTENDED) == 0) {
+ gf_msg_debug (this->name, 0,
+ "using regex %s = %s", name, temp_str);
+ *re_valid = _gf_true;
+ } else {
+ gf_msg (this->name, GF_LOG_WARNING, 0,
+ DHT_MSG_REGEX_INFO,
+ "compiling regex %s failed", temp_str);
+ }
}
+unlock:
+ UNLOCK (&conf->lock);
}
int
@@ -488,9 +492,9 @@ dht_reconfigure (xlator_t *this, dict_t *options)
}
dht_init_regex (this, options, "rsync-hash-regex",
- &conf->rsync_regex, &conf->rsync_regex_valid);
+ &conf->rsync_regex, &conf->rsync_regex_valid, conf);
dht_init_regex (this, options, "extra-hash-regex",
- &conf->extra_regex, &conf->extra_regex_valid);
+ &conf->extra_regex, &conf->extra_regex_valid, conf);
GF_OPTION_RECONF ("weighted-rebalance", conf->do_weighting, options,
bool, out);
@@ -632,6 +636,10 @@ dht_init (xlator_t *this)
goto err;
}
+ LOCK_INIT (&conf->subvolume_lock);
+ LOCK_INIT (&conf->layout_lock);
+ LOCK_INIT (&conf->lock);
+
/* We get the commit-hash to set only for rebalance process */
if (dict_get_uint32 (this->options,
"commit-hash", &commit_hash) == 0) {
@@ -789,17 +797,15 @@ dht_init (xlator_t *this)
}
dht_init_regex (this, this->options, "rsync-hash-regex",
- &conf->rsync_regex, &conf->rsync_regex_valid);
+ &conf->rsync_regex, &conf->rsync_regex_valid, conf);
dht_init_regex (this, this->options, "extra-hash-regex",
- &conf->extra_regex, &conf->extra_regex_valid);
+ &conf->extra_regex, &conf->extra_regex_valid, conf);
ret = dht_layouts_init (this, conf);
if (ret == -1) {
goto err;
}
- LOCK_INIT (&conf->subvolume_lock);
- LOCK_INIT (&conf->layout_lock);
conf->gen = 1;