From ba0d8d7fddd46ec7ef18336e9f7ce4c9b6c60579 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 20 Apr 2015 10:33:14 -0700 Subject: [PATCH] os/Newstore: add newstore_db_path option The load of Keyvalue DB is heavy, allow user to put DB to a seperate(fast) device. Signed-off-by: Xiaoxi Chen --- src/common/config_opts.h | 1 + src/os/newstore/NewStore.cc | 6 ++++++ src/os/newstore/NewStore.h | 1 + 3 files changed, 8 insertions(+) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index bfe7d0df665..ac913c2b0a6 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -809,6 +809,7 @@ OPTION(newstore_overlay_max_length, OPT_INT, 65536) OPTION(newstore_overlay_max, OPT_INT, 32) OPTION(newstore_open_by_handle, OPT_BOOL, true) OPTION(newstore_o_direct, OPT_BOOL, true) +OPTION(newstore_db_path, OPT_STR, "") OPTION(filestore_omap_backend, OPT_STR, "leveldb") diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index d4691f8b7f7..9db13d368c8 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -569,6 +569,7 @@ NewStore::NewStore(CephContext *cct, const string& path) cct(cct), db(NULL), fs(NULL), + db_path(cct->_conf->newstore_db_path), path_fd(-1), fsid_fd(-1), frag_fd(-1), @@ -895,6 +896,11 @@ int NewStore::mkfs() if (r < 0) goto out_close_fsid; + if (db_path != "") { + r = symlinkat(db_path.c_str(), path_fd, "db"); + if (r < 0) + goto out_close_frag; + } r = _open_db(); if (r < 0) goto out_close_frag; diff --git a/src/os/newstore/NewStore.h b/src/os/newstore/NewStore.h index 2563ba3d5bf..35b73770d63 100644 --- a/src/os/newstore/NewStore.h +++ b/src/os/newstore/NewStore.h @@ -452,6 +452,7 @@ private: KeyValueDB *db; FS *fs; uuid_d fsid; + string db_path; int path_fd; ///< open handle to $path int fsid_fd; ///< open handle (locked) to $path/fsid int frag_fd; ///< open handle to $path/fragments -- 2.47.3