From: Yehuda Sadeh Date: Mon, 26 Sep 2016 23:06:17 +0000 (-0700) Subject: rgw: use bucket_info.bucket_id instead of marker where needed X-Git-Tag: v0.94.10~8^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d41cbb44c55cf2dca5ab25d5a1ec76e30db26150;p=ceph.git 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 --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5854c64dbf8..8132bceaf8f 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2629,7 +2629,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); @@ -2637,6 +2637,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. @@ -4562,13 +4571,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; } @@ -4582,13 +4591,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;