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