From: Sage Weil Date: Fri, 23 Dec 2016 18:55:45 +0000 (-0500) Subject: os/bluestore,kstore: combine kv helpers in header X-Git-Tag: v12.0.0~181^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=685002ba6a70d6d8a32b1e3aed9e30966ac99b82;p=ceph.git os/bluestore,kstore: combine kv helpers in header Signed-off-by: Sage Weil --- diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index f751f97ed03..3ade0295a79 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -21,7 +21,6 @@ set(libos_srcs filestore/WBThrottle.cc filestore/ZFSFileStoreBackend.cc memstore/MemStore.cc - kstore/kv.cc kstore/KStore.cc kstore/kstore_types.cc fs/FS.cc diff --git a/src/os/bluestore/BitmapFreelistManager.cc b/src/os/bluestore/BitmapFreelistManager.cc index 1a1f9af8594..f5914011ecc 100644 --- a/src/os/bluestore/BitmapFreelistManager.cc +++ b/src/os/bluestore/BitmapFreelistManager.cc @@ -3,7 +3,7 @@ #include "BitmapFreelistManager.h" #include "kv/KeyValueDB.h" -#include "kv.h" +#include "os/kv.h" #include "common/debug.h" diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 4fec89b7932..a5f406f06dc 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -18,7 +18,7 @@ #include #include "BlueStore.h" -#include "kv.h" +#include "os/kv.h" #include "include/compat.h" #include "include/intarith.h" #include "include/stringify.h" diff --git a/src/os/bluestore/ExtentFreelistManager.cc b/src/os/bluestore/ExtentFreelistManager.cc index 85174e1834f..f211e5b8da4 100644 --- a/src/os/bluestore/ExtentFreelistManager.cc +++ b/src/os/bluestore/ExtentFreelistManager.cc @@ -3,7 +3,7 @@ #include "ExtentFreelistManager.h" #include "kv/KeyValueDB.h" -#include "kv.h" +#include "os/kv.h" #include "common/debug.h" diff --git a/src/os/bluestore/kv.cc b/src/os/bluestore/kv.cc deleted file mode 100644 index 8004e128786..00000000000 --- a/src/os/bluestore/kv.cc +++ /dev/null @@ -1,61 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "kv.h" - -#include "include/byteorder.h" -#include - -void _key_encode_u32(uint32_t u, std::string *key) -{ - uint32_t bu; -#ifdef CEPH_BIG_ENDIAN - bu = u; -#elif defined(CEPH_LITTLE_ENDIAN) - bu = swab32(u); -#else -# error wtf -#endif - key->append((char*)&bu, 4); -} - -const char *_key_decode_u32(const char *key, uint32_t *pu) -{ - uint32_t bu; - memcpy(&bu, key, 4); -#ifdef CEPH_BIG_ENDIAN - *pu = bu; -#elif defined(CEPH_LITTLE_ENDIAN) - *pu = swab32(bu); -#else -# error wtf -#endif - return key + 4; -} - -void _key_encode_u64(uint64_t u, std::string *key) -{ - uint64_t bu; -#ifdef CEPH_BIG_ENDIAN - bu = u; -#elif defined(CEPH_LITTLE_ENDIAN) - bu = swab64(u); -#else -# error wtf -#endif - key->append((char*)&bu, 8); -} - -const char *_key_decode_u64(const char *key, uint64_t *pu) -{ - uint64_t bu; - memcpy(&bu, key, 8); -#ifdef CEPH_BIG_ENDIAN - *pu = bu; -#elif defined(CEPH_LITTLE_ENDIAN) - *pu = swab64(bu); -#else -# error wtf -#endif - return key + 8; -} diff --git a/src/os/bluestore/kv.h b/src/os/bluestore/kv.h deleted file mode 100644 index 7a52d4f2dcf..00000000000 --- a/src/os/bluestore/kv.h +++ /dev/null @@ -1,15 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#ifndef CEPH_OS_BLUESTORE_KV_H -#define CEPH_OS_BLUESTORE_KV_H - -#include - -// some key encoding helpers -void _key_encode_u32(uint32_t u, std::string *key); -const char *_key_decode_u32(const char *key, uint32_t *pu); -void _key_encode_u64(uint64_t u, std::string *key); -const char *_key_decode_u64(const char *key, uint64_t *pu); - -#endif diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index 025fff8fd95..2319050423e 100755 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -21,7 +21,7 @@ #include "KStore.h" #include "osd/osd_types.h" -#include "kv.h" +#include "os/kv.h" #include "include/compat.h" #include "include/stringify.h" #include "common/errno.h" diff --git a/src/os/kstore/kv.cc b/src/os/kstore/kv.cc deleted file mode 100644 index 8004e128786..00000000000 --- a/src/os/kstore/kv.cc +++ /dev/null @@ -1,61 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "kv.h" - -#include "include/byteorder.h" -#include - -void _key_encode_u32(uint32_t u, std::string *key) -{ - uint32_t bu; -#ifdef CEPH_BIG_ENDIAN - bu = u; -#elif defined(CEPH_LITTLE_ENDIAN) - bu = swab32(u); -#else -# error wtf -#endif - key->append((char*)&bu, 4); -} - -const char *_key_decode_u32(const char *key, uint32_t *pu) -{ - uint32_t bu; - memcpy(&bu, key, 4); -#ifdef CEPH_BIG_ENDIAN - *pu = bu; -#elif defined(CEPH_LITTLE_ENDIAN) - *pu = swab32(bu); -#else -# error wtf -#endif - return key + 4; -} - -void _key_encode_u64(uint64_t u, std::string *key) -{ - uint64_t bu; -#ifdef CEPH_BIG_ENDIAN - bu = u; -#elif defined(CEPH_LITTLE_ENDIAN) - bu = swab64(u); -#else -# error wtf -#endif - key->append((char*)&bu, 8); -} - -const char *_key_decode_u64(const char *key, uint64_t *pu) -{ - uint64_t bu; - memcpy(&bu, key, 8); -#ifdef CEPH_BIG_ENDIAN - *pu = bu; -#elif defined(CEPH_LITTLE_ENDIAN) - *pu = swab64(bu); -#else -# error wtf -#endif - return key + 8; -} diff --git a/src/os/kstore/kv.h b/src/os/kstore/kv.h deleted file mode 100644 index 51fc7ed3d7d..00000000000 --- a/src/os/kstore/kv.h +++ /dev/null @@ -1,15 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#ifndef CEPH_OS_NEWSTORE_KV_H -#define CEPH_OS_NEWSTORE_KV_H - -#include - -// some key encoding helpers -void _key_encode_u32(uint32_t u, std::string *key); -const char *_key_decode_u32(const char *key, uint32_t *pu); -void _key_encode_u64(uint64_t u, std::string *key); -const char *_key_decode_u64(const char *key, uint64_t *pu); - -#endif diff --git a/src/os/kv.h b/src/os/kv.h new file mode 100644 index 00000000000..433526c554d --- /dev/null +++ b/src/os/kv.h @@ -0,0 +1,63 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_OS_KV_H +#define CEPH_OS_KV_H + +#include +#include "include/byteorder.h" + +// some key encoding helpers +template +inline static void _key_encode_u32(uint32_t u, T *key) { + uint32_t bu; +#ifdef CEPH_BIG_ENDIAN + bu = u; +#elif defined(CEPH_LITTLE_ENDIAN) + bu = swab32(u); +#else +# error wtf +#endif + key->append((char*)&bu, 4); +} + +inline static const char *_key_decode_u32(const char *key, uint32_t *pu) { + uint32_t bu; + memcpy(&bu, key, 4); +#ifdef CEPH_BIG_ENDIAN + *pu = bu; +#elif defined(CEPH_LITTLE_ENDIAN) + *pu = swab32(bu); +#else +# error wtf +#endif + return key + 4; +} + +template +inline static void _key_encode_u64(uint64_t u, T *key) { + uint64_t bu; +#ifdef CEPH_BIG_ENDIAN + bu = u; +#elif defined(CEPH_LITTLE_ENDIAN) + bu = swab64(u); +#else +# error wtf +#endif + key->append((char*)&bu, 8); +} + +inline static const char *_key_decode_u64(const char *key, uint64_t *pu) { + uint64_t bu; + memcpy(&bu, key, 8); +#ifdef CEPH_BIG_ENDIAN + *pu = bu; +#elif defined(CEPH_LITTLE_ENDIAN) + *pu = swab64(bu); +#else +# error wtf +#endif + return key + 8; +} + +#endif