diff options
Diffstat (limited to 'xlators')
36 files changed, 573 insertions, 289 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 6431432690d..747577c9380 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -936,7 +936,7 @@ afr_replies_interpret (call_frame_t *frame, xlator_t *this, inode_t *inode, for (i = 0; i < priv->child_count; i++) { if (start_heal && priv->child_up[i] && - (!data_readable[i] || !metadata_readable[i])) { + (data_accused[i] || metadata_accused[i])) { *start_heal = _gf_true; break; } @@ -1026,7 +1026,10 @@ afr_inode_refresh_done (call_frame_t *frame, xlator_t *this) } heal_local->refreshinode = inode_ref (local->refreshinode); heal_local->heal_frame = heal_frame; - afr_throttled_selfheal (heal_frame, this); + if (!afr_throttled_selfheal (heal_frame, this)) { + AFR_STACK_DESTROY (heal_frame); + goto refresh_done; + } } refresh_done: @@ -5170,7 +5173,6 @@ out: int afr_transaction_local_init (afr_local_t *local, xlator_t *this) { - int child_up_count = 0; int ret = -ENOMEM; afr_private_t *priv = NULL; @@ -5189,10 +5191,6 @@ afr_transaction_local_init (afr_local_t *local, xlator_t *this) } ret = -ENOMEM; - child_up_count = AFR_COUNT (local->child_up, priv->child_count); - if (priv->optimistic_change_log && child_up_count == priv->child_count) - local->optimistic_change_log = 1; - local->pre_op_compat = priv->pre_op_compat; local->transaction.eager_lock = diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 58db6d1e497..faee8dbb89b 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -1985,7 +1985,7 @@ afr_heal_synctask (xlator_t *this, afr_local_t *local) afr_refresh_heal_done (ret, heal_frame, heal_frame); } -void +gf_boolean_t afr_throttled_selfheal (call_frame_t *frame, xlator_t *this) { gf_boolean_t can_heal = _gf_true; @@ -2013,6 +2013,8 @@ afr_throttled_selfheal (call_frame_t *frame, xlator_t *this) gf_msg_debug (this->name, 0, "Max number of heals are " "pending, background self-heal rejected."); } + + return can_heal; } int diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index ec5337e60b2..1705c967f60 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -85,7 +85,7 @@ int afr_selfheal (xlator_t *this, uuid_t gfid); -void +gf_boolean_t afr_throttled_selfheal (call_frame_t *frame, xlator_t *this); int diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c index 848387fc0db..4d0ed943a81 100644 --- a/xlators/cluster/afr/src/afr-transaction.c +++ b/xlators/cluster/afr/src/afr-transaction.c @@ -1132,19 +1132,21 @@ void afr_changelog_populate_xdata (call_frame_t *frame, afr_xattrop_type_t op, dict_t **xdata, dict_t **newloc_xdata) { - dict_t *xdata1 = NULL; - dict_t *xdata2 = NULL; - afr_local_t *local = NULL; - afr_private_t *priv = NULL; - int ret = 0; - const char *name = NULL; + int i = 0; + int ret = 0; + char *key = NULL; + const char *name = NULL; + dict_t *xdata1 = NULL; + dict_t *xdata2 = NULL; + xlator_t *this = NULL; + afr_local_t *local = NULL; + afr_private_t *priv = NULL; + gf_boolean_t need_entry_key_set = _gf_true; local = frame->local; - priv = THIS->private; + this = THIS; + priv = this->private; - /*Populate xdata for POST_OP only.*/ - if (op == AFR_TRANSACTION_PRE_OP) - goto out; if (local->transaction.type == AFR_DATA_TRANSACTION || local->transaction.type == AFR_METADATA_TRANSACTION) goto out; @@ -1155,26 +1157,63 @@ afr_changelog_populate_xdata (call_frame_t *frame, afr_xattrop_type_t op, xdata1 = dict_new(); if (!xdata1) goto out; + name = local->loc.name; if (local->op == GF_FOP_LINK) name = local->newloc.name; - ret = dict_set_str (xdata1, GF_XATTROP_ENTRY_IN_KEY, (char *)name); - if (ret) - gf_msg (THIS->name, GF_LOG_ERROR, 0, AFR_MSG_DICT_SET_FAILED, - "%s/%s: Could not set xattrop-entry key during post-op", - uuid_utoa (local->loc.pargfid), local->loc.name); - if (local->transaction.type == AFR_ENTRY_RENAME_TRANSACTION) { - xdata2 = dict_new(); - if (!xdata2) - goto out; - ret = dict_set_str (xdata2, GF_XATTROP_ENTRY_IN_KEY, - (char *)local->newloc.name); + + switch (op) { + case AFR_TRANSACTION_PRE_OP: + key = GF_XATTROP_ENTRY_IN_KEY; + break; + case AFR_TRANSACTION_POST_OP: + if (afr_txn_nothing_failed (frame, this)) { + key = GF_XATTROP_ENTRY_OUT_KEY; + for (i = 0; i < priv->child_count; i++) { + if (!local->transaction.failed_subvols[i]) + continue; + need_entry_key_set = _gf_false; + break; + } + /* If the transaction itself did not fail and there + * are no failed subvolumes, check whether the fop + * failed due to a symmetric error. If it did, do + * not set the ENTRY_OUT xattr which would end up + * deleting a name index which was created possibly by + * an earlier entry txn that may have failed on some + * of the sub-volumes. + */ + if (local->op_ret) + need_entry_key_set = _gf_false; + } else { + key = GF_XATTROP_ENTRY_IN_KEY; + } + break; + } + + if (need_entry_key_set) { + ret = dict_set_str (xdata1, key, (char *)name); if (ret) gf_msg (THIS->name, GF_LOG_ERROR, 0, AFR_MSG_DICT_SET_FAILED, - "%s/%s: Could not set xattrop-entry key during" - " post-op", uuid_utoa (local->newloc.pargfid), - local->newloc.name); + "%s/%s: Could not set %s key during xattrop", + uuid_utoa (local->loc.pargfid), local->loc.name, + key); + if (local->transaction.type == AFR_ENTRY_RENAME_TRANSACTION) { + xdata2 = dict_new (); + if (!xdata2) + goto out; + + ret = dict_set_str (xdata2, key, + (char *)local->newloc.name); + if (ret) + gf_msg (THIS->name, GF_LOG_ERROR, 0, + AFR_MSG_DICT_SET_FAILED, + "%s/%s: Could not set %s key during " + "xattrop", + uuid_utoa (local->newloc.pargfid), + local->newloc.name, key); + } } *xdata = xdata1; @@ -1286,6 +1325,20 @@ afr_changelog_do (call_frame_t *frame, xlator_t *this, dict_t *xattr, return 0; } +static void +afr_init_optimistic_changelog_for_txn (xlator_t *this, afr_local_t *local) +{ + int locked_count = 0; + afr_private_t *priv = NULL; + + priv = this->private; + + locked_count = AFR_COUNT (local->transaction.pre_op, priv->child_count); + if (priv->optimistic_change_log && locked_count == priv->child_count) + local->optimistic_change_log = 1; + + return; +} int afr_changelog_pre_op (call_frame_t *frame, xlator_t *this) @@ -1317,6 +1370,8 @@ afr_changelog_pre_op (call_frame_t *frame, xlator_t *this) } } + afr_init_optimistic_changelog_for_txn (this, local); + /* This condition should not be met with present code, as * transaction.done will be called if locks are not acquired on even a * single node. 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; diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index 16975b58f6c..69f182c5194 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -4030,7 +4030,8 @@ init (xlator_t *this) GF_OPTION_INIT ("log-level", log_str, str, out); if (log_str) { log_level = glusterd_check_log_level (log_str); - gf_log_set_loglevel (log_level); + if (DEFAULT_LOG_LEVEL != log_level) + gf_log_set_loglevel (log_level); } GF_OPTION_INIT ("logger", logger_str, str, out); diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c index 7b8713c89ef..f68dd55d766 100644 --- a/xlators/features/index/src/index.c +++ b/xlators/features/index/src/index.c @@ -648,6 +648,8 @@ index_del (xlator_t *this, uuid_t gfid, const char *subdir, int type) index_priv_t *priv = NULL; int ret = 0; char gfid_path[PATH_MAX] = {0}; + char rename_dst[PATH_MAX] = {0,}; + uuid_t uuid; priv = this->private; GF_ASSERT_AND_GOTO_WITH_ERROR (this->name, !gf_uuid_is_null (gfid), @@ -655,10 +657,27 @@ index_del (xlator_t *this, uuid_t gfid, const char *subdir, int type) make_gfid_path (priv->index_basepath, subdir, gfid, gfid_path, sizeof (gfid_path)); - if ((strcmp (subdir, ENTRY_CHANGES_SUBDIR)) == 0) + if ((strcmp (subdir, ENTRY_CHANGES_SUBDIR)) == 0) { ret = sys_rmdir (gfid_path); - else + /* rmdir above could fail with ENOTEMPTY if the indices under + * it were created when granular-entry-heal was enabled, whereas + * the actual heal that happened was non-granular (or full) in + * nature, resulting in name indices getting left out. To + * clean up this directory without it affecting the IO path perf, + * the directory is renamed to a unique name under + * indices/entry-changes. Self-heal will pick up this entry + * during crawl and on lookup into the file system figure that + * the index is stale and subsequently wipe it out using rmdir(). + */ + if ((ret) && (errno == ENOTEMPTY)) { + gf_uuid_generate (uuid); + make_gfid_path (priv->index_basepath, subdir, uuid, + rename_dst, sizeof (rename_dst)); + ret = sys_rename (gfid_path, rename_dst); + } + } else { ret = sys_unlink (gfid_path); + } if (ret && (errno != ENOENT)) { gf_log (this->name, GF_LOG_ERROR, "%s: failed to delete" diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index e0e7c9857e6..f578f6c3f44 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -1492,6 +1492,8 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (priv->feature_enabled & GF_XTIME) { //update marks on oldpath + if (!local->loc.inode) + local->loc.inode = inode_ref (oplocal->loc.inode); gf_uuid_copy (local->loc.gfid, oplocal->loc.inode->gfid); marker_xtime_update_marks (this, oplocal); marker_xtime_update_marks (this, local); diff --git a/xlators/features/trash/src/trash.c b/xlators/features/trash/src/trash.c index fd5507ff694..fb413d00dd5 100644 --- a/xlators/features/trash/src/trash.c +++ b/xlators/features/trash/src/trash.c @@ -2105,13 +2105,7 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("trash-max-filesize", max_fsize, options, size_uint64, out); if (max_fsize) { - if (max_fsize > GF_ALLOWED_MAX_FILE_SIZE) { - gf_log (this->name, GF_LOG_DEBUG, - "Size specified for max-size(in MB) is too " - "large so using 1GB as max-size (NOT IDEAL)"); - priv->max_trash_file_size = GF_ALLOWED_MAX_FILE_SIZE; - } else - priv->max_trash_file_size = max_fsize; + priv->max_trash_file_size = max_fsize; gf_log (this->name, GF_LOG_DEBUG, "%"GF_PRI_SIZET" max-size", priv->max_trash_file_size); } @@ -2434,13 +2428,7 @@ init (xlator_t *this) GF_DEFAULT_MAX_FILE_SIZE / GF_UNIT_MB); priv->max_trash_file_size = GF_DEFAULT_MAX_FILE_SIZE; } else { - if( max_trash_file_size64 > GF_ALLOWED_MAX_FILE_SIZE ) { - gf_log (this->name, GF_LOG_DEBUG, - "Size specified for max-size(in MB) is too " - "large so using 1GB as max-size (NOT IDEAL)"); - priv->max_trash_file_size = GF_ALLOWED_MAX_FILE_SIZE; - } else - priv->max_trash_file_size = max_trash_file_size64; + priv->max_trash_file_size = max_trash_file_size64; gf_log (this->name, GF_LOG_DEBUG, "%"GF_PRI_SIZET" max-size", priv->max_trash_file_size); } diff --git a/xlators/features/trash/src/trash.h b/xlators/features/trash/src/trash.h index 088c1b9a286..7dd83afc09a 100644 --- a/xlators/features/trash/src/trash.h +++ b/xlators/features/trash/src/trash.h @@ -28,10 +28,6 @@ #define GF_DEFAULT_MAX_FILE_SIZE (200 * GF_UNIT_MB) #endif -#ifndef GF_ALLOWED_MAX_FILE_SIZE -#define GF_ALLOWED_MAX_FILE_SIZE (1 * GF_UNIT_GB) -#endif - struct trash_struct { fd_t *fd; /* for the fd of existing file */ fd_t *newfd; /* for the newly created file */ diff --git a/xlators/features/upcall/src/upcall-internal.c b/xlators/features/upcall/src/upcall-internal.c index 81199eb074c..66cbddf5fa9 100644 --- a/xlators/features/upcall/src/upcall-internal.c +++ b/xlators/features/upcall/src/upcall-internal.c @@ -279,6 +279,11 @@ upcall_cleanup_expired_clients (xlator_t *this, up_client->access_time; if (t_expired > (2*timeout)) { + + gf_log (THIS->name, GF_LOG_TRACE, + "Cleaning up client_entry(%s)", + up_client->client_uid); + ret = __upcall_cleanup_client_entry (up_client); @@ -289,9 +294,6 @@ upcall_cleanup_expired_clients (xlator_t *this, up_client); goto out; } - gf_log (THIS->name, GF_LOG_TRACE, - "Cleaned up client_entry(%s)", - up_client->client_uid); } } } @@ -511,8 +513,13 @@ upcall_cache_invalidate (call_frame_t *frame, xlator_t *this, client_t *client, gf_uuid_copy (up_inode_ctx->gfid, stbuf->ia_gfid); } - GF_VALIDATE_OR_GOTO ("upcall_cache_invalidate", - !(gf_uuid_is_null (up_inode_ctx->gfid)), out); + if (gf_uuid_is_null (up_inode_ctx->gfid)) { + gf_msg_debug (this->name, 0, "up_inode_ctx->gfid and " + "stbuf->ia_gfid is NULL, fop:%s", + gf_fop_list[frame->root->op]); + goto out; + } + pthread_mutex_lock (&up_inode_ctx->client_list_lock); { list_for_each_entry_safe (up_client_entry, tmp, diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index e7afb9b599d..9a702b70313 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -81,6 +81,8 @@ static char *gsync_reserved_opts[] = { static char *gsync_no_restart_opts[] = { "checkpoint", + "log_rsync_performance", + "log-rsync-performance", NULL }; @@ -583,7 +585,7 @@ struct dictidxmark { struct slave_vol_config { char old_slvhost[_POSIX_HOST_NAME_MAX+1]; - char old_slvuser[_POSIX_LOGIN_NAME_MAX]; + char old_slvuser[LOGIN_NAME_MAX]; unsigned old_slvidx; char slave_voluuid[GF_UUID_BUF_SIZE]; }; @@ -2914,6 +2916,14 @@ get_slavehost_from_voluuid (dict_t *dict, char *key, data_t *value, void *data) /* To go past username in non-root geo-rep session */ tmp = strchr (slave_host, '@'); if (tmp) { + if ((tmp - slave_host) >= LOGIN_NAME_MAX) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_SLAVE_VOL_PARSE_FAIL, + "Invalid slave user length in %s", + slave_host); + ret = -2; + goto out; + } strncpy (slave_vol->old_slvuser, slave_host, (tmp - slave_host)); slave_vol->old_slvuser[(tmp - slave_host) + 1] @@ -3336,7 +3346,8 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr) } } else if (ret == -2) { snprintf (errmsg, sizeof (errmsg), "get_slavehost_from_voluuid" - " failed %s %s!!", slave_host, slave_vol); + " failed for %s::%s. Please check the glusterd logs.", + slave_host, slave_vol); gf_msg (this->name, GF_LOG_INFO, 0, GD_MSG_FORCE_CREATE_SESSION, "get_slavehost_from_voluuid failed %s %s!!", slave_host, slave_vol); diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.h b/xlators/mgmt/glusterd/src/glusterd-geo-rep.h index 0524ec48fca..045bc2e4ba7 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.h +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.h @@ -20,7 +20,7 @@ /* slave info format: * <master host uuid>:ssh://{<slave_user>@}<slave host>::<slave volume> \ * :<slave volume uuid> */ -#define VOLINFO_SLAVE_URL_MAX (_POSIX_LOGIN_NAME_MAX + (2*GF_UUID_BUF_SIZE) \ +#define VOLINFO_SLAVE_URL_MAX (LOGIN_NAME_MAX + (2*GF_UUID_BUF_SIZE) \ + SLAVE_URL_INFO_MAX + 10) typedef struct glusterd_gsync_status_temp { diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index ba40b8f7628..623f4dc414e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -41,7 +41,7 @@ #define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD -#define GLFS_NUM_MESSAGES 578 +#define GLFS_NUM_MESSAGES 579 #define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1) /* Messaged with message IDs */ @@ -4673,6 +4673,14 @@ */ #define GD_MSG_DICT_GET_SUCCESS (GLUSTERD_COMP_BASE + 578) +/*! + * @messageid + * @diagnosis + * @recommendedaction + * + */ +#define GD_MSG_PMAP_REGISTRY_REMOVE_FAIL (GLUSTERD_COMP_BASE + 579) + /*------------*/ #define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages" #endif /* !_GLUSTERD_MESSAGES_H_ */ diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 9c26cb50e9b..20b51edee3c 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -1112,6 +1112,25 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr) if (key_fixed) key = key_fixed; + if (strcmp (key, "cluster.granular-entry-heal") == 0) { + /* For granular entry-heal, if the set command was + * invoked through volume-set CLI, then allow the + * command only if the volume is still in 'Created' + * state + */ + if ((dict_get (dict, "is-special-key") == NULL) && + (volinfo->status != GLUSTERD_STATUS_NONE)) { + snprintf (errstr, sizeof (errstr), " 'gluster " + "volume set <VOLNAME> %s {enable, " + "disable}' is not supported. Use " + "'gluster volume heal <VOLNAME> " + "granular-entry-heal {enable, " + "disable}' instead.", key); + ret = -1; + goto out; + } + } + /* Check if the key is cluster.op-version and set * local_new_op_version to the value given if possible. */ @@ -2017,7 +2036,6 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) gf_boolean_t all = _gf_false; char *next_version = NULL; gf_boolean_t quorum_action = _gf_false; - gf_boolean_t option = _gf_false; char *op_errstr = NULL; conf = this->private; @@ -2047,21 +2065,6 @@ glusterd_op_reset_all_volume_options (xlator_t *this, dict_t *dict) if (key_fixed) key = key_fixed; - option = dict_get_str_boolean (conf->opts, GLUSTERD_STORE_KEY_GANESHA_GLOBAL, - _gf_false); - if (option) { - ret = tear_down_cluster(); - if (ret == -1) - gf_msg (THIS->name, GF_LOG_WARNING, errno, - GD_MSG_DICT_GET_FAILED, - "Could not tear down NFS-Ganesha cluster"); - ret = stop_ganesha (&op_errstr); - if (ret) - gf_msg (THIS->name, GF_LOG_WARNING, 0, - GD_MSG_NFS_GNS_STOP_FAIL, - "Could not stop NFS-Ganesha service"); - } - ret = -1; dup_opt = dict_new (); if (!dup_opt) diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c index 6a89a4fe6e3..fd1936db301 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.c +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c @@ -203,6 +203,29 @@ pmap_registry_alloc (xlator_t *this) return port; } +/* pmap_assign_port does a pmap_registry_remove followed by pmap_registry_alloc, + * the reason for the former is to ensure we don't end up with stale ports + */ +int +pmap_assign_port (xlator_t *this, int old_port, const char *path) +{ + int ret = -1; + int new_port = 0; + + if (old_port) { + ret = pmap_registry_remove (this, 0, path, + GF_PMAP_PORT_BRICKSERVER, NULL); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, + GD_MSG_PMAP_REGISTRY_REMOVE_FAIL, 0, "Failed toi" + "remove pmap registry for older signin for path" + " %s", path); + } + } + new_port = pmap_registry_alloc (this); + return new_port; +} + int pmap_registry_bind (xlator_t *this, int port, const char *brickname, gf_pmap_port_type_t type, void *xprt) @@ -452,7 +475,6 @@ __gluster_pmap_signout (rpcsvc_request_t *req) req->rpc_err = GARBAGE_ARGS; goto fail; } - rsp.op_ret = pmap_registry_remove (THIS, args.port, args.brick, GF_PMAP_PORT_BRICKSERVER, req->trans); diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.h b/xlators/mgmt/glusterd/src/glusterd-pmap.h index 95ded04208d..14187daee2b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-pmap.h +++ b/xlators/mgmt/glusterd/src/glusterd-pmap.h @@ -35,6 +35,8 @@ struct pmap_registry { struct pmap_port_status ports[65536]; }; +int pmap_assign_port (xlator_t *this, int port, const char *path); +int pmap_mark_port_leased (xlator_t *this, int port); int pmap_registry_alloc (xlator_t *this); int pmap_registry_bind (xlator_t *this, int port, const char *brickname, gf_pmap_port_type_t type, void *xprt); diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c index 830dc1a706d..36e4a196845 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c @@ -295,28 +295,7 @@ glusterd_snapdsvc_start (glusterd_svc_t *svc, int flags) "--brick-name", snapd_id, "-S", svc->conn.sockpath, NULL); - /* Do a pmap registry remove on the older connected port */ - if (volinfo->snapd.port) { - ret = pmap_registry_remove (this, volinfo->snapd.port, - snapd_id, GF_PMAP_PORT_BRICKSERVER, - NULL); - if (ret) { - snprintf (msg, sizeof (msg), "Failed to remove pmap " - "registry for older signin"); - goto out; - } - } - - snapd_port = pmap_registry_alloc (THIS); - if (!snapd_port) { - snprintf (msg, sizeof (msg), "Could not allocate port " - "for snapd service for volume %s", - volinfo->volname); - runner_log (&runner, this->name, GF_LOG_DEBUG, msg); - ret = -1; - goto out; - } - + snapd_port = pmap_assign_port (THIS, volinfo->snapd.port, snapd_id); volinfo->snapd.port = snapd_port; runner_add_arg (&runner, "--brick-port"); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 97713c461c4..de5fce5a965 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1794,6 +1794,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, char socketpath[PATH_MAX] = {0}; char glusterd_uuid[1024] = {0,}; char valgrind_logfile[PATH_MAX] = {0}; + char rdma_brick_path[PATH_MAX] = {0,}; GF_ASSERT (volinfo); GF_ASSERT (brickinfo); @@ -1826,9 +1827,7 @@ glusterd_volume_start_glusterfs (glusterd_volinfo_t *volinfo, if (gf_is_service_running (pidfile, NULL)) goto connect; - port = brickinfo->port; - if (!port) - port = pmap_registry_alloc (THIS); + port = pmap_assign_port (THIS, brickinfo->port, brickinfo->path); /* Build the exp_path, before starting the glusterfsd even in valgrind mode. Otherwise all the glusterfsd processes start @@ -1893,9 +1892,10 @@ retry: if (volinfo->transport_type != GF_TRANSPORT_BOTH_TCP_RDMA) { runner_argprintf (&runner, "%d", port); } else { - rdma_port = brickinfo->rdma_port; - if (!rdma_port) - rdma_port = pmap_registry_alloc (THIS); + snprintf (rdma_brick_path, sizeof(rdma_brick_path), "%s.rdma", + brickinfo->path); + rdma_port = pmap_assign_port (THIS, brickinfo->rdma_port, + rdma_brick_path); runner_argprintf (&runner, "%d,%d", port, rdma_port); runner_add_arg (&runner, "--xlator-option"); runner_argprintf (&runner, "%s-server.transport.rdma.listen-port=%d", diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index 7b53ff5f645..2344fd169f1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -5693,6 +5693,8 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, char *xlator = NULL; char *value = NULL; char auth_path[] = "auth-path"; + char *ssl_str = NULL; + gf_boolean_t ssl_bool = _gf_false; set_dict = dict_copy (volinfo->dict, NULL); if (!set_dict) @@ -5737,6 +5739,19 @@ glusterd_snapdsvc_generate_volfile (volgen_graph_t *graph, if (ret) return -1; + if (dict_get_str (set_dict, "server.ssl", &ssl_str) == 0) { + if (gf_string2boolean (ssl_str, &ssl_bool) == 0) { + if (ssl_bool) { + ret = xlator_set_option(xl, + "transport.socket.ssl-enabled", + "true"); + if (ret) { + return -1; + } + } + } + } + RPC_SET_OPT(xl, SSL_OWN_CERT_OPT, "ssl-own-cert", return -1); RPC_SET_OPT(xl, SSL_PRIVATE_KEY_OPT,"ssl-private-key", return -1); RPC_SET_OPT(xl, SSL_CA_LIST_OPT, "ssl-ca-list", return -1); diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 0c56a90a6d3..61c79655ccf 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -766,8 +766,9 @@ out: return ret; } static int -glusterd_handle_heal_enable_disable (rpcsvc_request_t *req, dict_t *dict, - glusterd_volinfo_t *volinfo) +glusterd_handle_heal_options_enable_disable (rpcsvc_request_t *req, + dict_t *dict, + glusterd_volinfo_t *volinfo) { gf_xl_afr_op_t heal_op = GF_SHD_OP_INVALID; int ret = 0; @@ -781,30 +782,58 @@ glusterd_handle_heal_enable_disable (rpcsvc_request_t *req, dict_t *dict, } if ((heal_op != GF_SHD_OP_HEAL_ENABLE) && - (heal_op != GF_SHD_OP_HEAL_DISABLE)) { + (heal_op != GF_SHD_OP_HEAL_DISABLE) && + (heal_op != GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) && + (heal_op != GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE)) { ret = -EINVAL; goto out; } - if (heal_op == GF_SHD_OP_HEAL_ENABLE) { + if (((heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) || + (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE)) && + (volinfo->type == GF_CLUSTER_TYPE_DISPERSE)) { + ret = -1; + goto out; + } + + if ((heal_op == GF_SHD_OP_HEAL_ENABLE) || + (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE)) { value = "enable"; - } else if (heal_op == GF_SHD_OP_HEAL_DISABLE) { + } else if ((heal_op == GF_SHD_OP_HEAL_DISABLE) || + (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE)) { value = "disable"; } /* Convert this command to volume-set command based on volume type */ if (volinfo->type == GF_CLUSTER_TYPE_TIER) { - ret = glusterd_handle_shd_option_for_tier (volinfo, value, - dict); - if (!ret) - goto set_volume; - goto out; + switch (heal_op) { + case GF_SHD_OP_HEAL_ENABLE: + case GF_SHD_OP_HEAL_DISABLE: + ret = glusterd_handle_shd_option_for_tier (volinfo, + value, dict); + if (!ret) + goto set_volume; + goto out; + /* For any other heal_op, including granular-entry heal, + * just break out of the block but don't goto out yet. + */ + default: + break; + } } - key = volgen_get_shd_key (volinfo->type); - if (!key) { - ret = -1; - goto out; + if ((heal_op == GF_SHD_OP_HEAL_ENABLE) || + (heal_op == GF_SHD_OP_HEAL_DISABLE)) { + key = volgen_get_shd_key (volinfo->type); + if (!key) { + ret = -1; + goto out; + } + } else { + key = "cluster.granular-entry-heal"; + ret = dict_set_int8 (dict, "is-special-key", 1); + if (ret) + goto out; } ret = dict_set_str (dict, "key1", key); @@ -890,7 +919,7 @@ __glusterd_handle_cli_heal_volume (rpcsvc_request_t *req) goto out; } - ret = glusterd_handle_heal_enable_disable (req, dict, volinfo); + ret = glusterd_handle_heal_options_enable_disable (req, dict, volinfo); if (ret == -EINVAL) { ret = 0; } else { @@ -1480,6 +1509,15 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, goto out; } + /* This is an incremental approach to have all the volinfo objects ref + * count. The first attempt is made in volume start transaction to + * ensure it doesn't race with import volume where stale volume is + * deleted. There are multiple instances of GlusterD crashing in + * bug-948686.t because of this. Once this approach is full proof, all + * other volinfo objects will be refcounted. + */ + glusterd_volinfo_ref (volinfo); + if (priv->op_version > GD_OP_VERSION_3_7_5) { ret = glusterd_validate_quorum (this, GD_OP_START_VOLUME, dict, op_errstr); @@ -1491,15 +1529,6 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, } } - /* This is an incremental approach to have all the volinfo objects ref - * count. The first attempt is made in volume start transaction to - * ensure it doesn't race with import volume where stale volume is - * deleted. There are multiple instances of GlusterD crashing in - * bug-948686.t because of this. Once this approach is full proof, all - * other volinfo objects will be refcounted. - */ - glusterd_volinfo_ref (volinfo); - ret = glusterd_validate_volume_id (dict, volinfo); if (ret) goto out; @@ -1829,6 +1858,8 @@ glusterd_handle_heal_cmd (xlator_t *this, glusterd_volinfo_t *volinfo, case GF_SHD_OP_INVALID: case GF_SHD_OP_HEAL_ENABLE: /* This op should be handled in volume-set*/ case GF_SHD_OP_HEAL_DISABLE:/* This op should be handled in volume-set*/ + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE: /* This op should be handled in volume-set */ + case GF_SHD_OP_GRANULAR_ENTRY_HEAL_DISABLE: /* This op should be handled in volume-set */ case GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE:/*glfsheal cmd*/ case GF_SHD_OP_SBRAIN_HEAL_FROM_LATEST_MTIME:/*glfsheal cmd*/ case GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK:/*glfsheal cmd*/ @@ -2634,7 +2665,7 @@ glusterd_op_start_volume (dict_t *dict, char **op_errstr) ret = glusterd_svcs_manager (volinfo); out: - if (!volinfo) + if (volinfo) glusterd_volinfo_unref (volinfo); gf_msg_trace (this->name, 0, "returning %d ", ret); diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index dd737850c11..bff7e0669ff 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -1059,7 +1059,7 @@ __mnt3_resolve_export_subdir_comp (mnt3_resolve_t *mres) nfs_loc_wipe (&mres->resolveloc); ret = nfs_entry_loc_fill (mres->mstate->nfsx, mres->exp->vol->itable, gfid, nextcomp, &mres->resolveloc, - NFS_RESOLVE_CREATE); + NFS_RESOLVE_CREATE, NULL); if ((ret < 0) && (ret != -2)) { gf_msg (GF_MNT, GF_LOG_ERROR, EFAULT, NFS_MSG_RESOLVE_INODE_FAIL, "Failed to resolve and " @@ -1374,7 +1374,7 @@ __mnt3_resolve_subdir (mnt3_resolve_t *mres) rootgfid[15] = 1; ret = nfs_entry_loc_fill (mres->mstate->nfsx, mres->exp->vol->itable, rootgfid, firstcomp, &mres->resolveloc, - NFS_RESOLVE_CREATE); + NFS_RESOLVE_CREATE, NULL); if ((ret < 0) && (ret != -2)) { gf_msg (GF_MNT, GF_LOG_ERROR, EFAULT, NFS_MSG_RESOLVE_INODE_FAIL, "Failed to resolve and " diff --git a/xlators/nfs/server/src/nfs-common.c b/xlators/nfs/server/src/nfs-common.c index d2d1477fdc5..a39a0e6ee3a 100644 --- a/xlators/nfs/server/src/nfs-common.c +++ b/xlators/nfs/server/src/nfs-common.c @@ -312,7 +312,7 @@ err: */ int nfs_entry_loc_fill (xlator_t *this, inode_table_t *itable, uuid_t pargfid, - char *entry, loc_t *loc, int how) + char *entry, loc_t *loc, int how, gf_boolean_t *freshlookup) { inode_t *parent = NULL; inode_t *entryinode = NULL; @@ -341,8 +341,11 @@ nfs_entry_loc_fill (xlator_t *this, inode_table_t *itable, uuid_t pargfid, * that the caller can use the filled loc to call * lookup. */ - if (!entryinode) + if (!entryinode) { entryinode = inode_new (itable); + if (freshlookup) + *freshlookup = _gf_true; + } /* Cannot change ret because that must * continue to have -2. */ diff --git a/xlators/nfs/server/src/nfs-common.h b/xlators/nfs/server/src/nfs-common.h index 77bdfb0bbf0..8c9a1e33457 100644 --- a/xlators/nfs/server/src/nfs-common.h +++ b/xlators/nfs/server/src/nfs-common.h @@ -57,7 +57,8 @@ nfs_ino_loc_fill (inode_table_t *itable, uuid_t gfid, loc_t *l); extern int nfs_entry_loc_fill (xlator_t *this, inode_table_t *itable, uuid_t pargfid, - char *entry, loc_t *loc, int how); + char *entry, loc_t *loc, int how, + gf_boolean_t *freshlookup); extern int nfs_root_loc_fill (inode_table_t *itable, loc_t *loc); diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index 5ed57bde0e2..0b977092fbb 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -3757,8 +3757,9 @@ out: int nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs) { - int ret = -EFAULT; - nfs_user_t nfu = {0, }; + int ret = -EFAULT; + nfs_user_t nfu = {0, }; + gf_boolean_t freshlookup = _gf_false; if (!cs) return ret; @@ -3771,7 +3772,7 @@ nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs) ret = nfs_entry_loc_fill (cs->nfsx, cs->vol->itable, cs->resolvefh.gfid, cs->resolventry, &cs->resolvedloc, - NFS_RESOLVE_CREATE); + NFS_RESOLVE_CREATE, &freshlookup); if (ret == -2) { gf_msg_trace (GF_NFS3, 0, "Entry needs lookup: %s", @@ -3782,8 +3783,8 @@ nfs3_fh_resolve_entry_hard (nfs3_call_state_t *cs) * go ahead in the resume callback so that an EEXIST gets * handled at posix without an extra fop at this point. */ - if (nfs3_lookup_op (cs) || - (nfs3_create_op (cs) && !nfs3_create_exclusive_op (cs))) { + if (freshlookup && (nfs3_lookup_op (cs) || + (nfs3_create_op (cs) && !nfs3_create_exclusive_op (cs)))) { cs->lookuptype = GF_NFS3_FRESH; cs->resolve_ret = 0; cs->hardresolved = 0; diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index f370fae850d..7732a9711ae 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -87,6 +87,7 @@ out: /* Don't use 'GF_FREE', this is allocated by libc */ free (rsp.spec); + free (rsp.xdata.xdata_val); return 0; } diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index b26c4946d7f..2e965653e67 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -1534,10 +1534,6 @@ client3_3_inodelk_cbk (struct rpc_req *req, struct iovec *iov, int count, goto out; } - GF_PROTOCOL_DICT_UNSERIALIZE (this, xdata, (rsp.xdata.xdata_val), - (rsp.xdata.xdata_len), ret, - rsp.op_errno, out); - ret = client_post_inodelk (this, &rsp, &xdata); if (ret < 0) goto out; diff --git a/xlators/protocol/server/src/server-common.c b/xlators/protocol/server/src/server-common.c index 9a023aaa49e..2cabcf9aec0 100644 --- a/xlators/protocol/server/src/server-common.c +++ b/xlators/protocol/server/src/server-common.c @@ -226,6 +226,12 @@ server_post_fallocate (gfs3_fallocate_rsp *rsp, struct iatt *statpre, gf_stat_from_iatt (&rsp->statpost, statpost); } +void +server_post_seek (gfs3_seek_rsp *rsp, off_t offset) +{ + rsp->offset = offset; +} + int server_post_readdirp (gfs3_readdirp_rsp *rsp, gf_dirent_t *entries) { diff --git a/xlators/protocol/server/src/server-common.h b/xlators/protocol/server/src/server-common.h index afd9fb81269..f3b9ced939c 100644 --- a/xlators/protocol/server/src/server-common.h +++ b/xlators/protocol/server/src/server-common.h @@ -81,6 +81,9 @@ void server_post_fallocate (gfs3_fallocate_rsp *rsp, struct iatt *statpre, struct iatt *statpost); +void +server_post_seek (gfs3_seek_rsp *rsp, off_t offset); + int server_post_readdirp (gfs3_readdirp_rsp *rsp, gf_dirent_t *entries); diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index fa160a52d79..d5410573ac3 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -2008,6 +2008,7 @@ server_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this, goto out; } + server_post_seek (&rsp, offset); out: rsp.op_ret = op_ret; rsp.op_errno = gf_errno_to_error (op_errno); |
