From 62bfc7a1ab1587e81ed3bff0ddfbb1aa69d1c299 Mon Sep 17 00:00:00 2001 From: Rohan Mars Date: Wed, 12 Aug 2015 21:19:31 -0700 Subject: [PATCH] moved to use boost uuid implementation, based on commit 4fe89a7b14c97b2ed7f357132901beb2bdcec551 Signed-off-by: Rohan Mars Reviewed-by: Casey Bodley --- CMakeLists.txt | 1 - ceph.spec.in | 1 - configure.ac | 1 - debian/control | 3 --- src/Makefile-env.am | 2 +- src/ceph_osd.cc | 1 - src/common/Makefile.am | 2 +- src/common/blkdev.cc | 2 +- src/include/uuid.h | 40 ++++++++++++++++++++----------- src/messages/MCommand.h | 1 - src/messages/MGetPoolStats.h | 2 -- src/messages/MGetPoolStatsReply.h | 2 -- src/messages/MLog.h | 1 - src/messages/MLogAck.h | 2 -- src/messages/MMDSBeacon.h | 2 -- src/messages/MMDSMap.h | 2 -- src/messages/MStatfsReply.h | 2 +- src/os/FileJournal.h | 6 ++--- src/os/FileStore.cc | 4 ++-- src/os/KeyValueStore.cc | 4 ++-- src/test/CMakeLists.txt | 5 ---- src/test/Makefile-client.am | 14 +++++------ src/test/osd/TestOSDMap.cc | 2 +- 23 files changed, 45 insertions(+), 57 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c28362d55bfb3..1ad8d76e26350 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,6 @@ CHECK_INCLUDE_FILES("fcgios.h" FASTCGI_FASTCGIOS_DIR) CHECK_INCLUDE_FILES("fcgi_stdio.h" HAVE_FASTCGI_STDIO_H) CHECK_INCLUDE_FILES("openssl/ssl.h" HAVE_SSL_H) CHECK_INCLUDE_FILES("snappy.h" HAVE_SNAPPY_H) -CHECK_INCLUDE_FILES("uuid/uuid.h" HAVE_UUID_H) CHECK_INCLUDE_FILES("atomic_ops.h" HAVE_ATOMIC_OPS) CHECK_INCLUDE_FILES("keyutils.h" HAVE_KEYUTILS_H) diff --git a/ceph.spec.in b/ceph.spec.in index 428a3865f5bcd..9d85f76008bbe 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -95,7 +95,6 @@ BuildRequires: libaio-devel BuildRequires: libcurl-devel BuildRequires: libedit-devel BuildRequires: libxml2-devel -BuildRequires: libuuid-devel BuildRequires: libblkid-devel >= 2.17 BuildRequires: libudev-devel BuildRequires: libtool diff --git a/configure.ac b/configure.ac index 904f804164a0c..ebf280e830c16 100644 --- a/configure.ac +++ b/configure.ac @@ -274,7 +274,6 @@ AX_C_PRETTY_FUNC # Checks for libraries. ACX_PTHREAD -AC_CHECK_LIB([uuid], [uuid_parse], [true], AC_MSG_FAILURE([libuuid not found])) #Linux only dependencies if test x"$linux" = x"yes"; then diff --git a/debian/control b/debian/control index 28e8fe1b8820e..e37dfc0a5340f 100644 --- a/debian/control +++ b/debian/control @@ -50,8 +50,6 @@ Build-Depends: autoconf, python-sphinx, python-virtualenv, sdparm | hdparm, - uuid-dev, - uuid-runtime, xfslibs-dev, xfsprogs, xmlstarlet, @@ -73,7 +71,6 @@ Depends: binutils, python, python-argparse, sdparm | hdparm, - uuid-runtime, xfsprogs, python-flask, ${misc:Depends}, diff --git a/src/Makefile-env.am b/src/Makefile-env.am index e349b4f919647..1acb3563ef00a 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -145,7 +145,7 @@ AM_CCASFLAGS = -f elf64 ##################### ## library definitions and dependencies -EXTRALIBS = -luuid -lm +EXTRALIBS = -lm if FREEBSD EXTRALIBS += -lexecinfo endif # FREEBSD diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc index 3369460b6c88e..c5a369024b8f2 100644 --- a/src/ceph_osd.cc +++ b/src/ceph_osd.cc @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 2d1e2d3ed3877..a474c8ba5b367 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -135,7 +135,7 @@ LIBCOMMON_DEPS += \ $(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) if LINUX -LIBCOMMON_DEPS += -lrt -lblkid -luuid +LIBCOMMON_DEPS += -lrt -lblkid endif # LINUX libcommon_la_SOURCES = common/buffer.cc diff --git a/src/common/blkdev.cc b/src/common/blkdev.cc index eb152f83af671..f009dd13757ca 100644 --- a/src/common/blkdev.cc +++ b/src/common/blkdev.cc @@ -187,7 +187,7 @@ int get_device_by_uuid(uuid_d dev_uuid, const char* label, char* partition, blkid_dev dev = NULL; int rc = 0; - uuid_unparse((const unsigned char*)&dev_uuid.uuid, uuid_str); + dev_uuid.print(uuid_str); if (blkid_get_cache(&cache, NULL) >= 0) dev = blkid_find_dev_with_tag(cache, label, (const char*)uuid_str); diff --git a/src/include/uuid.h b/src/include/uuid.h index 942b807092262..df9e71a466224 100644 --- a/src/include/uuid.h +++ b/src/include/uuid.h @@ -8,36 +8,48 @@ #include "encoding.h" #include -extern "C" { -#include -#include -} +#include +#include +#include struct uuid_d { - uuid_t uuid; + boost::uuids::uuid uuid; uuid_d() { - memset(&uuid, 0, sizeof(uuid)); + boost::uuids::nil_generator gen; + uuid = gen(); } bool is_zero() const { - return uuid_is_null(uuid); + return uuid.is_nil(); } void generate_random() { - uuid_generate(uuid); + boost::uuids::random_generator gen; + uuid = gen(); } bool parse(const char *s) { - return uuid_parse(s, uuid) == 0; + try { + boost::uuids::string_generator gen; + uuid = gen(s); + return true; + } catch (std::runtime_error& e) { + return false; + } + } + void print(char *s) const { + memcpy(s, boost::uuids::to_string(uuid).c_str(), 37); } - void print(char *s) { - return uuid_unparse(uuid, s); + + char *bytes() const { + return (char*)uuid.data; } void encode(bufferlist& bl) const { ::encode_raw(uuid, bl); } + void decode(bufferlist::iterator& p) const { ::decode_raw(uuid, p); } @@ -46,15 +58,15 @@ WRITE_CLASS_ENCODER(uuid_d) inline std::ostream& operator<<(std::ostream& out, const uuid_d& u) { char b[37]; - uuid_unparse(u.uuid, b); + u.print(b); return out << b; } inline bool operator==(const uuid_d& l, const uuid_d& r) { - return uuid_compare(l.uuid, r.uuid) == 0; + return l.uuid == r.uuid; } inline bool operator!=(const uuid_d& l, const uuid_d& r) { - return uuid_compare(l.uuid, r.uuid) != 0; + return l.uuid != r.uuid; } diff --git a/src/messages/MCommand.h b/src/messages/MCommand.h index 802ef6942f598..d5f0b22f02472 100644 --- a/src/messages/MCommand.h +++ b/src/messages/MCommand.h @@ -16,7 +16,6 @@ #define CEPH_MCOMMAND_H #include -#include #include "msg/Message.h" diff --git a/src/messages/MGetPoolStats.h b/src/messages/MGetPoolStats.h index d004e2968aadc..b66a5b850d6bc 100644 --- a/src/messages/MGetPoolStats.h +++ b/src/messages/MGetPoolStats.h @@ -16,8 +16,6 @@ #ifndef CEPH_MGETPOOLSTATS_H #define CEPH_MGETPOOLSTATS_H -#include - #include "messages/PaxosServiceMessage.h" class MGetPoolStats : public PaxosServiceMessage { diff --git a/src/messages/MGetPoolStatsReply.h b/src/messages/MGetPoolStatsReply.h index 07b99cffd17b7..9dc2cbe17597c 100644 --- a/src/messages/MGetPoolStatsReply.h +++ b/src/messages/MGetPoolStatsReply.h @@ -16,8 +16,6 @@ #ifndef CEPH_MGETPOOLSTATSREPLY_H #define CEPH_MGETPOOLSTATSREPLY_H -#include - class MGetPoolStatsReply : public PaxosServiceMessage { public: uuid_d fsid; diff --git a/src/messages/MLog.h b/src/messages/MLog.h index c71f56bdab451..8b64e07e6fc2d 100644 --- a/src/messages/MLog.h +++ b/src/messages/MLog.h @@ -19,7 +19,6 @@ #include "messages/PaxosServiceMessage.h" #include -#include class MLog : public PaxosServiceMessage { public: diff --git a/src/messages/MLogAck.h b/src/messages/MLogAck.h index 713cee003a20f..414008c3e501a 100644 --- a/src/messages/MLogAck.h +++ b/src/messages/MLogAck.h @@ -15,8 +15,6 @@ #ifndef CEPH_MLOGACK_H #define CEPH_MLOGACK_H -#include - class MLogAck : public Message { public: uuid_d fsid; diff --git a/src/messages/MMDSBeacon.h b/src/messages/MMDSBeacon.h index da551f4e04010..e04fe3736989c 100644 --- a/src/messages/MMDSBeacon.h +++ b/src/messages/MMDSBeacon.h @@ -21,8 +21,6 @@ #include "mds/MDSMap.h" -#include - /** diff --git a/src/messages/MMDSMap.h b/src/messages/MMDSMap.h index 66566d01d3132..36b9e958144da 100644 --- a/src/messages/MMDSMap.h +++ b/src/messages/MMDSMap.h @@ -20,8 +20,6 @@ #include "mds/MDSMap.h" #include "include/ceph_features.h" -#include - class MMDSMap : public Message { public: /* diff --git a/src/messages/MStatfsReply.h b/src/messages/MStatfsReply.h index 6bf42d894d73a..59312abe700fe 100644 --- a/src/messages/MStatfsReply.h +++ b/src/messages/MStatfsReply.h @@ -22,7 +22,7 @@ public: MStatfsReply() : Message(CEPH_MSG_STATFS_REPLY) {} MStatfsReply(uuid_d &f, ceph_tid_t t, epoch_t epoch) : Message(CEPH_MSG_STATFS_REPLY) { - memcpy(&h.fsid, f.uuid, sizeof(h.fsid)); + memcpy(&h.fsid, f.bytes(), sizeof(h.fsid)); header.tid = t; h.version = epoch; } diff --git a/src/os/FileJournal.h b/src/os/FileJournal.h index 087ebe0c87adb..fbe616d301ac7 100644 --- a/src/os/FileJournal.h +++ b/src/os/FileJournal.h @@ -135,7 +135,7 @@ public: } uint64_t get_fsid64() const { - return *(uint64_t*)&fsid.uuid[0]; + return *(uint64_t*)fsid.bytes(); } void encode(bufferlist& bl) const { @@ -163,8 +163,8 @@ public: flags = 0; uint64_t tfsid; ::decode(tfsid, bl); - *(uint64_t*)&fsid.uuid[0] = tfsid; - *(uint64_t*)&fsid.uuid[8] = tfsid; + *(uint64_t*)&fsid.bytes()[0] = tfsid; + *(uint64_t*)&fsid.bytes()[8] = tfsid; ::decode(block_size, bl); ::decode(alignment, bl); ::decode(max_size, bl); diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index aed1b7d97086a..4efe9dc392269 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -960,8 +960,8 @@ int FileStore::read_fsid(int fd, uuid_d *uuid) return ret; if (ret == 8) { // old 64-bit fsid... mirror it. - *(uint64_t*)&uuid->uuid[0] = *(uint64_t*)fsid_str; - *(uint64_t*)&uuid->uuid[8] = *(uint64_t*)fsid_str; + *(uint64_t*)&uuid->bytes()[0] = *(uint64_t*)fsid_str; + *(uint64_t*)&uuid->bytes()[8] = *(uint64_t*)fsid_str; return 0; } diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 9ef3a4d4454e7..762571f1c92e5 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -738,8 +738,8 @@ int KeyValueStore::read_fsid(int fd, uuid_d *uuid) return ret; if (ret == 8) { // old 64-bit fsid... mirror it. - *(uint64_t*)&uuid->uuid[0] = *(uint64_t*)fsid_str; - *(uint64_t*)&uuid->uuid[8] = *(uint64_t*)fsid_str; + *(uint64_t*)&uuid->bytes()[0] = *(uint64_t*)fsid_str; + *(uint64_t*)&uuid->bytes()[8] = *(uint64_t*)fsid_str; return 0; } diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index f69207528fd9d..8763f972f1cfe 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -912,7 +912,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} ${TCMALLOC_LIBS} ${UNITTEST_LIBS}) @@ -939,7 +938,6 @@ if(${WITH_RADOSGW}) librados global curl - uuid expat ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} @@ -961,7 +959,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat cls_version_client cls_log_client @@ -989,7 +986,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat cls_version_client cls_log_client @@ -1027,7 +1023,6 @@ if(${WITH_RADOSGW}) cls_lock_client global curl - uuid expat ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS} diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am index 7e70dc9eddeea..01aaa0e4dc58d 100644 --- a/src/test/Makefile-client.am +++ b/src/test/Makefile-client.am @@ -176,7 +176,7 @@ bin_DEBUGPROGRAMS += ceph_test_cls_hello ceph_test_rados_api_cmd_SOURCES = test/librados/cmd.cc ceph_test_rados_api_cmd_LDADD = \ $(LIBCOMMON) $(LIBRADOS) $(CRYPTO_LIBS) \ - $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) -luuid + $(UNITTEST_LDADD) $(RADOS_TEST_LDADD) ceph_test_rados_api_cmd_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_rados_api_cmd @@ -350,7 +350,7 @@ if LINUX ceph_test_librbd_fsx_SOURCES = test/librbd/fsx.cc ceph_test_librbd_fsx_LDADD = \ $(LIBKRBD) $(LIBRBD) $(LIBRADOS) \ - $(CRYPTO_LIBS) $(PTHREAD_LIBS) -luuid + $(CRYPTO_LIBS) $(PTHREAD_LIBS) ceph_test_librbd_fsx_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_librbd_fsx endif @@ -494,7 +494,7 @@ ceph_test_cors_SOURCES = test/test_cors.cc ceph_test_cors_LDADD = \ $(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \ $(UNITTEST_LDADD) \ - -lcurl -luuid -lexpat + -lcurl -lexpat ceph_test_cors_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_cors @@ -502,7 +502,7 @@ ceph_test_rgw_manifest_SOURCES = test/rgw/test_rgw_manifest.cc ceph_test_rgw_manifest_LDADD = \ $(LIBRADOS) $(LIBRGW) $(LIBRGW_DEPS) $(CEPH_GLOBAL) \ $(UNITTEST_LDADD) $(CRYPTO_LIBS) \ - -lcurl -luuid -lexpat + -lcurl -lexpat ceph_test_rgw_manifest_CXXFLAGS = $(UNITTEST_CXXFLAGS) bin_DEBUGPROGRAMS += ceph_test_rgw_manifest @@ -511,7 +511,7 @@ ceph_test_cls_rgw_meta_SOURCES = test/test_rgw_admin_meta.cc ceph_test_cls_rgw_meta_LDADD = \ $(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \ $(UNITTEST_LDADD) $(CRYPTO_LIBS) \ - -lcurl -luuid -lexpat \ + -lcurl -lexpat \ libcls_version_client.a libcls_log_client.a \ libcls_statelog_client.a libcls_refcount_client.la \ libcls_rgw_client.la libcls_user_client.a libcls_lock_client.la @@ -522,7 +522,7 @@ ceph_test_cls_rgw_log_SOURCES = test/test_rgw_admin_log.cc ceph_test_cls_rgw_log_LDADD = \ $(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \ $(UNITTEST_LDADD) $(CRYPTO_LIBS) \ - -lcurl -luuid -lexpat \ + -lcurl -lexpat \ libcls_version_client.a libcls_log_client.a \ libcls_statelog_client.a libcls_refcount_client.la \ libcls_rgw_client.la libcls_user_client.a libcls_lock_client.la @@ -533,7 +533,7 @@ ceph_test_cls_rgw_opstate_SOURCES = test/test_rgw_admin_opstate.cc ceph_test_cls_rgw_opstate_LDADD = \ $(LIBRADOS) $(LIBRGW) $(CEPH_GLOBAL) \ $(UNITTEST_LDADD) $(CRYPTO_LIBS) \ - -lcurl -luuid -lexpat \ + -lcurl -lexpat \ libcls_version_client.a libcls_log_client.a \ libcls_statelog_client.a libcls_refcount_client.la \ libcls_rgw_client.la libcls_user_client.a libcls_lock_client.la \ diff --git a/src/test/osd/TestOSDMap.cc b/src/test/osd/TestOSDMap.cc index d4b05ac16e14a..ea4053f3f7891 100644 --- a/src/test/osd/TestOSDMap.cc +++ b/src/test/osd/TestOSDMap.cc @@ -38,7 +38,7 @@ public: entity_addr_t sample_addr; uuid_d sample_uuid; for (int i = 0; i < num_osds; ++i) { - sample_uuid.uuid[i] = i; + sample_uuid.generate_random(); sample_addr.nonce = i; pending_inc.new_state[i] = CEPH_OSD_EXISTS | CEPH_OSD_NEW; pending_inc.new_up_client[i] = sample_addr; -- 2.39.5