|
|
14f8ab |
From 7ad8c03a28fca67150972cda964ebe9233766b54 Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
14f8ab |
Date: Mon, 30 Mar 2020 11:09:39 +0200
|
|
|
14f8ab |
Subject: [PATCH 418/449] md-cache: avoid clearing cache when not necessary
|
|
|
14f8ab |
|
|
|
14f8ab |
mdc_inode_xatt_set() blindly cleared current cache when dict was not
|
|
|
14f8ab |
NULL, even if there was no xattr requested.
|
|
|
14f8ab |
|
|
|
14f8ab |
This patch fixes this by only calling mdc_inode_xatt_set() when we have
|
|
|
14f8ab |
explicitly requested something to cache.
|
|
|
14f8ab |
|
|
|
14f8ab |
Backport of:
|
|
|
14f8ab |
> Upstream-patch-link: https://review.gluster.org/24267
|
|
|
14f8ab |
> Change-Id: Idc91a4693f1ff39f7059acde26682ccc361b947d
|
|
|
14f8ab |
> Fixes: #1140
|
|
|
14f8ab |
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
BUG: 1815434
|
|
|
14f8ab |
Change-Id: Idc91a4693f1ff39f7059acde26682ccc361b947d
|
|
|
14f8ab |
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/202487
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
xlators/performance/md-cache/src/md-cache.c | 165 ++++++++++++++++------------
|
|
|
14f8ab |
1 file changed, 93 insertions(+), 72 deletions(-)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
|
|
|
14f8ab |
index a6b363f..bbbee3b 100644
|
|
|
14f8ab |
--- a/xlators/performance/md-cache/src/md-cache.c
|
|
|
14f8ab |
+++ b/xlators/performance/md-cache/src/md-cache.c
|
|
|
14f8ab |
@@ -133,6 +133,7 @@ struct mdc_local {
|
|
|
14f8ab |
char *key;
|
|
|
14f8ab |
dict_t *xattr;
|
|
|
14f8ab |
uint64_t incident_time;
|
|
|
14f8ab |
+ bool update_cache;
|
|
|
14f8ab |
};
|
|
|
14f8ab |
|
|
|
14f8ab |
int
|
|
|
14f8ab |
@@ -969,7 +970,7 @@ out:
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
-void
|
|
|
14f8ab |
+static bool
|
|
|
14f8ab |
mdc_load_reqs(xlator_t *this, dict_t *dict)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
@@ -978,6 +979,7 @@ mdc_load_reqs(xlator_t *this, dict_t *dict)
|
|
|
14f8ab |
char *tmp = NULL;
|
|
|
14f8ab |
char *tmp1 = NULL;
|
|
|
14f8ab |
int ret = 0;
|
|
|
14f8ab |
+ bool loaded = false;
|
|
|
14f8ab |
|
|
|
14f8ab |
tmp1 = conf->mdc_xattr_str;
|
|
|
14f8ab |
if (!tmp1)
|
|
|
14f8ab |
@@ -995,13 +997,17 @@ mdc_load_reqs(xlator_t *this, dict_t *dict)
|
|
|
14f8ab |
conf->mdc_xattr_str = NULL;
|
|
|
14f8ab |
gf_msg("md-cache", GF_LOG_ERROR, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
|
|
|
14f8ab |
"Disabled cache for xattrs, dict_set failed");
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
pattern = strtok_r(NULL, ",", &tmp);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- GF_FREE(mdc_xattr_str);
|
|
|
14f8ab |
+ loaded = true;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
- return;
|
|
|
14f8ab |
+ GF_FREE(mdc_xattr_str);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return loaded;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
struct checkpair {
|
|
|
14f8ab |
@@ -1092,6 +1098,25 @@ err:
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+static dict_t *
|
|
|
14f8ab |
+mdc_prepare_request(xlator_t *this, mdc_local_t *local, dict_t *xdata)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ if (xdata == NULL) {
|
|
|
14f8ab |
+ xdata = dict_new();
|
|
|
14f8ab |
+ if (xdata == NULL) {
|
|
|
14f8ab |
+ local->update_cache = false;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return NULL;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ } else {
|
|
|
14f8ab |
+ dict_ref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ local->update_cache = mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ return xdata;
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
int
|
|
|
14f8ab |
mdc_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
14f8ab |
int32_t op_ret, int32_t op_errno, struct statvfs *buf,
|
|
|
14f8ab |
@@ -1201,7 +1226,9 @@ mdc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
14f8ab |
|
|
|
14f8ab |
if (local->loc.inode) {
|
|
|
14f8ab |
mdc_inode_iatt_set(this, local->loc.inode, stbuf, local->incident_time);
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, local->loc.inode, dict);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, local->loc.inode, dict);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
}
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(lookup, frame, op_ret, op_errno, inode, stbuf, dict,
|
|
|
14f8ab |
@@ -1220,7 +1247,6 @@ mdc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
|
|
|
14f8ab |
0,
|
|
|
14f8ab |
};
|
|
|
14f8ab |
dict_t *xattr_rsp = NULL;
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -1271,18 +1297,18 @@ mdc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
uncached:
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
STACK_WIND(frame, mdc_lookup_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->lookup, loc, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
if (xattr_rsp)
|
|
|
14f8ab |
dict_unref(xattr_rsp);
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -1305,7 +1331,9 @@ mdc_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, local->loc.inode, xdata);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, local->loc.inode, xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(stat, frame, op_ret, op_errno, buf, xdata);
|
|
|
14f8ab |
@@ -1319,7 +1347,6 @@ mdc_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
|
|
|
14f8ab |
int ret;
|
|
|
14f8ab |
struct iatt stbuf;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, loc->inode);
|
|
|
14f8ab |
@@ -1343,17 +1370,16 @@ mdc_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
uncached:
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
|
|
|
14f8ab |
STACK_WIND(frame, mdc_stat_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->stat, loc, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -1376,7 +1402,9 @@ mdc_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
mdc_inode_iatt_set(this, local->fd->inode, buf, local->incident_time);
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, local->fd->inode, xdata);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, local->fd->inode, xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(fstat, frame, op_ret, op_errno, buf, xdata);
|
|
|
14f8ab |
@@ -1390,7 +1418,6 @@ mdc_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
|
|
|
14f8ab |
int ret;
|
|
|
14f8ab |
struct iatt stbuf;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, fd->inode);
|
|
|
14f8ab |
@@ -1409,17 +1436,16 @@ mdc_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
uncached:
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
|
|
|
14f8ab |
STACK_WIND(frame, mdc_fstat_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->fstat, fd, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -2393,7 +2419,9 @@ mdc_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, local->loc.inode, xdata);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, local->loc.inode, xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(getxattr, frame, op_ret, op_errno, xattr, xdata);
|
|
|
14f8ab |
@@ -2410,7 +2438,6 @@ mdc_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
dict_t *xattr = NULL;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
gf_boolean_t key_satisfied = _gf_true;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, loc->inode);
|
|
|
14f8ab |
@@ -2443,18 +2470,17 @@ mdc_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
|
|
|
14f8ab |
|
|
|
14f8ab |
uncached:
|
|
|
14f8ab |
if (key_satisfied) {
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
|
|
|
14f8ab |
STACK_WIND(frame, mdc_getxattr_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->getxattr, loc, key, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+ if (key_satisfied && (xdata != NULL)) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -2481,7 +2507,9 @@ mdc_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, local->fd->inode, xdata);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, local->fd->inode, xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, xattr, xdata);
|
|
|
14f8ab |
@@ -2498,7 +2526,6 @@ mdc_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *key,
|
|
|
14f8ab |
dict_t *xattr = NULL;
|
|
|
14f8ab |
int op_errno = ENODATA;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
gf_boolean_t key_satisfied = _gf_true;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, fd->inode);
|
|
|
14f8ab |
@@ -2531,18 +2558,17 @@ mdc_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *key,
|
|
|
14f8ab |
|
|
|
14f8ab |
uncached:
|
|
|
14f8ab |
if (key_satisfied) {
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
|
|
|
14f8ab |
STACK_WIND(frame, mdc_fgetxattr_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->fgetxattr, fd, key, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+ if (key_satisfied && (xdata != NULL)) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -2752,27 +2778,22 @@ int
|
|
|
14f8ab |
mdc_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
|
|
|
14f8ab |
dict_t *xdata)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, loc->inode);
|
|
|
14f8ab |
|
|
|
14f8ab |
loc_copy(&local->loc, loc);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- if (xdata) {
|
|
|
14f8ab |
- /* Tell readdir-ahead to include these keys in xdata when it
|
|
|
14f8ab |
- * internally issues readdirp() in it's opendir_cbk */
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
+ /* Tell readdir-ahead to include these keys in xdata when it
|
|
|
14f8ab |
+ * internally issues readdirp() in it's opendir_cbk */
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
STACK_WIND(frame, mdc_opendir_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
@@ -2800,7 +2821,9 @@ mdc_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
|
|
|
14f8ab |
continue;
|
|
|
14f8ab |
mdc_inode_iatt_set(this, entry->inode, &entry->d_stat,
|
|
|
14f8ab |
local->incident_time);
|
|
|
14f8ab |
- mdc_inode_xatt_set(this, entry->inode, entry->dict);
|
|
|
14f8ab |
+ if (local->update_cache) {
|
|
|
14f8ab |
+ mdc_inode_xatt_set(this, entry->inode, entry->dict);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
unwind:
|
|
|
14f8ab |
@@ -2812,7 +2835,6 @@ int
|
|
|
14f8ab |
mdc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
14f8ab |
off_t offset, dict_t *xdata)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- dict_t *xattr_alloc = NULL;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
|
|
|
14f8ab |
local = mdc_local_get(frame, fd->inode);
|
|
|
14f8ab |
@@ -2821,15 +2843,15 @@ mdc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
14f8ab |
|
|
|
14f8ab |
local->fd = fd_ref(fd);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (!xdata)
|
|
|
14f8ab |
- xdata = xattr_alloc = dict_new();
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
STACK_WIND(frame, mdc_readdirp_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata);
|
|
|
14f8ab |
- if (xattr_alloc)
|
|
|
14f8ab |
- dict_unref(xattr_alloc);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
+ dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
out:
|
|
|
14f8ab |
MDC_STACK_UNWIND(readdirp, frame, -1, ENOMEM, NULL, NULL);
|
|
|
14f8ab |
@@ -2860,7 +2882,6 @@ int
|
|
|
14f8ab |
mdc_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
14f8ab |
off_t offset, dict_t *xdata)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- int need_unref = 0;
|
|
|
14f8ab |
mdc_local_t *local = NULL;
|
|
|
14f8ab |
struct mdc_conf *conf = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -2876,19 +2897,14 @@ mdc_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (!xdata) {
|
|
|
14f8ab |
- xdata = dict_new();
|
|
|
14f8ab |
- need_unref = 1;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- if (xdata)
|
|
|
14f8ab |
- mdc_load_reqs(this, xdata);
|
|
|
14f8ab |
+ xdata = mdc_prepare_request(this, local, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
STACK_WIND(frame, mdc_readdirp_cbk, FIRST_CHILD(this),
|
|
|
14f8ab |
FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (need_unref && xdata)
|
|
|
14f8ab |
+ if (xdata != NULL) {
|
|
|
14f8ab |
dict_unref(xdata);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
unwind:
|
|
|
14f8ab |
@@ -3468,7 +3484,12 @@ mdc_register_xattr_inval(xlator_t *this)
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- mdc_load_reqs(this, xattr);
|
|
|
14f8ab |
+ if (!mdc_load_reqs(this, xattr)) {
|
|
|
14f8ab |
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
|
|
|
14f8ab |
+ "failed to populate cache entries");
|
|
|
14f8ab |
+ ret = -1;
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
|
|
|
14f8ab |
frame = create_frame(this, this->ctx->pool);
|
|
|
14f8ab |
if (!frame) {
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|