diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2016-06-02 19:45:03 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2016-06-03 18:58:10 -0700 |
commit | 9e0cdf1d2393d7bdb0eac019e70dce7c5f4f59c9 (patch) | |
tree | 81cf229359880db68b2ca7dea88f8cd4a1199ddd /xlators/storage | |
parent | 42b2c259658b017ec08ecf419c7ea83112779236 (diff) |
posix, shard: Use page-aligned buffer for o-direct reads
and also make shard_readv_do() pass the correct flags when
the original fd is opened with O_DIRECT.
Change-Id: Ic2f8ad900743ed3f7cab56948bcf1358d247a311
BUG: 1342171
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/14639
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 9ee2b2ed274..c6bf5174186 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3042,6 +3042,8 @@ posix_readv (call_frame_t *frame, xlator_t *this, int32_t op_ret = -1; int32_t op_errno = 0; int _fd = -1; + char *buf = NULL; + char *alloc_buf = NULL; struct posix_private * priv = NULL; struct iobuf * iobuf = NULL; struct iobref * iobref = NULL; @@ -3080,14 +3082,35 @@ posix_readv (call_frame_t *frame, xlator_t *this, } _fd = pfd->fd; - op_ret = sys_pread (_fd, iobuf->ptr, size, offset); - if (op_ret == -1) { - op_errno = errno; - gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READ_FAILED, - "read failed on gfid=%s, fd=%p, offset=%"PRIu64" " - "size=%"GF_PRI_SIZET"", uuid_utoa (fd->inode->gfid), fd, - offset, size); - goto out; + if (pfd->flags & O_DIRECT) { + alloc_buf = _page_aligned_alloc (size, &buf); + if (!alloc_buf) { + op_ret = -1; + op_errno = errno; + goto out; + } + + op_ret = sys_pread (_fd, buf, size, offset); + if (op_ret == -1) { + op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, errno, + P_MSG_READ_FAILED, "read failed on gfid=%s, " + "fd=%p, offset=%"PRIu64" size=%"GF_PRI_SIZET", " + "buf=%p", uuid_utoa (fd->inode->gfid), fd, + offset, size, buf); + goto out; + } + memcpy(iobuf->ptr, buf, size); + } else { + op_ret = sys_pread (_fd, iobuf->ptr, size, offset); + if (op_ret == -1) { + op_errno = errno; + gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_READ_FAILED, + "read failed on gfid=%s, fd=%p, offset=%"PRIu64" " + "size=%"GF_PRI_SIZET"", uuid_utoa (fd->inode->gfid), fd, + offset, size); + goto out; + } } LOCK (&priv->lock); @@ -3130,6 +3153,7 @@ out: iobref_unref (iobref); if (iobuf) iobuf_unref (iobuf); + GF_FREE (alloc_buf); return 0; } |