mirror of
https://github.com/ceph/ceph
synced 2025-01-20 18:21:57 +00:00
rgw: remove references to pool_id and replace with new bucket_id.
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
This commit is contained in:
parent
57ea6b67e7
commit
c2fbde4df7
@ -816,11 +816,7 @@ int main(int argc, char **argv)
|
||||
return r;
|
||||
}
|
||||
bucket = bucket_info.bucket;
|
||||
int ret = rgwstore->get_bucket_id(bucket, (uint64_t *)&bucket_id);
|
||||
if (ret < 0) {
|
||||
cerr << "could not get bucket id for bucket" << bucket << std::endl;
|
||||
return ret;
|
||||
}
|
||||
bucket_id = bucket.bucket_id;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1104,7 +1100,7 @@ int main(int argc, char **argv)
|
||||
bufferlist::iterator first_iter = iter;
|
||||
if (!first_iter.end()) {
|
||||
::decode(entry, first_iter);
|
||||
int ret = rgw_retrieve_pool_info(entry.pool_id, pool_info);
|
||||
int ret = rgw_retrieve_pool_info(entry.bucket_id, pool_info);
|
||||
if (ret >= 0) {
|
||||
formatter->dump_string("bucket", pool_info.bucket.name.c_str());
|
||||
formatter->dump_string("pool", pool_info.bucket.pool.c_str());
|
||||
@ -1112,7 +1108,7 @@ int main(int argc, char **argv)
|
||||
} else {
|
||||
cerr << "could not retrieve pool info for bucket_id=" << bucket_id << std::endl;
|
||||
}
|
||||
formatter->dump_format("bucket_id", "%lld", entry.pool_id);
|
||||
formatter->dump_format("bucket_id", "%lld", entry.bucket_id);
|
||||
}
|
||||
formatter->open_array_section("log_entries");
|
||||
}
|
||||
@ -1209,7 +1205,7 @@ int main(int argc, char **argv)
|
||||
formatter->open_object_section("stats");
|
||||
formatter->dump_string("bucket", bucket.name.c_str());
|
||||
formatter->dump_string("pool", bucket.pool.c_str());
|
||||
formatter->dump_int("id", bucket_id);
|
||||
formatter->dump_int("id", bucket.bucket_id);
|
||||
formatter->dump_string("marker", bucket.marker.c_str());
|
||||
formatter->dump_string("owner", pool_info.owner.c_str());
|
||||
formatter->open_array_section("categories");
|
||||
|
@ -353,19 +353,23 @@ struct rgw_bucket {
|
||||
std::string name;
|
||||
std::string pool;
|
||||
std::string marker;
|
||||
uint64_t bucket_id;
|
||||
|
||||
rgw_bucket() {}
|
||||
rgw_bucket(const char *n) : name(n) {
|
||||
assert(*n == '.'); // only rgw private buckets should be initialized without pool
|
||||
pool = n;
|
||||
marker = "";
|
||||
bucket_id = 0;
|
||||
}
|
||||
rgw_bucket(const char *n, const char *p, const char *m) : name(n), pool(p), marker(m) {}
|
||||
rgw_bucket(const char *n, const char *p, const char *m, uint64_t id) :
|
||||
name(n), pool(p), marker(m), bucket_id(id) {}
|
||||
|
||||
void clear() {
|
||||
name = "";
|
||||
pool = "";
|
||||
marker = "";
|
||||
bucket_id = 0;
|
||||
}
|
||||
|
||||
void encode(bufferlist& bl) const {
|
||||
@ -374,14 +378,17 @@ struct rgw_bucket {
|
||||
::encode(name, bl);
|
||||
::encode(pool, bl);
|
||||
::encode(marker, bl);
|
||||
::encode(bucket_id, bl);
|
||||
}
|
||||
void decode(bufferlist::iterator& bl) {
|
||||
__u8 struct_v;
|
||||
::decode(struct_v, bl);
|
||||
::decode(name, bl);
|
||||
::decode(pool, bl);
|
||||
if (struct_v >= 2)
|
||||
if (struct_v >= 2) {
|
||||
::decode(marker, bl);
|
||||
::decode(bucket_id, bl);
|
||||
}
|
||||
}
|
||||
};
|
||||
WRITE_CLASS_ENCODER(rgw_bucket)
|
||||
@ -499,8 +506,6 @@ struct req_state {
|
||||
|
||||
utime_t time;
|
||||
|
||||
uint64_t pool_id;
|
||||
|
||||
struct RGWEnv *env;
|
||||
|
||||
void *obj_ctx;
|
||||
|
@ -17,7 +17,7 @@ static void set_param_str(struct req_state *s, const char *name, string& str)
|
||||
int rgw_log_op(struct req_state *s)
|
||||
{
|
||||
struct rgw_log_entry entry;
|
||||
uint64_t pool_id;
|
||||
uint64_t bucket_id;
|
||||
|
||||
if (!s->should_log)
|
||||
return 0;
|
||||
@ -31,9 +31,9 @@ int rgw_log_op(struct req_state *s)
|
||||
RGW_LOG(0) << "bucket " << s->bucket << " doesn't exist, not logging" << dendl;
|
||||
return 0;
|
||||
}
|
||||
pool_id = 0;
|
||||
bucket_id = 0;
|
||||
} else {
|
||||
pool_id = s->pool_id;
|
||||
bucket_id = s->bucket.bucket_id;
|
||||
}
|
||||
entry.bucket = s->bucket_name;
|
||||
|
||||
@ -73,7 +73,7 @@ int rgw_log_op(struct req_state *s)
|
||||
entry.http_status = "200"; // default
|
||||
|
||||
entry.error_code = s->err.s3_code;
|
||||
entry.pool_id = pool_id;
|
||||
entry.bucket_id = bucket_id;
|
||||
|
||||
bufferlist bl;
|
||||
::encode(entry, bl);
|
||||
@ -83,7 +83,7 @@ int rgw_log_op(struct req_state *s)
|
||||
gmtime_r(&t, &bdt);
|
||||
|
||||
char buf[entry.bucket.size() + 16];
|
||||
sprintf(buf, "%.4d-%.2d-%.2d-%lld-%s", (bdt.tm_year+1900), (bdt.tm_mon+1), bdt.tm_mday, (long long)s->pool_id, entry.bucket.c_str());
|
||||
sprintf(buf, "%.4d-%.2d-%.2d-%lld-%s", (bdt.tm_year+1900), (bdt.tm_mon+1), bdt.tm_mday, (long long)s->bucket.bucket_id, entry.bucket.c_str());
|
||||
string oid(buf);
|
||||
rgw_obj obj(log_bucket, oid);
|
||||
|
||||
@ -119,7 +119,7 @@ int rgw_log_intent(struct req_state *s, rgw_obj& obj, RGWIntentEvent intent)
|
||||
gmtime_r(&t, &bdt);
|
||||
|
||||
char buf[obj.bucket.name.size() + 16];
|
||||
sprintf(buf, "%.4d-%.2d-%.2d-%lld-%s", (bdt.tm_year+1900), (bdt.tm_mon+1), bdt.tm_mday, (long long)s->pool_id, obj.bucket.name.c_str());
|
||||
sprintf(buf, "%.4d-%.2d-%.2d-%lld-%s", (bdt.tm_year+1900), (bdt.tm_mon+1), bdt.tm_mday, (long long)s->bucket.bucket_id, obj.bucket.name.c_str());
|
||||
string oid(buf);
|
||||
rgw_obj log_obj(intent_log_bucket, oid);
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct rgw_log_entry {
|
||||
utime_t total_time;
|
||||
string user_agent;
|
||||
string referrer;
|
||||
uint64_t pool_id;
|
||||
uint64_t bucket_id;
|
||||
|
||||
void encode(bufferlist &bl) const {
|
||||
uint8_t ver;
|
||||
@ -51,7 +51,7 @@ struct rgw_log_entry {
|
||||
::encode(user_agent, bl);
|
||||
::encode(referrer, bl);
|
||||
::encode(bytes_received, bl);
|
||||
::encode(pool_id, bl);
|
||||
::encode(bucket_id, bl);
|
||||
}
|
||||
void decode(bufferlist::iterator &p) {
|
||||
uint8_t ver;
|
||||
@ -77,9 +77,9 @@ struct rgw_log_entry {
|
||||
bytes_received = 0;
|
||||
|
||||
if (ver >= 3)
|
||||
::decode(pool_id, p);
|
||||
::decode(bucket_id, p);
|
||||
else
|
||||
pool_id = -1;
|
||||
bucket_id = -1;
|
||||
}
|
||||
};
|
||||
WRITE_CLASS_ENCODER(rgw_log_entry)
|
||||
|
@ -444,7 +444,7 @@ void RGWCreateBucket::execute()
|
||||
bufferlist aclbl;
|
||||
bool existed;
|
||||
bool pol_ret;
|
||||
uint64_t pool_id;
|
||||
uint64_t bucket_id;
|
||||
RGWPoolInfo info;
|
||||
|
||||
rgw_obj obj(rgw_root_bucket, s->bucket_name_str);
|
||||
@ -487,14 +487,13 @@ void RGWCreateBucket::execute()
|
||||
if (ret == -EEXIST)
|
||||
ret = 0;
|
||||
|
||||
ret = rgwstore->get_bucket_id(s->bucket, &pool_id);
|
||||
ret = rgwstore->get_bucket_id(s->bucket, &bucket_id);
|
||||
if (ret < 0)
|
||||
goto done;
|
||||
|
||||
s->pool_id = pool_id;
|
||||
info.owner = s->user.user_id;
|
||||
info.bucket = s->bucket;
|
||||
rgw_store_pool_info(pool_id, info);
|
||||
rgw_store_pool_info(bucket_id, info);
|
||||
|
||||
done:
|
||||
send_response();
|
||||
@ -1527,12 +1526,6 @@ int RGWHandler::do_read_permissions(bool only_bucket)
|
||||
ret = -EACCES;
|
||||
}
|
||||
|
||||
if (ret == 0 && !s->bucket.name.empty()) {
|
||||
ret = rgwstore->get_bucket_id(s->bucket, &s->pool_id);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -323,6 +323,7 @@ int RGWRados::create_bucket(std::string& id, rgw_bucket& bucket,
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), "%llu", (unsigned long long)ver);
|
||||
bucket.marker = buf;
|
||||
bucket.bucket_id = ver;
|
||||
|
||||
string dir_oid = dir_oid_prefix;
|
||||
dir_oid.append(bucket.marker);
|
||||
|
Loading…
Reference in New Issue
Block a user