Skip to content

Commit

Permalink
Merge pull request #9741: hammer: boost uuid makes valgrind complain
Browse files Browse the repository at this point in the history
Reviewed-by: Nathan Cutler <ncutler@suse.com>
  • Loading branch information
smithfarm committed Jun 27, 2016
2 parents 5ea9912 + 187d308 commit ca5f8fb
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 56 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion ceph.spec.in
Expand Up @@ -50,6 +50,7 @@ BuildRequires: sharutils
%endif
BuildRequires: gcc-c++
BuildRequires: boost-devel
BuildRequires: boost-random
%if 0%{defined suse_version}
BuildRequires: libbz2-devel
%else
Expand All @@ -63,7 +64,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
Expand Down
12 changes: 11 additions & 1 deletion configure.ac
Expand Up @@ -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
Expand Down Expand Up @@ -883,6 +882,17 @@ BOOST_THREAD_LIBS="${LIBS}"
LIBS="${saved_LIBS}"
AC_SUBST(BOOST_THREAD_LIBS)

# boost-random
BOOST_RANDOM_LIBS=""
saved_LIBS="${LIBS}"
LIBS=""
AC_CHECK_LIB(boost_random, main, [],
[AC_CHECK_LIB(boost_random, main, [],
AC_MSG_FAILURE(["Boost random library not found."]))])
BOOST_RANDOM_LIBS="${LIBS}"
LIBS="${saved_LIBS}"
AC_SUBST(BOOST_RANDOM_LIBS)

#
# Check for boost_program_options library (defines BOOST_PROGRAM_OPTIONS_LIBS).
#
Expand Down
4 changes: 1 addition & 3 deletions debian/control
Expand Up @@ -27,6 +27,7 @@ Build-Depends: autoconf,
libboost-program-options-dev (>= 1.42),
libboost-system-dev (>= 1.42),
libboost-thread-dev (>= 1.42),
libboost-random-dev,
libcurl4-gnutls-dev,
libedit-dev,
libexpat1-dev,
Expand All @@ -50,8 +51,6 @@ Build-Depends: autoconf,
python-virtualenv,
sdparm | hdparm,
sed,
uuid-dev,
uuid-runtime,
xfslibs-dev,
xfsprogs,
xmlstarlet,
Expand All @@ -71,7 +70,6 @@ Depends: binutils,
python,
python-argparse,
sdparm | hdparm,
uuid-runtime,
xfsprogs,
python-flask,
${misc:Depends},
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile-env.am
Expand Up @@ -120,7 +120,7 @@ AM_CCASFLAGS = -f elf64
#####################
## library definitions and dependencies

EXTRALIBS = -luuid -lm
EXTRALIBS = -lm
if FREEBSD
EXTRALIBS += -lexecinfo
endif # FREEBSD
Expand Down
1 change: 0 additions & 1 deletion src/ceph_osd.cc
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion src/common/Makefile.am
Expand Up @@ -134,7 +134,8 @@ noinst_HEADERS += \
LIBCOMMON_DEPS += \
$(LIBERASURE_CODE) \
$(LIBMSG) $(LIBAUTH) \
$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH)
$(LIBCRUSH) $(LIBJSON_SPIRIT) $(LIBLOG) $(LIBARCH) \
$(BOOST_RANDOM_LIBS)

if LINUX
LIBCOMMON_DEPS += -lrt
Expand Down
42 changes: 28 additions & 14 deletions src/include/uuid.h
Expand Up @@ -8,36 +8,50 @@
#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>
#include <boost/random/random_device.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::random::random_device rng("/dev/urandom");
boost::uuids::basic_random_generator<boost::random::random_device> gen(&rng);
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);
}
Expand All @@ -46,15 +60,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;
}


Expand Down
1 change: 0 additions & 1 deletion src/messages/MCommand.h
Expand Up @@ -16,7 +16,6 @@
#define CEPH_MCOMMAND_H

#include <vector>
#include <uuid/uuid.h>

#include "msg/Message.h"

Expand Down
2 changes: 0 additions & 2 deletions src/messages/MGetPoolStats.h
Expand Up @@ -16,8 +16,6 @@
#ifndef CEPH_MGETPOOLSTATS_H
#define CEPH_MGETPOOLSTATS_H

#include <uuid/uuid.h>

#include "messages/PaxosServiceMessage.h"

class MGetPoolStats : public PaxosServiceMessage {
Expand Down
2 changes: 0 additions & 2 deletions src/messages/MGetPoolStatsReply.h
Expand Up @@ -16,8 +16,6 @@
#ifndef CEPH_MGETPOOLSTATSREPLY_H
#define CEPH_MGETPOOLSTATSREPLY_H

#include <uuid/uuid.h>

class MGetPoolStatsReply : public PaxosServiceMessage {
public:
uuid_d fsid;
Expand Down
1 change: 0 additions & 1 deletion src/messages/MLog.h
Expand Up @@ -19,7 +19,6 @@
#include "messages/PaxosServiceMessage.h"

#include <deque>
#include <uuid/uuid.h>

class MLog : public PaxosServiceMessage {
public:
Expand Down
2 changes: 0 additions & 2 deletions src/messages/MLogAck.h
Expand Up @@ -15,8 +15,6 @@
#ifndef CEPH_MLOGACK_H
#define CEPH_MLOGACK_H

#include <uuid/uuid.h>

class MLogAck : public Message {
public:
uuid_d fsid;
Expand Down
2 changes: 0 additions & 2 deletions src/messages/MMDSBeacon.h
Expand Up @@ -21,8 +21,6 @@

#include "mds/MDSMap.h"

#include <uuid/uuid.h>



/**
Expand Down
2 changes: 0 additions & 2 deletions src/messages/MMDSMap.h
Expand Up @@ -20,8 +20,6 @@
#include "mds/MDSMap.h"
#include "include/ceph_features.h"

#include <uuid/uuid.h>

class MMDSMap : public Message {
public:
/*
Expand Down
2 changes: 1 addition & 1 deletion src/messages/MStatfsReply.h
Expand Up @@ -22,7 +22,7 @@ class MStatfsReply : public Message {

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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/os/FileJournal.h
Expand Up @@ -135,7 +135,7 @@ class FileJournal : public Journal {
}

uint64_t get_fsid64() const {
return *(uint64_t*)&fsid.uuid[0];
return *(uint64_t*)fsid.bytes();
}

void encode(bufferlist& bl) const {
Expand Down Expand Up @@ -163,8 +163,8 @@ class FileJournal : public Journal {
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);
Expand Down
4 changes: 2 additions & 2 deletions src/os/FileStore.cc
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/os/KeyValueStore.cc
Expand Up @@ -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;
}

Expand Down
5 changes: 0 additions & 5 deletions src/test/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -984,7 +983,6 @@ if(${WITH_RADOSGW})
librados
global
curl
uuid
expat
${CMAKE_DL_LIBS}
${TCMALLOC_LIBS}
Expand All @@ -1005,7 +1003,6 @@ if(${WITH_RADOSGW})
rgw_a
global
curl
uuid
expat
cls_version_client
cls_log_client
Expand All @@ -1032,7 +1029,6 @@ if(${WITH_RADOSGW})
rgw_a
global
curl
uuid
expat
cls_version_client
cls_log_client
Expand Down Expand Up @@ -1069,7 +1065,6 @@ if(${WITH_RADOSGW})
cls_lock_client
global
curl
uuid
expat
${CMAKE_DL_LIBS}
${TCMALLOC_LIBS}
Expand Down
14 changes: 7 additions & 7 deletions src/test/Makefile-client.am
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -485,15 +485,15 @@ 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

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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ca5f8fb

Please sign in to comment.