rgw: don't try to canonicalize raw obj

and other minor fixes

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
This commit is contained in:
Yehuda Sadeh 2018-10-04 15:44:20 -07:00
parent 58680b8860
commit 2053556de1
7 changed files with 62 additions and 83 deletions

View File

@ -115,20 +115,6 @@ public:
public:
Obj() {}
Obj(const Obj& o) : rados_svc(o.rados_svc),
rados_handle(o.rados_handle),
ref(o.ref) {}
Obj(Obj&& o) : rados_svc(o.rados_svc),
rados_handle(o.rados_handle),
ref(std::move(o.ref)) {}
Obj& operator=(Obj&& o) {
rados_svc = o.rados_svc;
rados_handle = o.rados_handle;
ref = std::move(o.ref);
return *this;
}
int open();
@ -170,9 +156,6 @@ public:
Pool(RGWSI_RADOS *_rados_svc) : rados_svc(_rados_svc) {}
public:
Pool() {}
Pool(const Pool& p) : rados_svc(p.rados_svc),
rados_handle(p.rados_handle),
pool(p.pool) {}
int create(const std::vector<rgw_pool>& pools, std::vector<int> *retcodes);
int lookup(const rgw_pool& pool);

View File

@ -51,7 +51,7 @@ static string normal_name(rgw_pool& pool, const std::string& oid) {
return buf;
}
void RGWSI_SysObj_Cache::normalize_pool_and_obj(rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj)
void RGWSI_SysObj_Cache::normalize_pool_and_obj(const rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj)
{
if (src_obj.size()) {
dst_pool = src_pool;
@ -65,7 +65,7 @@ void RGWSI_SysObj_Cache::normalize_pool_and_obj(rgw_pool& src_pool, const string
int RGWSI_SysObj_Cache::remove(RGWSysObjectCtxBase& obj_ctx,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj)
const rgw_raw_obj& obj)
{
rgw_pool pool;
@ -87,7 +87,7 @@ int RGWSI_SysObj_Cache::remove(RGWSysObjectCtxBase& obj_ctx,
int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx,
GetObjState& read_state,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
bufferlist *obl, off_t ofs, off_t end,
map<string, bufferlist> *attrs,
rgw_cache_entry_info *cache_info,
@ -164,7 +164,7 @@ int RGWSI_SysObj_Cache::read(RGWSysObjectCtxBase& obj_ctx,
return r;
}
int RGWSI_SysObj_Cache::get_attr(rgw_raw_obj& obj,
int RGWSI_SysObj_Cache::get_attr(const rgw_raw_obj& obj,
const char *attr_name,
bufferlist *dest)
{
@ -194,7 +194,7 @@ int RGWSI_SysObj_Cache::get_attr(rgw_raw_obj& obj,
return RGWSI_SysObj_Core::get_attr(obj, attr_name, dest);
}
int RGWSI_SysObj_Cache::set_attrs(rgw_raw_obj& obj,
int RGWSI_SysObj_Cache::set_attrs(const rgw_raw_obj& obj,
map<string, bufferlist>& attrs,
map<string, bufferlist> *rmattrs,
RGWObjVersionTracker *objv_tracker)
@ -227,7 +227,7 @@ int RGWSI_SysObj_Cache::set_attrs(rgw_raw_obj& obj,
return ret;
}
int RGWSI_SysObj_Cache::write(rgw_raw_obj& obj,
int RGWSI_SysObj_Cache::write(const rgw_raw_obj& obj,
real_time *pmtime,
map<std::string, bufferlist>& attrs,
bool exclusive,
@ -278,7 +278,7 @@ int RGWSI_SysObj_Cache::write(rgw_raw_obj& obj,
return ret;
}
int RGWSI_SysObj_Cache::write_data(rgw_raw_obj& obj,
int RGWSI_SysObj_Cache::write_data(const rgw_raw_obj& obj,
const bufferlist& data,
bool exclusive,
RGWObjVersionTracker *objv_tracker)
@ -311,7 +311,7 @@ int RGWSI_SysObj_Cache::write_data(rgw_raw_obj& obj,
return ret;
}
int RGWSI_SysObj_Cache::raw_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *pepoch,
int RGWSI_SysObj_Cache::raw_stat(const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *pepoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker)
{
@ -371,7 +371,7 @@ done:
return 0;
}
int RGWSI_SysObj_Cache::distribute_cache(const string& normal_name, rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op)
int RGWSI_SysObj_Cache::distribute_cache(const string& normal_name, const rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op)
{
RGWCacheNotifyInfo info;

View File

@ -22,7 +22,7 @@ class RGWSI_SysObj_Cache : public RGWSI_SysObj_Core
std::shared_ptr<RGWSI_SysObj_Cache_CB> cb;
void normalize_pool_and_obj(rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj);
void normalize_pool_and_obj(const rgw_pool& src_pool, const string& src_obj, rgw_pool& dst_pool, string& dst_obj);
protected:
void init(std::shared_ptr<RGWSI_RADOS>& _rados_svc,
std::shared_ptr<RGWSI_Zone>& _zone_svc,
@ -33,31 +33,31 @@ protected:
int do_start() override;
int raw_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
int raw_stat(const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker) override;
int read(RGWSysObjectCtxBase& obj_ctx,
GetObjState& read_state,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
map<string, bufferlist> *attrs,
rgw_cache_entry_info *cache_info,
boost::optional<obj_version>) override;
int get_attr(rgw_raw_obj& obj, const char *name, bufferlist *dest) override;
int get_attr(const rgw_raw_obj& obj, const char *name, bufferlist *dest) override;
int set_attrs(rgw_raw_obj& obj,
int set_attrs(const rgw_raw_obj& obj,
map<string, bufferlist>& attrs,
map<string, bufferlist> *rmattrs,
RGWObjVersionTracker *objv_tracker);
int remove(RGWSysObjectCtxBase& obj_ctx,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj) override;
const rgw_raw_obj& obj) override;
int write(rgw_raw_obj& obj,
int write(const rgw_raw_obj& obj,
real_time *pmtime,
map<std::string, bufferlist>& attrs,
bool exclusive,
@ -65,12 +65,12 @@ protected:
RGWObjVersionTracker *objv_tracker,
real_time set_mtime) override;
int write_data(rgw_raw_obj& obj,
int write_data(const rgw_raw_obj& obj,
const bufferlist& bl,
bool exclusive,
RGWObjVersionTracker *objv_tracker);
int distribute_cache(const string& normal_name, rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op);
int distribute_cache(const string& normal_name, const rgw_raw_obj& obj, ObjectCacheInfo& obj_info, int op);
int watch_cb(uint64_t notify_id,
uint64_t cookie,

View File

@ -8,11 +8,14 @@
int RGWSI_SysObj_Core::GetObjState::get_rados_obj(RGWSI_RADOS *rados_svc,
RGWSI_Zone *zone_svc,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
RGWSI_RADOS::Obj **pobj)
{
if (!has_rados_obj) {
zone_svc->canonicalize_raw_obj(&obj);
if (obj.oid.empty()) {
ldout(rados_svc->ctx(), 0) << "ERROR: obj.oid is empty" << dendl;
return -EINVAL;
}
rados_obj = rados_svc->obj(obj);
int r = rados_obj.open();
@ -26,10 +29,13 @@ int RGWSI_SysObj_Core::GetObjState::get_rados_obj(RGWSI_RADOS *rados_svc,
}
int RGWSI_SysObj_Core::get_rados_obj(RGWSI_Zone *zone_svc,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
RGWSI_RADOS::Obj *pobj)
{
zone_svc->canonicalize_raw_obj(&obj);
if (obj.oid.empty()) {
ldout(rados_svc->ctx(), 0) << "ERROR: obj.oid is empty" << dendl;
return -EINVAL;
}
*pobj = std::move(rados_svc->obj(obj));
int r = pobj->open();
@ -40,7 +46,7 @@ int RGWSI_SysObj_Core::get_rados_obj(RGWSI_Zone *zone_svc,
return 0;
}
int RGWSI_SysObj_Core::get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker)
int RGWSI_SysObj_Core::get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, const rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker)
{
if (obj.empty()) {
return -EINVAL;
@ -78,7 +84,7 @@ int RGWSI_SysObj_Core::get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, rgw_
return 0;
}
int RGWSI_SysObj_Core::get_system_obj_state(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker)
int RGWSI_SysObj_Core::get_system_obj_state(RGWSysObjectCtxBase *rctx, const rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker)
{
int ret;
@ -89,7 +95,7 @@ int RGWSI_SysObj_Core::get_system_obj_state(RGWSysObjectCtxBase *rctx, rgw_raw_o
return ret;
}
int RGWSI_SysObj_Core::raw_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
int RGWSI_SysObj_Core::raw_stat(const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker)
{
@ -139,7 +145,7 @@ int RGWSI_SysObj_Core::raw_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pm
int RGWSI_SysObj_Core::stat(RGWSysObjectCtxBase& obj_ctx,
GetObjState& state,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
map<string, bufferlist> *attrs,
real_time *lastmod,
uint64_t *obj_size,
@ -176,7 +182,7 @@ int RGWSI_SysObj_Core::stat(RGWSysObjectCtxBase& obj_ctx,
int RGWSI_SysObj_Core::read(RGWSysObjectCtxBase& obj_ctx,
GetObjState& read_state,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
map<string, bufferlist> *attrs,
rgw_cache_entry_info *cache_info,
@ -234,7 +240,7 @@ int RGWSI_SysObj_Core::read(RGWSysObjectCtxBase& obj_ctx,
* dest: bufferlist to store the result in
* Returns: 0 on success, -ERR# otherwise.
*/
int RGWSI_SysObj_Core::get_attr(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::get_attr(const rgw_raw_obj& obj,
const char *name,
bufferlist *dest)
{
@ -257,7 +263,7 @@ int RGWSI_SysObj_Core::get_attr(rgw_raw_obj& obj,
return 0;
}
int RGWSI_SysObj_Core::set_attrs(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::set_attrs(const rgw_raw_obj& obj,
map<string, bufferlist>& attrs,
map<string, bufferlist> *rmattrs,
RGWObjVersionTracker *objv_tracker)
@ -305,7 +311,7 @@ int RGWSI_SysObj_Core::set_attrs(rgw_raw_obj& obj,
return 0;
}
int RGWSI_SysObj_Core::omap_get_vals(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::omap_get_vals(const rgw_raw_obj& obj,
const string& marker,
uint64_t count,
std::map<string, bufferlist> *m,
@ -346,7 +352,7 @@ int RGWSI_SysObj_Core::omap_get_vals(rgw_raw_obj& obj,
return 0;
}
int RGWSI_SysObj_Core::omap_get_all(rgw_raw_obj& obj, std::map<string, bufferlist> *m)
int RGWSI_SysObj_Core::omap_get_all(const rgw_raw_obj& obj, std::map<string, bufferlist> *m)
{
RGWSI_RADOS::Obj rados_obj;
int r = get_rados_obj(zone_svc.get(), obj, &rados_obj);
@ -380,7 +386,7 @@ int RGWSI_SysObj_Core::omap_get_all(rgw_raw_obj& obj, std::map<string, bufferlis
return 0;
}
int RGWSI_SysObj_Core::omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist)
int RGWSI_SysObj_Core::omap_set(const rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist)
{
RGWSI_RADOS::Obj rados_obj;
int r = get_rados_obj(zone_svc.get(), obj, &rados_obj);
@ -401,7 +407,7 @@ int RGWSI_SysObj_Core::omap_set(rgw_raw_obj& obj, const std::string& key, buffer
return r;
}
int RGWSI_SysObj_Core::omap_set(rgw_raw_obj& obj, const std::map<std::string, bufferlist>& m, bool must_exist)
int RGWSI_SysObj_Core::omap_set(const rgw_raw_obj& obj, const std::map<std::string, bufferlist>& m, bool must_exist)
{
RGWSI_RADOS::Obj rados_obj;
int r = get_rados_obj(zone_svc.get(), obj, &rados_obj);
@ -418,7 +424,7 @@ int RGWSI_SysObj_Core::omap_set(rgw_raw_obj& obj, const std::map<std::string, bu
return r;
}
int RGWSI_SysObj_Core::omap_del(rgw_raw_obj& obj, const std::string& key)
int RGWSI_SysObj_Core::omap_del(const rgw_raw_obj& obj, const std::string& key)
{
RGWSI_RADOS::Obj rados_obj;
int r = get_rados_obj(zone_svc.get(), obj, &rados_obj);
@ -438,7 +444,7 @@ int RGWSI_SysObj_Core::omap_del(rgw_raw_obj& obj, const std::string& key)
return r;
}
int RGWSI_SysObj_Core::notify(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::notify(const rgw_raw_obj& obj,
bufferlist& bl,
uint64_t timeout_ms,
bufferlist *pbl)
@ -456,7 +462,7 @@ int RGWSI_SysObj_Core::notify(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::remove(RGWSysObjectCtxBase& obj_ctx,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj)
const rgw_raw_obj& obj)
{
RGWSI_RADOS::Obj rados_obj;
int r = get_rados_obj(zone_svc.get(), obj, &rados_obj);
@ -479,7 +485,7 @@ int RGWSI_SysObj_Core::remove(RGWSysObjectCtxBase& obj_ctx,
return 0;
}
int RGWSI_SysObj_Core::write(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::write(const rgw_raw_obj& obj,
real_time *pmtime,
map<std::string, bufferlist>& attrs,
bool exclusive,
@ -545,7 +551,7 @@ int RGWSI_SysObj_Core::write(rgw_raw_obj& obj,
}
int RGWSI_SysObj_Core::write_data(rgw_raw_obj& obj,
int RGWSI_SysObj_Core::write_data(const rgw_raw_obj& obj,
const bufferlist& bl,
bool exclusive,
RGWObjVersionTracker *objv_tracker)

View File

@ -112,7 +112,7 @@ protected:
int get_rados_obj(RGWSI_RADOS *rados_svc,
RGWSI_Zone *zone_svc,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
RGWSI_RADOS::Obj **pobj);
};
@ -122,16 +122,16 @@ protected:
rados_svc = _rados_svc;
zone_svc = _zone_svc;
}
int get_rados_obj(RGWSI_Zone *zone_svc, rgw_raw_obj& obj, RGWSI_RADOS::Obj *pobj);
int get_rados_obj(RGWSI_Zone *zone_svc, const rgw_raw_obj& obj, RGWSI_RADOS::Obj *pobj);
virtual int raw_stat(rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
virtual int raw_stat(const rgw_raw_obj& obj, uint64_t *psize, real_time *pmtime, uint64_t *epoch,
map<string, bufferlist> *attrs, bufferlist *first_chunk,
RGWObjVersionTracker *objv_tracker);
virtual int read(RGWSysObjectCtxBase& obj_ctx,
GetObjState& read_state,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
bufferlist *bl, off_t ofs, off_t end,
map<string, bufferlist> *attrs,
rgw_cache_entry_info *cache_info,
@ -139,9 +139,9 @@ protected:
virtual int remove(RGWSysObjectCtxBase& obj_ctx,
RGWObjVersionTracker *objv_tracker,
rgw_raw_obj& obj);
const rgw_raw_obj& obj);
virtual int write(rgw_raw_obj& obj,
virtual int write(const rgw_raw_obj& obj,
real_time *pmtime,
map<std::string, bufferlist>& attrs,
bool exclusive,
@ -149,40 +149,40 @@ protected:
RGWObjVersionTracker *objv_tracker,
real_time set_mtime);
virtual int write_data(rgw_raw_obj& obj,
virtual int write_data(const rgw_raw_obj& obj,
const bufferlist& bl,
bool exclusive,
RGWObjVersionTracker *objv_tracker);
virtual int get_attr(rgw_raw_obj& obj, const char *name, bufferlist *dest);
virtual int get_attr(const rgw_raw_obj& obj, const char *name, bufferlist *dest);
virtual int set_attrs(rgw_raw_obj& obj,
virtual int set_attrs(const rgw_raw_obj& obj,
map<string, bufferlist>& attrs,
map<string, bufferlist> *rmattrs,
RGWObjVersionTracker *objv_tracker);
virtual int omap_get_all(rgw_raw_obj& obj, std::map<string, bufferlist> *m);
virtual int omap_get_vals(rgw_raw_obj& obj,
virtual int omap_get_all(const rgw_raw_obj& obj, std::map<string, bufferlist> *m);
virtual int omap_get_vals(const rgw_raw_obj& obj,
const string& marker,
uint64_t count,
std::map<string, bufferlist> *m,
bool *pmore);
virtual int omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist = false);
virtual int omap_set(rgw_raw_obj& obj, const map<std::string, bufferlist>& m, bool must_exist = false);
virtual int omap_del(rgw_raw_obj& obj, const std::string& key);
virtual int omap_set(const rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist = false);
virtual int omap_set(const rgw_raw_obj& obj, const map<std::string, bufferlist>& m, bool must_exist = false);
virtual int omap_del(const rgw_raw_obj& obj, const std::string& key);
virtual int notify(rgw_raw_obj& obj,
virtual int notify(const rgw_raw_obj& obj,
bufferlist& bl,
uint64_t timeout_ms,
bufferlist *pbl);
/* wrappers */
int get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker);
int get_system_obj_state(RGWSysObjectCtxBase *rctx, rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker);
int get_system_obj_state_impl(RGWSysObjectCtxBase *rctx, const rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker);
int get_system_obj_state(RGWSysObjectCtxBase *rctx, const rgw_raw_obj& obj, RGWSysObjState **state, RGWObjVersionTracker *objv_tracker);
int stat(RGWSysObjectCtxBase& obj_ctx,
GetObjState& state,
rgw_raw_obj& obj,
const rgw_raw_obj& obj,
map<string, bufferlist> *attrs,
real_time *lastmod,
uint64_t *obj_size,

View File

@ -933,14 +933,6 @@ bool RGWSI_Zone::is_syncing_bucket_meta(const rgw_bucket& bucket)
}
void RGWSI_Zone::canonicalize_raw_obj(rgw_raw_obj *obj)
{
if (obj->oid.empty()) {
obj->oid = obj->pool.to_str();
obj->pool = zone_params->domain_root;
}
}
int RGWSI_Zone::select_new_bucket_location(RGWUserInfo& user_info, const string& zonegroup_id, const string& request_rule,
string *pselected_rule_name, RGWZonePlacementInfo *rule_info)

View File

@ -127,8 +127,6 @@ public:
int list_realms(list<string>& realms);
int list_periods(list<string>& periods);
int list_periods(const string& current_period, list<string>& periods);
void canonicalize_raw_obj(rgw_raw_obj *obj);
};
#endif