From 94afaf722fc8289af6e75025ba7d783f11c4b7d0 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 26 Sep 2016 16:06:17 -0700 Subject: [PATCH] rgw: use bucket_info.bucket_id instead of marker where needed We used to use these interchangeably, but they actually have diffent meaning. The marker is the prefix we assign to the objects in this bucket, whereas the bucket_id is the bucket instance's id. These used to hold the same value, but with bucket resharding it's not going to be true anymore. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_rados.cc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c265a659160b2..3e1229ed0eca1 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5274,7 +5274,7 @@ int RGWRados::init_bucket_index(rgw_bucket& bucket, int num_shards) return r; string dir_oid = dir_oid_prefix; - dir_oid.append(bucket.marker); + dir_oid.append(bucket.bucket_id); map bucket_objs; get_bucket_index_objects(dir_oid, num_shards, bucket_objs); @@ -5282,6 +5282,15 @@ int RGWRados::init_bucket_index(rgw_bucket& bucket, int num_shards) return CLSRGWIssueBucketIndexInit(index_ctx, bucket_objs, cct->_conf->rgw_bucket_index_max_aio)(); } +void RGWRados::create_bucket_id(string *bucket_id) +{ + uint64_t iid = instance_id(); + uint64_t bid = next_bucket_id(); + char buf[get_zone_params().get_id().size() + 48]; + snprintf(buf, sizeof(buf), "%s.%llu.%llu", get_zone_params().get_id().c_str(), (long long)iid, (long long)bid); + *bucket_id = buf; +} + /** * create a bucket with name bucket and the given list of attrs * returns 0 on success, -ERR# otherwise. @@ -7793,13 +7802,13 @@ int RGWRados::open_bucket_index(rgw_bucket& bucket, librados::IoCtx& index_ctx, if (r < 0) return r; - if (bucket.marker.empty()) { - ldout(cct, 0) << "ERROR: empty marker for bucket operation" << dendl; + if (bucket.bucket_id.empty()) { + ldout(cct, 0) << "ERROR: empty bucket id for bucket operation" << dendl; return -EIO; } bucket_oid = dir_oid_prefix; - bucket_oid.append(bucket.marker); + bucket_oid.append(bucket.bucket_id); return 0; } @@ -7810,13 +7819,13 @@ int RGWRados::open_bucket_index_base(rgw_bucket& bucket, librados::IoCtx& index_ if (r < 0) return r; - if (bucket.marker.empty()) { - ldout(cct, 0) << "ERROR: empty marker for bucket operation" << dendl; + if (bucket.bucket_id.empty()) { + ldout(cct, 0) << "ERROR: empty bucket_id for bucket operation" << dendl; return -EIO; } bucket_oid_base = dir_oid_prefix; - bucket_oid_base.append(bucket.marker); + bucket_oid_base.append(bucket.bucket_id); return 0; -- 2.39.5