2
Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
3
This file is part of GlusterFS.
5
This file is licensed to you under your choice of the GNU Lesser
6
General Public License, version 3 or any later version (LGPLv3 or
7
later), or the GNU General Public License, version 2 (GPLv2), in all
8
cases as published by the Free Software Foundation.
11
#include "quotad-aggregator.h"
14
qd_notify(xlator_t *this, int32_t event, void *data, ...)
17
case GF_EVENT_PARENT_UP:
18
quotad_aggregator_init(this);
21
default_notify(this, event, data);
26
mem_acct_init(xlator_t *this)
33
ret = xlator_mem_acct_init(this, gf_quota_mt_end);
36
gf_log(this->name, GF_LOG_WARNING,
46
qd_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
47
int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata,
48
struct iatt *postparent)
50
quotad_aggregator_lookup_cbk_t lookup_cbk = NULL;
51
gfs3_lookup_rsp rsp = {
58
rsp.op_errno = op_errno;
60
gf_stat_from_iatt(&rsp.postparent, postparent);
62
GF_PROTOCOL_DICT_SERIALIZE(this, xdata, (&rsp.xdata.xdata_val),
63
rsp.xdata.xdata_len, rsp.op_errno, out);
65
gf_stat_from_iatt(&rsp.stat, buf);
68
lookup_cbk(this, frame, &rsp);
70
GF_FREE(rsp.xdata.xdata_val);
78
qd_find_subvol(xlator_t *this, char *volume_uuid)
80
xlator_list_t *child = NULL;
81
xlator_t *subvol = NULL;
86
if (!this || !volume_uuid)
89
for (child = this->children; child; child = child->next) {
90
keylen = snprintf(key, sizeof(key), "%s.volume-id",
92
if (dict_get_strn(this->options, key, keylen, &optstr) < 0)
95
if (strcmp(optstr, volume_uuid) == 0) {
96
subvol = child->xlator;
106
qd_nameless_lookup(xlator_t *this, call_frame_t *frame, char *gfid,
107
dict_t *xdata, char *volume_uuid,
108
quotad_aggregator_lookup_cbk_t lookup_cbk)
110
gfs3_lookup_rsp rsp = {
113
int op_errno = 0, ret = -1;
117
quotad_aggregator_state_t *state = NULL;
118
xlator_t *subvol = NULL;
120
state = frame->root->state;
122
frame->root->op = GF_FOP_LOOKUP;
124
loc.inode = inode_new(state->itable);
125
if (loc.inode == NULL) {
130
memcpy(loc.gfid, gfid, 16);
132
ret = dict_set_int8(xdata, QUOTA_READ_ONLY_KEY, 1);
134
gf_msg(this->name, GF_LOG_WARNING, ENOMEM, Q_MSG_ENOMEM,
140
subvol = qd_find_subvol(this, volume_uuid);
141
if (subvol == NULL) {
146
STACK_WIND_COOKIE(frame, qd_lookup_cbk, lookup_cbk, subvol,
147
subvol->fops->lookup, &loc, xdata);
152
rsp.op_errno = op_errno;
154
lookup_cbk(this, frame, &rsp);
156
inode_unref(loc.inode);
161
qd_reconfigure(xlator_t *this, dict_t *options)
163
/* As of now quotad is restarted upon alteration of volfile */
168
qd_fini(xlator_t *this)
170
quota_priv_t *priv = NULL;
172
if (this == NULL || this->private == NULL)
175
priv = this->private;
178
GF_FREE(priv->rpcsvc);
189
qd_init(xlator_t *this)
192
quota_priv_t *priv = NULL;
194
if (NULL == this->children) {
195
gf_log(this->name, GF_LOG_ERROR,
196
"FATAL: quota (%s) not configured for min of 1 child",
202
QUOTA_ALLOC_OR_GOTO(priv, quota_priv_t, err);
203
LOCK_INIT(&priv->lock);
205
this->private = priv;
215
struct xlator_fops fops = {};
217
struct xlator_cbks cbks = {};
219
struct volume_options options[] = {
220
{.key = {"transport-type"},
221
.value = {"rpc", "rpc-over-rdma", "tcp", "socket", "ib-verbs", "unix",
222
"ib-sdp", "tcp/server", "ib-verbs/server", "rdma",
223
"rdma*([ \t]),*([ \t])socket", "rdma*([ \t]),*([ \t])tcp",
224
"tcp*([ \t]),*([ \t])rdma", "socket*([ \t]),*([ \t])rdma"},
225
.type = GF_OPTION_TYPE_STR},
227
.key = {"transport.*"},
228
.type = GF_OPTION_TYPE_ANY,
233
xlator_api_t xlator_api = {
236
.reconfigure = qd_reconfigure,
238
.mem_acct_init = mem_acct_init,
243
.identifier = "quotad",
244
.category = GF_MAINTAINED,