From 5f9ad8a2bcc18d8ae828140d20203de496b371a4 Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Sun, 30 Sep 2012 13:26:59 -0700 Subject: linux-aio: fixes while setting O_DIRECT flag Linux AIO needs O_DIRECT to be set for effective operation. O_DIRECT in turn has constraints on when it can work (offset, size alignment) So use O_DIRECT (unless instructed by application) only when offset and size alignments match. Else, io_submit() will happen over non-O_DIRECT fd, effectively blocking till the completion of the IO. Also fix a multithreading bug where detection/setting of O_DIRECT for a request was not atomic with io_submit() of that request. Change-Id: I190017e8bc78217429aff0714dca224cbe6f251d BUG: 837495 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/4006 Tested-by: Gluster Build System Reviewed-by: Amar Tumballi Tested-by: Amar Tumballi --- xlators/storage/posix/src/posix-helpers.c | 32 ------------------------------- 1 file changed, 32 deletions(-) (limited to 'xlators/storage/posix/src/posix-helpers.c') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 9ccf08272..dc1c1750a 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -1044,35 +1044,3 @@ posix_fd_ctx_get (fd_t *fd, xlator_t *this, struct posix_fd **pfd) return ret; } - - -int -posix_fd_ctx_get_off (fd_t *fd, xlator_t *this, struct posix_fd **pfd, - off_t offset) -{ - 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; -} -- cgit