diff options
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 26 |
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; } |