Skip to content

Commit

Permalink
Refactored project structure of the Key Value file system
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-JanGootzen committed Apr 11, 2023
1 parent 643452e commit 5b35a10
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 80 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "extern/eRPC-arm"]
path = extern/eRPC-arm
url = [email protected]:Peter-JanGootzen/eRPC-arm.git
[submodule "extern/RAMCloud"]
path = extern/RAMCloud
url = [email protected]:PepperJo/RAMCloud.git
4 changes: 4 additions & 0 deletions conf_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ dpu_uri = "10.100.0.115:31850"
# If enabled then rvfs_dpu will do RVFS and hal polling on two seperate threads
# TODO make this work for the RVFS version of hal as well?
two_threads = true

[kv]
# The remote RAMCloud server that KV will connect to
ramcloud_coordinator = "PLACEHOLDER"
24 changes: 24 additions & 0 deletions dpfs_kv/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2023- IBM Inc. All rights reserved
# SPDX-License-Identifier: LGPL-2.1-or-later
#

if HAVE_SNAP

bin_PROGRAMS = dpfs_kv

dpfs_kv_LDADD = $(srcdir)/../dpfs_fuse/libdpfs_fuse.la \
$(srcdir)/../dpfs_hal/libdpfs_hal.la \
-L$(srcdir)/../extern/RAMCloud/obj.c-api -lramcloud -lpthread

dpfs_kv_CPPFLAGS = $(BASE_CPPFLAGS) \
-I$(srcdir)/../dpfs_fuse \
-I$(srcdir)/../dpfs_hal/include \
-I$(srcdir)/../extern/tomlcpp \
-I/usr/local/include \
-I$(srcdir)/../extern/RAMCloud/obj.c-api \
-I$(srcdir)/../extern/RAMCloud/src

dpfs_kv_SOURCES = main.cpp

endif
75 changes: 20 additions & 55 deletions dpfs_ramcloud/main.cpp → dpfs_kv/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
#
# Copyright 2020- IBM Inc. All rights reserved
# Copyright 2023- IBM Inc. All rights reserved
# SPDX-License-Identifier: LGPL-2.1-or-later
#
*/
Expand All @@ -20,8 +20,7 @@
#include "TableEnumerator.h"

#include "dpfs_fuse.h"
#include "dpfs_hal.h"

#include "dpfs/hal.h"

struct RamCloudUserData {
RAMCloud::RamCloud *ramcloud;
Expand Down Expand Up @@ -49,8 +48,6 @@ uint64_t fnv1a_hash(const char* str, uint64_t hash = FNV_BASIS)
return *str ? fnv1a_hash(str + 1, (hash ^ *str) * FNV_PRIME) : hash;
}



class BufferHolder {
protected:
RAMCloud::Buffer value;
Expand Down Expand Up @@ -693,68 +690,44 @@ static void *ramcloud_poll(void *arg)
return NULL;
}


void usage()
{
printf("virtiofs_ramcloud [-p pf_id] [-v vf_id ] [-e emulation_manager_name] [-c RAMCloud coordinator]\n");
printf("dpfs_kv [-c config_path]\n");
}

int main(int argc, char **argv)
{
int pf = -1;
int vf = -1;
char *emu_manager = NULL; // the rdma device name which supports being an emulation manager and virtio_fs emu
char *coordinator = NULL;

int opt;
while ((opt = getopt(argc, argv, "p:v:e:c:")) != -1) {
while ((opt = getopt(argc, argv, "c:")) != -1) {
switch (opt) {
case 'p':
pf = atoi(optarg);
break;
case 'v':
vf = atoi(optarg);
break;
case 'e':
emu_manager = optarg;
break;
case 'c':
coordinator = optarg;
config_path = optarg;
break;
default: /* '?' */
usage();
exit(1);
}
}

struct virtiofs_emu_params emu_params;
memset(&emu_params, 0, sizeof(struct virtiofs_emu_params));

if (pf >= 0)
emu_params.pf_id = pf;
else {
fprintf(stderr, "You must supply a pf with -p\n");
usage();
exit(1);
auto res = toml::parseFile(conf_path);
if (!res.table) {
std::cerr << "cannot parse file: " << res.errmsg << std::endl;
return -1;
}
if (vf >= 0)
emu_params.vf_id = vf;
else
emu_params.vf_id = -1;

if (emu_manager != NULL) {
emu_params.emu_manager = emu_manager;
} else {
fprintf(stderr, "You must supply an emu manager name with -e\n");
usage();
exit(1);
auto conf = res.table->getTable("kv");
if (!conf) {
std::cerr << "missing [kv]" << std::endl;
return -1;
}
if (coordinator == NULL) {
fprintf(stderr, "You must supply a coordinator path with -c\n");
usage();
exit(1);
auto [ok, coordinator] = conf->getString("ramcloud_coordinator");
if (!ok) {
std::cerr << "The config must contain [kv]:`ramcloud_coordinator`" << std::endl;
return -1;
}
printf("virtiofs_ramcloud starting up!\n");

printf("dpfs_kv starting up!\n");
printf("Connecting to RAMCloud coordinator %s\n", coordinator);

RAMCloud::RamCloud ramcloud(coordinator);
Expand All @@ -773,12 +746,6 @@ int main(int argc, char **argv)
return -1;
}

emu_params.polling_interval_usec = 0;
emu_params.nthreads = 0;
emu_params.tag = new char[sizeof "virtiofs_ramcloud"];
emu_params.queue_depth = 64;
std::strcpy(emu_params.tag, "virtiofs_ramcloud");

struct fuse_ll_operations ops;
memset(&ops, 0, sizeof(ops));
ops.init = (typeof(ops.init)) fuse_init;
Expand All @@ -799,13 +766,11 @@ int main(int argc, char **argv)
ops.mknod = (typeof(ops.mknod)) fuse_mknod; /* not sure if this is needed at all */
ops.unlink = (typeof(ops.unlink)) fuse_unlink;

dpfs_fuse_main(&ops, &emu_params, &user_data, false);
dpfs_fuse_main(&ops, conf_path, &user_data, false);

user_data.stopPoller = true;
pthread_join(ramcloud_poll_thread, NULL);

delete[] emu_params.tag;

return 0;
}

25 changes: 0 additions & 25 deletions dpfs_ramcloud/Makefile.am

This file was deleted.

1 change: 1 addition & 0 deletions extern/RAMCloud
Submodule RAMCloud added at f8ee0e

0 comments on commit 5b35a10

Please sign in to comment.