summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/store.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-04-28 22:05:44 +0300
committerAtin Mukherjee <amukherj@redhat.com>2019-05-08 06:46:24 +0000
commit1fa089e7a2b180e0bdcc1e7e09a63934a2a0c0ef (patch)
tree92e28f0fb24fd550375e4cb401b9e7bfaa098efa /libglusterfs/src/store.c
parentaa52259de7b50625b754ce9fb5c0f38e22d79dd6 (diff)
glusterd/store: store all key-values in one shot
Instead of saving each key-value separately, which is slow ( especially as we fflush() after each!), store them all as one string and write all together. Implements https://github.com/gluster/glusterfs/issues/629 Change-Id: Ie77a272446b0b6785584b710a4fdd9c613dd9578 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat,.com>
Diffstat (limited to 'libglusterfs/src/store.c')
-rw-r--r--libglusterfs/src/store.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/libglusterfs/src/store.c b/libglusterfs/src/store.c
index cdf0aeafe4c..0416a86d540 100644
--- a/libglusterfs/src/store.c
+++ b/libglusterfs/src/store.c
@@ -388,6 +388,53 @@ out:
}
int32_t
+gf_store_save_items(int fd, char *items)
+{
+ int32_t ret = -1;
+ int dup_fd = -1;
+ FILE *fp = NULL;
+
+ GF_ASSERT(fd > 0);
+ GF_ASSERT(items);
+
+ dup_fd = dup(fd);
+ if (dup_fd == -1)
+ goto out;
+
+ fp = fdopen(dup_fd, "a+");
+ if (fp == NULL) {
+ gf_msg(THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "fdopen failed.");
+ ret = -1;
+ goto out;
+ }
+
+ ret = fputs(items, fp);
+ if (ret < 0) {
+ gf_msg(THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "Unable to store items: %s", items);
+ ret = -1;
+ goto out;
+ }
+
+ ret = fflush(fp);
+ if (ret) {
+ gf_msg(THIS->name, GF_LOG_WARNING, errno, LG_MSG_FILE_OP_FAILED,
+ "fflush failed.");
+ ret = -1;
+ goto out;
+ }
+
+ ret = 0;
+out:
+ if (fp)
+ fclose(fp);
+
+ gf_msg_debug(THIS->name, 0, "returning: %d", ret);
+ return ret;
+}
+
+int32_t
gf_store_handle_new(const char *path, gf_store_handle_t **handle)
{
int32_t ret = -1;