From: Rohan Mars Date: Thu, 13 Aug 2015 04:19:31 +0000 (-0700) Subject: moved to use boost uuid implementation, based on commit 4fe89a7b14c97b2ed7f357132901b... X-Git-Tag: v0.94.8~6^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=174de7fce8080df6e02b363e7821e8cca6f8157f;p=ceph.git moved to use boost uuid implementation, based on commit 4fe89a7b14c97b2ed7f357132901beb2bdcec551 Signed-off-by: Rohan Mars Reviewed-by: Casey Bodley (cherry picked from commit 62bfc7a1ab1587e81ed3bff0ddfbb1aa69d1c299) Conflicts: debian/control (trivial resolution) src/common/Makefile.am (trivial resolution) src/common/blkdev.cc (no get_device_by_uuid() function in hammer) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f827fcf2a460..ba6fbe33194c 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 e36fd0fbbb73..600afc50676c 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -63,7 +63,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 d1f98aac33f1..2fa729bcda1d 100644 --- a/configure.ac +++ b/configure.ac @@ -255,7 +255,6 @@ AX_C_PRETTY_FUNC # Checks for libraries. ACX_PTHREAD -AC_CHECK_LIB([uuid], [uuid_parse], [true], AC_MSG_FAILURE([libuuid not found])) # rbd {map,unmap,showmapped} dependencies, Linux only if test x"$linux" = x"yes" -a x"$with_rbd" = x"yes"; then diff --git a/debian/control b/debian/control index 2289ca304519..c16db0f550dd 100644 --- a/debian/control +++ b/debian/control @@ -50,8 +50,6 @@ Build-Depends: autoconf, python-virtualenv, sdparm | hdparm, sed, - uuid-dev, - uuid-runtime, xfslibs-dev, xfsprogs, xmlstarlet, @@ -71,7 +69,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 8a00954c0331..c28a355d1f32 100644 --- a/src/Makefile-env.am +++ b/src/Makefile-env.am @@ -120,7 +120,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 18bc46c86892..73fa937d6395 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/include/uuid.h b/src/include/uuid.h index 942b80709226..df9e71a46622 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 802ef6942f59..d5f0b22f0247 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 d004e2968aad..b66a5b850d6b 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 07b99cffd17b..9dc2cbe17597 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 c71f56bdab45..8b64e07e6fc2 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 713cee003a20..414008c3e501 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 48d5d04e5611..60ce7d4e2e7a 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 66566d01d313..36b9e958144d 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 6bf42d894d73..59312abe700f 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 9e07b4046d97..8077e29f9bbd 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 c7f9bea31a9e..2a41d7402fc2 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -944,8 +944,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 1881f2dcc17a..95346e410ffe 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -693,8 +693,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 73e80840949e..315df9eadcb8 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -958,7 +958,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat ${CMAKE_DL_LIBS} ${TCMALLOC_LIBS} ${UNITTEST_LIBS}) set_target_properties(test_cors PROPERTIES COMPILE_FLAGS @@ -984,7 +983,6 @@ if(${WITH_RADOSGW}) librados global curl - uuid expat ${CMAKE_DL_LIBS} ${TCMALLOC_LIBS} @@ -1005,7 +1003,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat cls_version_client cls_log_client @@ -1032,7 +1029,6 @@ if(${WITH_RADOSGW}) rgw_a global curl - uuid expat cls_version_client cls_log_client @@ -1069,7 +1065,6 @@ if(${WITH_RADOSGW}) cls_lock_client global curl - uuid expat ${CMAKE_DL_LIBS} ${TCMALLOC_LIBS} diff --git a/src/test/Makefile-client.am b/src/test/Makefile-client.am index d5b506bb7c48..094c1c32def1 100644 --- a/src/test/Makefile-client.am +++ b/src/test/Makefile-client.am @@ -175,7 +175,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 @@ -342,7 +342,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 @@ -485,7 +485,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 @@ -493,7 +493,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 @@ -502,7 +502,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 @@ -513,7 +513,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 @@ -524,7 +524,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 d4b05ac16e14..ea4053f3f789 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;