summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2016-09-20 12:05:23 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-09-23 07:46:33 -0700
commit48f4ca93d5ea859ae5975239bf3d288709fdaf12 (patch)
tree3ba88becc41d7cef1055b18deca4b400e4a4bbd6
parent801cdb1e2381b988b515819f02120cd129fc4740 (diff)
performance/open-behind: Pass O_DIRECT flags for anon fd reads when required
Backport of: http://review.gluster.org/15537 cherry-picked from a412a4f50d8ca2ae68dbfa93b80757889150ce99 Writes are already passing the correct flags at the time of open(). Also, make io-cache honor direct-io for anon-fds with O_DIRECT flag during reads. Change-Id: I221d6e8e7431931a0c1fc93f1a886a62ab58d0ca BUG: 1378695 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/15551 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
-rw-r--r--xlators/performance/io-cache/src/io-cache.c45
-rw-r--r--xlators/performance/open-behind/src/open-behind.c22
2 files changed, 28 insertions, 39 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 62bedb6e644..58b9b0dd279 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -898,29 +898,6 @@ ioc_release (xlator_t *this, fd_t *fd)
return 0;
}
-/*
- * ioc_readv_disabled_cbk
- * @frame:
- * @cookie:
- * @this:
- * @op_ret:
- * @op_errno:
- * @vector:
- * @count:
- *
- */
-int32_t
-ioc_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *stbuf,
- struct iobref *iobref, dict_t *xdata)
-{
- STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, vector, count,
- stbuf, iobref, xdata);
- return 0;
-}
-
-
int32_t
ioc_need_prune (ioc_table_t *table)
{
@@ -1133,10 +1110,17 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
if (!ioc_inode) {
/* caching disabled, go ahead with normal readv */
- STACK_WIND (frame, ioc_readv_disabled_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv, fd, size,
- offset, flags, xdata);
+ STACK_WIND_TAIL (frame, FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->readv, fd,
+ size, offset, flags, xdata);
+ return 0;
+ }
+
+ if (flags & O_DIRECT) {
+ /* disable caching for this fd, if O_DIRECT is used */
+ STACK_WIND_TAIL (frame, FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->readv, fd,
+ size, offset, flags, xdata);
return 0;
}
@@ -1170,10 +1154,9 @@ ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (!fd_ctx_get (fd, this, NULL)) {
/* disable caching for this fd, go ahead with normal readv */
- STACK_WIND (frame, ioc_readv_disabled_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv, fd, size,
- offset, flags, xdata);
+ STACK_WIND_TAIL (frame, FIRST_CHILD (frame->this),
+ FIRST_CHILD (frame->this)->fops->readv, fd,
+ size, offset, flags, xdata);
return 0;
}
diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c
index efab88582ff..00e8906910a 100644
--- a/xlators/performance/open-behind/src/open-behind.c
+++ b/xlators/performance/open-behind/src/open-behind.c
@@ -351,19 +351,25 @@ err:
fd_t *
-ob_get_wind_fd (xlator_t *this, fd_t *fd)
+ob_get_wind_fd (xlator_t *this, fd_t *fd, uint32_t *flag)
{
- ob_conf_t *conf = NULL;
- ob_fd_t *ob_fd = NULL;
+ fd_t *wind_fd = NULL;
+ ob_fd_t *ob_fd = NULL;
+ ob_conf_t *conf = NULL;
conf = this->private;
ob_fd = ob_fd_ctx_get (this, fd);
- if (ob_fd && conf->use_anonymous_fd)
- return fd_anonymous (fd->inode);
+ if (ob_fd && conf->use_anonymous_fd) {
+ wind_fd = fd_anonymous (fd->inode);
+ if ((ob_fd->flags & O_DIRECT) && (flag))
+ *flag = *flag | O_DIRECT;
+ } else {
+ wind_fd = fd_ref (fd);
+ }
- return fd_ref (fd);
+ return wind_fd;
}
@@ -378,7 +384,7 @@ ob_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
conf = this->private;
if (!conf->read_after_open)
- wind_fd = ob_get_wind_fd (this, fd);
+ wind_fd = ob_get_wind_fd (this, fd, &flags);
else
wind_fd = fd_ref (fd);
@@ -427,7 +433,7 @@ ob_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
call_stub_t *stub = NULL;
fd_t *wind_fd = NULL;
- wind_fd = ob_get_wind_fd (this, fd);
+ wind_fd = ob_get_wind_fd (this, fd, NULL);
stub = fop_fstat_stub (frame, default_fstat_resume, wind_fd, xdata);