Skip to content

Commit

Permalink
rgw: use bucket_info.bucket_id instead of marker where needed
Browse files Browse the repository at this point in the history
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 <yehuda@redhat.com>
(cherry picked from commit 94afaf7)
See: http://tracker.ceph.com/issues/17556
See: #11368
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
  • Loading branch information
yehudasa authored and Robin H. Johnson committed Feb 9, 2017
1 parent 5fe58c5 commit 0ce2a12
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/rgw/rgw_rados.cc
Expand Up @@ -5112,14 +5112,23 @@ 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<int, string> bucket_objs;
get_bucket_index_objects(dir_oid, num_shards, bucket_objs);

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.
Expand Down Expand Up @@ -7518,13 +7527,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;
}
Expand All @@ -7535,13 +7544,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;

Expand Down

0 comments on commit 0ce2a12

Please sign in to comment.