summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-03-11 17:43:12 +0530
committerVijay Bellur <vbellur@redhat.com>2015-03-25 11:10:40 -0700
commit21cd43cfd62f69cd011fced7ebec93b9347f9fce (patch)
treee3736b832dea4721754623cae8c27b3de49cb220 /xlators/cluster
parent18dd162e00c8655648cea702bdb7b8bf25f1da97 (diff)
libxlator: Change marker xattr handling interface
- Changed the implementation of marker xattr handling to take just a function which populates important data that is different from default 'gauge' values and subvolumes where the call needs to be wound. - Removed duplicate code I found while reading the code and moved it to cluster_marker_unwind. Removed unused structure members. - Changed dht/afr/stripe implementations to follow the new implementation - Implemented marker xattr handling for ec. Change-Id: Ib0c3626fe31eb7c8aae841eabb694945bf23abd4 BUG: 1200372 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/9892 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Xavier Hernandez <xhernandez@datalab.es> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c90
-rw-r--r--xlators/cluster/afr/src/afr.h2
-rw-r--r--xlators/cluster/dht/src/dht-common.c70
-rw-r--r--xlators/cluster/dht/src/dht-common.h3
-rw-r--r--xlators/cluster/ec/src/ec.c23
-rw-r--r--xlators/cluster/ec/src/ec.h2
-rw-r--r--xlators/cluster/stripe/src/stripe.c84
-rw-r--r--xlators/cluster/stripe/src/stripe.h2
8 files changed, 88 insertions, 188 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index 77acf0b25b9..afa40fbad2a 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1408,6 +1408,23 @@ afr_getxattr_all_subvols (xlator_t *this, call_frame_t *frame,
return;
}
+int
+afr_marker_populate_args (call_frame_t *frame, int type, int *gauge,
+ xlator_t **subvols)
+{
+ xlator_t *this = frame->this;
+ afr_private_t *priv = this->private;
+
+ memcpy (subvols, priv->children, sizeof (*subvols) * priv->child_count);
+
+ if (type == MARKER_XTIME_TYPE) {
+ /*Don't error out on ENOENT/ENOTCONN */
+ gauge[MCNT_NOTFOUND] = 0;
+ gauge[MCNT_ENOTCONN] = 0;
+ }
+ return priv->child_count;
+}
+
int32_t
afr_getxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, const char *name, dict_t *xdata)
@@ -1415,13 +1432,10 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
afr_private_t *priv = NULL;
xlator_t **children = NULL;
afr_local_t *local = NULL;
- xlator_list_t *trav = NULL;
- xlator_t **sub_volumes = NULL;
int i = 0;
int32_t op_errno = 0;
int ret = -1;
fop_getxattr_cbk_t cbk = NULL;
- int afr_xtime_gauge[MCNT_MAX] = {0,};
local = AFR_FRAME_INIT (frame, op_errno);
@@ -1457,35 +1471,11 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
op_errno = ENODATA;
goto out;
}
- if ((strcmp (GF_XATTR_MARKER_KEY, name) == 0)
- && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
-
- local->marker.call_count = priv->child_count;
-
- sub_volumes = alloca ( priv->child_count * sizeof (xlator_t *));
- for (i = 0, trav = this->children; trav ;
- trav = trav->next, i++) {
-
- *(sub_volumes + i) = trav->xlator;
- }
-
- if (cluster_getmarkerattr (frame, this, loc, name,
- local, afr_getxattr_unwind,
- sub_volumes,
- priv->child_count,
- MARKER_UUID_TYPE,
- marker_uuid_default_gauge,
- priv->vol_uuid)) {
-
- gf_log (this->name, GF_LOG_INFO,
- "%s: failed to get marker attr (%s)",
- loc->path, name);
- op_errno = EINVAL;
- goto out;
- }
+ if (cluster_handle_marker_getxattr (frame, loc, name, priv->vol_uuid,
+ afr_getxattr_unwind,
+ afr_marker_populate_args) == 0)
return 0;
- }
if (!strcmp (name, GF_AFR_HEAL_INFO)) {
afr_get_heal_info (frame, this, loc, xdata);
@@ -1519,46 +1509,6 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
return 0;
}
- if (*priv->vol_uuid) {
- if ((match_uuid_local (name, priv->vol_uuid) == 0)
- && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
- local->marker.call_count = priv->child_count;
-
- sub_volumes = alloca ( priv->child_count
- * sizeof (xlator_t *));
- for (i = 0, trav = this->children; trav ;
- trav = trav->next, i++) {
-
- *(sub_volumes + i) = trav->xlator;
-
- }
-
- /* don't err out on getting ENOTCONN (brick down)
- * from a subset of the bricks
- */
- memcpy (afr_xtime_gauge, marker_xtime_default_gauge,
- sizeof (afr_xtime_gauge));
- afr_xtime_gauge[MCNT_NOTFOUND] = 0;
- afr_xtime_gauge[MCNT_ENOTCONN] = 0;
- if (cluster_getmarkerattr (frame, this, loc,
- name, local,
- afr_getxattr_unwind,
- sub_volumes,
- priv->child_count,
- MARKER_XTIME_TYPE,
- afr_xtime_gauge,
- priv->vol_uuid)) {
- gf_log (this->name, GF_LOG_INFO,
- "%s: failed to get marker attr (%s)",
- loc->path, name);
- op_errno = EINVAL;
- goto out;
- }
-
- return 0;
- }
- }
-
no_name:
afr_read_txn (frame, this, local->loc.inode, afr_getxattr_wind,
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 0885b582d77..de000e765ea 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -720,8 +720,6 @@ typedef struct _afr_local {
syncbarrier_t barrier;
- struct marker_str marker;
-
/* extra data for fops */
dict_t *xdata_req;
dict_t *xdata_rsp;
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 3a196e07be9..b7df1f4da4b 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -2791,6 +2791,22 @@ dht_getxattr_get_real_filename (call_frame_t *frame, xlator_t *this,
return 0;
}
+int
+dht_marker_populate_args (call_frame_t *frame, int type, int *gauge,
+ xlator_t **subvols)
+{
+ dht_local_t *local = NULL;
+ int i = 0;
+ dht_layout_t *layout = NULL;
+
+ local = frame->local;
+ layout = local->layout;
+
+ for (i = 0; i < layout->cnt; i++)
+ subvols[i] = layout->list[i].xlator;
+
+ return layout->cnt;
+}
int
dht_getxattr (call_frame_t *frame, xlator_t *this,
@@ -2804,7 +2820,6 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
dht_conf_t *conf = NULL;
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
- xlator_t **sub_volumes = NULL;
int op_errno = -1;
int i = 0;
int cnt = 0;
@@ -2918,30 +2933,6 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
return 0;
}
- if (key && (!strcmp (GF_XATTR_MARKER_KEY, key))
- && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
- if (DHT_IS_DIR(layout)) {
- cnt = layout->cnt;
- } else {
- cnt = 1;
- }
-
- sub_volumes = alloca ( cnt * sizeof (xlator_t *));
- for (i = 0; i < cnt; i++)
- *(sub_volumes + i) = layout->list[i].xlator;
-
- if (cluster_getmarkerattr (frame, this, loc, key,
- local, dht_getxattr_unwind,
- sub_volumes, cnt,
- MARKER_UUID_TYPE, marker_uuid_default_gauge,
- conf->vol_uuid)) {
- op_errno = EINVAL;
- goto err;
- }
-
- return 0;
- }
-
if (key && (!strcmp (GF_XATTR_QUOTA_LIMIT_LIST, key) ||
!strcmp (GF_XATTR_QUOTA_LIMIT_LIST_OBJECT, key))) {
/* quota hardlimit and aggregated size of a directory is stored
@@ -2955,31 +2946,10 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
return 0;
}
- if (key && *conf->vol_uuid) {
- if ((match_uuid_local (key, conf->vol_uuid) == 0) &&
- (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
- if (DHT_IS_DIR(layout)) {
- cnt = layout->cnt;
- } else {
- cnt = 1;
- }
- sub_volumes = alloca ( cnt * sizeof (xlator_t *));
- for (i = 0; i < cnt; i++)
- sub_volumes[i] = layout->list[i].xlator;
-
- if (cluster_getmarkerattr (frame, this, loc, key,
- local, dht_getxattr_unwind,
- sub_volumes, cnt,
- MARKER_XTIME_TYPE,
- marker_xtime_default_gauge,
- conf->vol_uuid)) {
- op_errno = EINVAL;
- goto err;
- }
-
- return 0;
- }
- }
+ if (cluster_handle_marker_getxattr (frame, loc, key, conf->vol_uuid,
+ dht_getxattr_unwind,
+ dht_marker_populate_args) == 0)
+ return 0;
if (DHT_IS_DIR(layout)) {
cnt = local->call_cnt = layout->cnt;
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 9145f336d7c..9d505c1e601 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -216,9 +216,6 @@ struct dht_local {
/* gfid related */
uuid_t gfid;
- /*Marker Related*/
- struct marker_str marker;
-
/* flag used to make sure we need to return estale in
{lookup,revalidate}_cbk */
char return_estale;
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 9fecde4c495..9b8251a5403 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -576,16 +576,39 @@ int32_t ec_gf_fsyncdir(call_frame_t * frame, xlator_t * this, fd_t * fd,
return 0;
}
+int
+ec_marker_populate_args (call_frame_t *frame, int type, int *gauge,
+ xlator_t **subvols)
+{
+ xlator_t *this = frame->this;
+ ec_t *ec = this->private;
+
+ memcpy (subvols, ec->xl_list, sizeof (*subvols) * ec->nodes);
+
+ if (type == MARKER_XTIME_TYPE) {
+ /*Don't error out on ENOENT/ENOTCONN */
+ gauge[MCNT_NOTFOUND] = 0;
+ gauge[MCNT_ENOTCONN] = 0;
+ }
+
+ return ec->nodes;
+}
+
int32_t
ec_gf_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
const char *name, dict_t *xdata)
{
int error = 0;
+ ec_t *ec = this->private;
if (name && strcmp (name, EC_XATTR_HEAL) != 0) {
EC_INTERNAL_XATTR_OR_GOTO(name, NULL, error, out);
}
+ if (cluster_handle_marker_getxattr (frame, loc, name, ec->vol_uuid,
+ NULL, ec_marker_populate_args) == 0)
+ return 0;
+
ec_getxattr (frame, this, -1, EC_MINIMUM_MIN, default_getxattr_cbk,
NULL, loc, name, xdata);
diff --git a/xlators/cluster/ec/src/ec.h b/xlators/cluster/ec/src/ec.h
index 1c740187757..d565bf8fcb4 100644
--- a/xlators/cluster/ec/src/ec.h
+++ b/xlators/cluster/ec/src/ec.h
@@ -14,6 +14,7 @@
#include "xlator.h"
#include "timer.h"
#include "ec-heald.h"
+#include "libxlator.h"
#define EC_XATTR_PREFIX "trusted.ec."
#define EC_XATTR_CONFIG EC_XATTR_PREFIX"config"
@@ -45,5 +46,6 @@ struct _ec
struct mem_pool * cbk_pool;
struct mem_pool * lock_pool;
ec_self_heald_t shd;
+ char vol_uuid[UUID_SIZE + 1];
};
#endif /* __EC_H__ */
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index 7af9442a7ff..8896d7a2ad2 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -5454,6 +5454,25 @@ stripe_vgetxattr_cbk (call_frame_t *frame, void *cookie,
return ret;
}
+int
+stripe_marker_populate_args (call_frame_t *frame, int type, int *gauge,
+ xlator_t **subvols)
+{
+ xlator_t *this = frame->this;
+ stripe_private_t *priv = this->private;
+ stripe_local_t *local = frame->local;
+ int count = 0;
+
+ count = priv->child_count;
+ if (MARKER_XTIME_TYPE == type) {
+ if (!IA_FILE_OR_DIR (local->loc.inode->ia_type))
+ count = 1;
+ }
+ memcpy (subvols, priv->xl_array, sizeof (*subvols) * count);
+
+ return count;
+}
+
int32_t
stripe_getxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, const char *name, dict_t *xdata)
@@ -5463,7 +5482,6 @@ stripe_getxattr (call_frame_t *frame, xlator_t *this,
stripe_private_t *priv = NULL;
int32_t op_errno = EINVAL;
int i = 0;
- xlator_t **sub_volumes;
int ret = 0;
VALIDATE_OR_GOTO (frame, err);
@@ -5486,31 +5504,6 @@ stripe_getxattr (call_frame_t *frame, xlator_t *this,
loc_copy (&local->loc, loc);
- if (name && (strcmp (GF_XATTR_MARKER_KEY, name) == 0)
- && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
- local->marker.call_count = priv->child_count;
-
- sub_volumes = alloca ( priv->child_count *
- sizeof (xlator_t *));
- for (i = 0, trav = this->children; trav ;
- trav = trav->next, i++) {
-
- *(sub_volumes + i) = trav->xlator;
-
- }
-
- if (cluster_getmarkerattr (frame, this, loc, name,
- local, stripe_getxattr_unwind,
- sub_volumes, priv->child_count,
- MARKER_UUID_TYPE, marker_uuid_default_gauge,
- priv->vol_uuid)) {
- op_errno = EINVAL;
- goto err;
- }
-
- return 0;
- }
-
if (name && strncmp (name, GF_XATTR_QUOTA_SIZE_KEY,
strlen (GF_XATTR_QUOTA_SIZE_KEY)) == 0) {
local->wind_count = priv->child_count;
@@ -5555,41 +5548,10 @@ stripe_getxattr (call_frame_t *frame, xlator_t *this,
return 0;
}
- if (name &&(*priv->vol_uuid)) {
- if ((match_uuid_local (name, priv->vol_uuid) == 0)
- && (GF_CLIENT_PID_GSYNCD == frame->root->pid)) {
-
- if (!IA_FILE_OR_DIR (loc->inode->ia_type))
- local->marker.call_count = 1;
- else
- local->marker.call_count = priv->child_count;
-
- sub_volumes = alloca (local->marker.call_count *
- sizeof (xlator_t *));
-
- for (i = 0, trav = this->children;
- i < local->marker.call_count;
- i++, trav = trav->next) {
- *(sub_volumes + i) = trav->xlator;
-
- }
-
- if (cluster_getmarkerattr (frame, this, loc, name,
- local,
- stripe_getxattr_unwind,
- sub_volumes,
- local->marker.call_count,
- MARKER_XTIME_TYPE,
- marker_xtime_default_gauge,
- priv->vol_uuid)) {
- op_errno = EINVAL;
- goto err;
- }
-
- return 0;
- }
- }
-
+ if (cluster_handle_marker_getxattr (frame, loc, name, priv->vol_uuid,
+ stripe_getxattr_unwind,
+ stripe_marker_populate_args) == 0)
+ return 0;
STACK_WIND (frame, stripe_internal_getxattr_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->getxattr, loc, name, xdata);
diff --git a/xlators/cluster/stripe/src/stripe.h b/xlators/cluster/stripe/src/stripe.h
index 5673d18f390..150d9e49f93 100644
--- a/xlators/cluster/stripe/src/stripe.h
+++ b/xlators/cluster/stripe/src/stripe.h
@@ -190,8 +190,6 @@ struct stripe_local {
int32_t nallocs;
char xsel[256];
- struct marker_str marker;
-
/* General usage */
off_t offset;
off_t stripe_size;