mirror of
https://github.com/ceph/ceph
synced 2025-02-23 02:57:21 +00:00
Merge pull request #22675 from nuyhah/fix_block_name_prefix
librbd: block_name_prefix is not created randomly Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
722724e829
@ -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
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user