Skip to contentSkip to conversation

Rocksdb with SPDK

SPDK dimitra.giantsidi at gmail.com 1 participant 3 messages Sep 30, 2020 – Oct 1, 2020

lore
Share & tools
lore

dimitra.giantsidi at gmail.com

#0 lore raw

Hi all,

I am running Rocksdb on top of a blobfs filesystem and I have a couple of questions.

1. What exactly does the ```sanitize_path()``` function do and why do we need to sanitize the path before opening a file? If the fname is /mnt/rocksdb/log, the sanitize path returns /log .. What does that means for my application?
2. the file->Sync() operations fails with a message "Not Implemented". In particular, I am having the following code :

```
if (!FLAGS__spdk.empty()) {
                        FLAGS_env = rocksdb::NewSpdkEnv(FLAGS_env, FLAGS_dir, FLAGS__spdk, FLAGS__spdk_bdev, FLAGS__spdk_cache_size);
                        fprintf(stdout, "Using rocksdb::NewSpdkEnv() environment.\n");
                        if (FLAGS_env == nullptr) {
                                fprintf(stderr, "Could not load SPDK blobfs - check that SPDK mkfs was run "
                                                "against block device %s.\n", FLAGS__spdk_bdev.c_str());
                                exit(1);
                        } 
                }

                unique_ptr<WritableFile> file;
                EnvOptions soptions;

                rocksdb::Slice data = return_data(FLAGS__value_size);
                Status s = FLAGS_env->NewWritableFile(FLAGS_file, &file, soptions);
                if (!s.ok()) {
                        fprintf(stderr, "oops ..\n");
                        abort();
                }

                size_t size = 0;
                size_t total_size = FLAGS_total_size*1024;
                struct timeval start_time, end_time;
                gettimeofday(&start_time, NULL);
                while (size < total_size) {
                        s = file->Append(data);

                        if (s.ok()) {
                                s = file->Sync();
                        }

                        size += FLAGS__value_size;

                        if (!s.ok()) {
                                fprintf(stdout, "written %d bytes to %s (%s)..\n", size, FLAGS_file.c_str(), s.ToString().c_str());
                                abort();
                        }
                }
```

However, I am seeing that the rocksdb::SpdkWritableFile::Sync() is implemented .. Any ideas?
Thanks for your help :)

Dimitra

#1 lore raw

Hi Dimitra

Quoted 9 lines

From: dimitra.giantsidi(a)gmail.com <dimitra.giantsidi(a)gmail.com>> Hi all,

I am running Rocksdb on top of a blobfs filesystem and I have a couple of questions.

1. What exactly does the ```sanitize_path()``` function do and why do we need to sanitize the path before opening a file? If the fname is /mnt/rocksdb/log, the sanitize path returns /log .. What does that means for my application?

Blobfs doesn't actually have a hierarchical directory structure. It stores the file names as string keys. Therefore it is very important that the same file, however it's described via valid POSIX paths, translate into a consistent string name. That's what sanitize_path() is doing.

Quoted 48 lines

2. the file->Sync() operations fails with a message "Not Implemented". In particular, I am having the following code :

```
if (!FLAGS__spdk.empty()) {
                        FLAGS_env = rocksdb::NewSpdkEnv(FLAGS_env, FLAGS_dir,
FLAGS__spdk, FLAGS__spdk_bdev, FLAGS__spdk_cache_size);
                        fprintf(stdout, "Using rocksdb::NewSpdkEnv() environment.\n");
                        if (FLAGS_env == nullptr) {
                                fprintf(stderr, "Could not load SPDK blobfs - check that SPDK
mkfs was run "
                                                "against block device %s.\n",
FLAGS__spdk_bdev.c_str());
                                exit(1);
                        }
                }

                unique_ptr<WritableFile> file;
                EnvOptions soptions;

                rocksdb::Slice data = return_data(FLAGS__value_size);
                Status s = FLAGS_env->NewWritableFile(FLAGS_file, &file, soptions);
                if (!s.ok()) {
                        fprintf(stderr, "oops ..\n");
                        abort();
                }

                size_t size = 0;
                size_t total_size = FLAGS_total_size*1024;
                struct timeval start_time, end_time;
                gettimeofday(&start_time, NULL);
                while (size < total_size) {
                        s = file->Append(data);

                        if (s.ok()) {
                                s = file->Sync();
                        }

                        size += FLAGS__value_size;

                        if (!s.ok()) {
                                fprintf(stdout, "written %d bytes to %s (%s)..\n", size,
FLAGS_file.c_str(), s.ToString().c_str());
                                abort();
                        }
                }
```
Quoted 1 line

However, I am seeing that the rocksdb::SpdkWritableFile::Sync() is implemented

Where is that "Not implemented" message coming from in the code? Is that something from RocksDB? It does look like sync is implemented.

Quoted 8 lines

..
Any ideas?
Thanks for your help :)

Dimitra
_______________________________________________
SPDK mailing list -- spdk(a)lists.01.org
To unsubscribe send an email to spdk-leave(a)lists.01.org

#2 lore raw

Hi Benjamin,
Thank you for your prompt reply!

I got rid of the "Not implemented"-error by working on a more "stable" and sane compiler/linker environment -- thanks again for your help.

However, even with a stable gcc release I am having some important (might trivial) questions.

All in all, I want to use the rocksdb logging interface (based on blobfs) for a very simple parallel (multithreaded) logging application. In particular, I want to measure the time a thread takes to append and sync (to the disk) manually some data (for benchmarking purposes).

The workflow of my code is simple (I can attach my code if it is required :)):
-- in the main function I am creating a "rocksdb::NewSpdkEnv()" which is global and thus visible to all application threads.
-- Also the main thread creates a unique-for-each-thread "NewWritableFile(fname, &file, soptions);" which is of type SpdkWritableFile and forwards the unique_ptr of it to the thread function. -- Afterwards each thread will append data on its assigned file and also might invoke Sync().

However, even this code works fine when using the kernel driver, it does not work with spdk (breaks with a segfault). The trace of the gdb is not really deterministic:

"Thread 4 "spdk_rocksdb" received signal SIGSEGV, Segmentation fault.
0x00000000008c1734 in alloc_fs_request (channel=channel(a)entry=0x30) at blobfs.c:264
264 if (channel->sync) {
"
Any idea of what it might be? Is the logic of my application orthogonal to the context of the SpdkEnv() for rocksdb? Lastly, does the " __thread struct sync_args g_sync_args;" in "spdk/lib/rocksdb/env_spdk.cc"  play any role when spawning new threads? I feel that my error is related to how spdk channels are configured regarding to the thread_context information.

Any help would be highly appreciated :)

Thank you again for your time,
Dimitra