Skip to content

Commit

Permalink
librbd: block_name_prefix is not created randomly
Browse files Browse the repository at this point in the history
fixes: http://tracker.ceph.com/issues/24634
Signed-off-by: hyun ha hyun.ha@navercorp.com
  • Loading branch information
hyun-ha authored and Jason Dillaman committed Sep 11, 2018
1 parent 86f3bcf commit be83736
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/librbd/Utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "common/dout.h"
#include "librbd/ImageCtx.h"
#include "librbd/Features.h"
#include <random>

#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
Expand Down Expand Up @@ -51,7 +52,9 @@ std::string generate_image_id(librados::IoCtx &ioctx) {
librados::Rados rados(ioctx);

uint64_t bid = rados.get_instance_id();
uint32_t extra = rand() % 0xFFFFFFFF;
std::mt19937 generator{std::random_device{}()};
std::uniform_int_distribution<uint32_t> distribution{0, 0xFFFFFFFF};
uint32_t extra = distribution(generator);

ostringstream bid_ss;
bid_ss << std::hex << bid << std::hex << extra;
Expand Down

0 comments on commit be83736

Please sign in to comment.