summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2019-01-18 11:00:56 +0800
committerAmar Tumballi <amarts@redhat.com>2019-03-04 09:13:06 +0000
commit2b51b89f0f67ba1f7655cadb3fab9b4d3766faa6 (patch)
tree2e0122b1736d3afc09dbb7fa52d56781cd735eda /xlators
parent16b4936696c8b602243513fbde0b20a1e8417432 (diff)
quotad: fix passing GF_DATA_TYPE_STR_OLD dict data to v4 protocol
quotad prints many logs as, [glusterfs3.h:752:dict_to_xdr] 0-dict: key 'trusted.glusterfs.quota.size' is not sent on wire [Invalid argument] [glusterfs3.h:752:dict_to_xdr] 0-dict: key 'volume-uuid' is not sent on wire [Invalid argument] For quota, there is a deamon named quotad which has a rpcsvc_program quotad_aggregator_prog that only supports v3 right now. Quotad has two actors (LOOKUP,GETLIMIT) that contains a dict in request, quotad just decodes the dict by dict_unserialize, those dict dates's type is GF_DATA_TYPE_STR_OLD, which type is not supported at glusterfs v4. Change-Id: Ib649d7a2e3c68c32dc26bc0f88923a0ba967ebd7 Updates: bz#1596787 Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/features/quota/src/quotad-aggregator.c50
-rw-r--r--xlators/features/quota/src/quotad-aggregator.h4
-rw-r--r--xlators/features/quota/src/quotad-helpers.c3
-rw-r--r--xlators/features/quota/src/quotad.c11
4 files changed, 52 insertions, 16 deletions
diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c
index 379bc05af27..5a755c45fda 100644
--- a/xlators/features/quota/src/quotad-aggregator.c
+++ b/xlators/features/quota/src/quotad-aggregator.c
@@ -13,6 +13,13 @@
#include "quotad-helpers.h"
#include "quotad-aggregator.h"
+static char *qd_ext_xattrs[] = {
+ QUOTA_SIZE_KEY,
+ QUOTA_LIMIT_KEY,
+ QUOTA_LIMIT_OBJECTS_KEY,
+ NULL,
+};
+
struct rpcsvc_program quotad_aggregator_prog;
struct iobuf *
@@ -141,7 +148,7 @@ quotad_aggregator_getlimit_cbk(xlator_t *this, call_frame_t *frame,
if (xdata) {
state = frame->root->state;
- ret = dict_get_int32n(state->xdata, "type", SLEN("type"), &type);
+ ret = dict_get_int32n(state->req_xdata, "type", SLEN("type"), &type);
if (ret < 0)
goto out;
@@ -191,6 +198,7 @@ quotad_aggregator_getlimit(rpcsvc_request_t *req)
int ret = -1, op_errno = 0;
char *gfid_str = NULL;
uuid_t gfid = {0};
+ char *volume_uuid = NULL;
GF_VALIDATE_OR_GOTO("quotad-aggregator", req, err);
@@ -224,6 +232,11 @@ quotad_aggregator_getlimit(rpcsvc_request_t *req)
goto err;
}
+ ret = dict_get_strn(dict, "volume-uuid", SLEN("volume-uuid"), &volume_uuid);
+ if (ret) {
+ goto err;
+ }
+
gf_uuid_parse((const char *)gfid_str, gfid);
frame = quotad_aggregator_get_frame_from_req(req);
@@ -232,7 +245,9 @@ quotad_aggregator_getlimit(rpcsvc_request_t *req)
goto errx;
}
state = frame->root->state;
- state->xdata = dict;
+ state->req_xdata = dict;
+ state->xdata = dict_new();
+ dict = NULL;
ret = dict_set_int32_sizen(state->xdata, QUOTA_LIMIT_KEY, 42);
if (ret)
@@ -254,7 +269,7 @@ quotad_aggregator_getlimit(rpcsvc_request_t *req)
goto err;
ret = qd_nameless_lookup(this, frame, (char *)gfid, state->xdata,
- quotad_aggregator_getlimit_cbk);
+ volume_uuid, quotad_aggregator_getlimit_cbk);
if (ret) {
cli_rsp.op_errno = ret;
goto errx;
@@ -293,12 +308,14 @@ quotad_aggregator_lookup(rpcsvc_request_t *req)
0,
},
};
- int ret = -1, op_errno = 0;
+ int i = 0, ret = -1, op_errno = 0;
gfs3_lookup_rsp rsp = {
0,
};
quotad_aggregator_state_t *state = NULL;
xlator_t *this = NULL;
+ dict_t *dict = NULL;
+ char *volume_uuid = NULL;
GF_VALIDATE_OR_GOTO("quotad-aggregator", req, err);
@@ -321,16 +338,34 @@ quotad_aggregator_lookup(rpcsvc_request_t *req)
state = frame->root->state;
- GF_PROTOCOL_DICT_UNSERIALIZE(this, state->xdata, (args.xdata.xdata_val),
+ GF_PROTOCOL_DICT_UNSERIALIZE(this, dict, (args.xdata.xdata_val),
(args.xdata.xdata_len), ret, op_errno, err);
- ret = qd_nameless_lookup(this, frame, args.gfid, state->xdata,
+ ret = dict_get_str(dict, "volume-uuid", &volume_uuid);
+ if (ret) {
+ goto err;
+ }
+
+ state->xdata = dict_new();
+
+ for (i = 0; qd_ext_xattrs[i]; i++) {
+ if (dict_get(dict, qd_ext_xattrs[i])) {
+ ret = dict_set_uint32(state->xdata, qd_ext_xattrs[i], 1);
+ if (ret < 0)
+ goto err;
+ }
+ }
+
+ ret = qd_nameless_lookup(this, frame, args.gfid, state->xdata, volume_uuid,
quotad_aggregator_lookup_cbk);
if (ret) {
rsp.op_errno = ret;
goto err;
}
+ if (dict)
+ dict_unref(dict);
+
return ret;
err:
@@ -338,6 +373,9 @@ err:
rsp.op_errno = op_errno;
quotad_aggregator_lookup_cbk(this, frame, &rsp);
+ if (dict)
+ dict_unref(dict);
+
return ret;
}
diff --git a/xlators/features/quota/src/quotad-aggregator.h b/xlators/features/quota/src/quotad-aggregator.h
index 318ad7f4995..706592c7d50 100644
--- a/xlators/features/quota/src/quotad-aggregator.h
+++ b/xlators/features/quota/src/quotad-aggregator.h
@@ -23,13 +23,15 @@ typedef struct {
inode_table_t *itable;
loc_t loc;
dict_t *xdata;
+ dict_t *req_xdata;
} quotad_aggregator_state_t;
typedef int (*quotad_aggregator_lookup_cbk_t)(xlator_t *this,
call_frame_t *frame, void *rsp);
int
qd_nameless_lookup(xlator_t *this, call_frame_t *frame, char *gfid,
- dict_t *xdata, quotad_aggregator_lookup_cbk_t lookup_cbk);
+ dict_t *xdata, char *volume_uuid,
+ quotad_aggregator_lookup_cbk_t lookup_cbk);
int
quotad_aggregator_init(xlator_t *this);
diff --git a/xlators/features/quota/src/quotad-helpers.c b/xlators/features/quota/src/quotad-helpers.c
index be8f9080f14..bb66a314705 100644
--- a/xlators/features/quota/src/quotad-helpers.c
+++ b/xlators/features/quota/src/quotad-helpers.c
@@ -47,6 +47,9 @@ quotad_aggregator_free_state(quotad_aggregator_state_t *state)
if (state->xdata)
dict_unref(state->xdata);
+ if (state->req_xdata)
+ dict_unref(state->req_xdata);
+
GF_FREE(state);
}
diff --git a/xlators/features/quota/src/quotad.c b/xlators/features/quota/src/quotad.c
index 11ef2b1189c..146ec749930 100644
--- a/xlators/features/quota/src/quotad.c
+++ b/xlators/features/quota/src/quotad.c
@@ -105,7 +105,8 @@ out:
int
qd_nameless_lookup(xlator_t *this, call_frame_t *frame, char *gfid,
- dict_t *xdata, quotad_aggregator_lookup_cbk_t lookup_cbk)
+ dict_t *xdata, char *volume_uuid,
+ quotad_aggregator_lookup_cbk_t lookup_cbk)
{
gfs3_lookup_rsp rsp = {
0,
@@ -116,7 +117,6 @@ qd_nameless_lookup(xlator_t *this, call_frame_t *frame, char *gfid,
};
quotad_aggregator_state_t *state = NULL;
xlator_t *subvol = NULL;
- char *volume_uuid = NULL;
state = frame->root->state;
@@ -130,13 +130,6 @@ qd_nameless_lookup(xlator_t *this, call_frame_t *frame, char *gfid,
memcpy(loc.gfid, gfid, 16);
- ret = dict_get_strn(xdata, "volume-uuid", SLEN("volume-uuid"),
- &volume_uuid);
- if (ret < 0) {
- op_errno = EINVAL;
- goto out;
- }
-
ret = dict_set_int8(xdata, QUOTA_READ_ONLY_KEY, 1);
if (ret < 0) {
gf_msg(this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,