diff options
author | Shreyas Siravara <sshreyas@fb.com> | 2017-09-07 16:41:15 -0700 |
---|---|---|
committer | Shreyas Siravara <sshreyas@fb.com> | 2017-09-07 23:55:14 +0000 |
commit | 4a007de8e1bcef9ce059cdca4dcc510846702e1d (patch) | |
tree | 3cdabb33d59c42a36607224ce198b01dfe0f8ccf | |
parent | e698fd3e3a0ff8f54e31e810706a011cdf938dca (diff) |
md-cache: Invalidate inode metadata on flush
Summary:
- When you write a file and then stat it immediately, md-cache returns stale stat information.
- This diff implements flush() in md-cache so that we can correctly invalidate inodes after
a write.
- This is a port of D4762171 to 3.8
Reviewers: kvigor, dph
Reviewed By: kvigor
Change-Id: I368b7870d61b14a7e390917d195cbccc67029eb7
Reviewed-on: https://review.gluster.org/18233
Reviewed-by: Shreyas Siravara <sshreyas@fb.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
-rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 75a2b26ef65..1dcf2354634 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -1894,6 +1894,40 @@ mdc_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync, int +mdc_flush_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; + + local = frame->local; + + if (local && local->fd) { + mdc_inode_iatt_invalidate (this, local->fd->inode); + } + + MDC_STACK_UNWIND (flush, frame, op_ret, op_errno, xdata); + + return 0; +} + + +int +mdc_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata) +{ + mdc_local_t *local = NULL; + + local = mdc_local_get (frame); + + local->fd = fd_ref (fd); + + STACK_WIND (frame, mdc_flush_cbk, FIRST_CHILD (this), + FIRST_CHILD (this)->fops->flush, fd, xdata); + + return 0; +} + + +int mdc_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *xdata) { @@ -2584,6 +2618,7 @@ struct xlator_fops fops = { .setattr = mdc_setattr, .fsetattr = mdc_fsetattr, .fsync = mdc_fsync, + .flush = mdc_flush, .setxattr = mdc_setxattr, .fsetxattr = mdc_fsetxattr, .getxattr = mdc_getxattr, |