summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2011-09-30 13:29:18 +0530
committerAnand Avati <avati@redhat.com>2012-07-14 18:09:07 -0700
commitfb8efa4c6ab4bc1af49d05b0bc6b16eb188ea3b1 (patch)
tree1f9e0576e735745d8ddb215fa8b53b9831c992f6 /xlators/storage/posix/src/posix-helpers.c
parentab44480749a289aaaf78dad4123ef16d1872ea1b (diff)
storage/posix: implement native linux AIO support
Configurable via cli with "storage.linux-aio" settable option Change-Id: I9929e0d6fc1bbc2a0fe1fb67bfc8d15d8a483d3f BUG: 837495 Signed-off-by: Anand Avati <avati@redhat.com> Reviewed-on: http://review.gluster.com/3627 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index c649482f4a5..3c19ba7a3fd 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1058,5 +1058,29 @@ int
posix_fd_ctx_get_off (fd_t *fd, xlator_t *this, struct posix_fd **pfd,
off_t offset)
{
- return posix_fd_ctx_get (fd, this, pfd);
+ int ret;
+ int flags;
+
+ LOCK (&fd->inode->lock);
+ {
+ ret = __posix_fd_ctx_get (fd, this, pfd);
+ if (ret)
+ goto unlock;
+
+ if ((offset & 0xfff) && (*pfd)->odirect) {
+ flags = fcntl ((*pfd)->fd, F_GETFL);
+ ret = fcntl ((*pfd)->fd, F_SETFL, (flags & (~O_DIRECT)));
+ (*pfd)->odirect = 0;
+ }
+
+ if (((offset & 0xfff) == 0) && (!(*pfd)->odirect)) {
+ flags = fcntl ((*pfd)->fd, F_GETFL);
+ ret = fcntl ((*pfd)->fd, F_SETFL, (flags | O_DIRECT));
+ (*pfd)->odirect = 1;
+ }
+ }
+unlock:
+ UNLOCK (&fd->inode->lock);
+
+ return ret;
}