summaryrefslogtreecommitdiffstats
path: root/xlators/performance
diff options
context:
space:
mode:
authorPoornima G <pgurusid@redhat.com>2018-06-27 14:59:40 +0530
committerAmar Tumballi <amarts@redhat.com>2018-07-11 04:11:59 +0000
commit69f77d28c3ecacba77fbae2f789b5110641347f3 (patch)
tree746f1470476a981b6becaedb6c7c1e681f457f41 /xlators/performance
parentaf6c6429f9743f287baaad68f8e3d56ed7390d1b (diff)
md-cache: Do not invalidate cache post set/remove xattr
Since setxattr and removexattr fops cbk do not carry poststat, the stat cache was being invalidated in setxatr/remoxattr cbk. Hence the further lookup wouldn't be served from cache. To prevent this invalidation, md-cache is modified to get the poststat in set/removexattr_cbk in dict. Co-authored with Xavi Hernandez. Change-Id: I6b946be2d20b807e2578825743c25ba5927a60b4 fixes: bz#1586018 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com> Signed-off-by: Poornima G <pgurusid@redhat.com>
Diffstat (limited to 'xlators/performance')
-rw-r--r--xlators/performance/md-cache/src/md-cache.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 2180cb25960..a3721a8e3f4 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -2157,6 +2157,9 @@ mdc_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
mdc_local_t *local = NULL;
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
local = frame->local;
if (!local)
@@ -2170,7 +2173,15 @@ mdc_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
mdc_inode_xatt_update (this, local->loc.inode, local->xattr);
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate (this, local->loc.inode, &prestat,
+ &poststat, _gf_true);
+ }
+
+ if (ret < 0)
+ mdc_inode_iatt_invalidate (this, local->loc.inode);
out:
MDC_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata);
@@ -2193,6 +2204,7 @@ mdc_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
STACK_WIND (frame, mdc_setxattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr,
loc, xattr, flags, xdata);
+
return 0;
}
@@ -2202,6 +2214,9 @@ mdc_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
mdc_local_t *local = NULL;
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
local = frame->local;
if (!local)
@@ -2215,7 +2230,16 @@ mdc_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
mdc_inode_xatt_update (this, local->fd->inode, local->xattr);
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate (this, local->fd->inode, &prestat,
+ &poststat, _gf_true);
+ }
+
+ if (ret < 0)
+ mdc_inode_iatt_invalidate (this, local->fd->inode);
+
out:
MDC_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata);
@@ -2237,6 +2261,7 @@ mdc_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
STACK_WIND (frame, mdc_fsetxattr_cbk,
FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetxattr,
fd, xattr, flags, xdata);
+
return 0;
}
@@ -2380,6 +2405,9 @@ mdc_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
mdc_local_t *local = NULL;
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
local = frame->local;
if (!local)
@@ -2396,7 +2424,15 @@ mdc_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
else
mdc_inode_xatt_invalidate (this, local->loc.inode);
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate (this, local->loc.inode, &prestat,
+ &poststat, _gf_true);
+ }
+
+ if (ret < 0)
+ mdc_inode_iatt_invalidate (this, local->loc.inode);
out:
MDC_STACK_UNWIND (removexattr, frame, op_ret, op_errno, xdata);
@@ -2451,6 +2487,9 @@ mdc_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
mdc_local_t *local = NULL;
+ struct iatt prestat = {0,};
+ struct iatt poststat = {0,};
+ int ret = 0;
local = frame->local;
if (!local)
@@ -2467,7 +2506,16 @@ mdc_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
else
mdc_inode_xatt_invalidate (this, local->fd->inode);
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate (this, local->fd->inode, &prestat,
+ &poststat, _gf_true);
+ }
+
+ if (ret < 0)
+ mdc_inode_iatt_invalidate (this, local->fd->inode);
+
out:
MDC_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, xdata);