summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Bellur <vbellur@redhat.com>2013-09-01 23:49:22 -0700
committerGerrit Code Review <review@dev.gluster.org>2013-09-01 23:49:22 -0700
commit1a502d0ee5024842bd325b72271aa1c0991e2869 (patch)
treea588b366f484c2a2a946adef0db83be994168529
parent0b6f50e611937c3d1a06197bafa0a71d141a3868 (diff)
parentbf99fd9d5c439b8be283f5a6f971a95491e13301 (diff)
Merge "features/quota-enforcer: build inode contexts in readdirp" into upstream_on_quota
-rw-r--r--xlators/features/marker/src/marker-quota.c3
-rw-r--r--xlators/features/quota/src/quota.c59
2 files changed, 52 insertions, 10 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index e0028b34..e71288e8 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -2111,7 +2111,8 @@ mq_inspect_directory_xattr (xlator_t *this,
if (contribution == NULL) {
if (!uuid_is_null (loc->inode->gfid))
gf_log (this->name, GF_LOG_WARNING,
- "cannot add a new contribution node");
+ "cannot add a new contribution node "
+ "(%s)", uuid_utoa (loc->inode->gfid));
ret = -1;
goto err;
}
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index e634a4ae..1ee13af5 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -401,8 +401,7 @@ quota_build_ancestry_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
* other. Stumbling upon a root inode means,
* we are about to process a new path.
*/
- parent = entry->inode;
- continue;
+ parent = NULL;
}
uuid_copy (loc.gfid, entry->inode->gfid);
@@ -3250,40 +3249,72 @@ wind:
return 0;
}
-
int
quota_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int op_ret, int op_errno, gf_dirent_t *entries,
dict_t *xdata)
{
- gf_dirent_t *entry = NULL;
+ gf_dirent_t *entry = NULL;
+ quota_local_t *local = NULL;
+ loc_t loc = {0, };
if (op_ret <= 0)
goto unwind;
+ local = frame->local;
+
list_for_each_entry (entry, &entries->list, list) {
- /* TODO: fill things */
+ uuid_copy (loc.gfid, entry->inode->gfid);
+ loc.inode = inode_ref (entry->inode);
+ loc.parent = inode_ref (local->loc.inode);
+ uuid_copy (loc.pargfid, loc.parent->gfid);
+ loc.name = entry->d_name;
+
+ quota_fill_inodectx (this, entry->inode, entry->dict,
+ &loc, &entry->d_stat, &op_errno);
+
+ loc_wipe (&loc);
}
unwind:
- STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata);
+ QUOTA_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata);
return 0;
}
+
int
quota_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
off_t offset, dict_t *dict)
{
- quota_priv_t *priv = NULL;
- int ret = 0;
+ quota_priv_t *priv = NULL;
+ int ret = 0;
+ gf_boolean_t new_dict = _gf_false;
+ quota_local_t *local = NULL;
priv = this->private;
WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
+ local = quota_local_new ();
+
+ if (local == NULL) {
+ goto err;
+ }
+
+ frame->local = local;
+
+ local->loc.inode = inode_ref (fd->inode);
+
+ if (dict == NULL) {
+ dict = dict_new ();
+ new_dict = _gf_true;
+ }
+
if (dict) {
- ret = dict_set_uint64 (dict, QUOTA_SIZE_KEY, 0);
+ ret = dict_set_int8 (dict, QUOTA_LIMIT_KEY, 1);
if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "dict set of key for hard-limit failed");
goto err;
}
}
@@ -3293,9 +3324,19 @@ wind:
priv->is_quota_on? quota_readdirp_cbk: default_readdirp_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp, fd,
size, offset, dict);
+
+ if (new_dict) {
+ dict_unref (dict);
+ }
+
return 0;
err:
STACK_UNWIND_STRICT (readdirp, frame, -1, EINVAL, NULL, NULL);
+
+ if (new_dict) {
+ dict_unref (dict);
+ }
+
return 0;
}