summaryrefslogtreecommitdiffstats
path: root/daemon/gluster-blockd.c
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-01 15:08:44 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-05 22:12:20 +0530
commit15d9ee36c71bfe3499d7f3baf3a483199211261f (patch)
treea085afa3fabe33aab37128a7f140f69032c4844f /daemon/gluster-blockd.c
parent3994aa8cf1bdcf3a07cddfefdb96cc2b94e01a97 (diff)
daemon: make glfs lru cache capacity configurable
$ gluster-blockd --help gluster-blockd (0.2) usage: gluster-blockd [--glfs-lru-count <count>] commands: --glfs-lru-count <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 <prasanna.kalever@redhat.com>
Diffstat (limited to 'daemon/gluster-blockd.c')
-rw-r--r--daemon/gluster-blockd.c65
1 files changed, 65 insertions, 0 deletions
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 <pthread.h>
# include <rpc/pmap_clnt.h>
+# 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 <count>]\n"
+ "\n"
+ "commands:\n"
+ " --glfs-lru-count <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 <count>\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;
}