summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-05-04 10:34:13 +0530
committerRaghavendra G <rgowdapp@redhat.com>2018-05-09 03:46:36 +0000
commit2d3b44641dc7820043eae37572292b7b3cc26625 (patch)
tree1e248b7b3f7ca313e36fe7e6da51a0b80da37cc0 /xlators/cluster
parentd3e3b11d38b927cf849d2d7a20460650963fd438 (diff)
cluster/dht: Debug virtual xattrs for dht
Provide a virtual xattr with which to query the hashed subvol for a file. Change-Id: Ic7abd031f875da4b9084841ea7c25d6c8a851992 fixes: bz#1574421 Signed-off-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-common.c95
-rw-r--r--xlators/cluster/dht/src/dht-common.h6
2 files changed, 101 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 679fc8e5bb5..1ad408f0c0d 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -120,6 +120,12 @@ char *xattrs_to_heal[] = {
NULL
};
+
+char *dht_dbg_vxattrs[] = {
+ DHT_DBG_HASHED_SUBVOL_KEY,
+ NULL
+};
+
/* Return true if key exists in array
*/
static gf_boolean_t
@@ -4730,6 +4736,90 @@ dht_marker_populate_args (call_frame_t *frame, int type, int *gauge,
return layout->cnt;
}
+
+/* Note we already have frame->local initialised here*/
+
+int
+dht_handle_debug_getxattr (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, const char *key)
+{
+ dht_local_t *local = NULL;
+ int ret = -1;
+ int op_errno = ENODATA;
+ ia_type_t type = 0;
+ char *value = NULL;
+
+ local = frame->local;
+ if (!key) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ if (gf_get_index_by_elem (dht_dbg_vxattrs, (char *)key) == -1) {
+ goto out;
+ }
+
+ /* getxattr does not set the parent inode*/
+ if (!loc->parent) {
+ loc->parent =
+ inode_parent(local->loc.inode, NULL, NULL);
+ }
+ if (!loc->parent) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ gf_uuid_copy (loc->pargfid, loc->parent->gfid);
+
+ if (!loc->name && loc->path) {
+ loc->name = strrchr (loc->path, '/');
+ if (loc->name) {
+ ++(loc->name);
+ }
+ }
+
+ local->xattr = dict_new ();
+ if (!local->xattr) {
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ type = loc->inode->ia_type;
+
+ if (strcmp (key, DHT_DBG_HASHED_SUBVOL_KEY) == 0) {
+ if (IA_ISDIR (type)) {
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ local->hashed_subvol = dht_subvol_get_hashed (this, loc);
+ if (local->hashed_subvol == NULL) {
+ op_errno = ENODATA;
+ goto out;
+ }
+
+ value = gf_strdup (local->hashed_subvol->name);
+ if (!value) {
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ ret = dict_set_dynstr (local->xattr, (char *)key, value);
+ if (ret < 0) {
+ op_errno = -ret;
+ ret = -1;
+ goto out;
+ }
+ ret = 0;
+ goto out;
+ }
+
+out:
+ DHT_STACK_UNWIND (getxattr, frame, ret, op_errno, local->xattr, NULL);
+ return 0;
+}
+
+
int
dht_getxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, const char *key, dict_t *xdata)
@@ -4919,6 +5009,11 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
return 0;
}
+ if (key && (gf_get_index_by_elem (dht_dbg_vxattrs, (char *)key) >= 0)) {
+ dht_handle_debug_getxattr (frame, this, loc, key);
+ return 0;
+ }
+
if (cluster_handle_marker_getxattr (frame, loc, key, conf->vol_uuid,
dht_getxattr_unwind,
dht_marker_populate_args) == 0)
diff --git a/xlators/cluster/dht/src/dht-common.h b/xlators/cluster/dht/src/dht-common.h
index 999a7874a22..b82d3c4d267 100644
--- a/xlators/cluster/dht/src/dht-common.h
+++ b/xlators/cluster/dht/src/dht-common.h
@@ -45,6 +45,12 @@
#define DHT_DIR_STAT_BLOCKS 8
#define DHT_DIR_STAT_SIZE 4096
+
+/* Virtual xattrs for debugging */
+
+#define DHT_DBG_HASHED_SUBVOL_KEY "dht.file.hashed-subvol"
+
+
/* Array to hold custom xattr keys
*/
extern char *xattrs_to_heal[];