|
|
12a457 |
From a4a8a68a7f884e6cfd52fcf2733bdf339fa4a289 Mon Sep 17 00:00:00 2001
|
|
|
12a457 |
From: vmallika <vmallika@redhat.com>
|
|
|
12a457 |
Date: Sat, 2 Apr 2016 08:57:00 +0530
|
|
|
12a457 |
Subject: [PATCH 57/80] marker: optimize mq_update_dirty_inode_task
|
|
|
12a457 |
|
|
|
12a457 |
This is a backport of http://review.gluster.org/13892
|
|
|
12a457 |
|
|
|
12a457 |
In function mq_update_dirty_inode_task we do readdirp
|
|
|
12a457 |
on a dirty directory and for entry we again do
|
|
|
12a457 |
lookup to fecth the contribution xattr.
|
|
|
12a457 |
We can fetch this contribution as part of readdirp
|
|
|
12a457 |
|
|
|
12a457 |
> Change-Id: I766593c0dba793f1ab3b43625acce1c7d9af8d7f
|
|
|
12a457 |
> BUG: 1320818
|
|
|
12a457 |
> Signed-off-by: vmallika <vmallika@redhat.com>
|
|
|
12a457 |
> Reviewed-on: http://review.gluster.org/13892
|
|
|
12a457 |
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
12a457 |
> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
> Smoke: Gluster Build System <jenkins@build.gluster.com>
|
|
|
12a457 |
> Reviewed-by: Manikandan Selvaganesh <mselvaga@redhat.com>
|
|
|
12a457 |
|
|
|
12a457 |
Change-Id: I289886de9a203431aee7a0cc06be986136d44506
|
|
|
12a457 |
BUG: 1318170
|
|
|
12a457 |
Signed-off-by: vmallika <vmallika@redhat.com>
|
|
|
12a457 |
Reviewed-on: https://code.engineering.redhat.com/gerrit/71540
|
|
|
12a457 |
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
12a457 |
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
|
|
|
12a457 |
---
|
|
|
12a457 |
libglusterfs/src/quota-common-utils.c | 11 +++
|
|
|
12a457 |
libglusterfs/src/quota-common-utils.h | 3 +
|
|
|
12a457 |
xlators/features/marker/src/marker-quota.c | 94 +++++++++++++---------------
|
|
|
12a457 |
3 files changed, 58 insertions(+), 50 deletions(-)
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c
|
|
|
12a457 |
index 5e688e5..ad7e4dc 100644
|
|
|
12a457 |
--- a/libglusterfs/src/quota-common-utils.c
|
|
|
12a457 |
+++ b/libglusterfs/src/quota-common-utils.c
|
|
|
12a457 |
@@ -16,6 +16,17 @@
|
|
|
12a457 |
#include "common-utils.h"
|
|
|
12a457 |
#include "libglusterfs-messages.h"
|
|
|
12a457 |
|
|
|
12a457 |
+gf_boolean_t
|
|
|
12a457 |
+quota_meta_is_null (const quota_meta_t *meta)
|
|
|
12a457 |
+{
|
|
|
12a457 |
+ if (meta->size == 0 &&
|
|
|
12a457 |
+ meta->file_count == 0 &&
|
|
|
12a457 |
+ meta->dir_count == 0)
|
|
|
12a457 |
+ return _gf_true;
|
|
|
12a457 |
+
|
|
|
12a457 |
+ return _gf_false;
|
|
|
12a457 |
+}
|
|
|
12a457 |
+
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta)
|
|
|
12a457 |
{
|
|
|
12a457 |
diff --git a/libglusterfs/src/quota-common-utils.h b/libglusterfs/src/quota-common-utils.h
|
|
|
12a457 |
index c930db8..e479398 100644
|
|
|
12a457 |
--- a/libglusterfs/src/quota-common-utils.h
|
|
|
12a457 |
+++ b/libglusterfs/src/quota-common-utils.h
|
|
|
12a457 |
@@ -37,6 +37,9 @@ struct _quota_meta {
|
|
|
12a457 |
} __attribute__ ((__packed__));
|
|
|
12a457 |
typedef struct _quota_meta quota_meta_t;
|
|
|
12a457 |
|
|
|
12a457 |
+gf_boolean_t
|
|
|
12a457 |
+quota_meta_is_null (const quota_meta_t *meta);
|
|
|
12a457 |
+
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta);
|
|
|
12a457 |
|
|
|
12a457 |
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
|
|
|
12a457 |
index 8b7ce90..e23b769 100644
|
|
|
12a457 |
--- a/xlators/features/marker/src/marker-quota.c
|
|
|
12a457 |
+++ b/xlators/features/marker/src/marker-quota.c
|
|
|
12a457 |
@@ -377,17 +377,6 @@ mq_sub_meta (quota_meta_t *dst, const quota_meta_t *src)
|
|
|
12a457 |
}
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
-gf_boolean_t
|
|
|
12a457 |
-quota_meta_is_null (const quota_meta_t *meta)
|
|
|
12a457 |
-{
|
|
|
12a457 |
- if (meta->size == 0 &&
|
|
|
12a457 |
- meta->file_count == 0 &&
|
|
|
12a457 |
- meta->dir_count == 0)
|
|
|
12a457 |
- return _gf_true;
|
|
|
12a457 |
-
|
|
|
12a457 |
- return _gf_false;
|
|
|
12a457 |
-}
|
|
|
12a457 |
-
|
|
|
12a457 |
int32_t
|
|
|
12a457 |
mq_are_xattrs_set (xlator_t *this, loc_t *loc, gf_boolean_t *contri_set,
|
|
|
12a457 |
gf_boolean_t *size_set)
|
|
|
12a457 |
@@ -1769,24 +1758,24 @@ out:
|
|
|
12a457 |
int
|
|
|
12a457 |
mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
{
|
|
|
12a457 |
- int32_t ret = -1;
|
|
|
12a457 |
- fd_t *fd = NULL;
|
|
|
12a457 |
- off_t offset = 0;
|
|
|
12a457 |
- loc_t child_loc = {0, };
|
|
|
12a457 |
+ int32_t ret = -1;
|
|
|
12a457 |
+ fd_t *fd = NULL;
|
|
|
12a457 |
+ off_t offset = 0;
|
|
|
12a457 |
gf_dirent_t entries;
|
|
|
12a457 |
- gf_dirent_t *entry = NULL;
|
|
|
12a457 |
- gf_boolean_t locked = _gf_false;
|
|
|
12a457 |
- gf_boolean_t free_entries = _gf_false;
|
|
|
12a457 |
- gf_boolean_t updated = _gf_false;
|
|
|
12a457 |
- int32_t dirty = 0;
|
|
|
12a457 |
- quota_meta_t contri = {0, };
|
|
|
12a457 |
- quota_meta_t size = {0, };
|
|
|
12a457 |
- quota_meta_t contri_sum = {0, };
|
|
|
12a457 |
- quota_meta_t delta = {0, };
|
|
|
12a457 |
- quota_synctask_t *args = NULL;
|
|
|
12a457 |
- xlator_t *this = NULL;
|
|
|
12a457 |
- loc_t *loc = NULL;
|
|
|
12a457 |
- quota_inode_ctx_t *ctx = NULL;
|
|
|
12a457 |
+ gf_dirent_t *entry = NULL;
|
|
|
12a457 |
+ gf_boolean_t locked = _gf_false;
|
|
|
12a457 |
+ gf_boolean_t updated = _gf_false;
|
|
|
12a457 |
+ int32_t dirty = 0;
|
|
|
12a457 |
+ quota_meta_t contri = {0, };
|
|
|
12a457 |
+ quota_meta_t size = {0, };
|
|
|
12a457 |
+ quota_meta_t contri_sum = {0, };
|
|
|
12a457 |
+ quota_meta_t delta = {0, };
|
|
|
12a457 |
+ quota_synctask_t *args = NULL;
|
|
|
12a457 |
+ xlator_t *this = NULL;
|
|
|
12a457 |
+ loc_t *loc = NULL;
|
|
|
12a457 |
+ quota_inode_ctx_t *ctx = NULL;
|
|
|
12a457 |
+ dict_t *xdata = NULL;
|
|
|
12a457 |
+ char contri_key[QUOTA_KEY_MAX] = {0, };
|
|
|
12a457 |
|
|
|
12a457 |
GF_ASSERT (opaque);
|
|
|
12a457 |
|
|
|
12a457 |
@@ -1794,11 +1783,29 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
loc = &args->loc;
|
|
|
12a457 |
this = args->this;
|
|
|
12a457 |
THIS = this;
|
|
|
12a457 |
+ INIT_LIST_HEAD (&entries.list);
|
|
|
12a457 |
|
|
|
12a457 |
ret = mq_inode_ctx_get (loc->inode, this, &ctx;;
|
|
|
12a457 |
if (ret < 0)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
|
|
|
12a457 |
+ GET_CONTRI_KEY (this, contri_key, loc->gfid, ret);
|
|
|
12a457 |
+ if (ret < 0)
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+
|
|
|
12a457 |
+ xdata = dict_new ();
|
|
|
12a457 |
+ if (xdata == NULL) {
|
|
|
12a457 |
+ gf_log (this->name, GF_LOG_ERROR, "dict_new failed");
|
|
|
12a457 |
+ ret = -1;
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
+ ret = dict_set_int64 (xdata, contri_key, 0);
|
|
|
12a457 |
+ if (ret < 0) {
|
|
|
12a457 |
+ gf_log (this->name, GF_LOG_ERROR, "dict_set failed");
|
|
|
12a457 |
+ goto out;
|
|
|
12a457 |
+ }
|
|
|
12a457 |
+
|
|
|
12a457 |
ret = mq_lock (this, loc, F_WRLCK);
|
|
|
12a457 |
if (ret < 0)
|
|
|
12a457 |
goto out;
|
|
|
12a457 |
@@ -1826,9 +1833,8 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
fd_bind (fd);
|
|
|
12a457 |
- INIT_LIST_HEAD (&entries.list);
|
|
|
12a457 |
while ((ret = syncop_readdirp (this, fd, 131072, offset, &entries,
|
|
|
12a457 |
- NULL, NULL)) != 0) {
|
|
|
12a457 |
+ xdata, NULL)) != 0) {
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
gf_log (this->name, (-ret == ENOENT || -ret == ESTALE)
|
|
|
12a457 |
? GF_LOG_DEBUG:GF_LOG_ERROR, "readdirp failed "
|
|
|
12a457 |
@@ -1839,7 +1845,6 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
if (list_empty (&entries.list))
|
|
|
12a457 |
break;
|
|
|
12a457 |
|
|
|
12a457 |
- free_entries = _gf_true;
|
|
|
12a457 |
list_for_each_entry (entry, &entries.list, list) {
|
|
|
12a457 |
offset = entry->d_off;
|
|
|
12a457 |
|
|
|
12a457 |
@@ -1847,26 +1852,15 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
!strcmp (entry->d_name, ".."))
|
|
|
12a457 |
continue;
|
|
|
12a457 |
|
|
|
12a457 |
- ret = loc_build_child (&child_loc, loc, entry->d_name);
|
|
|
12a457 |
- if (ret < 0) {
|
|
|
12a457 |
- gf_log (this->name, GF_LOG_WARNING,
|
|
|
12a457 |
- "Couldn't build loc for %s/%s "
|
|
|
12a457 |
- "returning from updation of dirty "
|
|
|
12a457 |
- "inode", loc->path, entry->d_name);
|
|
|
12a457 |
- goto out;
|
|
|
12a457 |
- }
|
|
|
12a457 |
-
|
|
|
12a457 |
- ret = mq_get_contri (this, &child_loc, &contri,
|
|
|
12a457 |
- loc->gfid);
|
|
|
12a457 |
- if (ret < 0)
|
|
|
12a457 |
- goto out;
|
|
|
12a457 |
+ memset (&contri, 0, sizeof (contri));
|
|
|
12a457 |
+ quota_dict_get_meta (entry->dict, contri_key, &contri);
|
|
|
12a457 |
+ if (quota_meta_is_null (&contri))
|
|
|
12a457 |
+ continue;
|
|
|
12a457 |
|
|
|
12a457 |
mq_add_meta (&contri_sum, &contri);
|
|
|
12a457 |
- loc_wipe (&child_loc);
|
|
|
12a457 |
}
|
|
|
12a457 |
|
|
|
12a457 |
gf_dirent_free (&entries);
|
|
|
12a457 |
- free_entries = _gf_false;
|
|
|
12a457 |
}
|
|
|
12a457 |
/* Inculde for self */
|
|
|
12a457 |
contri_sum.dir_count++;
|
|
|
12a457 |
@@ -1903,12 +1897,14 @@ mq_update_dirty_inode_task (void *opaque)
|
|
|
12a457 |
updated = _gf_true;
|
|
|
12a457 |
|
|
|
12a457 |
out:
|
|
|
12a457 |
- if (free_entries)
|
|
|
12a457 |
- gf_dirent_free (&entries);
|
|
|
12a457 |
+ gf_dirent_free (&entries);
|
|
|
12a457 |
|
|
|
12a457 |
if (fd)
|
|
|
12a457 |
fd_unref (fd);
|
|
|
12a457 |
|
|
|
12a457 |
+ if (xdata)
|
|
|
12a457 |
+ dict_unref (xdata);
|
|
|
12a457 |
+
|
|
|
12a457 |
if (ret < 0) {
|
|
|
12a457 |
/* On failure clear dirty status flag.
|
|
|
12a457 |
* In the next lookup inspect_directory_xattr
|
|
|
12a457 |
@@ -1924,8 +1920,6 @@ out:
|
|
|
12a457 |
if (locked)
|
|
|
12a457 |
mq_lock (this, loc, F_UNLCK);
|
|
|
12a457 |
|
|
|
12a457 |
- loc_wipe(&child_loc);
|
|
|
12a457 |
-
|
|
|
12a457 |
if (updated)
|
|
|
12a457 |
mq_initiate_quota_blocking_txn (this, loc, NULL);
|
|
|
12a457 |
|
|
|
12a457 |
--
|
|
|
12a457 |
1.7.1
|
|
|
12a457 |
|