|
|
14f8ab |
From 54d4ea44fec96560aad9c41f7e4f5aad164ffb8b Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Ravishankar N <ravishankar@redhat.com>
|
|
|
14f8ab |
Date: Fri, 5 Jun 2020 14:14:15 +0530
|
|
|
14f8ab |
Subject: [PATCH 424/449] afr: make heal info lockless
|
|
|
14f8ab |
|
|
|
14f8ab |
Changes in locks xlator:
|
|
|
14f8ab |
Added support for per-domain inodelk count requests.
|
|
|
14f8ab |
Caller needs to set GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS key in the
|
|
|
14f8ab |
dict and then set each key with name
|
|
|
14f8ab |
'GLUSTERFS_INODELK_DOM_PREFIX:<domain name>'.
|
|
|
14f8ab |
In the response dict, the xlator will send the per domain count as
|
|
|
14f8ab |
values for each of these keys.
|
|
|
14f8ab |
|
|
|
14f8ab |
Changes in AFR:
|
|
|
14f8ab |
Replaced afr_selfheal_locked_inspect() with afr_lockless_inspect(). Logic has
|
|
|
14f8ab |
been added to make the latter behave same as the former, thus not
|
|
|
14f8ab |
breaking the current heal info output behaviour.
|
|
|
14f8ab |
|
|
|
14f8ab |
> Upstream patch: https://review.gluster.org/#/c/glusterfs/+/23771/
|
|
|
14f8ab |
> fixes: bz#1774011
|
|
|
14f8ab |
> Change-Id: Ie9e83c162aa77f44a39c2ba7115de558120ada4d
|
|
|
14f8ab |
|
|
|
14f8ab |
BUG: 1721355
|
|
|
14f8ab |
Change-Id: I8ed4b504880b19e00068312efd90cd0706787404
|
|
|
14f8ab |
Signed-off-by: Ravishankar N <ravishankar@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202490
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Karthik Subrahmanya <ksubrahm@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
heal/src/glfs-heal.c | 17 +-
|
|
|
14f8ab |
libglusterfs/src/glusterfs/glusterfs.h | 2 +
|
|
|
14f8ab |
xlators/cluster/afr/src/afr-common.c | 367 +++++++++++--------------
|
|
|
14f8ab |
xlators/cluster/afr/src/afr-self-heal-common.c | 43 ++-
|
|
|
14f8ab |
xlators/cluster/afr/src/afr-self-heal.h | 3 +-
|
|
|
14f8ab |
xlators/features/locks/src/common.h | 4 +
|
|
|
14f8ab |
xlators/features/locks/src/locks.h | 8 +
|
|
|
14f8ab |
xlators/features/locks/src/posix.c | 117 +++++++-
|
|
|
14f8ab |
8 files changed, 338 insertions(+), 223 deletions(-)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
|
|
|
14f8ab |
index 125b12c..5af9e31 100644
|
|
|
14f8ab |
--- a/heal/src/glfs-heal.c
|
|
|
14f8ab |
+++ b/heal/src/glfs-heal.c
|
|
|
14f8ab |
@@ -775,7 +775,8 @@ static int
|
|
|
14f8ab |
glfsh_process_entries(xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
|
|
|
14f8ab |
uint64_t *offset, num_entries_t *num_entries,
|
|
|
14f8ab |
print_status glfsh_print_status,
|
|
|
14f8ab |
- gf_boolean_t ignore_dirty, glfsh_fail_mode_t mode)
|
|
|
14f8ab |
+ gf_boolean_t ignore_dirty, glfsh_fail_mode_t mode,
|
|
|
14f8ab |
+ dict_t *xattr_req)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
gf_dirent_t *entry = NULL;
|
|
|
14f8ab |
gf_dirent_t *tmp = NULL;
|
|
|
14f8ab |
@@ -807,7 +808,7 @@ glfsh_process_entries(xlator_t *xl, fd_t *fd, gf_dirent_t *entries,
|
|
|
14f8ab |
|
|
|
14f8ab |
gf_uuid_parse(entry->d_name, gfid);
|
|
|
14f8ab |
gf_uuid_copy(loc.gfid, gfid);
|
|
|
14f8ab |
- ret = syncop_getxattr(this, &loc, &dict, GF_HEAL_INFO, NULL, NULL);
|
|
|
14f8ab |
+ ret = syncop_getxattr(this, &loc, &dict, GF_HEAL_INFO, xattr_req, NULL);
|
|
|
14f8ab |
if (ret) {
|
|
|
14f8ab |
if ((mode != GLFSH_MODE_CONTINUE_ON_ERROR) && (ret == -ENOTCONN))
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
@@ -876,19 +877,19 @@ glfsh_crawl_directory(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
|
|
|
14f8ab |
if (heal_op == GF_SHD_OP_INDEX_SUMMARY) {
|
|
|
14f8ab |
ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
|
|
|
14f8ab |
num_entries, glfsh_print_heal_status,
|
|
|
14f8ab |
- ignore, mode);
|
|
|
14f8ab |
+ ignore, mode, xattr_req);
|
|
|
14f8ab |
if (ret < 0)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
} else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES) {
|
|
|
14f8ab |
ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
|
|
|
14f8ab |
num_entries, glfsh_print_spb_status,
|
|
|
14f8ab |
- ignore, mode);
|
|
|
14f8ab |
+ ignore, mode, xattr_req);
|
|
|
14f8ab |
if (ret < 0)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
} else if (heal_op == GF_SHD_OP_HEAL_SUMMARY) {
|
|
|
14f8ab |
ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
|
|
|
14f8ab |
num_entries, glfsh_print_summary_status,
|
|
|
14f8ab |
- ignore, mode);
|
|
|
14f8ab |
+ ignore, mode, xattr_req);
|
|
|
14f8ab |
if (ret < 0)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
} else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK) {
|
|
|
14f8ab |
@@ -897,7 +898,7 @@ glfsh_crawl_directory(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
|
|
|
14f8ab |
} else if (heal_op == GF_SHD_OP_GRANULAR_ENTRY_HEAL_ENABLE) {
|
|
|
14f8ab |
ret = glfsh_process_entries(readdir_xl, fd, &entries, &offset,
|
|
|
14f8ab |
num_entries, glfsh_heal_status_boolean,
|
|
|
14f8ab |
- ignore, mode);
|
|
|
14f8ab |
+ ignore, mode, xattr_req);
|
|
|
14f8ab |
if (ret < 0)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
@@ -951,6 +952,10 @@ glfsh_print_pending_heals_type(glfs_t *fs, xlator_t *top_subvol, loc_t *rootloc,
|
|
|
14f8ab |
int32_t op_errno = 0;
|
|
|
14f8ab |
gf_boolean_t ignore = _gf_false;
|
|
|
14f8ab |
|
|
|
14f8ab |
+ ret = dict_set_str(xattr_req, "index-vgfid", vgfid);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ return ret;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
if (!strcmp(vgfid, GF_XATTROP_DIRTY_GFID))
|
|
|
14f8ab |
ignore = _gf_true;
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
index 3b594c0..177a020 100644
|
|
|
14f8ab |
--- a/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
+++ b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
@@ -217,6 +217,8 @@ enum gf_internal_fop_indicator {
|
|
|
14f8ab |
#define GLUSTERFS_POSIXLK_COUNT "glusterfs.posixlk-count"
|
|
|
14f8ab |
#define GLUSTERFS_PARENT_ENTRYLK "glusterfs.parent-entrylk"
|
|
|
14f8ab |
#define GLUSTERFS_INODELK_DOM_COUNT "glusterfs.inodelk-dom-count"
|
|
|
14f8ab |
+#define GLUSTERFS_INODELK_DOM_PREFIX "glusterfs.inodelk-dom-prefix"
|
|
|
14f8ab |
+#define GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS "glusterfs.multi-dom-lk-cnt-req"
|
|
|
14f8ab |
#define GFID_TO_PATH_KEY "glusterfs.gfid2path"
|
|
|
14f8ab |
#define GF_XATTR_STIME_PATTERN "trusted.glusterfs.*.stime"
|
|
|
14f8ab |
#define GF_XATTR_XTIME_PATTERN "trusted.glusterfs.*.xtime"
|
|
|
14f8ab |
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
|
|
|
14f8ab |
index 59710aa..c355ec5 100644
|
|
|
14f8ab |
--- a/xlators/cluster/afr/src/afr-common.c
|
|
|
14f8ab |
+++ b/xlators/cluster/afr/src/afr-common.c
|
|
|
14f8ab |
@@ -5908,259 +5908,218 @@ out:
|
|
|
14f8ab |
return _gf_true;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
-int
|
|
|
14f8ab |
-afr_selfheal_locked_metadata_inspect(call_frame_t *frame, xlator_t *this,
|
|
|
14f8ab |
- inode_t *inode, gf_boolean_t *msh,
|
|
|
14f8ab |
- unsigned char *pending)
|
|
|
14f8ab |
+static dict_t *
|
|
|
14f8ab |
+afr_set_heal_info(char *status)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
+ dict_t *dict = NULL;
|
|
|
14f8ab |
int ret = -1;
|
|
|
14f8ab |
- unsigned char *locked_on = NULL;
|
|
|
14f8ab |
- unsigned char *sources = NULL;
|
|
|
14f8ab |
- unsigned char *sinks = NULL;
|
|
|
14f8ab |
- unsigned char *healed_sinks = NULL;
|
|
|
14f8ab |
- unsigned char *undid_pending = NULL;
|
|
|
14f8ab |
- struct afr_reply *locked_replies = NULL;
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- afr_private_t *priv = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
- locked_on = alloca0(priv->child_count);
|
|
|
14f8ab |
- sources = alloca0(priv->child_count);
|
|
|
14f8ab |
- sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
- healed_sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
- undid_pending = alloca0(priv->child_count);
|
|
|
14f8ab |
+ dict = dict_new();
|
|
|
14f8ab |
+ if (!dict) {
|
|
|
14f8ab |
+ ret = -ENOMEM;
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
- locked_replies = alloca0(sizeof(*locked_replies) * priv->child_count);
|
|
|
14f8ab |
+ ret = dict_set_dynstr_sizen(dict, "heal-info", status);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ gf_msg("", GF_LOG_WARNING, -ret, AFR_MSG_DICT_SET_FAILED,
|
|
|
14f8ab |
+ "Failed to set heal-info key to "
|
|
|
14f8ab |
+ "%s",
|
|
|
14f8ab |
+ status);
|
|
|
14f8ab |
+out:
|
|
|
14f8ab |
+ /* Any error other than EINVAL, dict_set_dynstr frees status */
|
|
|
14f8ab |
+ if (ret == -ENOMEM || ret == -EINVAL) {
|
|
|
14f8ab |
+ GF_FREE(status);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
- ret = afr_selfheal_inodelk(frame, this, inode, this->name, LLONG_MAX - 1, 0,
|
|
|
14f8ab |
- locked_on);
|
|
|
14f8ab |
- {
|
|
|
14f8ab |
- if (ret == 0) {
|
|
|
14f8ab |
- /* Not a single lock */
|
|
|
14f8ab |
- ret = -afr_final_errno(frame->local, priv);
|
|
|
14f8ab |
- if (ret == 0)
|
|
|
14f8ab |
- ret = -ENOTCONN; /* all invalid responses */
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
- ret = __afr_selfheal_metadata_prepare(
|
|
|
14f8ab |
- frame, this, inode, locked_on, sources, sinks, healed_sinks,
|
|
|
14f8ab |
- undid_pending, locked_replies, pending);
|
|
|
14f8ab |
- *msh = afr_decide_heal_info(priv, sources, ret);
|
|
|
14f8ab |
+ if (ret && dict) {
|
|
|
14f8ab |
+ dict_unref(dict);
|
|
|
14f8ab |
+ dict = NULL;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
- afr_selfheal_uninodelk(frame, this, inode, this->name, LLONG_MAX - 1, 0,
|
|
|
14f8ab |
- locked_on);
|
|
|
14f8ab |
-out:
|
|
|
14f8ab |
- if (locked_replies)
|
|
|
14f8ab |
- afr_replies_wipe(locked_replies, priv->child_count);
|
|
|
14f8ab |
- return ret;
|
|
|
14f8ab |
+ return dict;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
-int
|
|
|
14f8ab |
-afr_selfheal_locked_data_inspect(call_frame_t *frame, xlator_t *this, fd_t *fd,
|
|
|
14f8ab |
- gf_boolean_t *dsh, unsigned char *pflag)
|
|
|
14f8ab |
+static gf_boolean_t
|
|
|
14f8ab |
+afr_is_dirty_count_non_unary_for_txn(xlator_t *this, struct afr_reply *replies,
|
|
|
14f8ab |
+ afr_transaction_type type)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- int ret = -1;
|
|
|
14f8ab |
- unsigned char *data_lock = NULL;
|
|
|
14f8ab |
- unsigned char *sources = NULL;
|
|
|
14f8ab |
- unsigned char *sinks = NULL;
|
|
|
14f8ab |
- unsigned char *healed_sinks = NULL;
|
|
|
14f8ab |
- unsigned char *undid_pending = NULL;
|
|
|
14f8ab |
- afr_private_t *priv = NULL;
|
|
|
14f8ab |
- struct afr_reply *locked_replies = NULL;
|
|
|
14f8ab |
- inode_t *inode = fd->inode;
|
|
|
14f8ab |
+ afr_private_t *priv = this->private;
|
|
|
14f8ab |
+ int *dirty = alloca0(priv->child_count * sizeof(int));
|
|
|
14f8ab |
+ int i = 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
- priv = this->private;
|
|
|
14f8ab |
- data_lock = alloca0(priv->child_count);
|
|
|
14f8ab |
- sources = alloca0(priv->child_count);
|
|
|
14f8ab |
- sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
- healed_sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
- undid_pending = alloca0(priv->child_count);
|
|
|
14f8ab |
+ afr_selfheal_extract_xattr(this, replies, type, dirty, NULL);
|
|
|
14f8ab |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
14f8ab |
+ if (dirty[i] > 1)
|
|
|
14f8ab |
+ return _gf_true;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
- locked_replies = alloca0(sizeof(*locked_replies) * priv->child_count);
|
|
|
14f8ab |
+ return _gf_false;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
|
|
|
14f8ab |
- ret = afr_selfheal_inodelk(frame, this, inode, this->name, 0, 0, data_lock);
|
|
|
14f8ab |
- {
|
|
|
14f8ab |
- if (ret == 0) {
|
|
|
14f8ab |
- ret = -afr_final_errno(frame->local, priv);
|
|
|
14f8ab |
- if (ret == 0)
|
|
|
14f8ab |
- ret = -ENOTCONN; /* all invalid responses */
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
- ret = __afr_selfheal_data_prepare(frame, this, inode, data_lock,
|
|
|
14f8ab |
- sources, sinks, healed_sinks,
|
|
|
14f8ab |
- undid_pending, locked_replies, pflag);
|
|
|
14f8ab |
- *dsh = afr_decide_heal_info(priv, sources, ret);
|
|
|
14f8ab |
+static gf_boolean_t
|
|
|
14f8ab |
+afr_is_dirty_count_non_unary(xlator_t *this, struct afr_reply *replies,
|
|
|
14f8ab |
+ ia_type_t ia_type)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ gf_boolean_t data_chk = _gf_false;
|
|
|
14f8ab |
+ gf_boolean_t mdata_chk = _gf_false;
|
|
|
14f8ab |
+ gf_boolean_t entry_chk = _gf_false;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ switch (ia_type) {
|
|
|
14f8ab |
+ case IA_IFDIR:
|
|
|
14f8ab |
+ mdata_chk = _gf_true;
|
|
|
14f8ab |
+ entry_chk = _gf_true;
|
|
|
14f8ab |
+ break;
|
|
|
14f8ab |
+ case IA_IFREG:
|
|
|
14f8ab |
+ mdata_chk = _gf_true;
|
|
|
14f8ab |
+ data_chk = _gf_true;
|
|
|
14f8ab |
+ break;
|
|
|
14f8ab |
+ default:
|
|
|
14f8ab |
+ /*IA_IFBLK, IA_IFCHR, IA_IFLNK, IA_IFIFO, IA_IFSOCK*/
|
|
|
14f8ab |
+ mdata_chk = _gf_true;
|
|
|
14f8ab |
+ break;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
- afr_selfheal_uninodelk(frame, this, inode, this->name, 0, 0, data_lock);
|
|
|
14f8ab |
-out:
|
|
|
14f8ab |
- if (locked_replies)
|
|
|
14f8ab |
- afr_replies_wipe(locked_replies, priv->child_count);
|
|
|
14f8ab |
- return ret;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (data_chk && afr_is_dirty_count_non_unary_for_txn(
|
|
|
14f8ab |
+ this, replies, AFR_DATA_TRANSACTION)) {
|
|
|
14f8ab |
+ return _gf_true;
|
|
|
14f8ab |
+ } else if (mdata_chk && afr_is_dirty_count_non_unary_for_txn(
|
|
|
14f8ab |
+ this, replies, AFR_METADATA_TRANSACTION)) {
|
|
|
14f8ab |
+ return _gf_true;
|
|
|
14f8ab |
+ } else if (entry_chk && afr_is_dirty_count_non_unary_for_txn(
|
|
|
14f8ab |
+ this, replies, AFR_ENTRY_TRANSACTION)) {
|
|
|
14f8ab |
+ return _gf_true;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return _gf_false;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
-int
|
|
|
14f8ab |
-afr_selfheal_locked_entry_inspect(call_frame_t *frame, xlator_t *this,
|
|
|
14f8ab |
- inode_t *inode, gf_boolean_t *esh,
|
|
|
14f8ab |
- unsigned char *pflag)
|
|
|
14f8ab |
+static int
|
|
|
14f8ab |
+afr_update_heal_status(xlator_t *this, struct afr_reply *replies,
|
|
|
14f8ab |
+ char *index_vgfid, ia_type_t ia_type, gf_boolean_t *esh,
|
|
|
14f8ab |
+ gf_boolean_t *dsh, gf_boolean_t *msh)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
int ret = -1;
|
|
|
14f8ab |
- int source = -1;
|
|
|
14f8ab |
+ GF_UNUSED int ret1 = 0;
|
|
|
14f8ab |
+ int i = 0;
|
|
|
14f8ab |
+ int io_domain_lk_count = 0;
|
|
|
14f8ab |
+ int shd_domain_lk_count = 0;
|
|
|
14f8ab |
afr_private_t *priv = NULL;
|
|
|
14f8ab |
- unsigned char *locked_on = NULL;
|
|
|
14f8ab |
- unsigned char *data_lock = NULL;
|
|
|
14f8ab |
- unsigned char *sources = NULL;
|
|
|
14f8ab |
- unsigned char *sinks = NULL;
|
|
|
14f8ab |
- unsigned char *healed_sinks = NULL;
|
|
|
14f8ab |
- struct afr_reply *locked_replies = NULL;
|
|
|
14f8ab |
- gf_boolean_t granular_locks = _gf_false;
|
|
|
14f8ab |
+ char *key1 = NULL;
|
|
|
14f8ab |
+ char *key2 = NULL;
|
|
|
14f8ab |
|
|
|
14f8ab |
priv = this->private;
|
|
|
14f8ab |
- granular_locks = priv->granular_locks; /*Assign to local variable so that
|
|
|
14f8ab |
- reconfigure doesn't change this
|
|
|
14f8ab |
- value between locking and unlocking
|
|
|
14f8ab |
- below*/
|
|
|
14f8ab |
- locked_on = alloca0(priv->child_count);
|
|
|
14f8ab |
- data_lock = alloca0(priv->child_count);
|
|
|
14f8ab |
- sources = alloca0(priv->child_count);
|
|
|
14f8ab |
- sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
- healed_sinks = alloca0(priv->child_count);
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- locked_replies = alloca0(sizeof(*locked_replies) * priv->child_count);
|
|
|
14f8ab |
+ key1 = alloca0(strlen(GLUSTERFS_INODELK_DOM_PREFIX) + 2 +
|
|
|
14f8ab |
+ strlen(this->name));
|
|
|
14f8ab |
+ key2 = alloca0(strlen(GLUSTERFS_INODELK_DOM_PREFIX) + 2 +
|
|
|
14f8ab |
+ strlen(priv->sh_domain));
|
|
|
14f8ab |
+ sprintf(key1, "%s:%s", GLUSTERFS_INODELK_DOM_PREFIX, this->name);
|
|
|
14f8ab |
+ sprintf(key2, "%s:%s", GLUSTERFS_INODELK_DOM_PREFIX, priv->sh_domain);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (!granular_locks) {
|
|
|
14f8ab |
- ret = afr_selfheal_tryentrylk(frame, this, inode, priv->sh_domain, NULL,
|
|
|
14f8ab |
- locked_on);
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
- {
|
|
|
14f8ab |
- if (!granular_locks && ret == 0) {
|
|
|
14f8ab |
- ret = -afr_final_errno(frame->local, priv);
|
|
|
14f8ab |
- if (ret == 0)
|
|
|
14f8ab |
- ret = -ENOTCONN; /* all invalid responses */
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
14f8ab |
+ if ((replies[i].valid != 1) || (replies[i].op_ret != 0))
|
|
|
14f8ab |
+ continue;
|
|
|
14f8ab |
+ if (!io_domain_lk_count) {
|
|
|
14f8ab |
+ ret1 = dict_get_int32(replies[i].xdata, key1, &io_domain_lk_count);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
+ if (!shd_domain_lk_count) {
|
|
|
14f8ab |
+ ret1 = dict_get_int32(replies[i].xdata, key2, &shd_domain_lk_count);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
- ret = afr_selfheal_entrylk(frame, this, inode, this->name, NULL,
|
|
|
14f8ab |
- data_lock);
|
|
|
14f8ab |
- {
|
|
|
14f8ab |
- if (ret == 0) {
|
|
|
14f8ab |
- ret = -afr_final_errno(frame->local, priv);
|
|
|
14f8ab |
- if (ret == 0)
|
|
|
14f8ab |
- ret = -ENOTCONN;
|
|
|
14f8ab |
- /* all invalid responses */
|
|
|
14f8ab |
- goto unlock;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
- ret = __afr_selfheal_entry_prepare(frame, this, inode, data_lock,
|
|
|
14f8ab |
- sources, sinks, healed_sinks,
|
|
|
14f8ab |
- locked_replies, &source, pflag);
|
|
|
14f8ab |
- if ((ret == 0) && (*pflag & PFLAG_SBRAIN))
|
|
|
14f8ab |
- ret = -EIO;
|
|
|
14f8ab |
- *esh = afr_decide_heal_info(priv, sources, ret);
|
|
|
14f8ab |
+ if (!strcmp(index_vgfid, GF_XATTROP_INDEX_GFID)) {
|
|
|
14f8ab |
+ if (shd_domain_lk_count) {
|
|
|
14f8ab |
+ ret = -EAGAIN; /*For 'possibly-healing'. */
|
|
|
14f8ab |
+ } else {
|
|
|
14f8ab |
+ ret = 0; /*needs heal. Just set a non -ve value so that it is
|
|
|
14f8ab |
+ assumed as the source index.*/
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ } else if (!strcmp(index_vgfid, GF_XATTROP_DIRTY_GFID)) {
|
|
|
14f8ab |
+ if ((afr_is_dirty_count_non_unary(this, replies, ia_type)) ||
|
|
|
14f8ab |
+ (!io_domain_lk_count)) {
|
|
|
14f8ab |
+ /* Needs heal. */
|
|
|
14f8ab |
+ ret = 0;
|
|
|
14f8ab |
+ } else {
|
|
|
14f8ab |
+ /* No heal needed. */
|
|
|
14f8ab |
+ *dsh = *esh = *msh = 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
- afr_selfheal_unentrylk(frame, this, inode, this->name, NULL, data_lock,
|
|
|
14f8ab |
- NULL);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
-unlock:
|
|
|
14f8ab |
- if (!granular_locks)
|
|
|
14f8ab |
- afr_selfheal_unentrylk(frame, this, inode, priv->sh_domain, NULL,
|
|
|
14f8ab |
- locked_on, NULL);
|
|
|
14f8ab |
-out:
|
|
|
14f8ab |
- if (locked_replies)
|
|
|
14f8ab |
- afr_replies_wipe(locked_replies, priv->child_count);
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+/*return EIO, EAGAIN or pending*/
|
|
|
14f8ab |
int
|
|
|
14f8ab |
-afr_selfheal_locked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
|
|
|
14f8ab |
- inode_t **inode, gf_boolean_t *entry_selfheal,
|
|
|
14f8ab |
- gf_boolean_t *data_selfheal,
|
|
|
14f8ab |
- gf_boolean_t *metadata_selfheal,
|
|
|
14f8ab |
- unsigned char *pending)
|
|
|
14f8ab |
-
|
|
|
14f8ab |
+afr_lockless_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
|
|
|
14f8ab |
+ inode_t **inode, char *index_vgfid,
|
|
|
14f8ab |
+ gf_boolean_t *entry_selfheal, gf_boolean_t *data_selfheal,
|
|
|
14f8ab |
+ gf_boolean_t *metadata_selfheal, unsigned char *pending)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
int ret = -1;
|
|
|
14f8ab |
- fd_t *fd = NULL;
|
|
|
14f8ab |
+ int i = 0;
|
|
|
14f8ab |
+ afr_private_t *priv = NULL;
|
|
|
14f8ab |
+ struct afr_reply *replies = NULL;
|
|
|
14f8ab |
gf_boolean_t dsh = _gf_false;
|
|
|
14f8ab |
gf_boolean_t msh = _gf_false;
|
|
|
14f8ab |
gf_boolean_t esh = _gf_false;
|
|
|
14f8ab |
+ unsigned char *sources = NULL;
|
|
|
14f8ab |
+ unsigned char *sinks = NULL;
|
|
|
14f8ab |
+ unsigned char *valid_on = NULL;
|
|
|
14f8ab |
+ uint64_t *witness = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ priv = this->private;
|
|
|
14f8ab |
+ replies = alloca0(sizeof(*replies) * priv->child_count);
|
|
|
14f8ab |
+ sources = alloca0(sizeof(*sources) * priv->child_count);
|
|
|
14f8ab |
+ sinks = alloca0(sizeof(*sinks) * priv->child_count);
|
|
|
14f8ab |
+ witness = alloca0(sizeof(*witness) * priv->child_count);
|
|
|
14f8ab |
+ valid_on = alloca0(sizeof(*valid_on) * priv->child_count);
|
|
|
14f8ab |
|
|
|
14f8ab |
ret = afr_selfheal_unlocked_inspect(frame, this, gfid, inode, &dsh, &msh,
|
|
|
14f8ab |
- &esh;;
|
|
|
14f8ab |
+ &esh, replies);
|
|
|
14f8ab |
if (ret)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- /* For every heal type hold locks and check if it indeed needs heal */
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- /* Heal-info does an open() on the file being examined so that the
|
|
|
14f8ab |
- * current eager-lock holding client, if present, at some point sees
|
|
|
14f8ab |
- * open-fd count being > 1 and releases the eager-lock so that heal-info
|
|
|
14f8ab |
- * doesn't remain blocked forever until IO completes.
|
|
|
14f8ab |
- */
|
|
|
14f8ab |
- if ((*inode)->ia_type == IA_IFREG) {
|
|
|
14f8ab |
- ret = afr_selfheal_data_open(this, *inode, &fd;;
|
|
|
14f8ab |
- if (ret < 0) {
|
|
|
14f8ab |
- gf_msg_debug(this->name, -ret, "%s: Failed to open",
|
|
|
14f8ab |
- uuid_utoa((*inode)->gfid));
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
14f8ab |
+ if (replies[i].valid && replies[i].op_ret == 0) {
|
|
|
14f8ab |
+ valid_on[i] = 1;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
}
|
|
|
14f8ab |
-
|
|
|
14f8ab |
if (msh) {
|
|
|
14f8ab |
- ret = afr_selfheal_locked_metadata_inspect(frame, this, *inode, &msh,
|
|
|
14f8ab |
- pending);
|
|
|
14f8ab |
- if (ret == -EIO)
|
|
|
14f8ab |
+ ret = afr_selfheal_find_direction(frame, this, replies,
|
|
|
14f8ab |
+ AFR_METADATA_TRANSACTION, valid_on,
|
|
|
14f8ab |
+ sources, sinks, witness, pending);
|
|
|
14f8ab |
+ if (*pending & PFLAG_SBRAIN)
|
|
|
14f8ab |
+ ret = -EIO;
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
-
|
|
|
14f8ab |
if (dsh) {
|
|
|
14f8ab |
- ret = afr_selfheal_locked_data_inspect(frame, this, fd, &dsh, pending);
|
|
|
14f8ab |
- if (ret == -EIO || (ret == -EAGAIN))
|
|
|
14f8ab |
+ ret = afr_selfheal_find_direction(frame, this, replies,
|
|
|
14f8ab |
+ AFR_DATA_TRANSACTION, valid_on,
|
|
|
14f8ab |
+ sources, sinks, witness, pending);
|
|
|
14f8ab |
+ if (*pending & PFLAG_SBRAIN)
|
|
|
14f8ab |
+ ret = -EIO;
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
-
|
|
|
14f8ab |
if (esh) {
|
|
|
14f8ab |
- ret = afr_selfheal_locked_entry_inspect(frame, this, *inode, &esh,
|
|
|
14f8ab |
- pending);
|
|
|
14f8ab |
+ ret = afr_selfheal_find_direction(frame, this, replies,
|
|
|
14f8ab |
+ AFR_ENTRY_TRANSACTION, valid_on,
|
|
|
14f8ab |
+ sources, sinks, witness, pending);
|
|
|
14f8ab |
+ if (*pending & PFLAG_SBRAIN)
|
|
|
14f8ab |
+ ret = -EIO;
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+ ret = afr_update_heal_status(this, replies, index_vgfid, (*inode)->ia_type,
|
|
|
14f8ab |
+ &esh, &dsh, &msh;;
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
*data_selfheal = dsh;
|
|
|
14f8ab |
*entry_selfheal = esh;
|
|
|
14f8ab |
*metadata_selfheal = msh;
|
|
|
14f8ab |
- if (fd)
|
|
|
14f8ab |
- fd_unref(fd);
|
|
|
14f8ab |
+ if (replies)
|
|
|
14f8ab |
+ afr_replies_wipe(replies, priv->child_count);
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
-static dict_t *
|
|
|
14f8ab |
-afr_set_heal_info(char *status)
|
|
|
14f8ab |
-{
|
|
|
14f8ab |
- dict_t *dict = NULL;
|
|
|
14f8ab |
- int ret = -1;
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- dict = dict_new();
|
|
|
14f8ab |
- if (!dict) {
|
|
|
14f8ab |
- ret = -ENOMEM;
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- ret = dict_set_dynstr_sizen(dict, "heal-info", status);
|
|
|
14f8ab |
- if (ret)
|
|
|
14f8ab |
- gf_msg("", GF_LOG_WARNING, -ret, AFR_MSG_DICT_SET_FAILED,
|
|
|
14f8ab |
- "Failed to set heal-info key to "
|
|
|
14f8ab |
- "%s",
|
|
|
14f8ab |
- status);
|
|
|
14f8ab |
-out:
|
|
|
14f8ab |
- /* Any error other than EINVAL, dict_set_dynstr frees status */
|
|
|
14f8ab |
- if (ret == -ENOMEM || ret == -EINVAL) {
|
|
|
14f8ab |
- GF_FREE(status);
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- if (ret && dict) {
|
|
|
14f8ab |
- dict_unref(dict);
|
|
|
14f8ab |
- dict = NULL;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
- return dict;
|
|
|
14f8ab |
-}
|
|
|
14f8ab |
-
|
|
|
14f8ab |
int
|
|
|
14f8ab |
afr_get_heal_info(call_frame_t *frame, xlator_t *this, loc_t *loc)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
@@ -6174,10 +6133,18 @@ afr_get_heal_info(call_frame_t *frame, xlator_t *this, loc_t *loc)
|
|
|
14f8ab |
inode_t *inode = NULL;
|
|
|
14f8ab |
char *substr = NULL;
|
|
|
14f8ab |
char *status = NULL;
|
|
|
14f8ab |
+ afr_local_t *local = NULL;
|
|
|
14f8ab |
+ char *index_vgfid = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ local = frame->local;
|
|
|
14f8ab |
+ if (dict_get_str(local->xdata_req, "index-vgfid", &index_vgfid)) {
|
|
|
14f8ab |
+ ret = -1;
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
- ret = afr_selfheal_locked_inspect(frame, this, loc->gfid, &inode,
|
|
|
14f8ab |
- &entry_selfheal, &data_selfheal,
|
|
|
14f8ab |
- &metadata_selfheal, &pending);
|
|
|
14f8ab |
+ ret = afr_lockless_inspect(frame, this, loc->gfid, &inode, index_vgfid,
|
|
|
14f8ab |
+ &entry_selfheal, &data_selfheal,
|
|
|
14f8ab |
+ &metadata_selfheal, &pending);
|
|
|
14f8ab |
|
|
|
14f8ab |
if (ret == -ENOMEM) {
|
|
|
14f8ab |
ret = -1;
|
|
|
14f8ab |
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
14f8ab |
index d942ccf..1608f75 100644
|
|
|
14f8ab |
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
14f8ab |
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
14f8ab |
@@ -1827,6 +1827,37 @@ afr_selfheal_unlocked_lookup_on(call_frame_t *frame, inode_t *parent,
|
|
|
14f8ab |
return inode;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+static int
|
|
|
14f8ab |
+afr_set_multi_dom_lock_count_request(xlator_t *this, dict_t *dict)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ int ret = 0;
|
|
|
14f8ab |
+ afr_private_t *priv = NULL;
|
|
|
14f8ab |
+ char *key1 = NULL;
|
|
|
14f8ab |
+ char *key2 = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ priv = this->private;
|
|
|
14f8ab |
+ key1 = alloca0(strlen(GLUSTERFS_INODELK_DOM_PREFIX) + 2 +
|
|
|
14f8ab |
+ strlen(this->name));
|
|
|
14f8ab |
+ key2 = alloca0(strlen(GLUSTERFS_INODELK_DOM_PREFIX) + 2 +
|
|
|
14f8ab |
+ strlen(priv->sh_domain));
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ ret = dict_set_uint32(dict, GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS, 1);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ return ret;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ sprintf(key1, "%s:%s", GLUSTERFS_INODELK_DOM_PREFIX, this->name);
|
|
|
14f8ab |
+ ret = dict_set_uint32(dict, key1, 1);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ return ret;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ sprintf(key2, "%s:%s", GLUSTERFS_INODELK_DOM_PREFIX, priv->sh_domain);
|
|
|
14f8ab |
+ ret = dict_set_uint32(dict, key2, 1);
|
|
|
14f8ab |
+ if (ret)
|
|
|
14f8ab |
+ return ret;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return 0;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
int
|
|
|
14f8ab |
afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
|
|
|
14f8ab |
uuid_t gfid, struct afr_reply *replies,
|
|
|
14f8ab |
@@ -1851,6 +1882,11 @@ afr_selfheal_unlocked_discover_on(call_frame_t *frame, inode_t *inode,
|
|
|
14f8ab |
return -ENOMEM;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+ if (afr_set_multi_dom_lock_count_request(frame->this, xattr_req)) {
|
|
|
14f8ab |
+ dict_unref(xattr_req);
|
|
|
14f8ab |
+ return -1;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
loc.inode = inode_ref(inode);
|
|
|
14f8ab |
gf_uuid_copy(loc.gfid, gfid);
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -2241,7 +2277,8 @@ int
|
|
|
14f8ab |
afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
|
|
|
14f8ab |
inode_t **link_inode, gf_boolean_t *data_selfheal,
|
|
|
14f8ab |
gf_boolean_t *metadata_selfheal,
|
|
|
14f8ab |
- gf_boolean_t *entry_selfheal)
|
|
|
14f8ab |
+ gf_boolean_t *entry_selfheal,
|
|
|
14f8ab |
+ struct afr_reply *replies_dst)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
afr_private_t *priv = NULL;
|
|
|
14f8ab |
inode_t *inode = NULL;
|
|
|
14f8ab |
@@ -2377,6 +2414,8 @@ afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
|
|
|
14f8ab |
|
|
|
14f8ab |
ret = 0;
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
+ if (replies && replies_dst)
|
|
|
14f8ab |
+ afr_replies_copy(replies_dst, replies, priv->child_count);
|
|
|
14f8ab |
if (inode)
|
|
|
14f8ab |
inode_unref(inode);
|
|
|
14f8ab |
if (replies)
|
|
|
14f8ab |
@@ -2493,7 +2532,7 @@ afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid)
|
|
|
14f8ab |
|
|
|
14f8ab |
ret = afr_selfheal_unlocked_inspect(frame, this, gfid, &inode,
|
|
|
14f8ab |
&data_selfheal, &metadata_selfheal,
|
|
|
14f8ab |
- &entry_selfheal);
|
|
|
14f8ab |
+ &entry_selfheal, NULL);
|
|
|
14f8ab |
if (ret)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
14f8ab |
index f7ecf5d..b39af02 100644
|
|
|
14f8ab |
--- a/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
14f8ab |
+++ b/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
14f8ab |
@@ -327,7 +327,8 @@ int
|
|
|
14f8ab |
afr_selfheal_unlocked_inspect(call_frame_t *frame, xlator_t *this, uuid_t gfid,
|
|
|
14f8ab |
inode_t **link_inode, gf_boolean_t *data_selfheal,
|
|
|
14f8ab |
gf_boolean_t *metadata_selfheal,
|
|
|
14f8ab |
- gf_boolean_t *entry_selfheal);
|
|
|
14f8ab |
+ gf_boolean_t *entry_selfheal,
|
|
|
14f8ab |
+ struct afr_reply *replies);
|
|
|
14f8ab |
|
|
|
14f8ab |
int
|
|
|
14f8ab |
afr_selfheal_do(call_frame_t *frame, xlator_t *this, uuid_t gfid);
|
|
|
14f8ab |
diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h
|
|
|
14f8ab |
index 3a74967..ea86b96 100644
|
|
|
14f8ab |
--- a/xlators/features/locks/src/common.h
|
|
|
14f8ab |
+++ b/xlators/features/locks/src/common.h
|
|
|
14f8ab |
@@ -45,6 +45,10 @@
|
|
|
14f8ab |
fd_unref(__local->fd); \
|
|
|
14f8ab |
if (__local->inode) \
|
|
|
14f8ab |
inode_unref(__local->inode); \
|
|
|
14f8ab |
+ if (__local->xdata) { \
|
|
|
14f8ab |
+ dict_unref(__local->xdata); \
|
|
|
14f8ab |
+ __local->xdata = NULL; \
|
|
|
14f8ab |
+ } \
|
|
|
14f8ab |
mem_put(__local); \
|
|
|
14f8ab |
} \
|
|
|
14f8ab |
} while (0)
|
|
|
14f8ab |
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
|
|
|
14f8ab |
index b817960..aa267de 100644
|
|
|
14f8ab |
--- a/xlators/features/locks/src/locks.h
|
|
|
14f8ab |
+++ b/xlators/features/locks/src/locks.h
|
|
|
14f8ab |
@@ -239,6 +239,7 @@ typedef struct {
|
|
|
14f8ab |
gf_boolean_t inodelk_count_req;
|
|
|
14f8ab |
gf_boolean_t posixlk_count_req;
|
|
|
14f8ab |
gf_boolean_t parent_entrylk_req;
|
|
|
14f8ab |
+ gf_boolean_t multiple_dom_lk_requests;
|
|
|
14f8ab |
int update_mlock_enforced_flag;
|
|
|
14f8ab |
} pl_local_t;
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -260,6 +261,13 @@ typedef struct _locks_ctx {
|
|
|
14f8ab |
struct list_head metalk_list;
|
|
|
14f8ab |
} pl_ctx_t;
|
|
|
14f8ab |
|
|
|
14f8ab |
+typedef struct _multi_dom_lk_data {
|
|
|
14f8ab |
+ xlator_t *this;
|
|
|
14f8ab |
+ inode_t *inode;
|
|
|
14f8ab |
+ dict_t *xdata_rsp;
|
|
|
14f8ab |
+ gf_boolean_t keep_max;
|
|
|
14f8ab |
+} multi_dom_lk_data;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
typedef enum { DECREMENT, INCREMENT } pl_count_op_t;
|
|
|
14f8ab |
|
|
|
14f8ab |
pl_ctx_t *
|
|
|
14f8ab |
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
|
|
|
14f8ab |
index 4592240..9a14c64 100644
|
|
|
14f8ab |
--- a/xlators/features/locks/src/posix.c
|
|
|
14f8ab |
+++ b/xlators/features/locks/src/posix.c
|
|
|
14f8ab |
@@ -150,13 +150,20 @@ fetch_pathinfo(xlator_t *, inode_t *, int32_t *, char **);
|
|
|
14f8ab |
gf_boolean_t
|
|
|
14f8ab |
pl_has_xdata_requests(dict_t *xdata)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- static char *reqs[] = {GLUSTERFS_ENTRYLK_COUNT, GLUSTERFS_INODELK_COUNT,
|
|
|
14f8ab |
- GLUSTERFS_INODELK_DOM_COUNT, GLUSTERFS_POSIXLK_COUNT,
|
|
|
14f8ab |
- GLUSTERFS_PARENT_ENTRYLK, NULL};
|
|
|
14f8ab |
- static int reqs_size[] = {
|
|
|
14f8ab |
- SLEN(GLUSTERFS_ENTRYLK_COUNT), SLEN(GLUSTERFS_INODELK_COUNT),
|
|
|
14f8ab |
- SLEN(GLUSTERFS_INODELK_DOM_COUNT), SLEN(GLUSTERFS_POSIXLK_COUNT),
|
|
|
14f8ab |
- SLEN(GLUSTERFS_PARENT_ENTRYLK), 0};
|
|
|
14f8ab |
+ static char *reqs[] = {GLUSTERFS_ENTRYLK_COUNT,
|
|
|
14f8ab |
+ GLUSTERFS_INODELK_COUNT,
|
|
|
14f8ab |
+ GLUSTERFS_INODELK_DOM_COUNT,
|
|
|
14f8ab |
+ GLUSTERFS_POSIXLK_COUNT,
|
|
|
14f8ab |
+ GLUSTERFS_PARENT_ENTRYLK,
|
|
|
14f8ab |
+ GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS,
|
|
|
14f8ab |
+ NULL};
|
|
|
14f8ab |
+ static int reqs_size[] = {SLEN(GLUSTERFS_ENTRYLK_COUNT),
|
|
|
14f8ab |
+ SLEN(GLUSTERFS_INODELK_COUNT),
|
|
|
14f8ab |
+ SLEN(GLUSTERFS_INODELK_DOM_COUNT),
|
|
|
14f8ab |
+ SLEN(GLUSTERFS_POSIXLK_COUNT),
|
|
|
14f8ab |
+ SLEN(GLUSTERFS_PARENT_ENTRYLK),
|
|
|
14f8ab |
+ SLEN(GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS),
|
|
|
14f8ab |
+ 0};
|
|
|
14f8ab |
int i = 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
if (!xdata)
|
|
|
14f8ab |
@@ -169,12 +176,22 @@ pl_has_xdata_requests(dict_t *xdata)
|
|
|
14f8ab |
return _gf_false;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+static int
|
|
|
14f8ab |
+dict_delete_domain_key(dict_t *dict, char *key, data_t *value, void *data)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ dict_del(dict, key);
|
|
|
14f8ab |
+ return 0;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
void
|
|
|
14f8ab |
pl_get_xdata_requests(pl_local_t *local, dict_t *xdata)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
if (!local || !xdata)
|
|
|
14f8ab |
return;
|
|
|
14f8ab |
|
|
|
14f8ab |
+ GF_ASSERT(local->xdata == NULL);
|
|
|
14f8ab |
+ local->xdata = dict_copy_with_ref(xdata, NULL);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
if (dict_get_sizen(xdata, GLUSTERFS_ENTRYLK_COUNT)) {
|
|
|
14f8ab |
local->entrylk_count_req = 1;
|
|
|
14f8ab |
dict_del_sizen(xdata, GLUSTERFS_ENTRYLK_COUNT);
|
|
|
14f8ab |
@@ -183,6 +200,12 @@ pl_get_xdata_requests(pl_local_t *local, dict_t *xdata)
|
|
|
14f8ab |
local->inodelk_count_req = 1;
|
|
|
14f8ab |
dict_del_sizen(xdata, GLUSTERFS_INODELK_COUNT);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
+ if (dict_get_sizen(xdata, GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS)) {
|
|
|
14f8ab |
+ local->multiple_dom_lk_requests = 1;
|
|
|
14f8ab |
+ dict_del_sizen(xdata, GLUSTERFS_MULTIPLE_DOM_LK_CNT_REQUESTS);
|
|
|
14f8ab |
+ dict_foreach_fnmatch(xdata, GLUSTERFS_INODELK_DOM_PREFIX "*",
|
|
|
14f8ab |
+ dict_delete_domain_key, NULL);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
local->inodelk_dom_count_req = dict_get_sizen(xdata,
|
|
|
14f8ab |
GLUSTERFS_INODELK_DOM_COUNT);
|
|
|
14f8ab |
@@ -210,7 +233,7 @@ pl_needs_xdata_response(pl_local_t *local)
|
|
|
14f8ab |
|
|
|
14f8ab |
if (local->parent_entrylk_req || local->entrylk_count_req ||
|
|
|
14f8ab |
local->inodelk_dom_count_req || local->inodelk_count_req ||
|
|
|
14f8ab |
- local->posixlk_count_req)
|
|
|
14f8ab |
+ local->posixlk_count_req || local->multiple_dom_lk_requests)
|
|
|
14f8ab |
return _gf_true;
|
|
|
14f8ab |
|
|
|
14f8ab |
return _gf_false;
|
|
|
14f8ab |
@@ -411,6 +434,75 @@ pl_posixlk_xattr_fill(xlator_t *this, inode_t *inode, dict_t *dict,
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
void
|
|
|
14f8ab |
+pl_inodelk_xattr_fill_each(xlator_t *this, inode_t *inode, dict_t *dict,
|
|
|
14f8ab |
+ char *domname, gf_boolean_t keep_max, char *key)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ int32_t count = 0;
|
|
|
14f8ab |
+ int32_t maxcount = -1;
|
|
|
14f8ab |
+ int ret = -1;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (keep_max) {
|
|
|
14f8ab |
+ ret = dict_get_int32(dict, key, &maxcount);
|
|
|
14f8ab |
+ if (ret < 0)
|
|
|
14f8ab |
+ gf_msg_debug(this->name, 0, " Failed to fetch the value for key %s",
|
|
|
14f8ab |
+ GLUSTERFS_INODELK_COUNT);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ count = get_inodelk_count(this, inode, domname);
|
|
|
14f8ab |
+ if (maxcount >= count)
|
|
|
14f8ab |
+ return;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ ret = dict_set_int32(dict, key, count);
|
|
|
14f8ab |
+ if (ret < 0) {
|
|
|
14f8ab |
+ gf_msg_debug(this->name, 0,
|
|
|
14f8ab |
+ "Failed to set count for "
|
|
|
14f8ab |
+ "key %s",
|
|
|
14f8ab |
+ key);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+static int
|
|
|
14f8ab |
+pl_inodelk_xattr_fill_multiple(dict_t *this, char *key, data_t *value,
|
|
|
14f8ab |
+ void *data)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ multi_dom_lk_data *d = data;
|
|
|
14f8ab |
+ char *tmp_key = NULL;
|
|
|
14f8ab |
+ char *save_ptr = NULL;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ tmp_key = gf_strdup(key);
|
|
|
14f8ab |
+ strtok_r(tmp_key, ":", &save_ptr);
|
|
|
14f8ab |
+ if (!*save_ptr) {
|
|
|
14f8ab |
+ gf_msg(THIS->name, GF_LOG_ERROR, 0, EINVAL,
|
|
|
14f8ab |
+ "Could not tokenize domain string from key %s", key);
|
|
|
14f8ab |
+ return -1;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ pl_inodelk_xattr_fill_each(d->this, d->inode, d->xdata_rsp, save_ptr,
|
|
|
14f8ab |
+ d->keep_max, key);
|
|
|
14f8ab |
+ if (tmp_key)
|
|
|
14f8ab |
+ GF_FREE(tmp_key);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return 0;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+void
|
|
|
14f8ab |
+pl_fill_multiple_dom_lk_requests(xlator_t *this, pl_local_t *local,
|
|
|
14f8ab |
+ inode_t *inode, dict_t *dict,
|
|
|
14f8ab |
+ gf_boolean_t keep_max)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ multi_dom_lk_data data;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ data.this = this;
|
|
|
14f8ab |
+ data.inode = inode;
|
|
|
14f8ab |
+ data.xdata_rsp = dict;
|
|
|
14f8ab |
+ data.keep_max = keep_max;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ dict_foreach_fnmatch(local->xdata, GLUSTERFS_INODELK_DOM_PREFIX "*",
|
|
|
14f8ab |
+ pl_inodelk_xattr_fill_multiple, &data);
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+void
|
|
|
14f8ab |
pl_set_xdata_response(xlator_t *this, pl_local_t *local, inode_t *parent,
|
|
|
14f8ab |
inode_t *inode, char *name, dict_t *xdata,
|
|
|
14f8ab |
gf_boolean_t max_lock)
|
|
|
14f8ab |
@@ -437,6 +529,9 @@ pl_set_xdata_response(xlator_t *this, pl_local_t *local, inode_t *parent,
|
|
|
14f8ab |
|
|
|
14f8ab |
if (local->posixlk_count_req)
|
|
|
14f8ab |
pl_posixlk_xattr_fill(this, inode, xdata, max_lock);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (local->multiple_dom_lk_requests)
|
|
|
14f8ab |
+ pl_fill_multiple_dom_lk_requests(this, local, inode, xdata, max_lock);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
/* Checks whether the region where fop is acting upon conflicts
|
|
|
14f8ab |
@@ -773,9 +868,6 @@ pl_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
14f8ab |
{
|
|
|
14f8ab |
pl_local_t *local = frame->local;
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (local->xdata)
|
|
|
14f8ab |
- dict_unref(local->xdata);
|
|
|
14f8ab |
-
|
|
|
14f8ab |
pl_track_io_fop_count(local, this, DECREMENT);
|
|
|
14f8ab |
|
|
|
14f8ab |
if (local->op == GF_FOP_TRUNCATE)
|
|
|
14f8ab |
@@ -932,9 +1024,6 @@ unwind:
|
|
|
14f8ab |
"ret: %d, error: %s",
|
|
|
14f8ab |
op_ret, strerror(op_errno));
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (local->xdata)
|
|
|
14f8ab |
- dict_unref(local->xdata);
|
|
|
14f8ab |
-
|
|
|
14f8ab |
switch (local->op) {
|
|
|
14f8ab |
case GF_FOP_TRUNCATE:
|
|
|
14f8ab |
PL_STACK_UNWIND(truncate, xdata, frame, op_ret, op_errno, buf,
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|