From 15d9ee36c71bfe3499d7f3baf3a483199211261f Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Thu, 1 Jun 2017 15:08:44 +0530 Subject: daemon: make glfs lru cache capacity configurable $ gluster-blockd --help gluster-blockd (0.2) usage: gluster-blockd [--glfs-lru-count ] commands: --glfs-lru-count glfs objects cache capacity [max: 512] (default: 5) --help show this message and exit. --version show version info and exit. Change-Id: I00a9277690a1c5ace51e223e9e4ed9ce61ae2428 Signed-off-by: Prasanna Kumar Kalever --- daemon/Makefile.am | 6 ++--- daemon/gluster-blockd.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) (limited to 'daemon') diff --git a/daemon/Makefile.am b/daemon/Makefile.am index a44158a..de5367c 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -3,10 +3,10 @@ sbin_PROGRAMS = gluster-blockd gluster_blockd_SOURCES = gluster-blockd.c gluster_blockd_CFLAGS = $(GFAPI_CFLAGS) -DDATADIR=\"$(localstatedir)\" \ - -I$(top_srcdir)/utils/ -I$(top_srcdir)/rpc \ - -I$(top_builddir)/rpc/rpcl + -I$(top_builddir)/ -I$(top_srcdir)/utils/ \ + -I$(top_srcdir)/rpc -I$(top_builddir)/rpc/rpcl -gluster_blockd_LDADD = $(PTHREAD) $(top_builddir)/rpc/libgbrpc.la \ +gluster_blockd_LDADD = $(PTHREAD) $(top_builddir)/rpc/libgbrpc.la \ $(top_builddir)/utils/libgb.la DISTCLEANFILES = Makefile.in diff --git a/daemon/gluster-blockd.c b/daemon/gluster-blockd.c index 0f06a70..5d546bd 100644 --- a/daemon/gluster-blockd.c +++ b/daemon/gluster-blockd.c @@ -15,6 +15,7 @@ # include # include +# include "config.h" # include "common.h" # include "lru.h" # include "block.h" @@ -22,6 +23,30 @@ +extern size_t glfsLruCount; +extern const char *argp_program_version; + + +static void +glusterBlockDHelp(void) +{ + MSG("%s", + "gluster-blockd ("PACKAGE_VERSION")\n" + "usage:\n" + " gluster-blockd [--glfs-lru-count ]\n" + "\n" + "commands:\n" + " --glfs-lru-count \n" + " glfs objects cache capacity [max: 512] (default: 5)\n" + " --help\n" + " show this message and exit.\n" + " --version\n" + " show version info and exit.\n" + "\n" + ); +} + + static bool glusterBlockLogdirCreate(void) { @@ -184,8 +209,48 @@ main (int argc, char **argv) pthread_t server_thread; struct flock lock = {0, }; int errnosv = 0; + size_t opt = 0; + if (argc > 1) { + opt = glusterBlockDaemonOptEnumParse(argv[1]); + if (!opt || opt >= GB_DAEMON_OPT_MAX) { + MSG("unknown option: %s\n", argv[1]); + return -1; + } + + switch (opt) { + case GB_DAEMON_HELP: + case GB_DAEMON_USAGE: + if (argc != 2) { + MSG("undesired options for: %s\n", argv[1]); + } + glusterBlockDHelp(); + return 0; + + case GB_DAEMON_VERSION: + MSG("%s\n", argp_program_version); + return 0; + + case GB_DAEMON_GLFS_LRU_COUNT: + if (argc != 3) { + MSG("undesired options for: %s\n", argv[1]); + return -1; + } + if (sscanf(argv[2], "%zu", &glfsLruCount) != 1) { + MSG("option '%s' expect argument type integer \n", argv[1]); + return -1; + } + if (!glfsLruCount || (glfsLruCount > LRU_COUNT_MAX)) { + MSG("glfs-lru-count argument should be [0 < count < %d]\n", LRU_COUNT_MAX); + LOG("mgmt", GB_LOG_ERROR, + "glfs-lru-count argument should be [0 < count < %d]\n", LRU_COUNT_MAX); + return -1; + } + break; + } + } + if (!glusterBlockLogdirCreate()) { return -1; } -- cgit