diff options
-rw-r--r-- | src/mon/Monitor.h | 1 | ||||
-rw-r--r-- | src/rgw/rgw_auth_s3.cc | 1 | ||||
-rw-r--r-- | src/rgw/rgw_bucket.cc | 6 | ||||
-rw-r--r-- | src/rgw/rgw_common.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_op.cc | 18 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 42 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 2 |
7 files changed, 62 insertions, 12 deletions
diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 35975e7a90f..69dfefe144a 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -168,6 +168,7 @@ public: case STATE_ELECTING: return "electing"; case STATE_LEADER: return "leader"; case STATE_PEON: return "peon"; + case STATE_SHUTDOWN: return "shutdown"; default: return "???"; } } diff --git a/src/rgw/rgw_auth_s3.cc b/src/rgw/rgw_auth_s3.cc index c93de7cd58a..f3f0c8322f0 100644 --- a/src/rgw/rgw_auth_s3.cc +++ b/src/rgw/rgw_auth_s3.cc @@ -6,6 +6,7 @@ static const char *signed_subresources[] = { "acl", + "cors", "delete", "lifecycle", "location", diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index bf8da99d616..d32af5df601 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -202,7 +202,11 @@ int rgw_bucket_set_attrs(RGWRados *store, rgw_bucket& bucket, string oid; store->get_bucket_meta_oid(bucket, oid); rgw_obj obj(store->zone.domain_root, oid); - return store->meta_mgr->set_attrs(bucket_meta_handler, oid, + + string key; + store->get_bucket_instance_entry(bucket, key); /* we want the bucket instance name without + the oid prefix cruft */ + return store->meta_mgr->set_attrs(bucket_instance_meta_handler, key, obj, attrs, rmattrs, objv_tracker); } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 543bdf21377..8e4126de271 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -542,6 +542,10 @@ struct rgw_bucket { std::string marker; std::string bucket_id; + std::string oid; /* + * runtime in-memory only info. If not empty, points to the bucket instance object + */ + rgw_bucket() { } rgw_bucket(const char *n) : name(n) { assert(*n == '.'); // only rgw private buckets should be initialized without pool diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 7760a2f5c52..e672de154ab 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -241,8 +241,10 @@ static int get_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx, } if (obj.object.empty()) { + rgw_obj instance_obj; + store->get_bucket_instance_obj(bucket_info.bucket, instance_obj); return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, - policy, obj); + policy, instance_obj); } return get_obj_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, policy, obj); @@ -1898,9 +1900,8 @@ void RGWPutCORS::execute() RGWObjVersionTracker *ptracker = (s->object ? NULL : &s->bucket_info.objv_tracker); - string no_obj; cors_config->encode(bl); - obj.init(s->bucket, no_obj); + store->get_bucket_instance_obj(s->bucket, obj); store->set_atomic(s->obj_ctx, obj); ret = store->set_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl, ptracker); } @@ -1917,13 +1918,12 @@ void RGWDeleteCORS::execute() { bufferlist bl; rgw_obj obj; - string no_obj; if (!s->bucket_cors) { dout(2) << "No CORS configuration set yet for this bucket" << dendl; ret = -ENOENT; return; } - obj.init(s->bucket, no_obj); + store->get_bucket_instance_obj(s->bucket, obj); store->set_atomic(s->obj_ctx, obj); map<string, bufferlist> orig_attrs, attrs, rmattrs; map<string, bufferlist>::iterator iter; @@ -2516,10 +2516,10 @@ int RGWHandler::read_cors_config(void) bufferlist bl; dout(10) << "Going to read cors from attrs" << dendl; - string no_object; - rgw_obj no_obj(s->bucket, no_object); - if (no_obj.bucket.name.size()) { - ret = store->get_attr(s->obj_ctx, no_obj, RGW_ATTR_CORS, bl); + rgw_obj obj; + store->get_bucket_instance_obj(s->bucket, obj); + if (obj.bucket.name.size()) { + ret = store->get_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl); if (ret >= 0) { bufferlist::iterator iter = bl.begin(); s->bucket_cors = new RGWCORSConfiguration(); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 8af03b03a8f..7131df9eaeb 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -831,6 +831,11 @@ void RGWRados::finalize() RGWRESTConn *conn = iter->second; delete conn; } + + for (iter = region_conn_map.begin(); iter != region_conn_map.end(); ++iter) { + RGWRESTConn *conn = iter->second; + delete conn; + } } /** @@ -896,6 +901,12 @@ int RGWRados::init_complete() } RGWRegion& region = iter->second; rest_master_conn = new RGWRESTConn(cct, this, region.endpoints); + + for (iter = region_map.regions.begin(); iter != region_map.regions.end(); ++iter) { + RGWRegion& region = iter->second; + + region_conn_map[region.name] = new RGWRESTConn(cct, this, region.endpoints); + } } map<string, RGWZone>::iterator ziter; @@ -2535,7 +2546,17 @@ int RGWRados::copy_obj(void *ctx, RGWRESTConn *conn; if (source_zone.empty()) { - conn = rest_master_conn; + if (dest_bucket_info.region.empty()) { + /* source is in the master region */ + conn = rest_master_conn; + } else { + map<string, RGWRESTConn *>::iterator iter = region_conn_map.find(src_bucket_info.region); + if (iter == zone_conn_map.end()) { + ldout(cct, 0) << "could not find region connection to region: " << source_zone << dendl; + return -ENOENT; + } + conn = iter->second; + } } else { map<string, RGWRESTConn *>::iterator iter = zone_conn_map.find(source_zone); if (iter == zone_conn_map.end()) { @@ -4546,6 +4567,17 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid) oid = RGW_BUCKET_INSTANCE_MD_PREFIX + entry; } +void RGWRados::get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj) +{ + if (!bucket.oid.empty()) { + obj.init(zone.domain_root, bucket.oid); + } else { + string oid; + get_bucket_meta_oid(bucket, oid); + obj.init(zone.domain_root, oid); + } +} + int RGWRados::get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs) { @@ -4562,7 +4594,11 @@ int RGWRados::get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketI time_t *pmtime, map<string, bufferlist> *pattrs) { string oid; - get_bucket_meta_oid(bucket, oid); + if (!bucket.oid.empty()) { + get_bucket_meta_oid(bucket, oid); + } else { + oid = bucket.oid; + } return get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs); } @@ -4586,6 +4622,7 @@ int RGWRados::get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo ldout(cct, 0) << "ERROR: could not decode buffer info, caught buffer::error" << dendl; return -EIO; } + info.bucket.oid = oid; return 0; } @@ -4628,6 +4665,7 @@ int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& inf if (entry_point.has_bucket_info) { info = entry_point.old_bucket_info; + info.bucket.oid = bucket_name; info.ep_objv = ot.read_version; ldout(cct, 20) << "rgw_get_bucket_info: old bucket info, bucket=" << info.bucket << " owner " << info.owner << dendl; return 0; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index bcc40900299..d01f76ec224 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -888,6 +888,7 @@ public: RGWRegionMap region_map; RGWRESTConn *rest_master_conn; map<string, RGWRESTConn *> zone_conn_map; + map<string, RGWRESTConn *> region_conn_map; RGWMetadataManager *meta_mgr; @@ -1285,6 +1286,7 @@ public: int decode_policy(bufferlist& bl, ACLOwner *owner); int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWBucketStats>& stats, string *max_marker); + void get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj); void get_bucket_instance_entry(rgw_bucket& bucket, string& entry); void get_bucket_meta_oid(rgw_bucket& bucket, string& oid); |