summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-01-28 12:49:39 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-01-28 12:49:39 +0000
commit738e76f0799fa598eac308144174c6cf9db21b7a (patch)
tree0cb787d50ff0753b81cd3b0913476c27adbe4686 /xlators
parent007182f1aad9d14e8d5bc7771d500b35026f0afa (diff)
parent6dfe01d7e726675913e98dc65c6c7406e5060e15 (diff)
Merge branch 'upstream'
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr.c2
-rw-r--r--xlators/cluster/dht/src/dht-common.c6
-rw-r--r--xlators/cluster/dht/src/dht-helper.c21
-rw-r--r--xlators/cluster/dht/src/dht-layout.c9
-rw-r--r--xlators/cluster/dht/src/dht-selfheal.c26
-rw-r--r--xlators/cluster/dht/src/switch.c2
-rw-r--r--xlators/cluster/stripe/src/stripe.c24
-rw-r--r--xlators/debug/io-stats/src/io-stats.c105
-rw-r--r--xlators/features/gfid-access/src/gfid-access.c67
-rw-r--r--xlators/features/gfid-access/src/gfid-access.h6
-rw-r--r--xlators/features/locks/src/entrylk.c7
-rw-r--r--xlators/features/locks/src/inodelk.c1
-rw-r--r--xlators/features/quota/src/quota-enforcer-client.c43
-rw-r--r--xlators/features/quota/src/quota.c944
-rw-r--r--xlators/features/quota/src/quota.h46
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c18
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c19
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c28
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-set.c51
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c2
-rw-r--r--xlators/nfs/server/src/mount3.c2
-rw-r--r--xlators/protocol/client/src/client.c1
-rw-r--r--xlators/protocol/server/src/server-rpc-fops.c1
-rw-r--r--xlators/storage/posix/src/posix-handle.c22
-rw-r--r--xlators/storage/posix/src/posix-handle.h1
-rw-r--r--xlators/storage/posix/src/posix.c1
-rw-r--r--xlators/storage/posix/src/posix.h2
29 files changed, 844 insertions, 625 deletions
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index b43fde47d..c26453807 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -716,7 +716,7 @@ struct volume_options options[] = {
},
{ .key = {"self-heal-daemon"},
.type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
+ .default_value = "on",
.description = "This option applies to only self-heal-daemon. "
"Index directory crawl and automatic healing of files "
"will not be performed if this option is turned off."
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index f59bc9667..cf4ec258d 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -2010,6 +2010,12 @@ dht_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (dict_get (xattr, conf->xattr_name)) {
dict_del (xattr, conf->xattr_name);
}
+
+ if (frame->root->pid >= 0 ) {
+ GF_REMOVE_INTERNAL_XATTR("trusted.glusterfs.quota*", xattr);
+ GF_REMOVE_INTERNAL_XATTR("trusted.pgfid*", xattr);
+ }
+
local->op_ret = 0;
if (!local->xattr) {
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index 76bfbaedb..381643b22 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -747,8 +747,10 @@ dht_migration_complete_check_task (void *data)
src_node = local->cached_subvol;
- if (!local->loc.inode && !local->fd)
+ if (!local->loc.inode && !local->fd) {
+ local->op_errno = EINVAL;
goto out;
+ }
inode = (!local->fd) ? local->loc.inode : local->fd->inode;
@@ -770,19 +772,23 @@ dht_migration_complete_check_task (void *data)
if (ret) {
if (!dht_inode_missing(-ret) || (!local->loc.inode)) {
+ local->op_errno = -ret;
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to get the 'linkto' xattr %s",
local->loc.path, strerror (-ret));
ret = -1;
goto out;
}
+
/* Need to do lookup on hashed subvol, then get the file */
ret = syncop_lookup (this, &local->loc, NULL, &stbuf, NULL,
NULL);
if (ret) {
+ local->op_errno = -ret;
ret = -1;
goto out;
}
+
dst_node = dht_subvol_get_cached (this, local->loc.inode);
}
@@ -791,17 +797,20 @@ dht_migration_complete_check_task (void *data)
"%s: failed to get the destination node",
local->loc.path);
ret = -1;
+ local->op_errno = EINVAL;
goto out;
}
/* lookup on dst */
if (local->loc.inode) {
- ret = syncop_lookup (dst_node, &local->loc, NULL, &stbuf, NULL, NULL);
+ ret = syncop_lookup (dst_node, &local->loc, NULL, &stbuf, NULL,
+ NULL);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to lookup the file on %s",
local->loc.path, dst_node->name);
+ local->op_errno = -ret;
ret = -1;
goto out;
}
@@ -811,6 +820,7 @@ dht_migration_complete_check_task (void *data)
"%s: gfid different on the target file on %s",
local->loc.path, dst_node->name);
ret = -1;
+ local->op_errno = EIO;
goto out;
}
}
@@ -824,6 +834,7 @@ dht_migration_complete_check_task (void *data)
"%s: could not set preset layout for subvol %s",
local->loc.path, dst_node->name);
ret = -1;
+ local->op_errno = EINVAL;
goto out;
}
@@ -833,6 +844,7 @@ dht_migration_complete_check_task (void *data)
"%s: no pre-set layout for subvolume %s",
local->loc.path, dst_node ? dst_node->name : "<nil>");
ret = -1;
+ local->op_errno = EINVAL;
goto out;
}
@@ -841,6 +853,7 @@ dht_migration_complete_check_task (void *data)
gf_log (this->name, GF_LOG_ERROR,
"%s: failed to set the new layout",
local->loc.path);
+ local->op_errno = EINVAL;
goto out;
}
@@ -877,13 +890,15 @@ dht_migration_complete_check_task (void *data)
gf_log (this->name, GF_LOG_ERROR, "failed to open "
"the fd (%p, flags=0%o) on file %s @ %s",
iter_fd, iter_fd->flags, path, dst_node->name);
- ret = -1;
open_failed = 1;
+ local->op_errno = -ret;
+ ret = -1;
}
}
GF_FREE (path);
SYNCTASK_SETID (frame->root->uid, frame->root->gid);
+
if (open_failed) {
ret = -1;
goto out;
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index f7413c8a0..1e38d6be1 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -443,8 +443,13 @@ dht_is_subvol_in_layout (dht_layout_t *layout, xlator_t *xlator)
int i = 0;
for (i = 0; i < layout->cnt; i++) {
- if (!strcmp (layout->list[i].xlator->name, xlator->name))
- return _gf_true;
+ /* Check if xlator is already part of layout, and layout is
+ * non-zero. */
+ if (!strcmp (layout->list[i].xlator->name, xlator->name)) {
+ if (layout->list[i].start != layout->list[i].stop)
+ return _gf_true;
+ break;
+ }
}
return _gf_false;
}
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 06fa1ed3a..0e6527544 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -127,6 +127,7 @@ dht_selfheal_dir_xattr_persubvol (call_frame_t *frame, loc_t *loc,
int32_t *disk_layout = NULL;
dht_local_t *local = NULL;
dht_conf_t *conf = NULL;
+ data_t *data = NULL;
local = frame->local;
if (req_subvol)
@@ -171,7 +172,16 @@ dht_selfheal_dir_xattr_persubvol (call_frame_t *frame, loc_t *loc,
layout->type, subvol->name, loc->path);
dict_ref (xattr);
-
+ if (local->xattr) {
+ data = dict_get (local->xattr, QUOTA_LIMIT_KEY);
+ if (data) {
+ ret = dict_add (xattr, QUOTA_LIMIT_KEY, data);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to "
+ "set quota limit key on %s",loc->path);
+ }
+ }
+ }
if (!uuid_is_null (local->gfid))
uuid_copy (loc->gfid, local->gfid);
@@ -265,7 +275,14 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout)
}
missing_xattr++;
}
-
+ /* Also account for subvolumes with no-layout. Used for zero'ing out
+ * the layouts and for setting quota key's if present */
+ for (i = 0; i < conf->subvolume_cnt; i++) {
+ if (_gf_false ==
+ dht_is_subvol_in_layout (layout, conf->subvolumes[i])) {
+ missing_xattr++;
+ }
+ }
gf_log (this->name, GF_LOG_TRACE,
"%d subvolumes missing xattr for %s",
missing_xattr, loc->path);
@@ -276,7 +293,6 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout)
}
local->call_cnt = missing_xattr;
-
for (i = 0; i < layout->cnt; i++) {
if (layout->list[i].err != -1 || !layout->list[i].stop)
continue;
@@ -289,13 +305,15 @@ dht_selfheal_dir_xattr (call_frame_t *frame, loc_t *loc, dht_layout_t *layout)
dummy = dht_layout_new (this, 1);
if (!dummy)
goto out;
- for (i = 0; i < conf->subvolume_cnt; i++) {
+ for (i = 0; i < conf->subvolume_cnt && missing_xattr; i++) {
if (_gf_false ==
dht_is_subvol_in_layout (layout, conf->subvolumes[i])) {
dht_selfheal_dir_xattr_persubvol (frame, loc, dummy, 0,
conf->subvolumes[i]);
+ missing_xattr--;
}
}
+
dht_layout_unref (this, dummy);
out:
return 0;
diff --git a/xlators/cluster/dht/src/switch.c b/xlators/cluster/dht/src/switch.c
index d3ea90ba8..2717ce975 100644
--- a/xlators/cluster/dht/src/switch.c
+++ b/xlators/cluster/dht/src/switch.c
@@ -670,6 +670,7 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
GF_FREE (dup_str);
continue;
}
+ GF_FREE (dup_str);
memcpy (switch_opt->path_pattern, pattern, strlen (pattern));
if (childs) {
dup_childs = gf_strdup (childs);
@@ -726,7 +727,6 @@ set_switch_pattern (xlator_t *this, dht_conf_t *conf,
"option in unify volume. Exiting");
goto err;
}
- GF_FREE (dup_str);
/* Link it to the main structure */
if (switch_buf) {
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index c98126225..c736e83ed 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -4211,30 +4211,6 @@ stripe_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
op_errno = ENOMEM;
goto err;
}
- fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
- stripe_size = fctx->stripe_size;
-
- STRIPE_VALIDATE_FCTX (fctx, err);
-
- remaining_size = len;
-
- local = mem_get0 (this->local_pool);
- if (!local) {
- op_errno = ENOMEM;
- goto err;
- }
- fctx = (stripe_fd_ctx_t *)(long)tmp_fctx;
- stripe_size = fctx->stripe_size;
-
- STRIPE_VALIDATE_FCTX (fctx, err);
-
- remaining_size = len;
-
- local = mem_get0 (this->local_pool);
- if (!local) {
- op_errno = ENOMEM;
- goto err;
- }
frame->local = local;
local->stripe_size = stripe_size;
local->fctx = fctx;
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c
index 65aeee52b..fa0dd395c 100644
--- a/xlators/debug/io-stats/src/io-stats.c
+++ b/xlators/debug/io-stats/src/io-stats.c
@@ -917,9 +917,19 @@ ios_dump_args_init (struct ios_dump_args *args, ios_dump_type_t type,
return ret;
}
+static void
+ios_global_stats_clear (struct ios_global_stats *stats, struct timeval *now)
+{
+ GF_ASSERT (stats);
+ GF_ASSERT (now);
+
+ memset (stats, 0, sizeof (*stats));
+ stats->started_at = *now;
+}
+
int
io_stats_dump (xlator_t *this, struct ios_dump_args *args,
- gf1_cli_stats_op op)
+ gf1_cli_stats_op op, gf_boolean_t is_peek)
{
struct ios_conf *conf = NULL;
struct ios_global_stats cumulative = {0, };
@@ -937,29 +947,31 @@ io_stats_dump (xlator_t *this, struct ios_dump_args *args,
gettimeofday (&now, NULL);
LOCK (&conf->lock);
{
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_CUMULATIVE)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_CUMULATIVE)
cumulative = conf->cumulative;
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_INCREMENTAL) {
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_INCREMENTAL) {
incremental = conf->incremental;
+ increment = conf->increment;
- increment = conf->increment++;
+ if (!is_peek) {
+ increment = conf->increment++;
- memset (&conf->incremental, 0,
- sizeof (conf->incremental));
- conf->incremental.started_at = now;
+ ios_global_stats_clear (&conf->incremental,
+ &now);
+ }
}
}
UNLOCK (&conf->lock);
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_CUMULATIVE)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_CUMULATIVE)
io_stats_dump_global (this, &cumulative, &now, -1, args);
- if (op == GF_CLI_STATS_INFO ||
- op == GF_CLI_STATS_INFO_INCREMENTAL)
+ if (op == GF_CLI_INFO_ALL ||
+ op == GF_CLI_INFO_INCREMENTAL)
io_stats_dump_global (this, &incremental, &now, increment, args);
return 0;
@@ -2218,10 +2230,10 @@ conditional_dump (dict_t *dict, char *key, data_t *value, void *data)
gf_log (this->name, GF_LOG_ERROR, "failed to open %s "
"for writing", filename);
return -1;
- }
+ }
(void) ios_dump_args_init (&args, IOS_DUMP_TYPE_FILE,
logfp);
- io_stats_dump (this, &args, GF_CLI_STATS_INFO);
+ io_stats_dump (this, &args, GF_CLI_INFO_ALL, _gf_false);
fclose (logfp);
}
return 0;
@@ -2625,6 +2637,29 @@ ios_destroy_top_stats (struct ios_conf *conf)
return;
}
+static int
+io_stats_clear (struct ios_conf *conf)
+{
+ struct timeval now;
+ int ret = -1;
+
+ GF_ASSERT (conf);
+
+ if (!gettimeofday (&now, NULL))
+ {
+ LOCK (&conf->lock);
+ {
+ ios_global_stats_clear (&conf->cumulative, &now);
+ ios_global_stats_clear (&conf->incremental, &now);
+ conf->increment = 0;
+ }
+ UNLOCK (&conf->lock);
+ ret = 0;
+ }
+
+ return ret;
+}
+
int
reconfigure (xlator_t *this, dict_t *options)
{
@@ -2791,6 +2826,7 @@ notify (xlator_t *this, int32_t event, void *data, ...)
int32_t list_cnt = 0;
double throughput = 0;
double time = 0;
+ gf_boolean_t is_peek = _gf_false;
va_list ap;
dict = data;
@@ -2851,13 +2887,40 @@ notify (xlator_t *this, int32_t event, void *data, ...)
}
} else {
ret = dict_get_int32 (dict, "info-op", &op);
- if (ret || op < GF_CLI_STATS_INFO ||
- GF_CLI_STATS_INFO_CUMULATIVE < op)
- op = GF_CLI_STATS_INFO;
+ if (ret || op < GF_CLI_INFO_ALL ||
+ GF_CLI_INFO_CLEAR < op)
+ op = GF_CLI_INFO_ALL;
+
+ ret = dict_set_int32 (output, "info-op", op);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set info-op in dict");
+ goto out;
+ }
+
+ if (GF_CLI_INFO_CLEAR == op) {
+ ret = io_stats_clear (this->private);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to clear info stats");
- (void) ios_dump_args_init (&args, IOS_DUMP_TYPE_DICT,
- output);
- ret = io_stats_dump (this, &args, op);
+ ret = dict_set_int32 (output, "stats-cleared",
+ ret ? 0 : 1);
+ if (ret)
+ gf_log (this->name, GF_LOG_ERROR,
+ "Failed to set stats-cleared"
+ " in dict");
+ }
+ else {
+ ret = dict_get_str_boolean (dict, "peek",
+ _gf_false);
+ if (-1 != ret)
+ is_peek = ret;
+
+ (void) ios_dump_args_init (&args,
+ IOS_DUMP_TYPE_DICT, output);
+ ret = io_stats_dump (this, &args, op, is_peek);
+ }
}
break;
default:
diff --git a/xlators/features/gfid-access/src/gfid-access.c b/xlators/features/gfid-access/src/gfid-access.c
index 1566278ef..362fdab5a 100644
--- a/xlators/features/gfid-access/src/gfid-access.c
+++ b/xlators/features/gfid-access/src/gfid-access.c
@@ -252,7 +252,7 @@ err:
}
static int32_t
-ga_fill_tmp_loc (loc_t *loc, xlator_t *this, char *gfid,
+ga_fill_tmp_loc (loc_t *loc, xlator_t *this, uuid_t gfid,
char *bname, dict_t *xdata, loc_t *new_loc)
{
int ret = -1;
@@ -263,6 +263,8 @@ ga_fill_tmp_loc (loc_t *loc, xlator_t *this, char *gfid,
ret = inode_ctx_get (loc->inode, this, &value);
if (!ret) {
parent = (void *)value;
+ if (uuid_is_null (parent->gfid))
+ parent = loc->inode;
}
/* parent itself should be looked up */
@@ -421,15 +423,20 @@ ga_new_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data,
call_frame_t *new_frame = NULL;
mode_t mode = 0;
ga_local_t *local = NULL;
+ uuid_t gfid = {0,};
args = ga_newfile_parse_args (this, data);
if (!args)
goto out;
+ ret = uuid_parse (args->gfid, gfid);
+ if (ret)
+ goto out;
+
if (!xdata)
xdata = dict_new ();
- ret = ga_fill_tmp_loc (loc, this, args->gfid,
+ ret = ga_fill_tmp_loc (loc, this, gfid,
args->bname, xdata, &tmp_loc);
if (ret)
goto out;
@@ -485,15 +492,20 @@ ga_heal_entry (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *data,
ga_heal_args_t *args = NULL;
loc_t tmp_loc = {0,};
call_frame_t *new_frame = NULL;
+ uuid_t gfid = {0,};
args = ga_heal_parse_args (this, data);
if (!args)
goto out;
+ ret = uuid_parse (args->gfid, gfid);
+ if (ret)
+ goto out;
+
if (!xdata)
xdata = dict_new ();
- ret = ga_fill_tmp_loc (loc, this, args->gfid, args->bname,
+ ret = ga_fill_tmp_loc (loc, this, gfid, args->bname,
xdata, &tmp_loc);
if (ret)
goto out;
@@ -617,7 +629,8 @@ ga_virtual_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
/* the inode is not present in itable, ie, the actual
path is not yet looked up. Use the current inode
itself for now */
- inode_ref (inode);
+
+ inode_link (inode, NULL, NULL, buf);
} else {
/* 'inode_ref()' has been done in inode_find() */
inode = true_inode;
@@ -708,8 +721,30 @@ ga_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
/* if its revalidate, and inode is not of type directory,
proceed with 'wind' */
if (loc->inode && loc->inode->ia_type &&
- !IA_ISDIR (loc->inode->ia_type))
+ !IA_ISDIR (loc->inode->ia_type)) {
+
+ /* a revalidate on ".gfid/<dentry>" is possible, check for it */
+ if (((loc->parent &&
+ __is_gfid_access_dir (loc->parent->gfid)) ||
+ __is_gfid_access_dir (loc->pargfid))) {
+
+ /* here, just send 'loc->gfid' and 'loc->inode' */
+ tmp_loc.inode = inode_ref (loc->inode);
+ uuid_copy (tmp_loc.gfid, loc->inode->gfid);
+
+ STACK_WIND (frame, default_lookup_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup,
+ &tmp_loc, xdata);
+
+ inode_unref (tmp_loc.inode);
+
+ return 0;
+ }
+
+ /* not something to bother, continue the flow */
goto wind;
+ }
priv = this->private;
@@ -729,8 +764,26 @@ ga_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
/* now, check if the lookup() is on an existing entry,
but on gfid-path */
if (!((loc->parent && __is_gfid_access_dir (loc->parent->gfid)) ||
- __is_gfid_access_dir (loc->pargfid)))
- goto wind;
+ __is_gfid_access_dir (loc->pargfid))) {
+ if (!loc->parent)
+ goto wind;
+
+ ret = inode_ctx_get (loc->parent, this, &value);
+ if (ret)
+ goto wind;
+
+ inode = (inode_t *) value;
+
+ ret = loc_copy_overload_parent (&tmp_loc, loc, inode);
+ if (ret)
+ goto err;
+
+ STACK_WIND (frame, ga_lookup_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->lookup, &tmp_loc, xdata);
+
+ loc_wipe (&tmp_loc);
+ return 0;
+ }
/* make sure the 'basename' is actually a 'canonical-gfid',
otherwise, return error */
diff --git a/xlators/features/gfid-access/src/gfid-access.h b/xlators/features/gfid-access/src/gfid-access.h
index 3b74ce112..e883eca69 100644
--- a/xlators/features/gfid-access/src/gfid-access.h
+++ b/xlators/features/gfid-access/src/gfid-access.h
@@ -44,8 +44,7 @@
if (ret) \
goto lbl; \
tmp_inode = (inode_t *)value; \
- unref = inode_ref (tmp_inode); \
- l->parent = tmp_inode; \
+ l->parent = inode_ref (tmp_inode); \
/* if parent is virtual, no need to handle */ \
/* loc->inode */ \
break; \
@@ -59,8 +58,7 @@
if (ret) \
goto lbl; \
tmp_inode = (inode_t *)value; \
- unref = inode_ref (tmp_inode); \
- l->inode = tmp_inode; \
+ l->inode = inode_ref (tmp_inode); \
} \
\
} while (0)
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index 208bc140e..c176306fe 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -371,7 +371,6 @@ __lock_entrylk (xlator_t *this, pl_inode_t *pinode, pl_entry_lock_t *lock,
__pl_entrylk_ref (lock);
gettimeofday (&lock->granted_time, NULL);
list_add (&lock->domain_list, &dom->entrylk_list);
- lock->frame = NULL;
ret = 0;
out:
@@ -576,10 +575,12 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
reqlock->pinode = pinode;
ret = __lock_entrylk (this, pinode, reqlock, nonblock, dom);
- if (ret == 0)
+ if (ret == 0) {
+ reqlock->frame = NULL;
op_ret = 0;
- else
+ } else {
op_errno = -ret;
+ }
if (ctx && (!ret || !nonblock))
list_add (&reqlock->client_list,
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
index 969b67a61..e7093e60e 100644
--- a/xlators/features/locks/src/inodelk.c
+++ b/xlators/features/locks/src/inodelk.c
@@ -478,6 +478,7 @@ pl_inode_setlk (xlator_t *this, pl_ctx_t *ctx, pl_inode_t *pl_inode,
if (lock->fl_type != F_UNLCK) {
ret = __lock_inodelk (this, pl_inode, lock, can_block, dom);
if (ret == 0) {
+ lock->frame = NULL;
gf_log (this->name, GF_LOG_TRACE,
"%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
index bfea5e420..7d8ab937d 100644
--- a/xlators/features/quota/src/quota-enforcer-client.c
+++ b/xlators/features/quota/src/quota-enforcer-client.c
@@ -295,6 +295,37 @@ quota_enforcer_notify (struct rpc_clnt *rpc, void *mydata,
return ret;
}
+int
+quota_enforcer_blocking_connect (rpc_clnt_t *rpc)
+{
+ dict_t *options = NULL;
+ int ret = -1;
+
+ options = dict_new ();
+ if (options == NULL)
+ goto out;
+
+ ret = dict_set_str (options, "non-blocking-io", "no");
+ if (ret)
+ goto out;
+
+ rpc->conn.trans->reconfigure (rpc->conn.trans, options);
+
+ rpc_clnt_start (rpc);
+
+ ret = dict_set_str (options, "non-blocking-io", "yes");
+ if (ret)
+ goto out;
+
+ rpc->conn.trans->reconfigure (rpc->conn.trans, options);
+
+ ret = 0;
+out:
+ dict_unref (options);
+
+ return ret;
+}
+
//Returns a started rpc_clnt. Creates a new rpc_clnt if quota_priv doesn't have
//one already
struct rpc_clnt *
@@ -309,9 +340,13 @@ quota_enforcer_init (xlator_t *this, dict_t *options)
gf_log (this->name, GF_LOG_TRACE, "quota enforcer clnt already "
"inited");
//Turns out to be a NOP if the clnt is already connected.
- rpc_clnt_start (priv->rpc_clnt);
+ ret = quota_enforcer_blocking_connect (priv->rpc_clnt);
+ if (ret)
+ goto out;
+
return priv->rpc_clnt;
}
+
priv->quota_enforcer = &quota_enforcer_clnt;
ret = dict_set_str (options, "transport.address-family", "unix");
@@ -339,7 +374,11 @@ quota_enforcer_init (xlator_t *this, dict_t *options)
goto out;
}
- rpc_clnt_start (rpc);
+ ret = quota_enforcer_blocking_connect (rpc);
+ if (ret)
+ goto out;
+
+ ret = 0;
out:
if (ret) {
if (rpc)
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 5cbd9f02d..2812a2b13 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -215,6 +215,7 @@ __quota_dentry_new (quota_inode_ctx_t *ctx, char *name, uuid_t par)
dentry->name = gf_strdup (name);
if (dentry->name == NULL) {
GF_FREE (dentry);
+ dentry = NULL;
goto err;
}
@@ -244,7 +245,7 @@ out:
}
inline void
-quota_resume_fop_if_validation_done (quota_local_t *local)
+quota_link_count_decrement (quota_local_t *local)
{
call_stub_t *stub = NULL;
int link_count = -1;
@@ -254,7 +255,7 @@ quota_resume_fop_if_validation_done (quota_local_t *local)
LOCK (&local->lock);
{
- link_count = local->link_count;
+ link_count = --local->link_count;
if (link_count == 0) {
stub = local->stub;
local->stub = NULL;
@@ -282,13 +283,11 @@ quota_handle_validate_error (quota_local_t *local, int32_t op_ret,
local->op_ret = op_ret;
local->op_errno = op_errno;
}
-
- /* we abort checking limits on this path to root */
- local->link_count--;
}
UNLOCK (&local->lock);
- quota_resume_fop_if_validation_done (local);
+ /* we abort checking limits on this path to root */
+ quota_link_count_decrement (local);
out:
return;
}
@@ -378,31 +377,51 @@ quota_timeout (struct timeval *tv, int32_t timeout)
return timed_out;
}
+inline void
+quota_add_parent (quota_dentry_t *dentry, struct list_head *list)
+{
+ quota_dentry_t *entry = NULL;
+ gf_boolean_t found = _gf_false;
+
+ if ((dentry == NULL) || (list == NULL)) {
+ goto out;
+ }
+
+ list_for_each_entry (entry, list, next) {
+ if (uuid_compare (dentry->par, entry->par) == 0) {
+ found = _gf_true;
+ goto out;
+ }
+ }
+
+ list_add_tail (&dentry->next, list);
+
+out:
+ return;
+}
+
int32_t
quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
gf_dirent_t *entries, dict_t *xdata)
{
- inode_t *parent = NULL;
- gf_dirent_t *entry = NULL;
- loc_t loc = {0, };
- quota_dentry_t *dentry = NULL, *tmp = NULL;
- quota_inode_ctx_t *ctx = NULL;
- struct list_head parents = {0, };
- quota_local_t *local = NULL;
- call_frame_t *continuation_frame = NULL;
+ inode_t *parent = NULL, *tmp_parent = NULL;
+ gf_dirent_t *entry = NULL;
+ loc_t loc = {0, };
+ quota_dentry_t *dentry = NULL, *tmp = NULL;
+ quota_inode_ctx_t *ctx = NULL;
+ struct list_head parents = {0, };
+ quota_local_t *local = NULL;
INIT_LIST_HEAD (&parents);
- continuation_frame = frame->local;
+ local = frame->local;
frame->local = NULL;
- local = continuation_frame->local;
-
if (op_ret < 0)
goto err;
- parent = inode_parent (local->validate_loc.inode, 0, NULL);
+ parent = inode_parent (local->loc.inode, 0, NULL);
if (parent == NULL) {
gf_log (this->name, GF_LOG_WARNING, "parent is NULL");
op_errno = EINVAL;
@@ -423,61 +442,77 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
* pointer and continue
*/
- parent = NULL;
+ tmp_parent = NULL;
}
uuid_copy (loc.gfid, entry->d_stat.ia_gfid);
loc.inode = inode_ref (entry->inode);
- loc.parent = inode_ref (parent);
+ loc.parent = inode_ref (tmp_parent);
loc.name = entry->d_name;
quota_fill_inodectx (this, entry->inode, entry->dict,
&loc, &entry->d_stat, &op_errno);
- parent = entry->inode;
+ tmp_parent = entry->inode;
loc_wipe (&loc);
}
}
- quota_inode_ctx_get (local->validate_loc.inode, this, &ctx, 0);
-
- local->link_count = 0;
+ quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx != NULL) {
LOCK (&ctx->lock);
{
list_for_each_entry (dentry, &ctx->parents, next) {
+ /* we built ancestry for a non-directory */
tmp = __quota_dentry_new (NULL, dentry->name,
dentry->par);
- list_add_tail (&tmp->next, &parents);
- local->link_count++;
+ quota_add_parent (tmp, &parents);
+
+ if (list_empty (&tmp->next)) {
+ __quota_dentry_free (tmp);
+ tmp = NULL;
+ }
}
}
UNLOCK (&ctx->lock);
}
- if (local->link_count != 0) {
- list_for_each_entry_safe (dentry, tmp, &parents, next) {
- quota_check_limit (continuation_frame,
- local->validate_loc.inode,
- this, dentry->name, dentry->par);
- __quota_dentry_free (dentry);
+ if (list_empty (&parents)) {
+ /* we built ancestry for a directory */
+ list_for_each_entry (entry, &entries->list, list) {
+ if (entry->inode == local->loc.inode)
+ break;
}
- } else {
- local->link_count = 1;
- quota_check_limit (continuation_frame, parent, this, NULL,
- NULL);
+
+ GF_ASSERT (&entry->list != &entries->list);
+
+ tmp = __quota_dentry_new (NULL, entry->d_name, parent->gfid);
+ quota_add_parent (tmp, &parents);
}
- STACK_DESTROY (frame->root);
- return 0;
+ local->ancestry_cbk (&parents, local->loc.inode, 0, 0,
+ local->ancestry_data);
+ goto cleanup;
err:
+ local->ancestry_cbk (NULL, NULL, -1, op_errno, local->ancestry_data);
+
+cleanup:
STACK_DESTROY (frame->root);
+ quota_local_cleanup (this, local);
+
+ if (parent != NULL) {
+ inode_unref (parent);
+ parent = NULL;
+ }
+
+ list_for_each_entry_safe (dentry, tmp, &parents, next) {
+ __quota_dentry_free (dentry);
+ }
- quota_handle_validate_error (local, -1, op_errno);
return 0;
}
@@ -486,85 +521,91 @@ quota_build_ancestry_open_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno,
fd_t *fd, dict_t *xdata)
{
- int ret = -1;
- dict_t *xdata_req = NULL;
- quota_local_t *local = NULL;
- call_frame_t *continuation_frame = NULL;
+ dict_t *xdata_req = NULL;
+ quota_local_t *local = NULL;
+
+ if (op_ret < 0) {
+ goto err;
+ }
xdata_req = dict_new ();
if (xdata_req == NULL) {
- ret = -ENOMEM;
+ op_ret = -ENOMEM;
goto err;
}
- ret = dict_set_int8 (xdata_req, QUOTA_LIMIT_KEY, 1);
- if (ret < 0)
+ op_ret = dict_set_int8 (xdata_req, QUOTA_LIMIT_KEY, 1);
+ if (op_ret < 0) {
+ op_errno = -op_ret;
goto err;
+ }
- ret = dict_set_int8 (xdata_req, GET_ANCESTRY_DENTRY_KEY, 1);
- if (ret < 0)
+ op_ret = dict_set_int8 (xdata_req, GET_ANCESTRY_DENTRY_KEY, 1);
+ if (op_ret < 0) {
+ op_errno = -op_ret;
goto err;
+ }
/* This would ask posix layer to construct dentry chain till root */
STACK_WIND (frame, quota_build_ancestry_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->readdirp, fd, 0, 0, xdata_req);
- ret = 0;
+ op_ret = 0;
err:
fd_unref (fd);
dict_unref (xdata_req);
- if (ret < 0) {
- continuation_frame = frame->local;
+ if (op_ret < 0) {
+ local = frame->local;
frame->local = NULL;
+ local->ancestry_cbk (NULL, NULL, -1, op_errno,
+ local->ancestry_data);
+ quota_local_cleanup (this, local);
STACK_DESTROY (frame->root);
-
- local = continuation_frame->local;
- quota_handle_validate_error (local, -1, op_errno);
}
- return ret;
+ return 0;
}
int
-quota_build_ancestry (call_frame_t *frame, inode_t *inode, xlator_t *this)
+quota_build_ancestry (inode_t *inode, quota_ancestry_built_t ancestry_cbk,
+ void *data)
{
loc_t loc = {0, };
fd_t *fd = NULL;
quota_local_t *local = NULL;
call_frame_t *new_frame = NULL;
- int ret = -1;
+ int op_errno = EINVAL;
+ xlator_t *this = NULL;
+
+ this = THIS;
loc.inode = inode_ref (inode);
uuid_copy (loc.gfid, inode->gfid);
- gf_log (this->name, GF_LOG_WARNING, "building ancestry");
-
- local = frame->local;
-
- LOCK (&local->lock);
- {
- loc_wipe (&local->validate_loc);
+ fd = fd_create (inode, 0);
- ret = quota_inode_loc_fill (inode, &local->validate_loc);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "cannot fill loc for inode (gfid:%s), hence "
- "aborting quota-checks and continuing with fop",
- uuid_utoa (inode->gfid));
- }
+ new_frame = create_frame (this, this->ctx->pool);
+ if (new_frame == NULL) {
+ op_errno = ENOMEM;
+ goto err;
}
- UNLOCK (&local->lock);
- fd = fd_create (inode, 0);
-
- new_frame = copy_frame (frame);
new_frame->root->uid = new_frame->root->gid = 0;
- new_frame->local = frame;
+ local = quota_local_new ();
+ if (local == NULL) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ new_frame->local = local;
+ local->ancestry_cbk = ancestry_cbk;
+ local->ancestry_data = data;
+ local->loc.inode = inode_ref (inode);
if (IA_ISDIR (inode->ia_type)) {
STACK_WIND (new_frame, quota_build_ancestry_open_cbk,
@@ -579,7 +620,25 @@ quota_build_ancestry (call_frame_t *frame, inode_t *inode, xlator_t *this)
}
loc_wipe (&loc);
+ return 0;
+
+err:
+ ancestry_cbk (NULL, NULL, -1, op_errno, data);
+
+ fd_unref (fd);
+
+ local = new_frame->local;
+ new_frame->local = NULL;
+ if (local != NULL) {
+ quota_local_cleanup (this, local);
+ }
+
+ if (new_frame != NULL) {
+ STACK_DESTROY (new_frame->root);
+ }
+
+ loc_wipe (&loc);
return 0;
}
@@ -646,6 +705,56 @@ err:
return ret;
}
+void
+quota_check_limit_continuation (struct list_head *parents, inode_t *inode,
+ int32_t op_ret, int32_t op_errno, void *data)
+{
+ call_frame_t *frame = NULL;
+ xlator_t *this = NULL;
+ quota_local_t *local = NULL;
+ quota_dentry_t *entry = NULL;
+ inode_t *parent = NULL;
+ int parent_count = 0;
+
+ frame = data;
+ local = frame->local;
+ this = THIS;
+
+ if ((op_ret < 0) || list_empty (parents)) {
+ if (list_empty (parents)) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "Couldn't build ancestry for inode (gfid:%s). "
+ "Without knowing ancestors till root, quota "
+ "cannot be enforced. "
+ "Hence, failing fop with EIO",
+ uuid_utoa (inode->gfid));
+ op_errno = EIO;
+ }
+
+ quota_handle_validate_error (local, -1, op_errno);
+ goto out;
+ }
+
+ list_for_each_entry (entry, parents, next) {
+ parent_count++;
+ }
+
+ LOCK (&local->lock);
+ {
+ local->link_count += (parent_count - 1);
+ }
+ UNLOCK (&local->lock);
+
+ list_for_each_entry (entry, parents, next) {
+ parent = inode_find (inode->table, entry->par);
+
+ quota_check_limit (frame, parent, this, NULL, NULL);
+ }
+
+out:
+ return;
+}
+
int32_t
quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
char *name, uuid_t par)
@@ -684,12 +793,8 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
*/
if (0 > frame->root->pid) {
ret = 0;
- LOCK (&local->lock);
- {
- --local->link_count;
- }
- UNLOCK (&local->lock);
- goto resume;
+ quota_link_count_decrement (local);
+ goto done;
}
priv = this->private;
@@ -772,12 +877,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
}
if (__is_root_gfid (_inode->gfid)) {
- LOCK (&local->lock);
- {
- --local->link_count;
- }
- UNLOCK (&local->lock);
-
+ quota_link_count_decrement (local);
break;
}
@@ -789,7 +889,9 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
}
if (parent == NULL) {
- ret = quota_build_ancestry (frame, _inode, this);
+ ret = quota_build_ancestry (_inode,
+ quota_check_limit_continuation,
+ frame);
if (ret < 0) {
op_errno = -ret;
goto err;
@@ -816,8 +918,7 @@ quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
_inode = NULL;
}
-resume:
- quota_resume_fop_if_validation_done (local);
+done:
return 0;
err:
@@ -978,7 +1079,7 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
if (!xattr_req)
goto err;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -995,14 +1096,8 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto err;
}
-wind:
- /* TODO: check with vshastry@redhat.com to cleanup the ugliness of
- * checking priv->is_quota_on here by using STACK_WIND_TAIL macro
- */
- STACK_WIND (frame,
- priv->is_quota_on ? quota_lookup_cbk : default_lookup_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup, loc,
- xattr_req);
+ STACK_WIND (frame, quota_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
ret = 0;
@@ -1016,79 +1111,13 @@ err:
}
return 0;
-}
-
-
-void
-quota_update_size (xlator_t *this, inode_t *inode, char *name, uuid_t par,
- int64_t delta)
-{
- inode_t *_inode = NULL;
- inode_t *parent = NULL;
- uint64_t value = 0;
- quota_inode_ctx_t *ctx = NULL;
- uuid_t trav_uuid = {0,};
-
- GF_VALIDATE_OR_GOTO ("quota", this, out);
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
-
- inode_ctx_get (inode, this, &value);
- ctx = (quota_inode_ctx_t *)(unsigned long)value;
-
- _inode = inode_ref (inode);
-
- if ( par != NULL ) {
- uuid_copy (trav_uuid, par);
- }
-
- do {
- if ((ctx != NULL) && (ctx->hard_lim >= 0)) {
- quota_log_usage (this, ctx, _inode, delta);
- LOCK (&ctx->lock);
- {
- ctx->size += delta;
- if (ctx->size < 0)
- ctx->size = 0;
- }
- UNLOCK (&ctx->lock);
- }
-
- if (__is_root_gfid (_inode->gfid)) {
- break;
- }
-
- parent = inode_parent (_inode, trav_uuid, name);
- if (parent == NULL) {
- /* TODO: build ancestry and continue updating size */
- gf_log (this->name, GF_LOG_DEBUG,
- "cannot find parent for inode (gfid:%s), hence "
- "aborting size updation of parents",
- uuid_utoa (_inode->gfid));
- }
-
- if (name != NULL) {
- name = NULL;
- uuid_clear (trav_uuid);
- }
-
- inode_unref (_inode);
- _inode = parent;
-
- if (_inode == NULL) {
- break;
- }
- value = 0;
- ctx = NULL;
- inode_ctx_get (_inode, this, &value);
- ctx = (quota_inode_ctx_t *)(unsigned long)value;
- } while (1);
-
-out:
- return;
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xattr_req);
+ return 0;
}
-
int32_t
quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
@@ -1098,9 +1127,6 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
uint64_t ctx_int = 0;
quota_inode_ctx_t *ctx = NULL;
quota_local_t *local = NULL;
- quota_dentry_t *dentry = NULL, *tmp = NULL;
- int64_t delta = 0;
- struct list_head head = {0, };
local = frame->local;
@@ -1108,8 +1134,6 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- INIT_LIST_HEAD (&head);
-
ret = inode_ctx_get (local->loc.inode, this, &ctx_int);
if (ret) {
gf_log (this->name, GF_LOG_WARNING,
@@ -1129,25 +1153,9 @@ quota_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
LOCK (&ctx->lock);
{
ctx->buf = *postbuf;
-
- list_for_each_entry (dentry, &ctx->parents, next) {
- tmp = __quota_dentry_new (NULL, dentry->name,
- dentry->par);
- list_add_tail (&tmp->next, &head);
- }
-
}
UNLOCK (&ctx->lock);
- if (postbuf->ia_blocks != prebuf->ia_blocks)
- delta = local->delta;
-
- list_for_each_entry_safe (dentry, tmp, &head, next) {
- quota_update_size (this, local->loc.inode, dentry->name,
- dentry->par, delta);
- __quota_dentry_free (dentry);
- }
-
out:
QUOTA_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf, postbuf,
xdata);
@@ -1202,8 +1210,7 @@ quota_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
}
- STACK_WIND (frame,
- priv->is_quota_on? quota_writev_cbk: default_writev_cbk,
+ STACK_WIND (frame, quota_writev_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, fd,
vector, count, off, flags, iobref, xdata);
@@ -1235,7 +1242,7 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
INIT_LIST_HEAD (&head);
@@ -1284,13 +1291,18 @@ quota_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
UNLOCK (&ctx->lock);
}
- local->delta = size;
-
- local->link_count = parents;
- local->stub = stub;
+ LOCK (&local->lock);
+ {
+ local->delta = size;
+ local->link_count = (parents != 0) ? parents : 1;
+ local->stub = stub;
+ }
+ UNLOCK (&local->lock);
if (parents == 0) {
- local->link_count = 1;
+ /* nameless lookup on this inode, allow quota to reconstruct
+ * ancestry as part of check_limit.
+ */
quota_check_limit (frame, fd->inode, this, NULL, NULL);
} else {
list_for_each_entry_safe (dentry, tmp, &head, next) {
@@ -1306,10 +1318,10 @@ unwind:
QUOTA_STACK_UNWIND (writev, frame, -1, op_errno, NULL, NULL, NULL);
return 0;
-wind:
- STACK_WIND (frame, default_writev_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->writev, fd,
- vector, count, off, flags, iobref, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd,
+ vector, count, off, flags, iobref, xdata);
return 0;
}
@@ -1345,8 +1357,7 @@ quota_mkdir_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto unwind;
}
- STACK_WIND (frame,
- quota_mkdir_cbk,
+ STACK_WIND (frame, quota_mkdir_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, loc,
mode, umask, xdata);
@@ -1370,7 +1381,7 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -1394,9 +1405,13 @@ quota_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
goto err;
}
- local->stub = stub;
- local->delta = 0;
- local->link_count = 1;
+ LOCK (&local->lock);
+ {
+ local->stub = stub;
+ local->delta = 0;
+ local->link_count = 1;
+ }
+ UNLOCK (&local->lock);
quota_check_limit (frame, loc->parent, this, NULL, NULL);
return 0;
@@ -1407,11 +1422,10 @@ err:
return 0;
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_mkdir_cbk: default_mkdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir, loc,
- mode, umask, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mkdir,
+ loc, mode, umask, xdata);
return 0;
}
@@ -1493,8 +1507,7 @@ quota_create_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
}
- STACK_WIND (frame,
- priv->is_quota_on? quota_create_cbk: default_create_cbk,
+ STACK_WIND (frame, quota_create_cbk,
FIRST_CHILD (this), FIRST_CHILD (this)->fops->create, loc,
flags, mode, umask, fd, xdata);
return 0;
@@ -1518,7 +1531,7 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -1541,9 +1554,13 @@ quota_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
goto err;
}
- local->link_count = 1;
- local->stub = stub;
- local->delta = 0;
+ LOCK (&local->lock);
+ {
+ local->link_count = 1;
+ local->stub = stub;
+ local->delta = 0;
+ }
+ UNLOCK (&local->lock);
quota_check_limit (frame, loc->parent, this, NULL, NULL);
return 0;
@@ -1553,11 +1570,10 @@ err:
return 0;
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_create_cbk: default_create_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->create, loc,
- flags, mode, umask, fd, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->create, loc,
+ flags, mode, umask, fd, xdata);
return 0;
}
@@ -1589,12 +1605,6 @@ quota_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- if (!local->skip_check)
- quota_update_size (this, local->loc.inode,
- (char *)local->loc.name,
- local->loc.parent->gfid,
- (-(ctx->buf.ia_blocks * 512)));
-
LOCK (&ctx->lock);
{
list_for_each_entry (dentry, &ctx->parents, next) {
@@ -1627,7 +1637,7 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -1646,11 +1656,8 @@ quota_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
goto err;
}
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_unlink_cbk: default_unlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink, loc,
- xflag, xdata);
+ STACK_WIND (frame, quota_unlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
ret = 0;
@@ -1660,6 +1667,11 @@ err:
}
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
+ return 0;
}
@@ -1684,9 +1696,6 @@ quota_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (local->skip_check)
goto out;
- quota_update_size (this, local->loc.parent, NULL, NULL,
- (buf->ia_blocks * 512));
-
ret = quota_inode_ctx_get (inode, this, &ctx, 0);
if ((ret == -1) || (ctx == NULL)) {
gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
@@ -1763,7 +1772,7 @@ quota_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
goto unwind;
}
- STACK_WIND (frame, priv->is_quota_on? quota_link_cbk: default_link_cbk,
+ STACK_WIND (frame, quota_link_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->link, oldloc,
newloc, xdata);
return 0;
@@ -1787,7 +1796,11 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
+
+ if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) {
+ goto off;
+ }
quota_inode_ctx_get (oldloc->inode, this, &ctx, 0);
if (ctx == NULL) {
@@ -1805,10 +1818,6 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
frame->local = (void *) local;
- if (xdata && dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) {
- local->skip_check = _gf_true;
- goto wind;
- }
ret = loc_copy (&local->loc, newloc);
if (ret == -1) {
@@ -1821,9 +1830,13 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
goto err;
}
- local->link_count = 1;
- local->stub = stub;
- local->delta = (ctx != NULL) ? ctx->buf.ia_blocks * 512 : 0;
+ LOCK (&local->lock);
+ {
+ local->link_count = 1;
+ local->stub = stub;
+ local->delta = (ctx != NULL) ? ctx->buf.ia_blocks * 512 : 0;
+ }
+ UNLOCK (&local->lock);
quota_check_limit (frame, newloc->parent, this, NULL, NULL);
return 0;
@@ -1831,13 +1844,12 @@ quota_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
err:
QUOTA_STACK_UNWIND (link, frame, -1, op_errno, NULL, NULL,
NULL, NULL, NULL);
-
return 0;
-wind:
- STACK_WIND (frame, default_link_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->link, oldloc,
- newloc, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->link, oldloc,
+ newloc, xdata);
return 0;
}
@@ -1872,13 +1884,6 @@ quota_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
size = buf->ia_blocks * 512;
}
- if (local->oldloc.parent != local->newloc.parent) {
- quota_update_size (this, local->oldloc.parent, NULL, NULL,
- (-size));
- quota_update_size (this, local->newloc.parent, NULL, NULL,
- size);
- }
-
if (!QUOTA_REG_OR_LNK_FILE (local->oldloc.inode->ia_type)) {
goto out;
}
@@ -1980,8 +1985,7 @@ quota_rename_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
goto unwind;
}
- STACK_WIND (frame,
- priv->is_quota_on? quota_rename_cbk: default_rename_cbk,
+ STACK_WIND (frame, quota_rename_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename, oldloc,
newloc, xdata);
@@ -2046,7 +2050,7 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2073,8 +2077,12 @@ quota_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
goto err;
}
- local->link_count = 1;
- local->stub = stub;
+ LOCK (&local->lock);
+ {
+ local->link_count = 1;
+ local->stub = stub;
+ }
+ UNLOCK (&local->lock);
if (QUOTA_REG_OR_LNK_FILE (oldloc->inode->ia_type)) {
ret = quota_inode_ctx_get (oldloc->inode, this, &ctx, 0);
@@ -2122,10 +2130,10 @@ err:
NULL, NULL, NULL, NULL, NULL);
return 0;
-wind:
- STACK_WIND (frame, default_rename_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename, oldloc,
- newloc, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rename, oldloc,
+ newloc, xdata);
return 0;
}
@@ -2137,7 +2145,6 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
struct iatt *buf, struct iatt *preparent,
struct iatt *postparent, dict_t *xdata)
{
- int64_t size = 0;
quota_local_t *local = NULL;
quota_inode_ctx_t *ctx = NULL;
quota_dentry_t *dentry = NULL;
@@ -2147,9 +2154,6 @@ quota_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
}
local = frame->local;
- size = buf->ia_blocks * 512;
-
- quota_update_size (this, local->loc.parent, NULL, NULL, size);
quota_inode_ctx_get (local->loc.inode, this, &ctx, 1);
if (ctx == NULL) {
@@ -2208,8 +2212,7 @@ quota_symlink_helper (call_frame_t *frame, xlator_t *this, const char *linkpath,
goto unwind;
}
- STACK_WIND (frame,
- priv->is_quota_on? quota_symlink_cbk: default_symlink_cbk,
+ STACK_WIND (frame, quota_symlink_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink,
linkpath, loc, umask, xdata);
return 0;
@@ -2233,7 +2236,7 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2254,9 +2257,13 @@ quota_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
goto err;
}
- local->stub = stub;
- local->delta = strlen (linkpath);
- local->link_count = 1;
+ LOCK (&local->lock);
+ {
+ local->stub = stub;
+ local->delta = strlen (linkpath);
+ local->link_count = 1;
+ }
+ UNLOCK (&local->lock);
quota_check_limit (frame, loc->parent, this, NULL, NULL);
return 0;
@@ -2267,11 +2274,10 @@ err:
return 0;
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_symlink_cbk: default_symlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink,
- linkpath, loc, umask, xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->symlink,
+ linkpath, loc, umask, xdata);
return 0;
}
@@ -2283,7 +2289,6 @@ quota_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
quota_local_t *local = NULL;
quota_inode_ctx_t *ctx = NULL;
- int64_t delta = 0;
if (op_ret < 0) {
goto out;
@@ -2295,10 +2300,6 @@ quota_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- delta = (postbuf->ia_blocks - prebuf->ia_blocks) * 512;
-
- quota_update_size (this, local->loc.inode, NULL, NULL, delta);
-
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
@@ -2332,8 +2333,7 @@ quota_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
-
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2348,17 +2348,19 @@ quota_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
goto err;
}
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_truncate_cbk: default_truncate_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate, loc,
- offset, xdata);
+ STACK_WIND (frame, quota_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
return 0;
+
err:
QUOTA_STACK_UNWIND (truncate, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
}
@@ -2369,7 +2371,6 @@ quota_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
{
quota_local_t *local = NULL;
quota_inode_ctx_t *ctx = NULL;
- int64_t delta = 0;
if (op_ret < 0) {
goto out;
@@ -2381,10 +2382,6 @@ quota_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- delta = (postbuf->ia_blocks - prebuf->ia_blocks) * 512;
-
- quota_update_size (this, local->loc.inode, NULL, NULL, delta);
-
quota_inode_ctx_get (local->loc.inode, this, &ctx, 0);
if (ctx == NULL) {
gf_log (this->name, GF_LOG_DEBUG, "quota context is NULL on "
@@ -2417,7 +2414,7 @@ quota_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL)
@@ -2427,9 +2424,7 @@ quota_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
local->loc.inode = inode_ref (fd->inode);
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_ftruncate_cbk: default_ftruncate_cbk,
+ STACK_WIND (frame, quota_ftruncate_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate, fd,
offset, xdata);
@@ -2438,6 +2433,12 @@ err:
QUOTA_STACK_UNWIND (ftruncate, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd,
+ offset, xdata);
+ return 0;
}
@@ -2581,8 +2582,7 @@ quota_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
-
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2596,15 +2596,20 @@ quota_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
goto unwind;
}
-wind:
- STACK_WIND (frame, priv->is_quota_on? quota_stat_cbk: default_stat_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat, loc,
+ STACK_WIND (frame, quota_stat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, loc,
xdata);
return 0;
unwind:
QUOTA_STACK_UNWIND (stat, frame, -1, ENOMEM, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, loc,
+ xdata);
+ return 0;
}
@@ -2661,7 +2666,7 @@ quota_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2672,9 +2677,7 @@ quota_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
local->loc.inode = inode_ref (fd->inode);
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_fstat_cbk: default_fstat_cbk,
+ STACK_WIND (frame, quota_fstat_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat, fd,
xdata);
return 0;
@@ -2682,6 +2685,12 @@ wind:
unwind:
QUOTA_STACK_UNWIND (fstat, frame, -1, ENOMEM, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, fd,
+ xdata);
+ return 0;
}
@@ -2736,7 +2745,7 @@ quota_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2751,9 +2760,7 @@ quota_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
goto unwind;
}
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_readlink_cbk: default_readlink_cbk,
+ STACK_WIND (frame, quota_readlink_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->readlink, loc,
size, xdata);
return 0;
@@ -2761,6 +2768,12 @@ wind:
unwind:
QUOTA_STACK_UNWIND (readlink, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readlink, loc,
+ size, xdata);
+ return 0;
}
@@ -2815,7 +2828,7 @@ quota_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2826,9 +2839,7 @@ quota_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
local->loc.inode = inode_ref (fd->inode);
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_readv_cbk: default_readv_cbk,
+ STACK_WIND (frame, quota_readv_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv, fd,
size, offset, flags, xdata);
return 0;
@@ -2837,6 +2848,12 @@ unwind:
QUOTA_STACK_UNWIND (readv, frame, -1, ENOMEM, NULL, -1, NULL, NULL,
NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd,
+ size, offset, flags, xdata);
+ return 0;
}
@@ -2890,7 +2907,7 @@ quota_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2901,10 +2918,8 @@ quota_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
frame->local = local;
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_fsync_cbk: default_fsync_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsync, fd,
+ STACK_WIND (frame, quota_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd,
flags, xdata);
return 0;
@@ -2912,6 +2927,11 @@ unwind:
QUOTA_STACK_UNWIND (fsync, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd,
+ flags, xdata);
+ return 0;
}
@@ -2970,7 +2990,7 @@ quota_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -2985,16 +3005,20 @@ quota_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto unwind;
}
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_setattr_cbk: default_setattr_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->setattr, loc,
+ STACK_WIND (frame, quota_setattr_cbk, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->setattr, loc,
stbuf, valid, xdata);
return 0;
unwind:
QUOTA_STACK_UNWIND (setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->setattr, loc,
+ stbuf, valid, xdata);
+ return 0;
}
@@ -3051,8 +3075,7 @@ quota_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
-
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -3063,9 +3086,7 @@ quota_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
local->loc.inode = inode_ref (fd->inode);
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_fsetattr_cbk: default_fsetattr_cbk,
+ STACK_WIND (frame, quota_fsetattr_cbk,
FIRST_CHILD (this), FIRST_CHILD (this)->fops->fsetattr, fd,
stbuf, valid, xdata);
return 0;
@@ -3073,6 +3094,12 @@ wind:
unwind:
QUOTA_STACK_UNWIND (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD (this),
+ FIRST_CHILD (this)->fops->fsetattr, fd,
+ stbuf, valid, xdata);
+ return 0;
}
@@ -3148,8 +3175,7 @@ quota_mknod_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
goto unwind;
}
- STACK_WIND (frame,
- priv->is_quota_on? quota_mknod_cbk: default_mknod_cbk,
+ STACK_WIND (frame, quota_mknod_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod, loc,
mode, rdev, umask, xdata);
@@ -3173,7 +3199,7 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
if (local == NULL) {
@@ -3194,26 +3220,27 @@ quota_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
goto err;
}
- local->link_count = 1;
- local->stub = stub;
- local->delta = 0;
+ LOCK (&local->lock);
+ {
+ local->link_count = 1;
+ local->stub = stub;
+ local->delta = 0;
+ }
+ UNLOCK (&local->lock);
quota_check_limit (frame, loc->parent, this, NULL, NULL);
return 0;
+
err:
QUOTA_STACK_UNWIND (mknod, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
NULL);
-
return 0;
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_mknod_cbk: default_mknod_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod, loc,
- mode, rdev, umask, xdata);
-
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod, loc,
+ mode, rdev, umask, xdata);
return 0;
-
}
int
@@ -3255,42 +3282,20 @@ quota_setxattr (call_frame_t *frame, xlator_t *this,
int op_ret = -1;
int64_t hard_lim = -1, soft_lim = -1;
quota_local_t *local = NULL;
- char *src = NULL;
- char *dst = NULL;
- int len = 0;
- int ret = -1;
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (loc, err);
- if (0 <= frame->root->pid) {
- ret = dict_get_ptr_and_len (dict, QUOTA_LIMIT_KEY,
- (void **)&src, &len);
- if (ret) {
- gf_log (this->name, GF_LOG_DEBUG, "dict_get on %s "
- "failed", QUOTA_LIMIT_KEY);
- } else {
- dst = GF_CALLOC (len, sizeof (char), gf_common_mt_char);
- if (dst)
- memcpy (dst, src, len);
- }
-
- GF_REMOVE_INTERNAL_XATTR ("trusted.glusterfs.quota*",
- dict);
- if (!ret && IA_ISDIR (loc->inode->ia_type) && dst) {
- ret = dict_set_dynptr (dict, QUOTA_LIMIT_KEY,
- dst, len);
- if (ret)
- gf_log (this->name, GF_LOG_WARNING, "setting "
- "key %s failed", QUOTA_LIMIT_KEY);
- else
- dst = NULL;
- }
+ if (frame->root->pid >= 0) {
+ GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", dict,
+ op_errno, err);
+ GF_IF_INTERNAL_XATTR_GOTO ("trusted.pgfid*", dict, op_errno,
+ err);
}
quota_get_limits (this, dict, &hard_lim, &soft_lim);
@@ -3309,15 +3314,19 @@ quota_setxattr (call_frame_t *frame, xlator_t *this,
local->limit.soft_lim_percent = soft_lim;
}
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_setxattr_cbk: default_setxattr_cbk,
+ STACK_WIND (frame, quota_setxattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr, loc,
dict, flags, xdata);
return 0;
err:
QUOTA_STACK_UNWIND (setxattr, frame, op_ret, op_errno, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setxattr, loc,
+ dict, flags, xdata);
+ return 0;
}
int
@@ -3361,15 +3370,18 @@ quota_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (fd, err);
- if (0 <= frame->root->pid)
- GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", dict,
+ if (0 <= frame->root->pid) {
+ GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*",
+ dict, op_errno, err);
+ GF_IF_INTERNAL_XATTR_GOTO ("trusted.pgfid*", dict,
op_errno, err);
+ }
quota_get_limits (this, dict, &hard_lim, &soft_lim);
@@ -3382,15 +3394,19 @@ quota_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
local->limit.soft_lim_percent = soft_lim;
}
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_fsetxattr_cbk: default_fsetxattr_cbk,
+ STACK_WIND (frame, quota_fsetxattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetxattr, fd,
dict, flags, xdata);
return 0;
- err:
+err:
QUOTA_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetxattr, fd,
+ dict, flags, xdata);
+ return 0;
}
@@ -3411,28 +3427,37 @@ quota_removexattr (call_frame_t *frame, xlator_t *this,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
VALIDATE_OR_GOTO (this, err);
/* all quota xattrs can be cleaned up by doing setxattr on special key.
* Hence its ok that we don't allow removexattr on quota keys here.
*/
- GF_IF_NATIVE_XATTR_GOTO ("trusted.quota*",
- name, op_errno, err);
+ if (frame->root->pid >= 0) {
+ GF_IF_NATIVE_XATTR_GOTO ("trusted.glusterfs.quota*",
+ name, op_errno, err);
+ GF_IF_NATIVE_XATTR_GOTO ("trusted.pgfid*", name,
+ op_errno, err);
+ }
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (loc, err);
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_removexattr_cbk: default_removexattr_cbk,
+ STACK_WIND (frame, quota_removexattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr,
loc, name, xdata);
return 0;
+
err:
QUOTA_STACK_UNWIND (removexattr, frame, -1, op_errno, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->removexattr,
+ loc, name, xdata);
+ return 0;
}
@@ -3454,24 +3479,31 @@ quota_fremovexattr (call_frame_t *frame, xlator_t *this,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (fd, err);
- GF_IF_NATIVE_XATTR_GOTO ("trusted.quota*",
- name, op_errno, err);
-
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_fremovexattr_cbk: default_fremovexattr_cbk,
+ if (frame->root->pid >= 0) {
+ GF_IF_NATIVE_XATTR_GOTO ("trusted.glusterfs.quota*",
+ name, op_errno, err);
+ GF_IF_NATIVE_XATTR_GOTO ("trusted.pgfid*", name,
+ op_errno, err);
+ }
+ STACK_WIND (frame, quota_fremovexattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->fremovexattr,
fd, name, xdata);
return 0;
- err:
+err:
QUOTA_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, NULL);
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fremovexattr,
+ fd, name, xdata);
+ return 0;
}
@@ -3640,9 +3672,7 @@ quota_statfs_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
UNLOCK (&ctx->lock);
resume:
- --local->link_count;
-
- quota_resume_fop_if_validation_done (local);
+ quota_link_count_decrement (local);
return 0;
}
@@ -3657,7 +3687,7 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
if (priv->consider_statfs && loc->inode) {
local = quota_local_new ();
@@ -3667,44 +3697,46 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
}
frame->local = local;
- local->inode = inode_ref (loc->inode);
- local->link_count = 1;
-
stub = fop_statfs_stub (frame, quota_statfs_helper, loc, xdata);
if (!stub) {
op_errno = ENOMEM;
goto err;
}
- local->stub = stub;
+ LOCK (&local->lock);
+ {
+ local->inode = inode_ref (loc->inode);
+ local->link_count = 1;
+ local->stub = stub;
+ }
+ UNLOCK (&local->lock);
ret = quota_validate (frame, local->inode, this,
quota_statfs_validate_cbk);
if (0 > ret) {
- op_errno = -ret;
- --local->link_count;
+ quota_handle_validate_error (local, -1, -ret);
}
- quota_resume_fop_if_validation_done (local);
- }
- else {
- /*
- * We have to make sure that we never get to quota_statfs_cbk
- * with a cookie that points to something other than an inode,
- * which is exactly what would happen with STACK_UNWIND using
- * that as a callback. Therefore, use default_statfs_cbk in
- * this case instead.
- *
- * Also if the option deem-statfs is not set to "on" don't
- * bother calculating quota limit on / in statfs_cbk.
- */
- if (priv->consider_statfs)
- gf_log(this->name,GF_LOG_WARNING,
- "missing inode, cannot adjust for quota");
-wind:
- STACK_WIND (frame, default_statfs_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->statfs, loc, xdata);
+ return 0;
}
+
+ /*
+ * We have to make sure that we never get to quota_statfs_cbk
+ * with a cookie that points to something other than an inode,
+ * which is exactly what would happen with STACK_UNWIND using
+ * that as a callback. Therefore, use default_statfs_cbk in
+ * this case instead.
+ *
+ * Also if the option deem-statfs is not set to "on" don't
+ * bother calculating quota limit on / in statfs_cbk.
+ */
+ if (priv->consider_statfs)
+ gf_log (this->name,GF_LOG_WARNING,
+ "missing inode, cannot adjust for quota");
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->statfs, loc, xdata);
return 0;
err:
@@ -3763,7 +3795,7 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
priv = this->private;
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
local = quota_local_new ();
@@ -3789,9 +3821,7 @@ quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
}
}
-wind:
- STACK_WIND (frame,
- priv->is_quota_on? quota_readdirp_cbk: default_readdirp_cbk,
+ STACK_WIND (frame, quota_readdirp_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, fd,
size, offset, dict);
@@ -3808,6 +3838,12 @@ err:
}
return 0;
+
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd,
+ size, offset, dict);
+ return 0;
}
int32_t
@@ -3819,8 +3855,6 @@ quota_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
uint64_t ctx_int = 0;
quota_inode_ctx_t *ctx = NULL;
quota_local_t *local = NULL;
- quota_dentry_t *dentry = NULL;
- int64_t delta = 0;
local = frame->local;
@@ -3850,12 +3884,6 @@ quota_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
}
UNLOCK (&ctx->lock);
- list_for_each_entry (dentry, &ctx->parents, next) {
- delta = (postbuf->ia_blocks - prebuf->ia_blocks) * 512;
- quota_update_size (this, local->loc.inode,
- dentry->name, dentry->par, delta);
- }
-
out:
QUOTA_STACK_UNWIND (fallocate, frame, op_ret, op_errno, prebuf, postbuf,
xdata);
@@ -3885,8 +3913,7 @@ quota_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
goto unwind;
}
- STACK_WIND (frame, priv->is_quota_on?
- quota_fallocate_cbk: default_fallocate_cbk,
+ STACK_WIND (frame, quota_fallocate_cbk,
FIRST_CHILD(this),
FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len,
xdata);
@@ -3913,7 +3940,7 @@ quota_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
priv = this->private;
GF_VALIDATE_OR_GOTO (this->name, priv, unwind);
- WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ WIND_IF_QUOTAOFF (priv->is_quota_on, off);
GF_ASSERT (frame);
GF_VALIDATE_OR_GOTO ("quota", this, unwind);
@@ -3981,12 +4008,10 @@ unwind:
QUOTA_STACK_UNWIND (fallocate, frame, -1, op_errno, NULL, NULL, NULL);
return 0;
-wind:
- STACK_WIND (frame, priv->is_quota_on?
- quota_fallocate_cbk: default_fallocate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len,
- xdata);
+off:
+ STACK_WIND_TAIL (frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, fd, mode, offset,
+ len, xdata);
return 0;
}
@@ -4152,14 +4177,15 @@ err:
int
reconfigure (xlator_t *this, dict_t *options)
{
- int32_t ret = -1;
- quota_priv_t *priv = NULL;
+ int32_t ret = -1;
+ quota_priv_t *priv = NULL;
+ gf_boolean_t quota_on = _gf_false;
priv = this->private;
GF_OPTION_RECONF ("deem-statfs", priv->consider_statfs, options, bool,
out);
- GF_OPTION_RECONF ("server-quota", priv->is_quota_on, options, bool,
+ GF_OPTION_RECONF ("server-quota", quota_on, options, bool,
out);
GF_OPTION_RECONF ("default-soft-limit", priv->default_soft_lim,
options, percent, out);
@@ -4170,7 +4196,7 @@ reconfigure (xlator_t *this, dict_t *options)
GF_OPTION_RECONF ("hard-timeout", priv->hard_timeout, options,
time, out);
- if (priv->is_quota_on) {
+ if (quota_on) {
priv->rpc_clnt = quota_enforcer_init (this,
this->options);
if (priv->rpc_clnt == NULL) {
@@ -4191,6 +4217,8 @@ reconfigure (xlator_t *this, dict_t *options)
}
}
+ priv->is_quota_on = quota_on;
+
ret = 0;
out:
return ret;
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
index 02bc0d8b6..84c3257fe 100644
--- a/xlators/features/quota/src/quota.h
+++ b/xlators/features/quota/src/quota.h
@@ -160,28 +160,34 @@ struct quota_limit {
} __attribute__ ((packed));
typedef struct quota_limit quota_limit_t;
+typedef void
+(*quota_ancestry_built_t) (struct list_head *parents, inode_t *inode,
+ int32_t op_ret, int32_t op_errno, void *data);
+
struct quota_local {
- gf_lock_t lock;
- uint32_t validate_count;
- uint32_t link_count;
- loc_t loc;
- loc_t oldloc;
- loc_t newloc;
- loc_t validate_loc;
- int64_t delta;
- int32_t op_ret;
- int32_t op_errno;
- int64_t size;
- gf_boolean_t skip_check;
- char just_validated;
- fop_lookup_cbk_t validate_cbk;
- inode_t *inode;
- call_stub_t *stub;
- struct iobref *iobref;
- quota_limit_t limit;
- int64_t space_available;
+ gf_lock_t lock;
+ uint32_t validate_count;
+ uint32_t link_count;
+ loc_t loc;
+ loc_t oldloc;
+ loc_t newloc;
+ loc_t validate_loc;
+ int64_t delta;
+ int32_t op_ret;
+ int32_t op_errno;
+ int64_t size;
+ gf_boolean_t skip_check;
+ char just_validated;
+ fop_lookup_cbk_t validate_cbk;
+ inode_t *inode;
+ call_stub_t *stub;
+ struct iobref *iobref;
+ quota_limit_t limit;
+ int64_t space_available;
+ quota_ancestry_built_t ancestry_cbk;
+ void *ancestry_data;
};
-typedef struct quota_local quota_local_t;
+typedef struct quota_local quota_local_t;
struct quota_priv {
uint32_t soft_timeout;
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 06ee849f5..963aa0762 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -1094,8 +1094,7 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr)
}
if ((GF_CLI_STATS_STOP == stats_op) ||
- (GF_CLI_STATS_INFO <= stats_op &&
- stats_op <= GF_CLI_STATS_INFO_CUMULATIVE)) {
+ (GF_CLI_STATS_INFO == stats_op)) {
if (_gf_false == glusterd_is_profile_on (volinfo)) {
snprintf (msg, sizeof (msg), "Profile on Volume %s is"
" not started", volinfo->volname);
@@ -1105,8 +1104,7 @@ glusterd_op_stage_stats_volume (dict_t *dict, char **op_errstr)
}
}
if ((GF_CLI_STATS_TOP == stats_op) ||
- (GF_CLI_STATS_INFO <= stats_op &&
- stats_op <= GF_CLI_STATS_INFO_CUMULATIVE)) {
+ (GF_CLI_STATS_INFO == stats_op)) {
if (_gf_false == glusterd_is_volume_started (volinfo)) {
snprintf (msg, sizeof (msg), "Volume %s is not started.",
volinfo->volname);
@@ -1541,10 +1539,12 @@ glusterd_op_set_volume (dict_t *dict)
if (dict_count == 0) {
ret = glusterd_volset_help (NULL, &op_errstr);
if (ret) {
- op_errstr = (op_errstr)? op_errstr:
- "Volume set help internal error";
- gf_log (this->name, GF_LOG_ERROR, "%s", op_errstr);
+ gf_log (this->name, GF_LOG_ERROR, "%s",
+ (op_errstr)? op_errstr:
+ "Volume set help internal error");
}
+
+ GF_FREE(op_errstr);
goto out;
}
@@ -1908,8 +1908,6 @@ glusterd_op_stats_volume (dict_t *dict, char **op_errstr,
glusterd_remove_profile_volume_options (volinfo);
break;
case GF_CLI_STATS_INFO:
- case GF_CLI_STATS_INFO_INCREMENTAL:
- case GF_CLI_STATS_INFO_CUMULATIVE:
case GF_CLI_STATS_TOP:
//info is already collected in brick op.
//just goto out;
@@ -4480,8 +4478,6 @@ glusterd_bricks_select_profile_volume (dict_t *dict, char **op_errstr,
goto out;
break;
case GF_CLI_STATS_INFO:
- case GF_CLI_STATS_INFO_INCREMENTAL:
- case GF_CLI_STATS_INFO_CUMULATIVE:
ret = dict_get_str_boolean (dict, "nfs", _gf_false);
if (ret) {
if (!glusterd_is_nodesvc_online ("nfs")) {
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index ffde532bd..d13533aa6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -996,14 +996,6 @@ glusterd_quotad_op (int opcode)
ret = glusterd_check_generate_start_quotad ();
break;
- case GF_QUOTA_OPTION_TYPE_DEFAULT_SOFT_LIMIT:
- case GF_QUOTA_OPTION_TYPE_HARD_TIMEOUT:
- case GF_QUOTA_OPTION_TYPE_SOFT_TIMEOUT:
- case GF_QUOTA_OPTION_TYPE_ALERT_TIME:
-
- ret = glusterd_reconfigure_quotad ();
- break;
-
default:
ret = 0;
break;
@@ -1131,6 +1123,12 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
goto out;
}
+ if (priv->op_version > GD_OP_VERSION_MIN) {
+ ret = glusterd_quotad_op (type);
+ if (ret)
+ goto out;
+ }
+
ret = glusterd_create_volfiles_and_notify_services (volinfo);
if (ret) {
gf_log (this->name, GF_LOG_ERROR, "Unable to re-create "
@@ -1151,11 +1149,6 @@ glusterd_op_quota (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (rsp_dict && start_crawl == _gf_true)
glusterd_quota_initiate_fs_crawl (priv, volname, type);
- if (priv->op_version > GD_OP_VERSION_MIN) {
- ret = glusterd_quotad_op (type);
- if (ret)
- goto out;
- }
ret = 0;
out:
return ret;
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index d0ad7dcdb..2c2fc6fb4 100644
--- a/xlators/mgmt/glusterd/src/glusterd-store.c
+++ b/xlators/mgmt/glusterd/src/glusterd-store.c
@@ -2582,8 +2582,10 @@ glusterd_store_retrieve_peers (xlator_t *this)
ret = gf_store_iter_get_next (iter, &key, &value,
&op_errno);
}
- if (op_errno != GD_STORE_EOF)
+ if (op_errno != GD_STORE_EOF) {
+ GF_FREE(hostname);
goto out;
+ }
(void) gf_store_iter_destroy (iter);
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index fc4018190..21a973086 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1295,11 +1295,14 @@ glusterd_brick_connect (glusterd_volinfo_t *volinfo,
glusterd_brick_rpc_notify,
brickid);
synclock_lock (&priv->big_lock);
- if (ret)
+ if (ret) {
+ GF_FREE (brickid);
goto out;
+ }
brickinfo->rpc = rpc;
}
out:
+
gf_log ("", GF_LOG_DEBUG, "Returning %d", ret);
return ret;
}
@@ -3965,7 +3968,7 @@ glusterd_nodesvc_disconnect (char *server)
}
int32_t
-glusterd_nodesvc_start (char *server)
+glusterd_nodesvc_start (char *server, gf_boolean_t wait)
{
int32_t ret = -1;
xlator_t *this = NULL;
@@ -4051,7 +4054,16 @@ glusterd_nodesvc_start (char *server)
runner_log (&runner, "", GF_LOG_DEBUG,
"Starting the nfs/glustershd services");
- ret = runner_run_nowait (&runner);
+ if (!wait) {
+ ret = runner_run_nowait (&runner);
+ } else {
+ synclock_unlock (&priv->big_lock);
+ {
+ ret = runner_run (&runner);
+ }
+ synclock_lock (&priv->big_lock);
+ }
+
if (ret == 0) {
glusterd_nodesvc_connect (server, sockfpath);
}
@@ -4062,19 +4074,19 @@ out:
int
glusterd_nfs_server_start ()
{
- return glusterd_nodesvc_start ("nfs");
+ return glusterd_nodesvc_start ("nfs", _gf_false);
}
int
glusterd_shd_start ()
{
- return glusterd_nodesvc_start ("glustershd");
+ return glusterd_nodesvc_start ("glustershd", _gf_false);
}
int
glusterd_quotad_start ()
{
- return glusterd_nodesvc_start ("quotad");
+ return glusterd_nodesvc_start ("quotad", _gf_true);
}
gf_boolean_t
@@ -4805,8 +4817,8 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data)
uuid_str, NULL);
out:
- if (path_list)
- GF_FREE (path_list);
+ GF_FREE (path_list);
+ GF_FREE (op_errstr);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index a94a47af3..303abd1bc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -1974,13 +1974,13 @@ server_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
}
/* Check for compress volume option, and add it to the graph on server side */
- if (dict_get_str_boolean (set_dict, "features.compress", 0)) {
+ if (dict_get_str_boolean (set_dict, "network.compression", 0)) {
xl = volgen_graph_add (graph, "features/cdc", volname);
if (!xl) {
ret = -1;
goto out;
}
- ret = dict_set_str (set_dict, "compress.mode", "server");
+ ret = dict_set_str (set_dict, "network.compression.mode", "server");
if (ret)
goto out;
}
@@ -2852,13 +2852,13 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
goto out;
/* Check for compress volume option, and add it to the graph on client side */
- if (dict_get_str_boolean (set_dict, "features.compress", 0)) {
+ if (dict_get_str_boolean (set_dict, "network.compression", 0)) {
xl = volgen_graph_add (graph, "features/cdc", volname);
if (!xl) {
ret = -1;
goto out;
}
- ret = dict_set_str (set_dict, "compress.mode", "client");
+ ret = dict_set_str (set_dict, "network.compression.mode", "client");
if (ret)
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
index 520b0f774..8d29e8edc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c
@@ -1023,47 +1023,52 @@ struct volopt_map_entry glusterd_volopt_map[] = {
#ifdef HAVE_LIB_Z
/* Compressor-decompressor xlator options
- * defaults used from xlator/feature/compress/src/cdc.h
+ * defaults used from xlator/features/compress/src/cdc.h
*/
- { .key = "features.compress",
+ { .key = "network.compression",
.voltype = "features/cdc",
- .option = "!compress",
.value = "off",
.type = NO_DOC,
- .op_version = 2,
- .description = "enable/disable compression translator"
+ .op_version = 3,
+ .description = "enable/disable network compression translator"
},
- { .key = "compress.mode",
+ { .key = "network.compression.mode",
.voltype = "features/cdc",
+ .option = "mode",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- { .key = "compress.window-size",
+ { .key = "network.compression.window-size",
.voltype = "features/cdc",
+ .option = "window-size",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- { .key = "compress.mem-level",
+ { .key = "network.compression.mem-level",
.voltype = "features/cdc",
+ .option = "mem-level",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- { .key = "compress.min-size",
+ { .key = "network.compression.min-size",
.voltype = "features/cdc",
+ .option = "min-size",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- { .key = "compress.compression-level",
+ { .key = "network.compression.compression-level",
.voltype = "features/cdc",
+ .option = "compression-level",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- { .key = "compress.debug",
+ { .key = "network.compression.debug",
.voltype = "features/cdc",
+ .option = "debug",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
- #endif
+#endif
/* Quota xlator options */
{ .key = VKEY_FEATURES_LIMIT_USAGE,
@@ -1470,27 +1475,27 @@ struct volopt_map_entry glusterd_volopt_map[] = {
{ .key = "changelog.changelog",
.voltype = "features/changelog",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
{ .key = "changelog.changelog-dir",
.voltype = "features/changelog",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
{ .key = "changelog.encoding",
.voltype = "features/changelog",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
{ .key = "changelog.rollover-time",
.voltype = "features/changelog",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
{ .key = "changelog.fsync-interval",
.voltype = "features/changelog",
.type = NO_DOC,
- .op_version = 2
+ .op_version = 3
},
{ .key = NULL
}
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index 6c54cb882..2774bdaa8 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -596,6 +596,8 @@ fuse_ignore_xattr_set (fuse_private_t *priv, char *key)
|| (fnmatch ("*.glusterfs.volume-mark",
key, FNM_PERIOD) == 0)
|| (fnmatch ("*.glusterfs.volume-mark.*",
+ key, FNM_PERIOD) == 0)
+ || (fnmatch ("glusterfs.gfid.newfile",
key, FNM_PERIOD) == 0)))
ret = -1;
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index e86235522..47ff3845e 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -469,7 +469,7 @@ mount_rewrite_rmtab (struct mount3_state *ms, char *new_rmtab)
"%s as rmtab", nfs->rmtab);
} else {
GF_FREE (nfs->rmtab);
- nfs->rmtab = new_rmtab;
+ nfs->rmtab = rmtab;
}
gf_store_unlock (nsh);
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index d8c5f4262..b0a71d3f9 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -943,6 +943,7 @@ client_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
args.vector = vector;
args.count = count;
args.offset = off;
+ args.size = iov_length (vector, count);
args.flags = flags;
args.iobref = iobref;
args.xdata = xdata;
diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c
index d43571e87..c56da30a7 100644
--- a/xlators/protocol/server/src/server-rpc-fops.c
+++ b/xlators/protocol/server/src/server-rpc-fops.c
@@ -3735,6 +3735,7 @@ server3_3_writev (rpcsvc_request_t *req)
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
state->offset = args.offset;
+ state->size = args.size;
state->flags = args.flag;
state->iobref = iobref_ref (req->iobref);
memcpy (state->resolve.gfid, args.gfid, 16);
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index 613709fc8..adb8acc07 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -145,7 +145,7 @@ posix_make_ancestryfromgfid (xlator_t *this, char *path, int pathsize,
dir_handle = alloca (handle_size);
linkname = alloca (PATH_MAX);
snprintf (dir_handle, handle_size, "%s/%s/%02x/%02x/%s",
- priv_base_path, HANDLE_PFX, gfid[0], gfid[1],
+ priv_base_path, GF_HIDDEN_PATH, gfid[0], gfid[1],
uuid_utoa (gfid));
len = readlink (dir_handle, linkname, PATH_MAX);
@@ -343,13 +343,13 @@ posix_handle_path (xlator_t *this, uuid_t gfid, const char *basename,
buf = alloca (maxlen);
}
- base_len = (priv->base_path_length + SLEN(HANDLE_PFX) + 45);
+ base_len = (priv->base_path_length + SLEN(GF_HIDDEN_PATH) + 45);
base_str = alloca (base_len + 1);
base_len = snprintf (base_str, base_len + 1, "%s/%s/%02x/%02x/%s",
- priv->base_path, HANDLE_PFX, gfid[0], gfid[1],
+ priv->base_path, GF_HIDDEN_PATH, gfid[0], gfid[1],
uuid_str);
- pfx_len = priv->base_path_length + 1 + SLEN(HANDLE_PFX) + 1;
+ pfx_len = priv->base_path_length + 1 + SLEN(GF_HIDDEN_PATH) + 1;
if (basename) {
len = snprintf (buf, maxlen, "%s/%s", base_str, basename);
@@ -391,7 +391,7 @@ posix_handle_gfid_path (xlator_t *this, uuid_t gfid, const char *basename,
len = priv->base_path_length /* option directory "/export" */
+ SLEN("/")
- + SLEN(HANDLE_PFX)
+ + SLEN(GF_HIDDEN_PATH)
+ SLEN("/")
+ SLEN("00/")
+ SLEN("00/")
@@ -422,10 +422,10 @@ posix_handle_gfid_path (xlator_t *this, uuid_t gfid, const char *basename,
if (basename) {
len = snprintf (buf, buflen, "%s/%s/%02x/%02x/%s/%s", priv->base_path,
- HANDLE_PFX, gfid[0], gfid[1], uuid_str, basename);
+ GF_HIDDEN_PATH, gfid[0], gfid[1], uuid_str, basename);
} else {
len = snprintf (buf, buflen, "%s/%s/%02x/%02x/%s", priv->base_path,
- HANDLE_PFX, gfid[0], gfid[1], uuid_str);
+ GF_HIDDEN_PATH, gfid[0], gfid[1], uuid_str);
}
out:
return len;
@@ -454,10 +454,10 @@ posix_handle_init (xlator_t *this)
return -1;
}
- handle_pfx = alloca (priv->base_path_length + 1 + strlen (HANDLE_PFX)
+ handle_pfx = alloca (priv->base_path_length + 1 + strlen (GF_HIDDEN_PATH)
+ 1);
- sprintf (handle_pfx, "%s/%s", priv->base_path, HANDLE_PFX);
+ sprintf (handle_pfx, "%s/%s", priv->base_path, GF_HIDDEN_PATH);
ret = stat (handle_pfx, &stbuf);
switch (ret) {
@@ -621,7 +621,7 @@ posix_handle_trash_init (xlator_t *this)
priv = this->private;
priv->trash_path = GF_CALLOC (1, priv->base_path_length + strlen ("/")
- + strlen (HANDLE_PFX) + strlen ("/")
+ + strlen (GF_HIDDEN_PATH) + strlen ("/")
+ strlen (TRASH_DIR) + 1,
gf_posix_mt_trash_path);
@@ -629,7 +629,7 @@ posix_handle_trash_init (xlator_t *this)
goto out;
strncpy (priv->trash_path, priv->base_path, priv->base_path_length);
- strcat (priv->trash_path, "/" HANDLE_PFX "/" TRASH_DIR);
+ strcat (priv->trash_path, "/" GF_HIDDEN_PATH "/" TRASH_DIR);
ret = posix_handle_new_trash_init (this, priv->trash_path);
if (ret)
goto out;
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
index 8874ca265..31cbf83fd 100644
--- a/xlators/storage/posix/src/posix-handle.h
+++ b/xlators/storage/posix/src/posix-handle.h
@@ -19,7 +19,6 @@
#include "xlator.h"
#include "gf-dirent.h"
-#define HANDLE_PFX ".glusterfs"
#define TRASH_DIR "landfill"
#define UUID0_STR "00000000-0000-0000-0000-000000000000"
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 83b689d06..c1cbc83f4 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -885,7 +885,6 @@ posix_opendir (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
VALIDATE_OR_GOTO (loc, out);
- VALIDATE_OR_GOTO (loc->path, out);
VALIDATE_OR_GOTO (fd, out);
SET_FS_ID (frame->root->uid, frame->root->gid);
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index d579bf673..91e0664ed 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -54,7 +54,7 @@
#define MAX_NO_VECT 1024
#define POSIX_GFID_HANDLE_SIZE(base_path_len) (base_path_len + SLEN("/") \
- + SLEN(HANDLE_PFX) + SLEN("/") \
+ + SLEN(GF_HIDDEN_PATH) + SLEN("/") \
+ SLEN("00/") \
+ SLEN("00/") + SLEN(UUID0_STR) + 1) /* '\0' */;