summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-01 00:31:45 +0530
committerPrasanna Kumar Kalever <pkalever@redhat.com>2017-06-05 11:47:16 +0000
commit3994aa8cf1bdcf3a07cddfefdb96cc2b94e01a97 (patch)
tree88fef27e5dd333c2d1321ff04a43f2dc6feed4ae /rpc
parent780849822afb665344e76eecf0d05e403840dd52 (diff)
cache: implement LRU cache to hold glfs objects
Problem: ------- 1. Currently, each cli command take ~5 secs for execution. The Maximum latency is due to initializing a glfs object (glfs_init() and friends). 2. OOM kills due to glfs_fini() leaks (~10MB per object) Solution: -------- Caching bipasses glfs_init() calls from the very next command, as in the first command it goes via the glfs_init route, since there will be cache miss. Hence with caching cli command on a local machine should take ~1 sec. ATM, the cache query looks at the volume name only, as the host name will be localhost in our case and transport will be tcp 24007 always. The default cache capacity is 5 i.e there can be a max of five glfs entries in the cache, anything more will lead to release of least recently used object. This way, if there are <= 5 volume in use for block, there will be no glfs_fini() calls, hence no leaks, no OOM's. The next patch will help in making cache capacity configurable. Change-Id: Ia891451cb92cf09959c1aff85976d78302ec7014 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> [ndevos: correct compiling+linking against libgfapi.so]
Diffstat (limited to 'rpc')
-rw-r--r--rpc/block_svc_routines.c6
-rw-r--r--rpc/glfs-operations.c10
-rw-r--r--rpc/glfs-operations.h3
3 files changed, 11 insertions, 8 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index e84ff8d..a6a7974 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -1495,7 +1495,6 @@ block_modify_cli_1_svc(blockModifyCli *blk, struct svc_req *rqstp)
blockModifyCliFormatResponse (blk, &mobj, asyncret?asyncret:errCode,
errMsg, savereply, info, reply, rollback);
blockFreeMetaInfo(info);
- glfs_fini(glfs);
if (savereply) {
GB_FREE(savereply->attempt);
@@ -1808,7 +1807,6 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
blockCreateCliFormatResponse(glfs, blk, &cobj, errCode, errMsg, savereply, reply);
GB_FREE(errMsg);
blockServerDefFree(list);
- glfs_fini(glfs);
blockCreateParsedRespFree(savereply);
GB_FREE (cobj.block_hosts);
@@ -2115,7 +2113,6 @@ block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp)
blockDeleteCliFormatResponse(blk, errCode, errMsg, savereply, reply);
- glfs_fini(glfs);
if (savereply) {
GB_FREE(savereply->d_attempt);
@@ -2502,8 +2499,6 @@ block_list_cli_1_svc(blockListCli *blk, struct svc_req *rqstp)
GB_TXLOCKFILE, blk->volume, strerror(errno));
}
- glfs_fini(glfs);
-
return reply;
}
@@ -2662,7 +2657,6 @@ block_info_cli_1_svc(blockInfoCli *blk, struct svc_req *rqstp)
blockInfoCliFormatResponse(blk, errCode, errMsg, info, reply);
- glfs_fini(glfs);
GB_FREE(errMsg);
blockFreeMetaInfo(info);
diff --git a/rpc/glfs-operations.c b/rpc/glfs-operations.c
index 9ae8ec5..72de38f 100644
--- a/rpc/glfs-operations.c
+++ b/rpc/glfs-operations.c
@@ -20,6 +20,10 @@ glusterBlockVolumeInit(char *volume, int *errCode, char **errMsg)
struct glfs *glfs;
int ret;
+ glfs = queryCache(volume);
+ if (glfs) {
+ return glfs;
+ }
glfs = glfs_new(volume);
if (!glfs) {
@@ -67,6 +71,12 @@ glusterBlockVolumeInit(char *volume, int *errCode, char **errMsg)
goto out;
}
+ if (appendNewEntry(volume, glfs)) {
+ *errCode = ENOMEM;
+ LOG("gfapi", GB_LOG_ERROR, "allocation failed in appendNewEntry(%s)", volume);
+ goto out;
+ }
+
return glfs;
out:
diff --git a/rpc/glfs-operations.h b/rpc/glfs-operations.h
index 150554e..bd6b497 100644
--- a/rpc/glfs-operations.h
+++ b/rpc/glfs-operations.h
@@ -17,8 +17,7 @@
# include <stdbool.h>
# include <errno.h>
-# include <glusterfs/api/glfs.h>
-
+# include "lru.h"
# include "block.h"