summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <sgowda@redhat.com>2012-08-23 18:34:09 +0530
committerVijay Bellur <vbellur@redhat.com>2012-12-12 00:10:12 -0500
commit508c239e0c85ad705f260fec9f14330e670b3e08 (patch)
tree8adf355bdd649350105f8898a1d3a727c67f9b55
parent323494932f955e645c399469faa2ed823a1364c6 (diff)
storage/posix: implement native linux AIO support
Configurable via cli with "storage.linux-aio" settable option Backported Avati's patch http://review.gluster.org/#change,3627 BUG: 837495 Change-Id: Ia7c26f5734d34d341debd422a5c59bba31eef844 Signed-off-by: shishir gowda <sgowda@redhat.com> Reviewed-on: http://review.gluster.org/3849 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/1849 Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--configure.ac11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c1
-rw-r--r--xlators/storage/posix/src/Makefile.am6
-rw-r--r--xlators/storage/posix/src/posix-helpers.c26
-rw-r--r--xlators/storage/posix/src/posix-mem-types.h1
-rw-r--r--xlators/storage/posix/src/posix.c48
-rw-r--r--xlators/storage/posix/src/posix.h13
7 files changed, 100 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index a77426dc3d6..7825d8a24ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -517,6 +517,15 @@ if test "x$RLLIBS" != "x"; then
BUILD_READLINE=yes
fi
+BUILD_LIBAIO=no
+AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])
+
+if test "x$LIBAIO" != "x"; then
+ AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
+ BUILD_LIBAIO=yes
+fi
+
+
AC_SUBST(GF_HOST_OS)
AC_SUBST(GF_GLUSTERFS_LDFLAGS)
AC_SUBST(GF_GLUSTERFS_CFLAGS)
@@ -526,6 +535,7 @@ AC_SUBST(GF_LDADD)
AC_SUBST(GF_FUSE_LDADD)
AC_SUBST(GF_FUSE_CFLAGS)
AC_SUBST(RLLIBS)
+AC_SUBST(LIBAIO)
AC_SUBST(AM_MAKEFLAGS)
AC_SUBST(AM_LIBTOOLFLAGS)
@@ -551,4 +561,5 @@ echo "argp-standalone : $BUILD_ARGP_STANDALONE"
echo "fusermount : $BUILD_FUSERMOUNT"
echo "readline : $BUILD_READLINE"
echo "georeplication : $BUILD_SYNCDAEMON"
+echo "Linux-AIO : $BUILD_LIBAIO"
echo
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index c5eb6b0f3ce..9795722f9c0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -231,6 +231,7 @@ static struct volopt_map_entry glusterd_volopt_map[] = {
{"feature.read-only", "features/read-only", "!read-only", "off", DOC, 0},
{GLUSTERD_QUORUM_TYPE_KEY, "mgmt/glusterd", NULL, "off", DOC, 0},
{GLUSTERD_QUORUM_RATIO_KEY, "mgmt/glusterd", NULL, "0", DOC, 0},
+ {"storage.linux-aio", "storage/posix", NULL, NULL, DOC, 0},
{NULL, }
};
diff --git a/xlators/storage/posix/src/Makefile.am b/xlators/storage/posix/src/Makefile.am
index 408dcb80ddf..4eae9798b15 100644
--- a/xlators/storage/posix/src/Makefile.am
+++ b/xlators/storage/posix/src/Makefile.am
@@ -4,10 +4,10 @@ xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/storage
posix_la_LDFLAGS = -module -avoidversion
-posix_la_SOURCES = posix.c posix-helpers.c posix-handle.c
-posix_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+posix_la_SOURCES = posix.c posix-helpers.c posix-handle.c posix-aio.c
+posix_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la $(LIBAIO)
-noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h
+noinst_HEADERS = posix.h posix-mem-types.h posix-handle.h posix-aio.h
AM_CFLAGS = -fPIC -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
-D$(GF_HOST_OS) -Wall -I$(top_srcdir)/libglusterfs/src -shared \
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 585b791b046..7d419cd9222 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1066,5 +1066,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;
}
diff --git a/xlators/storage/posix/src/posix-mem-types.h b/xlators/storage/posix/src/posix-mem-types.h
index 10aa75edc11..b8d81248c2d 100644
--- a/xlators/storage/posix/src/posix-mem-types.h
+++ b/xlators/storage/posix/src/posix-mem-types.h
@@ -30,6 +30,7 @@ enum gf_posix_mem_types_ {
gf_posix_mt_int32_t,
gf_posix_mt_posix_dev_t,
gf_posix_mt_trash_path,
+ gf_posix_mt_paiocb,
gf_posix_mt_end
};
#endif
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index cedf9538b25..9082b400749 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -59,6 +59,7 @@
#include "timer.h"
#include "glusterfs3-xdr.h"
#include "hashfn.h"
+#include "posix-aio.h"
extern char *marker_xattrs[];
@@ -3960,6 +3961,29 @@ mem_acct_init (xlator_t *this)
return ret;
}
+
+int
+reconfigure (xlator_t *this, dict_t *options)
+{
+ int ret = -1;
+ struct posix_private *priv = NULL;
+
+ priv = this->private;
+
+ GF_OPTION_RECONF ("linux-aio", priv->aio_configured,
+ options, bool, out);
+
+ if (priv->aio_configured)
+ posix_aio_on (this);
+ else
+ posix_aio_off (this);
+
+ ret = 0;
+out:
+ return ret;
+}
+
+
/**
* init -
*/
@@ -4300,7 +4324,23 @@ init (xlator_t *this)
"Posix handle setup failed");
ret = -1;
goto out;
- }
+ }
+
+ _private->aio_init_done = _gf_false;
+ _private->aio_capable = _gf_false;
+
+ GF_OPTION_INIT ("linux-aio", _private->aio_configured, bool, out);
+
+ if (_private->aio_configured) {
+ op_ret = posix_aio_on (this);
+
+ if (op_ret == -1) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "Posix AIO init failed");
+ ret = -1;
+ goto out;
+ }
+ }
pthread_mutex_init (&_private->janitor_lock, NULL);
pthread_cond_init (&_private->janitor_cond, NULL);
@@ -4399,5 +4439,11 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_ANY },
{ .key = {"glusterd-uuid"},
.type = GF_OPTION_TYPE_STR },
+ {
+ .key = {"linux-aio"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .description = "Support for native Linux AIO"
+ },
{ .key = {NULL} }
};
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 7c2b47bb02b..ce5c94c1686 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -54,6 +54,11 @@
#include "posix-mem-types.h"
#include "posix-handle.h"
+#ifdef HAVE_LIBAIO
+#include <libaio.h>
+#include "posix-aio.h"
+#endif
+
/**
* posix_fd - internal structure common to file and directory fd's
*/
@@ -64,7 +69,6 @@ struct posix_fd {
DIR * dir; /* handle returned by the kernel */
int flushwrites;
int odirect;
- int op_performed;
struct list_head list; /* to add to the janitor list */
};
@@ -124,6 +128,13 @@ struct posix_private {
/* uuid of glusterd that swapned the brick process */
uuid_t glusterd_uuid;
+ gf_boolean_t aio_configured;
+ gf_boolean_t aio_init_done;
+ gf_boolean_t aio_capable;
+#ifdef HAVE_LIBAIO
+ io_context_t ctxp;
+ pthread_t aiothread;
+#endif
};
#define POSIX_BASE_PATH(this) (((struct posix_private *)this->private)->base_path)