|
|
cb8e9e |
From fa6b4f05369b3ce0172cf05cd5770ac10d76ed0f Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: vmallika <vmallika@redhat.com>
|
|
|
cb8e9e |
Date: Thu, 20 Aug 2015 12:01:57 +0530
|
|
|
cb8e9e |
Subject: [PATCH 308/320] marker: fix log when loc.parent and inode gfid is NULL
|
|
|
cb8e9e |
|
|
|
cb8e9e |
This is a backport of http://review.gluster.org/#/c/11863/
|
|
|
cb8e9e |
|
|
|
cb8e9e |
This patch does the following
|
|
|
cb8e9e |
|
|
|
cb8e9e |
1) Set loc.parent if it is NULL
|
|
|
cb8e9e |
Don't log warning in txn if parent is NULL
|
|
|
cb8e9e |
2) Don't initiate txn when inode gfid is NULL
|
|
|
cb8e9e |
3) optimize invoking dirty txn with status flag
|
|
|
cb8e9e |
|
|
|
cb8e9e |
> Change-Id: I67dd9e6268014b0b257c136e951e6ded0a2e911f
|
|
|
cb8e9e |
> BUG: 1251454
|
|
|
cb8e9e |
> Signed-off-by: vmallika <vmallika@redhat.com>
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: I3851f1f0bf43168fb369ad17fdf5c0bf27c6a631
|
|
|
cb8e9e |
BUG: 1251457
|
|
|
cb8e9e |
Signed-off-by: vmallika <vmallika@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/56468
|
|
|
cb8e9e |
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
cb8e9e |
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
xlators/features/marker/src/marker-quota.c | 256 ++++++++++++++++++----------
|
|
|
cb8e9e |
xlators/features/marker/src/marker-quota.h | 1 +
|
|
|
cb8e9e |
2 files changed, 168 insertions(+), 89 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
|
|
|
cb8e9e |
index bb9dfa8..b582158 100644
|
|
|
cb8e9e |
--- a/xlators/features/marker/src/marker-quota.c
|
|
|
cb8e9e |
+++ b/xlators/features/marker/src/marker-quota.c
|
|
|
cb8e9e |
@@ -64,111 +64,129 @@ out:
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
-int32_t
|
|
|
cb8e9e |
-mq_get_ctx_updation_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
+static void
|
|
|
cb8e9e |
+mq_set_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag,
|
|
|
cb8e9e |
+ gf_boolean_t status)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ LOCK (&ctx->lock);
|
|
|
cb8e9e |
+ {
|
|
|
cb8e9e |
+ *flag = status;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+static void
|
|
|
cb8e9e |
+mq_test_and_set_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag,
|
|
|
cb8e9e |
gf_boolean_t *status)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
+ gf_boolean_t temp = _gf_false;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
- GF_VALIDATE_OR_GOTO ("marker", status, out);
|
|
|
cb8e9e |
+ LOCK (&ctx->lock);
|
|
|
cb8e9e |
+ {
|
|
|
cb8e9e |
+ temp = *status;
|
|
|
cb8e9e |
+ *status = *flag;
|
|
|
cb8e9e |
+ *flag = temp;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+static void
|
|
|
cb8e9e |
+mq_get_ctx_status (quota_inode_ctx_t *ctx, gf_boolean_t *flag,
|
|
|
cb8e9e |
+ gf_boolean_t *status)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
LOCK (&ctx->lock);
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- *status = ctx->updation_status;
|
|
|
cb8e9e |
+ *status = *flag;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret = 0;
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+mq_get_ctx_updation_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
+ gf_boolean_t *status)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", status, out);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ mq_get_ctx_status (ctx, &ctx->updation_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- return ret;
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
mq_set_ctx_updation_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
gf_boolean_t status)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- if (ctx == NULL)
|
|
|
cb8e9e |
- goto out;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- LOCK (&ctx->lock);
|
|
|
cb8e9e |
- {
|
|
|
cb8e9e |
- ctx->updation_status = status;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
- UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret = 0;
|
|
|
cb8e9e |
+ mq_set_ctx_status (ctx, &ctx->updation_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- return ret;
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
mq_test_and_set_ctx_updation_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
gf_boolean_t *status)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
- gf_boolean_t temp = _gf_false;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", status, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- LOCK (&ctx->lock);
|
|
|
cb8e9e |
- {
|
|
|
cb8e9e |
- temp = *status;
|
|
|
cb8e9e |
- *status = ctx->updation_status;
|
|
|
cb8e9e |
- ctx->updation_status = temp;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
- UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- ret = 0;
|
|
|
cb8e9e |
+ mq_test_and_set_ctx_status (ctx, &ctx->updation_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- return ret;
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
mq_set_ctx_create_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
gf_boolean_t status)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- if (ctx == NULL)
|
|
|
cb8e9e |
- goto out;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
- LOCK (&ctx->lock);
|
|
|
cb8e9e |
- {
|
|
|
cb8e9e |
- ctx->create_status = status;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
- UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret = 0;
|
|
|
cb8e9e |
+ mq_set_ctx_status (ctx, &ctx->create_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- return ret;
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
mq_test_and_set_ctx_create_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
gf_boolean_t *status)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
- gf_boolean_t temp = _gf_false;
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", status, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- LOCK (&ctx->lock);
|
|
|
cb8e9e |
- {
|
|
|
cb8e9e |
- temp = *status;
|
|
|
cb8e9e |
- *status = ctx->create_status;
|
|
|
cb8e9e |
- ctx->create_status = temp;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
- UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
+ mq_test_and_set_ctx_status (ctx, &ctx->create_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret = 0;
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+mq_set_ctx_dirty_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
+ gf_boolean_t status)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ mq_set_ctx_status (ctx, &ctx->dirty_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- return ret;
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int32_t
|
|
|
cb8e9e |
+mq_test_and_set_ctx_dirty_status (quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
+ gf_boolean_t *status)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", ctx, out);
|
|
|
cb8e9e |
+ GF_VALIDATE_OR_GOTO ("marker", status, out);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ mq_test_and_set_ctx_status (ctx, &ctx->dirty_status, status);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ return -1;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
void
|
|
|
cb8e9e |
@@ -2401,6 +2419,7 @@ mq_mark_dirty (xlator_t *this, loc_t *loc, int32_t dirty)
|
|
|
cb8e9e |
if (ret < 0) {
|
|
|
cb8e9e |
gf_log (this->name, GF_LOG_ERROR, "failed to get inode ctx for "
|
|
|
cb8e9e |
"%s", loc->path);
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -2833,8 +2852,7 @@ mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc,
|
|
|
cb8e9e |
quota_inode_ctx_t *ctxtmp = NULL;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (origin_loc == NULL || origin_loc->inode == NULL ||
|
|
|
cb8e9e |
- (gf_uuid_is_null(origin_loc->gfid) &&
|
|
|
cb8e9e |
- gf_uuid_is_null(origin_loc->inode->gfid)))
|
|
|
cb8e9e |
+ gf_uuid_is_null(origin_loc->inode->gfid))
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
loc_copy (loc, origin_loc);
|
|
|
cb8e9e |
@@ -2842,6 +2860,14 @@ mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc,
|
|
|
cb8e9e |
if (gf_uuid_is_null (loc->gfid))
|
|
|
cb8e9e |
gf_uuid_copy (loc->gfid, loc->inode->gfid);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ if (!loc_is_root(loc) && loc->parent == NULL) {
|
|
|
cb8e9e |
+ loc->parent = inode_parent (loc->inode, 0, NULL);
|
|
|
cb8e9e |
+ if (loc->parent == NULL) {
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
if (ctx)
|
|
|
cb8e9e |
ret = mq_inode_ctx_get (loc->inode, this, ctx);
|
|
|
cb8e9e |
else
|
|
|
cb8e9e |
@@ -2985,6 +3011,7 @@ mq_reduce_parent_size_task (void *opaque)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
int32_t ret = -1;
|
|
|
cb8e9e |
quota_inode_ctx_t *ctx = NULL;
|
|
|
cb8e9e |
+ quota_inode_ctx_t *parent_ctx = NULL;
|
|
|
cb8e9e |
inode_contribution_t *contribution = NULL;
|
|
|
cb8e9e |
quota_meta_t delta = {0, };
|
|
|
cb8e9e |
quota_meta_t contri = {0, };
|
|
|
cb8e9e |
@@ -3004,13 +3031,6 @@ mq_reduce_parent_size_task (void *opaque)
|
|
|
cb8e9e |
this = args->this;
|
|
|
cb8e9e |
THIS = this;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- ret = mq_inode_ctx_get (loc->inode, this, &ctx;;
|
|
|
cb8e9e |
- if (ret < 0) {
|
|
|
cb8e9e |
- gf_log_callingfn (this->name, GF_LOG_WARNING, "ctx for"
|
|
|
cb8e9e |
- " the node %s is NULL", loc->path);
|
|
|
cb8e9e |
- goto out;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
ret = mq_inode_loc_fill (NULL, loc->parent, &parent_loc);
|
|
|
cb8e9e |
if (ret < 0) {
|
|
|
cb8e9e |
gf_log (this->name, GF_LOG_ERROR, "loc fill failed");
|
|
|
cb8e9e |
@@ -3033,6 +3053,14 @@ mq_reduce_parent_size_task (void *opaque)
|
|
|
cb8e9e |
delta.dir_count = contri.dir_count;
|
|
|
cb8e9e |
} else {
|
|
|
cb8e9e |
remove_xattr = _gf_true;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = mq_inode_ctx_get (loc->inode, this, &ctx;;
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ gf_log_callingfn (this->name, GF_LOG_WARNING, "ctx for"
|
|
|
cb8e9e |
+ " the node %s is NULL", loc->path);
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
contribution = mq_get_contribution_node (loc->parent, ctx);
|
|
|
cb8e9e |
if (contribution == NULL) {
|
|
|
cb8e9e |
ret = -1;
|
|
|
cb8e9e |
@@ -3072,8 +3100,20 @@ mq_reduce_parent_size_task (void *opaque)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- if (dirty && ret >= 0)
|
|
|
cb8e9e |
- ret = mq_mark_dirty (this, &parent_loc, 0);
|
|
|
cb8e9e |
+ if (dirty) {
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ /* On failure clear dirty status flag.
|
|
|
cb8e9e |
+ * In the next lookup inspect_directory_xattr
|
|
|
cb8e9e |
+ * can set the status flag and fix the
|
|
|
cb8e9e |
+ * dirty directory
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+ ret = mq_inode_ctx_get (parent_loc.inode, this,
|
|
|
cb8e9e |
+ &parent_ctx);
|
|
|
cb8e9e |
+ mq_set_ctx_dirty_status (parent_ctx, _gf_false);
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ ret = mq_mark_dirty (this, &parent_loc, 0);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (locked)
|
|
|
cb8e9e |
ret = mq_lock (this, &parent_loc, F_UNLCK);
|
|
|
cb8e9e |
@@ -3108,12 +3148,6 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc,
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (loc.parent == NULL) {
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, "
|
|
|
cb8e9e |
- "aborting reduce parent size txn", loc.path);
|
|
|
cb8e9e |
- goto out;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
ret = mq_synctask1 (this, mq_reduce_parent_size_task, _gf_true, &loc,
|
|
|
cb8e9e |
contri);
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
@@ -3136,6 +3170,7 @@ mq_initiate_quota_task (void *opaque)
|
|
|
cb8e9e |
loc_t *loc = NULL;
|
|
|
cb8e9e |
inode_contribution_t *contri = NULL;
|
|
|
cb8e9e |
quota_inode_ctx_t *ctx = NULL;
|
|
|
cb8e9e |
+ quota_inode_ctx_t *parent_ctx = NULL;
|
|
|
cb8e9e |
inode_t *tmp_parent = NULL;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", opaque, out);
|
|
|
cb8e9e |
@@ -3303,8 +3338,20 @@ mq_initiate_quota_task (void *opaque)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
- if (ret >= 0 && dirty)
|
|
|
cb8e9e |
- ret = mq_mark_dirty (this, &parent_loc, 0);
|
|
|
cb8e9e |
+ if (dirty) {
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ /* On failure clear dirty status flag.
|
|
|
cb8e9e |
+ * In the next lookup inspect_directory_xattr
|
|
|
cb8e9e |
+ * can set the status flag and fix the
|
|
|
cb8e9e |
+ * dirty directory
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+ ret = mq_inode_ctx_get (parent_loc.inode, this,
|
|
|
cb8e9e |
+ &parent_ctx);
|
|
|
cb8e9e |
+ mq_set_ctx_dirty_status (parent_ctx, _gf_false);
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ ret = mq_mark_dirty (this, &parent_loc, 0);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (locked)
|
|
|
cb8e9e |
ret = mq_lock (this, &parent_loc, F_UNLCK);
|
|
|
cb8e9e |
@@ -3341,12 +3388,6 @@ _mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (loc.parent == NULL) {
|
|
|
cb8e9e |
- gf_log (this->name, GF_LOG_WARNING, "parent is NULL for %s, "
|
|
|
cb8e9e |
- "aborting updation txn", loc.path);
|
|
|
cb8e9e |
- goto out;
|
|
|
cb8e9e |
- }
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
ret = mq_test_and_set_ctx_updation_status (ctx, &status);
|
|
|
cb8e9e |
if (ret < 0 || status == _gf_true)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
@@ -3409,6 +3450,7 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
cb8e9e |
quota_synctask_t *args = NULL;
|
|
|
cb8e9e |
xlator_t *this = NULL;
|
|
|
cb8e9e |
loc_t *loc = NULL;
|
|
|
cb8e9e |
+ quota_inode_ctx_t *ctx = NULL;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
GF_ASSERT (opaque);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -3417,6 +3459,10 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
cb8e9e |
this = args->this;
|
|
|
cb8e9e |
THIS = this;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ ret = mq_inode_ctx_get (loc->inode, this, &ctx;;
|
|
|
cb8e9e |
+ if (ret < 0)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
ret = mq_lock (this, loc, F_WRLCK);
|
|
|
cb8e9e |
if (ret < 0)
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
@@ -3526,8 +3572,16 @@ out:
|
|
|
cb8e9e |
if (fd)
|
|
|
cb8e9e |
fd_unref (fd);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- if (ret >= 0 && dirty)
|
|
|
cb8e9e |
+ if (ret < 0) {
|
|
|
cb8e9e |
+ /* On failure clear dirty status flag.
|
|
|
cb8e9e |
+ * In the next lookup inspect_directory_xattr
|
|
|
cb8e9e |
+ * can set the status flag and fix the
|
|
|
cb8e9e |
+ * dirty directory
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+ mq_set_ctx_dirty_status (ctx, _gf_false);
|
|
|
cb8e9e |
+ } else if (dirty) {
|
|
|
cb8e9e |
mq_mark_dirty (this, loc, 0);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (locked)
|
|
|
cb8e9e |
mq_lock (this, loc, F_UNLCK);
|
|
|
cb8e9e |
@@ -3541,15 +3595,23 @@ out:
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int32_t
|
|
|
cb8e9e |
-mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc)
|
|
|
cb8e9e |
+mq_update_dirty_inode_txn (xlator_t *this, loc_t *loc, quota_inode_ctx_t *ctx)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
- int32_t ret = -1;
|
|
|
cb8e9e |
+ int32_t ret = -1;
|
|
|
cb8e9e |
+ gf_boolean_t status = _gf_true;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", loc, out);
|
|
|
cb8e9e |
GF_VALIDATE_OR_GOTO ("marker", loc->inode, out);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ ret = mq_test_and_set_ctx_dirty_status (ctx, &status);
|
|
|
cb8e9e |
+ if (ret < 0 || status == _gf_true)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
ret = mq_synctask (this, mq_update_dirty_inode_task, _gf_true, loc);
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
+ if (ret < 0 && status == _gf_false)
|
|
|
cb8e9e |
+ mq_set_ctx_dirty_status (ctx, _gf_false);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -3564,6 +3626,7 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
quota_meta_t contri = {0, };
|
|
|
cb8e9e |
quota_meta_t delta = {0, };
|
|
|
cb8e9e |
char contri_key[CONTRI_KEY_MAX] = {0, };
|
|
|
cb8e9e |
+ gf_boolean_t status = _gf_false;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = dict_get_int8 (dict, QUOTA_DIRTY_KEY, &dirty);
|
|
|
cb8e9e |
if (ret < 0) {
|
|
|
cb8e9e |
@@ -3603,15 +3666,21 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
ctx->size = size.size;
|
|
|
cb8e9e |
ctx->file_count = size.file_count;
|
|
|
cb8e9e |
ctx->dir_count = size.dir_count;
|
|
|
cb8e9e |
+ ctx->dirty = dirty;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
UNLOCK (&ctx->lock);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ ret = mq_get_ctx_updation_status (ctx, &status);
|
|
|
cb8e9e |
+ if (ret < 0 || status == _gf_true) {
|
|
|
cb8e9e |
+ /* If the update txn is in progress abort inspection */
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
mq_compute_delta (&delta, &size, &contri);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
if (dirty) {
|
|
|
cb8e9e |
- if (ctx->dirty == 0)
|
|
|
cb8e9e |
- ret = mq_update_dirty_inode_txn (this, loc);
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
+ ret = mq_update_dirty_inode_txn (this, loc, ctx);
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -3620,6 +3689,7 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
mq_initiate_quota_txn (this, loc);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = 0;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
create_xattr:
|
|
|
cb8e9e |
if (ret < 0)
|
|
|
cb8e9e |
@@ -3639,6 +3709,7 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
quota_meta_t contri = {0, };
|
|
|
cb8e9e |
quota_meta_t delta = {0, };
|
|
|
cb8e9e |
char contri_key[CONTRI_KEY_MAX] = {0, };
|
|
|
cb8e9e |
+ gf_boolean_t status = _gf_false;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
LOCK (&ctx->lock);
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
@@ -3669,6 +3740,13 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
UNLOCK (&contribution->lock);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ ret = mq_get_ctx_updation_status (ctx, &status);
|
|
|
cb8e9e |
+ if (ret < 0 || status == _gf_true) {
|
|
|
cb8e9e |
+ /* If the update txn is in progress abort inspection */
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
mq_compute_delta (&delta, &size, &contri);
|
|
|
cb8e9e |
if (!quota_meta_is_null (&delta))
|
|
|
cb8e9e |
mq_initiate_quota_txn (this, loc);
|
|
|
cb8e9e |
diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h
|
|
|
cb8e9e |
index 65cb0b2..1f50c26 100644
|
|
|
cb8e9e |
--- a/xlators/features/marker/src/marker-quota.h
|
|
|
cb8e9e |
+++ b/xlators/features/marker/src/marker-quota.h
|
|
|
cb8e9e |
@@ -91,6 +91,7 @@ struct quota_inode_ctx {
|
|
|
cb8e9e |
int8_t dirty;
|
|
|
cb8e9e |
gf_boolean_t create_status;
|
|
|
cb8e9e |
gf_boolean_t updation_status;
|
|
|
cb8e9e |
+ gf_boolean_t dirty_status;
|
|
|
cb8e9e |
gf_lock_t lock;
|
|
|
cb8e9e |
struct list_head contribution_head;
|
|
|
cb8e9e |
};
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|