]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
moved to use boost uuid implementation, based on commit 4fe89a7b14c97b2ed7f357132901b...
authorRohan Mars <code@rohanmars.com>
Thu, 13 Aug 2015 04:19:31 +0000 (21:19 -0700)
committerSage Weil <sage@redhat.com>
Wed, 19 Aug 2015 10:46:17 +0000 (06:46 -0400)
Signed-off-by: Rohan Mars <code@rohanmars.com>
Reviewed-by: Casey Bodley <cbodley@redhat.com>
23 files changed:
CMakeLists.txt
ceph.spec.in
configure.ac
debian/control
src/Makefile-env.am
src/ceph_osd.cc
src/common/Makefile.am
src/common/blkdev.cc
src/include/uuid.h
src/messages/MCommand.h
src/messages/MGetPoolStats.h
src/messages/MGetPoolStatsReply.h
src/messages/MLog.h
src/messages/MLogAck.h
src/messages/MMDSBeacon.h
src/messages/MMDSMap.h
src/messages/MStatfsReply.h
src/os/FileJournal.h
src/os/FileStore.cc
src/os/KeyValueStore.cc
src/test/CMakeLists.txt
src/test/Makefile-client.am
src/test/osd/TestOSDMap.cc

index c28362d55bfb334fd089acc26b750e0b033a4ce7..1ad8d76e263502d0457daf33281bca0b15ef2888 100644 (file)
@@ -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)
 
index 428a3865f5bcda0c609fd8ec11c2a1d4b2499cb0..9d85f76008bbee421b8cf74f0f01c1acd4266b8b 100644 (file)
@@ -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
index 904f804164a0cd0c420257c507bc499713ac139f..ebf280e830c16ef3a8ffc3b56dc4e6f11bd1c284 100644 (file)
@@ -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
index 28e8fe1b8820e8150eb4c7a8d46358a828cd500d..e37dfc0a5340f9c3fd12c6a9215652501dada7bb 100644 (file)
@@ -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},
index e349b4f9196470f826fd48178a346683aeeb4802..1acb3563ef00ac00d45fe0e4d817af0d89fae87c 100644 (file)
@@ -145,7 +145,7 @@ AM_CCASFLAGS = -f elf64
 #####################
 ## library definitions and dependencies
 
-EXTRALIBS = -luuid -lm
+EXTRALIBS = -lm
 if FREEBSD
 EXTRALIBS += -lexecinfo
 endif # FREEBSD
index 3369460b6c88e80662567634e45836c9cc15a8ca..c5a369024b8f24f6a33fd4925cfa34a79776b8ea 100644 (file)
@@ -15,7 +15,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <uuid/uuid.h>
 #include <boost/scoped_ptr.hpp>
 
 #include <iostream>
index 2d1e2d3ed3877b956aa4c06a7958c4a53185d130..a474c8ba5b367be55e1767faa74e2596657eb939 100644 (file)
@@ -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
index eb152f83af671c61064c280f074d4c03861db11b..f009dd13757ca1a7831013d3235366587d44f2fe 100644 (file)
@@ -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);
index 942b80709226254d5e3ec90e525c57c7c76b5203..df9e71a466224ca31d6060817322f6a7d4a653b1 100644 (file)
@@ -8,36 +8,48 @@
 #include "encoding.h"
 #include <ostream>
 
-extern "C" {
-#include <uuid/uuid.h>
-#include <unistd.h>
-}
+#include <boost/uuid/uuid.hpp>
+#include <boost/uuid/uuid_generators.hpp>
+#include <boost/uuid/uuid_io.hpp>
 
 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;
 }
 
 
index 802ef6942f5987e08c7a1c68a3fac8e04bd89cdf..d5f0b22f02472f7f2c9076614653876576a77615 100644 (file)
@@ -16,7 +16,6 @@
 #define CEPH_MCOMMAND_H
 
 #include <vector>
-#include <uuid/uuid.h>
 
 #include "msg/Message.h"
 
index d004e2968aadcf32c9946834b1962ee696af6c2e..b66a5b850d6bc0b2b09c2357ebab4ef199263495 100644 (file)
@@ -16,8 +16,6 @@
 #ifndef CEPH_MGETPOOLSTATS_H
 #define CEPH_MGETPOOLSTATS_H
 
-#include <uuid/uuid.h>
-
 #include "messages/PaxosServiceMessage.h"
 
 class MGetPoolStats : public PaxosServiceMessage {
index 07b99cffd17b749a59a0404888a066cb33154be0..9dc2cbe17597ca6df86588562d82a3ae609fc528 100644 (file)
@@ -16,8 +16,6 @@
 #ifndef CEPH_MGETPOOLSTATSREPLY_H
 #define CEPH_MGETPOOLSTATSREPLY_H
 
-#include <uuid/uuid.h>
-
 class MGetPoolStatsReply : public PaxosServiceMessage {
 public:
   uuid_d fsid;
index c71f56bdab451f462937280fa4b0bf0ce16396b2..8b64e07e6fc2da9783752ee50147f388967ca505 100644 (file)
@@ -19,7 +19,6 @@
 #include "messages/PaxosServiceMessage.h"
 
 #include <deque>
-#include <uuid/uuid.h>
 
 class MLog : public PaxosServiceMessage {
 public:
index 713cee003a20f8091d65accae942c59c5d6390f0..414008c3e501a5f36aff6d88e2e16ee72b7f3c6e 100644 (file)
@@ -15,8 +15,6 @@
 #ifndef CEPH_MLOGACK_H
 #define CEPH_MLOGACK_H
 
-#include <uuid/uuid.h>
-
 class MLogAck : public Message {
 public:
   uuid_d fsid;
index da551f4e0401086d9e5e538f22b054b2de3fe957..e04fe3736989c6e89c28852a7e93c4ea1811bc4f 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "mds/MDSMap.h"
 
-#include <uuid/uuid.h>
-
 
 
 /**
index 66566d01d31322461ae66b151457995eb504ca0e..36b9e958144da2ecd6bf8597683ef64acf03da5c 100644 (file)
@@ -20,8 +20,6 @@
 #include "mds/MDSMap.h"
 #include "include/ceph_features.h"
 
-#include <uuid/uuid.h>
-
 class MMDSMap : public Message {
  public:
   /*
index 6bf42d894d73a5d160f9a58d1ee67c70afb8a3d1..59312abe700fe80c1af34656ee0bee94a5f492a4 100644 (file)
@@ -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;
   }
index 087ebe0c87adbea9e691dd8c7d41e8244de0fe74..fbe616d301ac70f001d1e546261a454288c4a4e4 100644 (file)
@@ -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);
index aed1b7d97086a505f00be22c8de63cd8e5fcec2d..4efe9dc392269b94eaa95ac782eff66d9f75ba18 100644 (file)
@@ -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;
   }
 
index 9ef3a4d4454e71e55c3cf6a75d9715475d7771cf..762571f1c92e5b0d16f5d3f97c0b1d26943d2546 100644 (file)
@@ -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;
   }
 
index f69207528fd9d3c53f68f828a5e111a8cd3df4db..8763f972f1cfea77996117b364b48d64af811d24 100644 (file)
@@ -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}
index 7e70dc9eddeeadbe06224de64aa7042b38cfd6a8..01aaa0e4dc58d987edda83bd4f4505ae4d8c7c68 100644 (file)
@@ -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 \
index d4b05ac16e14a931c298ba4ed879ddefe65d9df8..ea4053f3f7891be01784dcb7631271706590ab61 100644 (file)
@@ -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;