}
formatter->open_object_section("stats");
formatter->dump_string("bucket", bucket.name);
- formatter->dump_string("pool", bucket.data_pool);
- formatter->dump_string("index_pool", bucket.index_pool);
+ ::encode_json("placement", bucket.placement, formatter);
formatter->dump_string("id", bucket.bucket_id);
formatter->dump_string("marker", bucket.marker);
string oid;
string locator;
- get_obj_bucket_and_oid_loc(obj, obj.bucket, oid, locator);
+ get_obj_bucket_and_oid_loc(obj, oid, locator);
f->dump_string("oid", oid);
f->dump_string("locator", locator);
return -EINVAL;
}
- std::string no_oid;
-
std::string display_name = op_state.get_user_display_name();
rgw_bucket bucket = op_state.get_bucket();
- rgw_obj obj(bucket, no_oid);
+ const rgw_pool& root_pool = store->get_zone_params().domain_root;
+ rgw_raw_obj obj(root_pool, bucket.name);
RGWObjVersionTracker objv_tracker;
map<string, bufferlist> attrs;
policy_instance.encode(aclbl);
string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key;
- rgw_bucket bucket_instance;
- bucket_instance.name = oid_bucket_instance;
- rgw_obj obj_bucket_instance(bucket_instance, no_oid);
+ rgw_raw_obj obj_bucket_instance(root_pool, oid_bucket_instance);
r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker);
r = rgw_link_bucket(store, user_info.user_id, bucket_info.bucket, real_time());
void decode_from_bucket(bufferlist::iterator& bl);
void decode(bufferlist::iterator& bl) {
- uint64_t start_off = bl.get_off();
DECODE_START_LEGACY_COMPAT_LEN(10, 3, 3, bl);
+
+ ::decode(name, bl);
+
if (struct_v < 10) {
- bl.seek(start_off);
- decode_from_bucket(bl);
- return;
+
+ /*
+ * note that rgw_pool can be used where rgw_bucket was used before
+ * therefore we inherit rgw_bucket's old versions. However, we only
+ * need the first field from rgw_bucket. unless we add more fields
+ * in which case we'll need to look at struct_v, and check the actual
+ * version. Anything older than 10 needs to be treated as old rgw_bucket
+ */
+
}
- ::decode(name, bl);
DECODE_FINISH(bl);
}
};
void dump(Formatter *f) const;
+ void decode_json(JSONObj *obj);
};
inline ostream& operator<<(ostream& out, const rgw_pool& p) {
}
return (r < 0);
}
+
+ void dump(Formatter *f) const;
+ void decode_json(JSONObj *obj);
};
WRITE_CLASS_ENCODER(rgw_raw_obj)
}
RGWAsyncGetSystemObj::RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
bufferlist *_pbl, off_t _ofs, off_t _end) : RGWAsyncRadosRequest(caller, cn), store(_store), obj_ctx(_obj_ctx),
objv_tracker(_objv_tracker), obj(_obj), pbl(_pbl), pattrs(NULL),
ofs(_ofs), end(_end)
int RGWSimpleRadosReadAttrsCR::send_request()
{
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(),
store, &obj_ctx, NULL,
obj,
}
RGWAsyncPutSystemObj::RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- rgw_obj& _obj, bool _exclusive,
+ const rgw_raw_obj& _obj, bool _exclusive,
bufferlist& _bl) : RGWAsyncRadosRequest(caller, cn), store(_store),
obj(_obj), exclusive(_exclusive),
bl(_bl)
}
RGWAsyncPutSystemObjAttrs::RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
map<string, bufferlist> *_attrs) : RGWAsyncRadosRequest(caller, cn), store(_store),
objv_tracker(_objv_tracker), obj(_obj),
attrs(_attrs)
}
-RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid,
+RGWOmapAppend::RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, const rgw_raw_obj& _obj,
uint64_t _window_size)
: RGWConsumerCR<string>(_store->ctx()), async_rados(_async_rados),
- store(_store), pool(_pool), oid(_oid), going_down(false), num_pending_entries(0), window_size(_window_size), total_entries(0)
+ store(_store), obj(_obj), going_down(false), num_pending_entries(0), window_size(_window_size), total_entries(0)
{
}
int RGWAsyncLockSystemObj::_send_request()
{
- librados::IoCtx ioctx;
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(obj.bucket.name.c_str(), ioctx); /* system object only! */
+ rgw_rados_ref ref;
+ int r = store->get_raw_obj_ref(obj, &ref);
if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open pool (" << obj.bucket.name << ") ret=" << r << dendl;
+ lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
return r;
}
l.set_cookie(cookie);
l.set_renew(true);
- return l.lock_exclusive(&ioctx, obj.get_object());
+ return l.lock_exclusive(&ref.ioctx, ref.oid);
}
RGWAsyncLockSystemObj::RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
const string& _name, const string& _cookie, uint32_t _duration_secs) : RGWAsyncRadosRequest(caller, cn), store(_store),
obj(_obj),
lock_name(_name),
int RGWAsyncUnlockSystemObj::_send_request()
{
- librados::IoCtx ioctx;
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(obj.bucket.name.c_str(), ioctx); /* system object only! */
+ rgw_rados_ref ref;
+ int r = store->get_raw_obj_ref(obj, &ref);
if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open pool (" << obj.bucket.name << ") ret=" << r << dendl;
+ lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
return r;
}
l.set_cookie(cookie);
- return l.unlock(&ioctx, obj.get_object());
+ return l.unlock(&ref.ioctx, ref.oid);
}
RGWAsyncUnlockSystemObj::RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
const string& _name, const string& _cookie) : RGWAsyncRadosRequest(caller, cn), store(_store),
obj(_obj),
lock_name(_name), cookie(_cookie)
RGWRadosSetOmapKeysCR::RGWRadosSetOmapKeysCR(RGWRados *_store,
- rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
map<string, bufferlist>& _entries) : RGWSimpleCoroutine(_store->ctx()),
store(_store),
entries(_entries),
- pool(_pool), oid(_oid), cn(NULL)
+ obj(_obj), cn(NULL)
{
stringstream& s = set_description();
- s << "set omap keys dest=" << pool.name << "/" << oid << " keys=[" << s.str() << "]";
+ s << "set omap keys dest=" << obj << " keys=[" << s.str() << "]";
for (auto i = entries.begin(); i != entries.end(); ++i) {
if (i != entries.begin()) {
s << ", ";
int RGWRadosSetOmapKeysCR::send_request()
{
- librados::IoCtx ioctx;
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */
+ rgw_rados_ref ref;
+ int r = store->get_raw_obj_ref(obj, &ref);
if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl;
+ lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
return r;
}
cn = stack->create_completion_notifier();
cn->get();
- return ioctx.aio_operate(oid, cn->completion(), &op);
+ return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op);
}
int RGWRadosSetOmapKeysCR::request_complete()
}
RGWRadosGetOmapKeysCR::RGWRadosGetOmapKeysCR(RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const string& _marker,
map<string, bufferlist> *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()),
store(_store),
marker(_marker),
entries(_entries), max_entries(_max_entries), rval(0),
- pool(_pool), oid(_oid), cn(NULL)
+ obj(_obj), cn(NULL)
{
- set_description() << "set omap keys dest=" << pool.name << "/" << oid << " marker=" << marker;
+ set_description() << "set omap keys dest=" << obj << " marker=" << marker;
}
RGWRadosGetOmapKeysCR::~RGWRadosGetOmapKeysCR()
}
int RGWRadosGetOmapKeysCR::send_request() {
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */
+ rgw_rados_ref ref;
+ int r = store->get_raw_obj_ref(obj, &ref);
if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl;
+ lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
return r;
}
op.omap_get_vals2(marker, max_entries, entries, nullptr, &rval);
cn = stack->create_completion_notifier();
- return ioctx.aio_operate(oid, cn->completion(), &op, NULL);
+ return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op, NULL);
}
RGWRadosRemoveOmapKeysCR::RGWRadosRemoveOmapKeysCR(RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const set<string>& _keys) : RGWSimpleCoroutine(_store->ctx()),
store(_store),
keys(_keys),
- pool(_pool), oid(_oid), cn(NULL)
+ obj(_obj), cn(NULL)
{
- set_description() << "remove omap keys dest=" << pool.name << "/" << oid << " keys=" << keys;
+ set_description() << "remove omap keys dest=" << obj << " keys=" << keys;
}
RGWRadosRemoveOmapKeysCR::~RGWRadosRemoveOmapKeysCR()
}
int RGWRadosRemoveOmapKeysCR::send_request() {
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(pool.name.c_str(), ioctx); /* system object only! */
+ rgw_rados_ref ref;
+ int r = store->get_raw_obj_ref(obj, &ref);
if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open pool (" << pool.name << ") ret=" << r << dendl;
+ lderr(store->ctx()) << "ERROR: failed to get ref for (" << obj << ") ret=" << r << dendl;
return r;
}
op.omap_rm_keys(keys);
cn = stack->create_completion_notifier();
- return ioctx.aio_operate(oid, cn->completion(), &op);
+ return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op);
}
RGWSimpleRadosLockCR::RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
+ const rgw_raw_obj& _obj,
+ const string& _lock_name,
const string& _cookie,
uint32_t _duration) : RGWSimpleCoroutine(_store->ctx()),
async_rados(_async_rados),
lock_name(_lock_name),
cookie(_cookie),
duration(_duration),
- pool(_pool), oid(_oid),
+ obj(_obj),
req(NULL)
{
- set_description() << "rados lock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration;
+ set_description() << "rados lock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie << " duration=" << duration;
}
void RGWSimpleRadosLockCR::request_cleanup()
int RGWSimpleRadosLockCR::send_request()
{
set_status() << "sending request";
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncLockSystemObj(this, stack->create_completion_notifier(),
store, NULL, obj, lock_name, cookie, duration);
async_rados->queue(req);
}
RGWSimpleRadosUnlockCR::RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
+ const rgw_raw_obj& _obj,
+ const string& _lock_name,
const string& _cookie) : RGWSimpleCoroutine(_store->ctx()),
async_rados(_async_rados),
store(_store),
lock_name(_lock_name),
cookie(_cookie),
- pool(_pool), oid(_oid),
+ obj(_obj),
req(NULL)
{
- set_description() << "rados unlock dest=" << pool << "/" << oid << " lock=" << lock_name << " cookie=" << cookie;
+ set_description() << "rados unlock dest=" << obj << " lock=" << lock_name << " cookie=" << cookie;
}
void RGWSimpleRadosUnlockCR::request_cleanup()
{
set_status() << "sending request";
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncUnlockSystemObj(this, stack->create_completion_notifier(),
store, NULL, obj, lock_name, cookie);
async_rados->queue(req);
}
if (entries.size() >= window_size || going_down) {
set_status() << "flushing to omap";
- call(new RGWRadosSetOmapKeysCR(store, pool, oid, entries));
+ call(new RGWRadosSetOmapKeysCR(store, obj, entries));
entries.clear();
}
}
ldout(store->ctx(), 0) << __func__ << "(): deleting obj=" << obj << dendl;
- obj_ctx.set_atomic(obj);
+ obj_ctx.obj.set_atomic(obj);
RGWObjState *state;
}
reenter(this) {
while (!going_down.read()) {
- yield call(new RGWSimpleRadosLockCR(async_rados, store, pool, oid, lock_name, cookie, interval));
+ yield call(new RGWSimpleRadosLockCR(async_rados, store, obj, lock_name, cookie, interval));
caller->set_sleeping(false); /* will only be relevant when we return, that's why we can do it early */
if (retcode < 0) {
set_locked(false);
- ldout(store->ctx(), 20) << *this << ": couldn't lock " << pool.name << ":" << oid << ":" << lock_name << ": retcode=" << retcode << dendl;
+ ldout(store->ctx(), 20) << *this << ": couldn't lock " << obj << ":" << lock_name << ": retcode=" << retcode << dendl;
return set_state(RGWCoroutine_Error, retcode);
}
set_locked(true);
yield wait(utime_t(interval / 2, 0));
}
set_locked(false); /* moot at this point anyway */
- yield call(new RGWSimpleRadosUnlockCR(async_rados, store, pool, oid, lock_name, cookie));
+ yield call(new RGWSimpleRadosUnlockCR(async_rados, store, obj, lock_name, cookie));
return set_state(RGWCoroutine_Done);
}
return 0;
int RGWAsyncStatObj::_send_request()
{
- return store->raw_obj_stat(obj, psize, pmtime, pepoch,
+ rgw_raw_obj raw_obj;
+ store->obj_to_raw(obj, &raw_obj);
+ return store->raw_obj_stat(raw_obj, psize, pmtime, pepoch,
nullptr, nullptr, objv_tracker);
}
RGWObjectCtx *obj_ctx;
RGWRados::SystemObject::Read::GetObjState read_state;
RGWObjVersionTracker *objv_tracker;
- rgw_obj obj;
+ rgw_raw_obj obj;
bufferlist *pbl;
map<string, bufferlist> *pattrs;
off_t ofs;
int _send_request();
public:
RGWAsyncGetSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store, RGWObjectCtx *_obj_ctx,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
bufferlist *_pbl, off_t _ofs, off_t _end);
void set_read_attrs(map<string, bufferlist> *_pattrs) { pattrs = _pattrs; }
};
class RGWAsyncPutSystemObj : public RGWAsyncRadosRequest {
RGWRados *store;
- rgw_obj obj;
+ rgw_raw_obj obj;
bool exclusive;
bufferlist bl;
int _send_request();
public:
RGWAsyncPutSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- rgw_obj& _obj, bool _exclusive,
+ const rgw_raw_obj& _obj, bool _exclusive,
bufferlist& _bl);
};
class RGWAsyncPutSystemObjAttrs : public RGWAsyncRadosRequest {
RGWRados *store;
RGWObjVersionTracker *objv_tracker;
- rgw_obj obj;
+ rgw_raw_obj obj;
map<string, bufferlist> *attrs;
protected:
int _send_request();
public:
RGWAsyncPutSystemObjAttrs(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
map<string, bufferlist> *_attrs);
};
class RGWAsyncLockSystemObj : public RGWAsyncRadosRequest {
RGWRados *store;
- rgw_obj obj;
+ rgw_raw_obj obj;
string lock_name;
string cookie;
uint32_t duration_secs;
int _send_request();
public:
RGWAsyncLockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
const string& _name, const string& _cookie, uint32_t _duration_secs);
};
class RGWAsyncUnlockSystemObj : public RGWAsyncRadosRequest {
RGWRados *store;
- rgw_obj obj;
+ rgw_raw_obj obj;
string lock_name;
string cookie;
int _send_request();
public:
RGWAsyncUnlockSystemObj(RGWCoroutine *caller, RGWAioCompletionNotifier *cn, RGWRados *_store,
- RGWObjVersionTracker *_objv_tracker, rgw_obj& _obj,
+ RGWObjVersionTracker *_objv_tracker, const rgw_raw_obj& _obj,
const string& _name, const string& _cookie);
};
RGWObjectCtx obj_ctx;
bufferlist bl;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
map<string, bufferlist> *pattrs{nullptr};
public:
RGWSimpleRadosReadCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
T *_result, bool empty_on_enoent = true)
: RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store),
- obj_ctx(store), pool(_pool), oid(_oid), result(_result),
+ obj_ctx(store), obj(_obj), result(_result),
empty_on_enoent(empty_on_enoent) {}
~RGWSimpleRadosReadCR() {
request_cleanup();
template <class T>
int RGWSimpleRadosReadCR<T>::send_request()
{
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncGetSystemObj(this, stack->create_completion_notifier(),
store, &obj_ctx, NULL,
obj,
RGWObjectCtx obj_ctx;
bufferlist bl;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
map<string, bufferlist> *pattrs;
public:
RGWSimpleRadosReadAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
map<string, bufferlist> *_pattrs) : RGWSimpleCoroutine(_store->ctx()),
async_rados(_async_rados), store(_store),
obj_ctx(store),
- pool(_pool), oid(_oid),
+ obj(_obj),
pattrs(_pattrs),
req(NULL) { }
~RGWSimpleRadosReadAttrsCR() {
RGWRados *store;
bufferlist bl;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAsyncPutSystemObj *req;
public:
RGWSimpleRadosWriteCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const T& _data) : RGWSimpleCoroutine(_store->ctx()),
async_rados(_async_rados),
store(_store),
- pool(_pool), oid(_oid),
+ obj(_obj),
req(NULL) {
::encode(_data, bl);
}
}
int send_request() {
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncPutSystemObj(this, stack->create_completion_notifier(),
store, obj, false, bl);
async_rados->queue(req);
RGWAsyncRadosProcessor *async_rados;
RGWRados *store;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
map<string, bufferlist> attrs;
public:
RGWSimpleRadosWriteAttrsCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
map<string, bufferlist>& _attrs) : RGWSimpleCoroutine(_store->ctx()),
async_rados(_async_rados),
store(_store),
- pool(_pool), oid(_oid),
+ obj(_obj),
attrs(_attrs), req(NULL) {
}
~RGWSimpleRadosWriteAttrsCR() {
}
int send_request() {
- rgw_obj obj = rgw_obj(pool, oid);
req = new RGWAsyncPutSystemObjAttrs(this, stack->create_completion_notifier(),
store, NULL, obj, &attrs);
async_rados->queue(req);
RGWRados *store;
map<string, bufferlist> entries;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAioCompletionNotifier *cn;
public:
RGWRadosSetOmapKeysCR(RGWRados *_store,
- rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
map<string, bufferlist>& _entries);
~RGWRadosSetOmapKeysCR();
int rval;
librados::IoCtx ioctx;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAioCompletionNotifier *cn;
public:
RGWRadosGetOmapKeysCR(RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const string& _marker,
map<string, bufferlist> *_entries, int _max_entries);
set<string> keys;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAioCompletionNotifier *cn;
public:
RGWRadosRemoveOmapKeysCR(RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const set<string>& _keys);
~RGWRadosRemoveOmapKeysCR();
string cookie;
uint32_t duration;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAsyncLockSystemObj *req;
public:
RGWSimpleRadosLockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
+ const rgw_raw_obj& _obj,
+ const string& _lock_name,
const string& _cookie,
uint32_t _duration);
~RGWSimpleRadosLockCR() {
string lock_name;
string cookie;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
RGWAsyncUnlockSystemObj *req;
public:
RGWSimpleRadosUnlockCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid, const string& _lock_name,
+ const rgw_raw_obj& _obj,
+ const string& _lock_name,
const string& _cookie);
~RGWSimpleRadosUnlockCR() {
request_cleanup();
RGWAsyncRadosProcessor *async_rados;
RGWRados *store;
- rgw_bucket pool;
- string oid;
+ rgw_raw_obj obj;
bool going_down;
uint64_t window_size;
uint64_t total_entries;
public:
- RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, rgw_bucket& _pool, const string& _oid,
+ RGWOmapAppend(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
+ const rgw_raw_obj& _obj,
uint64_t _window_size = OMAP_APPEND_MAX_ENTRIES_DEFAULT);
int operate();
void flush_pending();
return total_entries;
}
- const rgw_bucket& get_pool() {
- return pool;
- }
-
- const string& get_oid() {
- return oid;
+ const rgw_raw_obj& get_obj() {
+ return obj;
}
};
vector<RGWOmapAppend *> shards;
public:
- RGWShardedOmapCRManager(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, RGWCoroutine *_op, int _num_shards, rgw_bucket& pool, const string& oid_prefix)
+ RGWShardedOmapCRManager(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, RGWCoroutine *_op, int _num_shards, const rgw_pool& pool, const string& oid_prefix)
: async_rados(_async_rados),
store(_store), op(_op), num_shards(_num_shards) {
shards.reserve(num_shards);
for (int i = 0; i < num_shards; ++i) {
char buf[oid_prefix.size() + 16];
snprintf(buf, sizeof(buf), "%s.%d", oid_prefix.c_str(), i);
- RGWOmapAppend *shard = new RGWOmapAppend(async_rados, store, pool, buf);
+ RGWOmapAppend *shard = new RGWOmapAppend(async_rados, store, rgw_raw_obj(pool, buf));
shard->get();
shards.push_back(shard);
op->spawn(shard, false);
RGWAsyncRadosProcessor *async_rados;
RGWRados *store;
- const rgw_bucket& pool;
- const string oid;
+ const rgw_raw_obj obj;
const string lock_name;
const string cookie;
public:
RGWContinuousLeaseCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
- const rgw_bucket& _pool, const string& _oid,
+ const rgw_raw_obj& _obj,
const string& _lock_name, int _interval, RGWCoroutine *_caller)
: RGWCoroutine(_store->ctx()), async_rados(_async_rados), store(_store),
- pool(_pool), oid(_oid), lock_name(_lock_name),
+ obj(_obj), lock_name(_lock_name),
cookie(RGWSimpleRadosLockCR::gen_random_cookie(cct)),
interval(_interval), lock("RGWContinuousLeaseCR"), caller(_caller)
{}
RGWDataSyncEnv *env;
const int num_shards;
- int shard_id{0};
+ int shard_id{0};;
+
map<uint32_t, rgw_data_sync_marker>& markers;
public:
return false;
}
using CR = RGWSimpleRadosReadCR<rgw_data_sync_marker>;
- spawn(new CR(env->async_rados, env->store, env->store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id),
+ spawn(new CR(env->async_rados, env->store,
+ rgw_raw_obj(env->store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id)),
&markers[shard_id]),
false);
shard_id++;
yield {
bool empty_on_enoent = false; // fail on ENOENT
call(new ReadInfoCR(sync_env->async_rados, sync_env->store,
- sync_env->store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone),
+ rgw_raw_obj(sync_env->store->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)),
&sync_status->sync_info, empty_on_enoent));
}
if (retcode < 0) {
reenter(this) {
yield {
uint32_t lock_duration = 30;
- call(new RGWSimpleRadosLockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid,
+ call(new RGWSimpleRadosLockCR(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
lock_name, cookie, lock_duration));
if (retcode < 0) {
ldout(cct, 0) << "ERROR: failed to take a lock on " << sync_status_oid << dendl;
}
}
yield {
- call(new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_status_oid, status));
+ call(new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
+ status));
}
yield { /* take lock again, we just recreated the object */
uint32_t lock_duration = 30;
- call(new RGWSimpleRadosLockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid,
- lock_name, cookie, lock_duration));
+ call(new RGWSimpleRadosLockCR(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
+ lock_name, cookie, lock_duration));
if (retcode < 0) {
ldout(cct, 0) << "ERROR: failed to take a lock on " << sync_status_oid << dendl;
return set_cr_error(retcode);
RGWDataChangesLogInfo& info = shards_info[i];
marker.next_step_marker = info.marker;
marker.timestamp = info.last_update;
- spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, i), marker), true);
+ spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, i)),
+ marker), true);
}
}
yield {
status.state = rgw_data_sync_info::StateBuildingFullSyncMaps;
- call(new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_status_oid, status));
+ call(new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
+ status));
}
yield { /* unlock */
- call(new RGWSimpleRadosUnlockCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_status_oid,
- lock_name, cookie));
+ call(new RGWSimpleRadosUnlockCR(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
+ lock_name, cookie));
}
while (collect(&ret, NULL)) {
if (ret < 0) {
int shard_id = (int)iter->first;
rgw_data_sync_marker& marker = iter->second;
marker.total_entries = entries_index->get_total_entries(shard_id);
- spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id), marker), true);
+ spawn(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)),
+ marker), true);
}
} else {
yield call(sync_env->error_logger->log_error_cr(sync_env->conn->get_remote_id(), "data.init", "",
ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl;
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- marker_oid, sync_marker);
+ return new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, marker_oid),
+ sync_marker);
}
/*
}
} else if (error_repo && remove_from_repo) {
keys = {raw_key};
- yield call(new RGWRadosRemoveOmapKeysCR(sync_env->store, error_repo->get_pool(), error_repo->get_oid(), keys));
+ yield call(new RGWRadosRemoveOmapKeysCR(sync_env->store, error_repo->get_obj(), keys));
if (retcode < 0) {
ldout(sync_env->store->ctx(), 0) << "ERROR: failed to remove omap key from error repo ("
- << error_repo->get_pool() << ":" << error_repo->get_oid() << " retcode=" << retcode << dendl;
+ << error_repo->get_obj() << " retcode=" << retcode << dendl;
}
}
/* FIXME: what do do in case of error */
class RGWDataSyncShardCR : public RGWCoroutine {
RGWDataSyncEnv *sync_env;
- rgw_bucket pool;
+ rgw_pool pool;
uint32_t shard_id;
rgw_data_sync_marker sync_marker;
RGWDataSyncDebugLogger logger;
public:
RGWDataSyncShardCR(RGWDataSyncEnv *_sync_env,
- rgw_bucket& _pool,
+ rgw_pool& _pool,
uint32_t _shard_id, rgw_data_sync_marker& _marker, bool *_reset_backoff) : RGWCoroutine(_sync_env->cct),
sync_env(_sync_env),
pool(_pool),
lease_cr->put();
}
RGWRados *store = sync_env->store;
- lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, store->get_zone_params().log_pool, status_oid,
+ lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, status_oid),
lock_name, lock_duration, this);
lease_cr->get();
lease_stack = spawn(lease_cr, false);
set_marker_tracker(new RGWDataSyncShardMarkerTrack(sync_env, status_oid, sync_marker));
total_entries = sync_marker.pos;
do {
- yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, oid, sync_marker.marker, &entries, max_entries));
+ yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid), sync_marker.marker, &entries, max_entries));
if (retcode < 0) {
ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): RGWRadosGetOmapKeysCR() returned ret=" << retcode << dendl;
lease_cr->go_down();
sync_marker.marker = sync_marker.next_step_marker;
sync_marker.next_step_marker.clear();
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- status_oid, sync_marker));
+ call(new RGWSimpleRadosWriteCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, status_oid),
+ sync_marker));
}
if (retcode < 0) {
ldout(sync_env->cct, 0) << "ERROR: failed to set sync marker: retcode=" << retcode << dendl;
int incremental_sync() {
reenter(&incremental_cr) {
- error_repo = new RGWOmapAppend(sync_env->async_rados, sync_env->store, pool, error_oid, 1 /* no buffer */);
+ error_repo = new RGWOmapAppend(sync_env->async_rados, sync_env->store,
+ rgw_raw_obj(pool, error_oid),
+ 1 /* no buffer */);
error_repo->get();
spawn(error_repo, false);
yield init_lease_cr();
}
/* process bucket shards that previously failed */
- yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, error_oid, error_marker, &error_entries, max_error_entries));
+ yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, error_oid),
+ error_marker, &error_entries,
+ max_error_entries));
ldout(sync_env->cct, 20) << __func__ << "(): read error repo, got " << error_entries.size() << " entries" << dendl;
iter = error_entries.begin();
for (; iter != error_entries.end(); ++iter) {
class RGWDataSyncShardControlCR : public RGWBackoffControlCR {
RGWDataSyncEnv *sync_env;
- rgw_bucket pool;
+ rgw_pool pool;
uint32_t shard_id;
rgw_data_sync_marker sync_marker;
public:
- RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_bucket& _pool,
+ RGWDataSyncShardControlCR(RGWDataSyncEnv *_sync_env, rgw_pool& _pool,
uint32_t _shard_id, rgw_data_sync_marker& _marker) : RGWBackoffControlCR(_sync_env->cct, false),
sync_env(_sync_env),
pool(_pool),
RGWCoroutine *alloc_finisher_cr() override {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosReadCR<rgw_data_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id), &sync_marker);
+ return new RGWSimpleRadosReadCR<rgw_data_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::shard_obj_name(sync_env->source_zone, shard_id)),
+ &sync_marker);
}
void append_modified_shards(set<string>& keys) {
RGWCoroutine *set_sync_info_cr() {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone),
+ return new RGWSimpleRadosWriteCR<rgw_data_sync_info>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, RGWDataSyncStatusManager::sync_status_oid(sync_env->source_zone)),
sync_status.sync_info);
}
return -EINVAL;
}
- const char *log_pool = zone_params.log_pool.name.c_str();
- librados::Rados *rados = store->get_rados_handle();
- int r = rados->ioctx_create(log_pool, ioctx);
- if (r < 0) {
- lderr(store->ctx()) << "ERROR: failed to open log pool (" << zone_params.log_pool.name << " ret=" << r << dendl;
- return r;
- }
-
- source_status_obj = rgw_obj(zone_params.log_pool, RGWDataSyncStatusManager::sync_status_oid(source_zone));
-
error_logger = new RGWSyncErrorLogger(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, ERROR_LOGGER_SHARDS);
- r = source_log.init(source_zone, conn, error_logger, sync_module);
+ int r = source_log.init(source_zone, conn, error_logger);
if (r < 0) {
lderr(store->ctx()) << "ERROR: failed to init remote log, r=" << r << dendl;
finalize();
num_shards = datalog_info.num_shards;
for (int i = 0; i < num_shards; i++) {
- shard_objs[i] = rgw_obj(zone_params.log_pool, shard_obj_name(source_zone, i));
+ shard_objs[i] = rgw_raw_obj(zone_params.log_pool, shard_obj_name(source_zone, i));
}
return 0;
{
delete error_logger;
error_logger = nullptr;
- ioctx.close();
}
string RGWDataSyncStatusManager::sync_status_oid(const string& source_zone)
status.encode_all_attrs(attrs);
auto store = sync_env->store;
call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store,
- store->get_zone_params().log_pool,
- sync_status_oid, attrs));
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_status_oid),
+ attrs));
}
return set_cr_done();
}
{
reenter(this) {
yield call(new RGWSimpleRadosReadAttrsCR(sync_env->async_rados, sync_env->store,
- sync_env->store->get_zone_params().log_pool,
- oid,
+ rgw_raw_obj(sync_env->store->get_zone_params().log_pool, oid),
&attrs));
if (retcode == -ENOENT) {
*status = rgw_bucket_shard_sync_info();
RGWRados *store = sync_env->store;
ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl;
- return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, store->get_zone_params().log_pool,
- marker_oid, attrs);
+ return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, marker_oid),
+ attrs);
}
};
RGWRados *store = sync_env->store;
ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl;
- return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store, store->get_zone_params().log_pool,
- marker_oid, attrs);
+ return new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, marker_oid),
+ attrs);
}
/*
sync_status.encode_state_attr(attrs);
RGWRados *store = sync_env->store;
call(new RGWSimpleRadosWriteAttrsCR(sync_env->async_rados, store,
- store->get_zone_params().log_pool,
- status_oid, attrs));
+ rgw_raw_obj(store->get_zone_params().log_pool, status_oid),
+ attrs));
}
} else {
ldout(sync_env->cct, 0) << "ERROR: failure in sync, backing out (sync_status=" << sync_status<< ")" << dendl;
class RGWDataSyncStatusManager {
RGWRados *store;
- librados::IoCtx ioctx;
+ rgw_rados_ref ref;
string source_zone;
RGWRESTConn *conn;
string source_status_oid;
string source_shard_status_oid_prefix;
- rgw_obj source_status_obj;
- map<int, rgw_obj> shard_objs;
+ map<int, rgw_raw_obj> shard_objs;
int num_shards;
class RGWBucketSyncStatusManager {
RGWRados *store;
- librados::IoCtx ioctx;
RGWCoroutinesManager cr_mgr;
string source_status_oid;
string source_shard_status_oid_prefix;
- rgw_obj source_status_obj;
map<int, rgw_bucket_shard_sync_info> sync_status;
- rgw_obj status_obj;
+ rgw_raw_obj status_obj;
int num_shards;
static string shadow_ns = RGW_OBJ_NS_SHADOW;
+static void init_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
+{
+ b->tenant = t;
+ b->name = n;
+ b->marker = m;
+ b->bucket_id = id;
+ b->placement.data_pool = rgw_pool(dp);
+ b->placement.index_pool = rgw_pool(ip);
+}
+
void RGWObjManifestPart::generate_test_instances(std::list<RGWObjManifestPart*>& o)
{
o.push_back(new RGWObjManifestPart);
RGWObjManifestPart *p = new RGWObjManifestPart;
- rgw_bucket b("tenant", "bucket", ".pool", ".index_pool", "marker_", "12", "region");
+ rgw_bucket b;
+ init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
+
p->loc = rgw_obj(b, "object");
p->loc_ofs = 512 * 1024;
p->size = 128 * 1024;
RGWObjManifest *m = new RGWObjManifest;
for (int i = 0; i<10; i++) {
RGWObjManifestPart p;
- rgw_bucket b("tenant", "bucket", ".pool", ".index_pool", "marker_", "12", "region");
+ rgw_bucket b;
+ init_bucket(&b, "tenant", "bucket", ".pool", ".index_pool", "marker_", "12");
p.loc = rgw_obj(b, "object");
p.loc_ofs = 0;
p.size = 512 * 1024;
void rgw_bucket::generate_test_instances(list<rgw_bucket*>& o)
{
- rgw_bucket *b = new rgw_bucket("tenant", "name", "pool", ".index_pool", "marker", "123", "region");
+ rgw_bucket *b = new rgw_bucket;
+ init_bucket(b, "tenant", "name", "pool", ".index_pool", "marker", "123");
o.push_back(b);
o.push_back(new rgw_bucket);
}
void RGWBucketInfo::generate_test_instances(list<RGWBucketInfo*>& o)
{
RGWBucketInfo *i = new RGWBucketInfo;
- i->bucket = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region");
+ init_bucket(&i->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
i->owner = "owner";
i->flags = BUCKET_SUSPENDED;
o.push_back(i);
void RGWBucketEnt::generate_test_instances(list<RGWBucketEnt*>& o)
{
RGWBucketEnt *e = new RGWBucketEnt;
- e->bucket = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region");
+ init_bucket(&e->bucket, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
e->size = 1024;
e->size_rounded = 4096;
e->count = 1;
void rgw_obj::generate_test_instances(list<rgw_obj*>& o)
{
- rgw_bucket b = rgw_bucket("tenant", "bucket", "pool", ".index_pool", "marker", "10", "region");
+ rgw_bucket b;
+ init_bucket(&b, "tenant", "bucket", "pool", ".index_pool", "marker", "10");
rgw_obj *obj = new rgw_obj(b, "object");
o.push_back(obj);
o.push_back(new rgw_obj);
}
+void encode_json(const char *name, const rgw_pool& pool, Formatter *f)
+{
+ f->dump_string(name, pool.name);
+}
+
+void decode_json_obj(rgw_pool& pool, JSONObj *obj)
+{
+ string s;
+ decode_json_obj(s, obj);
+ pool = rgw_pool(s);
+}
+
void RGWOLHInfo::dump(Formatter *f) const
{
encode_json("target", target, f);
JSONDecoder::decode_json("enabled", enabled, obj);
}
-void rgw_bucket::dump(Formatter *f) const
+void rgw_data_placement_target::dump(Formatter *f) const
{
- encode_json("name", name, f);
- encode_json("pool", data_pool, f);
+ encode_json("data_pool", data_pool, f);
encode_json("data_extra_pool", data_extra_pool, f);
encode_json("index_pool", index_pool, f);
+}
+
+void rgw_data_placement_target::decode_json(JSONObj *obj) {
+ JSONDecoder::decode_json("data_pool", data_pool, obj);
+ JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
+ JSONDecoder::decode_json("index_pool", index_pool, obj);
+}
+
+void rgw_bucket::dump(Formatter *f) const
+{
+ encode_json("name", name, f);
encode_json("marker", marker, f);
encode_json("bucket_id", bucket_id, f);
encode_json("tenant", tenant, f);
+ encode_json("placement", placement, f);
}
void rgw_bucket::decode_json(JSONObj *obj) {
JSONDecoder::decode_json("name", name, obj);
- JSONDecoder::decode_json("pool", data_pool, obj);
- JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
- JSONDecoder::decode_json("index_pool", index_pool, obj);
JSONDecoder::decode_json("marker", marker, obj);
JSONDecoder::decode_json("bucket_id", bucket_id, obj);
JSONDecoder::decode_json("tenant", tenant, obj);
+ JSONDecoder::decode_json("placement", placement, obj);
+ if (placement.data_pool.empty()) {
+ /* decoding old format */
+ JSONDecoder::decode_json("pool", placement.data_pool, obj);
+ JSONDecoder::decode_json("data_extra_pool", placement.data_extra_pool, obj);
+ JSONDecoder::decode_json("index_pool", placement.index_pool, obj);
+ }
}
void RGWBucketEntryPoint::dump(Formatter *f) const
encode_json("modified", ut, f);
}
+void rgw_raw_obj::dump(Formatter *f) const
+{
+ encode_json("pool", pool, f);
+ encode_json("oid", oid, f);
+ encode_json("loc", loc, f);
+}
+
+void rgw_raw_obj::decode_json(JSONObj *obj) {
+ JSONDecoder::decode_json("pool", pool, obj);
+ JSONDecoder::decode_json("oid", oid, obj);
+ JSONDecoder::decode_json("loc", loc, obj);
+}
+
void rgw_obj::dump(Formatter *f) const
{
encode_json("bucket", bucket, f);
void RGWZoneParams::dump(Formatter *f) const
{
RGWSystemMetaObj::dump(f);
- encode_json("domain_root", domain_root.data_pool, f);
- encode_json("control_pool", control_pool.data_pool, f);
- encode_json("gc_pool", gc_pool.data_pool, f);
- encode_json("lc_pool", lc_pool.data_pool, f);
- encode_json("log_pool", log_pool.data_pool, f);
- encode_json("intent_log_pool", intent_log_pool.data_pool, f);
- encode_json("usage_log_pool", usage_log_pool.data_pool, f);
- encode_json("user_keys_pool", user_keys_pool.data_pool, f);
- encode_json("user_email_pool", user_email_pool.data_pool, f);
- encode_json("user_swift_pool", user_swift_pool.data_pool, f);
- encode_json("user_uid_pool", user_uid_pool.data_pool, f);
+ encode_json("domain_root", domain_root, f);
+ encode_json("control_pool", control_pool, f);
+ encode_json("gc_pool", gc_pool, f);
+ encode_json("lc_pool", lc_pool, f);
+ encode_json("log_pool", log_pool, f);
+ encode_json("intent_log_pool", intent_log_pool, f);
+ encode_json("usage_log_pool", usage_log_pool, f);
+ encode_json("user_keys_pool", user_keys_pool, f);
+ encode_json("user_email_pool", user_email_pool, f);
+ encode_json("user_swift_pool", user_swift_pool, f);
+ encode_json("user_uid_pool", user_uid_pool, f);
encode_json_plain("system_key", system_key, f);
encode_json("placement_pools", placement_pools, f);
- encode_json("metadata_heap", metadata_heap.data_pool, f);
+ encode_json("metadata_heap", metadata_heap, f);
encode_json("tier_config", tier_config, f);
encode_json("realm_id", realm_id, f);
}
-static void decode_json(const char *field, rgw_bucket& bucket, JSONObj *obj)
-{
- string pool;
- JSONDecoder::decode_json(field, pool, obj);
- bucket = rgw_bucket(pool.c_str());
-}
-
void RGWZonePlacementInfo::dump(Formatter *f) const
{
encode_json("index_pool", index_pool, f);
void RGWZoneParams::decode_json(JSONObj *obj)
{
RGWSystemMetaObj::decode_json(obj);
- ::decode_json("domain_root", domain_root, obj);
- ::decode_json("control_pool", control_pool, obj);
- ::decode_json("gc_pool", gc_pool, obj);
- ::decode_json("lc_pool", lc_pool, obj);
- ::decode_json("log_pool", log_pool, obj);
- ::decode_json("intent_log_pool", intent_log_pool, obj);
- ::decode_json("usage_log_pool", usage_log_pool, obj);
- ::decode_json("user_keys_pool", user_keys_pool, obj);
- ::decode_json("user_email_pool", user_email_pool, obj);
- ::decode_json("user_swift_pool", user_swift_pool, obj);
- ::decode_json("user_uid_pool", user_uid_pool, obj);
+ JSONDecoder::decode_json("domain_root", domain_root, obj);
+ JSONDecoder::decode_json("control_pool", control_pool, obj);
+ JSONDecoder::decode_json("gc_pool", gc_pool, obj);
+ JSONDecoder::decode_json("lc_pool", lc_pool, obj);
+ JSONDecoder::decode_json("log_pool", log_pool, obj);
+ JSONDecoder::decode_json("intent_log_pool", intent_log_pool, obj);
+ JSONDecoder::decode_json("usage_log_pool", usage_log_pool, obj);
+ JSONDecoder::decode_json("user_keys_pool", user_keys_pool, obj);
+ JSONDecoder::decode_json("user_email_pool", user_email_pool, obj);
+ JSONDecoder::decode_json("user_swift_pool", user_swift_pool, obj);
+ JSONDecoder::decode_json("user_uid_pool", user_uid_pool, obj);
JSONDecoder::decode_json("system_key", system_key, obj);
JSONDecoder::decode_json("placement_pools", placement_pools, obj);
- ::decode_json("metadata_heap", metadata_heap, obj);
+ JSONDecoder::decode_json("metadata_heap", metadata_heap, obj);
JSONDecoder::decode_json("tier_config", tier_config, obj);
JSONDecoder::decode_json("realm_id", realm_id, obj);
string oid = render_log_object_name(s->cct->_conf->rgw_log_object_name, &bdt,
s->bucket.bucket_id, entry.bucket);
- rgw_obj obj(store->get_zone_params().log_pool, oid);
+ rgw_raw_obj obj(store->get_zone_params().log_pool, oid);
ret = store->append_async(obj, bl.length(), bl);
if (ret == -ENOENT) {
int put(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker,
real_time mtime, JSONObj *obj, sync_type_t sync_type) override { return -ENOTSUP; }
- void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {}
+ virtual void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {}
int remove(RGWRados *store, string& entry, RGWObjVersionTracker& objv_tracker) override { return -ENOTSUP; }
if (ret < 0)
return ret;
- rgw_bucket pool;
+ rgw_pool pool;
string oid;
handler->get_pool_and_oid(store, entry, pool, oid);
if (ret < 0)
return ret;
- rgw_bucket pool;
+ rgw_pool pool;
string oid;
handler->get_pool_and_oid(store, entry, pool, oid);
return -EINVAL;
}
- rgw_bucket heap_pool(store->get_zone_params().metadata_heap);
+ rgw_pool heap_pool(store->get_zone_params().metadata_heap);
if (heap_pool.name.empty()) {
return 0;
return -EINVAL;
}
- rgw_bucket heap_pool(store->get_zone_params().metadata_heap);
+ rgw_pool heap_pool(store->get_zone_params().metadata_heap);
if (heap_pool.name.empty()) {
return 0;
}
string oid = heap_oid(handler, key, objv_tracker->write_version);
- rgw_obj obj(heap_pool, oid);
+ rgw_raw_obj obj(heap_pool, oid);
int ret = store->delete_system_obj(obj);
if (ret < 0) {
ldout(store->ctx(), 0) << "ERROR: store->delete_system_obj()=" << oid << ") returned ret=" << ret << dendl;
return ret;
string oid;
- rgw_bucket bucket;
+ rgw_pool pool;
- handler->get_pool_and_oid(store, key, bucket, oid);
+ handler->get_pool_and_oid(store, key, pool, oid);
ret = store_in_heap(handler, key, bl, objv_tracker, mtime, pattrs);
if (ret < 0) {
goto done;
}
- ret = rgw_put_system_obj(store, bucket, oid,
+ ret = rgw_put_system_obj(store, pool, oid,
bl.c_str(), bl.length(), exclusive,
objv_tracker, mtime, pattrs);
return ret;
string oid;
- rgw_bucket bucket;
+ rgw_pool pool;
- handler->get_pool_and_oid(store, key, bucket, oid);
+ handler->get_pool_and_oid(store, key, pool, oid);
- rgw_obj obj(bucket, oid);
+ rgw_raw_obj obj(pool, oid);
ret = store->delete_system_obj(obj, objv_tracker);
/* cascading ret into post_modify() */
return 0;
}
-static int get_bucket_policy_from_attr(CephContext *cct,
+static int get_bucket_instance_policy_from_attr(CephContext *cct,
RGWRados *store,
- void *ctx,
RGWBucketInfo& bucket_info,
map<string, bufferlist>& bucket_attrs,
RGWAccessControlPolicy *policy,
- rgw_obj& obj)
+ rgw_raw_obj& obj)
{
map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL);
* object: name of the object to get the ACL for.
* Returns: 0 on success, -ERR# otherwise.
*/
-static int get_policy_from_attr(CephContext *cct,
+static int get_bucket_policy_from_attr(CephContext *cct,
RGWRados *store,
- void *ctx,
RGWBucketInfo& bucket_info,
map<string, bufferlist>& bucket_attrs,
- RGWAccessControlPolicy *policy,
- rgw_obj& obj)
+ RGWAccessControlPolicy *policy)
{
- if (obj.bucket.name.empty()) {
- return 0;
- }
-
- if (obj.get_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, instance_obj);
- }
- return get_obj_policy_from_attr(cct, store, *static_cast<RGWObjectCtx *>(ctx), bucket_info, bucket_attrs,
- policy, obj);
+ rgw_raw_obj instance_obj;
+ store->get_bucket_instance_obj(bucket_info.bucket, instance_obj);
+ return get_bucket_instance_policy_from_attr(cct, store, bucket_info, bucket_attrs,
+ policy, instance_obj);
}
static int get_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map<string, bufferlist>& attrs)
return store->set_attrs(s->obj_ctx, read_op.state.obj, attrs, NULL);
}
-static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map<string, bufferlist>& attrs,
+static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_raw_obj& obj, map<string, bufferlist>& attrs,
uint64_t *obj_size, RGWObjVersionTracker *objv_tracker)
{
RGWRados::SystemObject src(store, *static_cast<RGWObjectCtx *>(s->obj_ctx), obj);
return ret;
}
-static int read_policy(RGWRados *store,
- struct req_state *s,
- RGWBucketInfo& bucket_info,
- map<string, bufferlist>& bucket_attrs,
- RGWAccessControlPolicy *policy,
- rgw_bucket& bucket,
- rgw_obj_key& object)
+static int read_bucket_policy(RGWRados *store,
+ struct req_state *s,
+ RGWBucketInfo& bucket_info,
+ map<string, bufferlist>& bucket_attrs,
+ RGWAccessControlPolicy *policy,
+ rgw_bucket& bucket)
+{
+ if (!s->system_request && bucket_info.flags & BUCKET_SUSPENDED) {
+ ldout(s->cct, 0) << "NOTICE: bucket " << bucket_info.bucket.name << " is suspended" << dendl;
+ return -ERR_USER_SUSPENDED;
+ }
+
+ if (bucket.name.empty()) {
+ return 0;
+ }
+
+ int ret = get_bucket_policy_from_attr(s->cct, store, bucket_info, bucket_attrs, policy);
+ if (ret == -ENOENT) {
+ ret = -ERR_NO_SUCH_BUCKET;
+ }
+
+ return ret;
+}
+
+static int read_obj_policy(RGWRados *store,
+ struct req_state *s,
+ RGWBucketInfo& bucket_info,
+ map<string, bufferlist>& bucket_attrs,
+ RGWAccessControlPolicy *policy,
+ rgw_bucket& bucket,
+ rgw_obj_key& object)
{
string upload_id;
upload_id = s->info.args.get("uploadId");
return -ERR_USER_SUSPENDED;
}
- if (!object.empty() && !upload_id.empty()) {
+ if (!upload_id.empty()) {
/* multipart upload */
RGWMPObj mp(object.name, upload_id);
string oid = mp.get_meta();
obj = rgw_obj(bucket, object.name);
obj.set_instance(object.instance);
}
- int ret = get_policy_from_attr(s->cct, store, s->obj_ctx, bucket_info, bucket_attrs, policy, obj);
- if (ret == -ENOENT && !object.empty()) {
+ RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
+ int ret = get_obj_policy_from_attr(s->cct, store, *obj_ctx,
+ bucket_info, bucket_attrs, policy, obj);
+ if (ret == -ENOENT) {
/* object does not exist checking the bucket's ACL to make sure
that we send a proper error code */
RGWAccessControlPolicy bucket_policy(s->cct);
- string no_object;
- rgw_obj no_obj(bucket, no_object);
- ret = get_policy_from_attr(s->cct, store, s->obj_ctx, bucket_info, bucket_attrs, &bucket_policy, no_obj);
+ ret = get_bucket_policy_from_attr(s->cct, store, bucket_info, bucket_attrs, &bucket_policy);
if (ret < 0) {
return ret;
}
} else {
ret = -ENOENT;
}
- } else if (ret == -ENOENT) {
- ret = -ERR_NO_SUCH_BUCKET;
}
return ret;
s->bucket = s->bucket_info.bucket;
if (s->bucket_exists) {
- rgw_obj_key no_obj;
- ret = read_policy(store, s, s->bucket_info, s->bucket_attrs, s->bucket_acl, s->bucket, no_obj);
+ ret = read_bucket_policy(store, s, s->bucket_info, s->bucket_attrs, s->bucket_acl, s->bucket);
acct_acl_user = {
s->bucket_info.owner,
s->bucket_acl->get_owner().get_display_name(),
if (prefetch_data) {
store->set_prefetch_data(s->obj_ctx, obj);
}
- ret = read_policy(store, s, s->bucket_info, s->bucket_attrs, s->object_acl, s->bucket, s->object);
+ ret = read_obj_policy(store, s, s->bucket_info, s->bucket_attrs, s->object_acl, s->bucket, s->object);
}
return ret;
ldout(s->cct, 20) << "reading obj=" << part << " ofs=" << cur_ofs << " end=" << cur_end << dendl;
- obj_ctx.set_atomic(part);
+ obj_ctx.obj.set_atomic(part);
store->set_prefetch_data(&obj_ctx, part);
RGWRados::Object op_target(store, s->bucket_info, obj_ctx, part);
}
bucket = bucket_info.bucket;
pbucket_info = &bucket_info;
- rgw_obj_key no_obj;
bucket_policy = &_bucket_policy;
- r = read_policy(store, s, bucket_info, bucket_attrs, bucket_policy, bucket, no_obj);
+ r = read_bucket_policy(store, s, bucket_info, bucket_attrs, bucket_policy, bucket);
if (r < 0) {
ldout(s->cct, 0) << "failed to read bucket policy" << dendl;
return r;
return r;
}
bucket = bucket_info.bucket;
- rgw_obj_key no_obj;
bucket_policy = &_bucket_policy;
- r = read_policy(store, s, bucket_info, bucket_attrs, bucket_policy,
- bucket, no_obj);
+ r = read_bucket_policy(store, s, bucket_info, bucket_attrs, bucket_policy,
+ bucket);
if (r < 0) {
ldout(s->cct, 0) << "failed to read bucket policy for bucket "
<< bucket << dendl;
bool existed;
string bucket_name;
rgw_make_bucket_entry_name(s->bucket_tenant, s->bucket_name, bucket_name);
- rgw_obj obj(store->get_zone_params().domain_root, bucket_name);
+ rgw_raw_obj obj(store->get_zone_params().domain_root, bucket_name);
obj_version objv, *pobjv = NULL;
op_ret = get_params();
s->bucket_owner.set_id(s->user->user_id);
s->bucket_owner.set_name(s->user->display_name);
if (s->bucket_exists) {
- int r = get_policy_from_attr(s->cct, store, s->obj_ctx, s->bucket_info,
- s->bucket_attrs, &old_policy, obj);
+ int r = get_bucket_policy_from_attr(s->cct, store, s->bucket_info,
+ s->bucket_attrs, &old_policy);
if (r >= 0) {
if (old_policy.get_owner().get_id().compare(s->user->user_id) != 0) {
op_ret = -EEXIST;
meta_obj.init_ns(bucket, multipart_meta_obj, mp_ns);
meta_obj.set_in_extra_data(true);
- r = store->omap_set(meta_obj, p, bl);
+ rgw_raw_obj raw_meta_obj;
+
+ store->obj_to_raw(meta_obj, &raw_meta_obj);
+
+ r = store->omap_set(raw_meta_obj, p, bl);
return r;
}
}
RGWObjectCtx *obj_ctx = static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx->set_atomic(obj);
+ obj_ctx->obj.set_atomic(obj);
bool ver_restored = false;
op_ret = store->swift_versioning_restore(*obj_ctx, s->bucket_owner.get_id(),
store->set_prefetch_data(s->obj_ctx, src_obj);
/* check source object permissions */
- op_ret = read_policy(store, s, src_bucket_info, src_attrs, &src_policy,
+ op_ret = read_obj_policy(store, s, src_bucket_info, src_attrs, &src_policy,
src_bucket, src_object);
if (op_ret < 0) {
return op_ret;
rgw_obj dest_obj(dest_bucket, dest_object);
store->set_atomic(s->obj_ctx, dest_obj);
- rgw_obj_key no_obj;
-
/* check dest bucket permissions */
- op_ret = read_policy(store, s, dest_bucket_info, dest_attrs,
- &dest_bucket_policy, dest_bucket, no_obj);
+ op_ret = read_bucket_policy(store, s, dest_bucket_info, dest_attrs,
+ &dest_bucket_policy, dest_bucket);
if (op_ret < 0) {
return op_ret;
}
rgw_obj dst_obj(dest_bucket, dest_object);
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx.set_atomic(src_obj);
- obj_ctx.set_atomic(dst_obj);
+ obj_ctx.obj.set_atomic(src_obj);
+ obj_ctx.obj.set_atomic(dst_obj);
encode_delete_at_attr(delete_at, attrs);
}
new_policy.encode(bl);
- obj = rgw_obj(s->bucket, s->object.name);
- obj.set_instance(s->object.instance);
map<string, bufferlist> attrs;
if (!s->object.empty()) {
+ obj = rgw_obj(s->bucket, s->object);
+ store->set_atomic(s->obj_ctx, obj);
//if instance is empty, we should modify the latest object
op_ret = modify_obj_attr(store, s, obj, RGW_ATTR_ACL, bl);
} else {
- store->set_atomic(s->obj_ctx, obj);
-
attrs = s->bucket_attrs;
attrs[RGW_ATTR_ACL] = bl;
op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker);
bufferlist bl;
map<string, bufferlist> orig_attrs, attrs;
map<string, bufferlist>::iterator iter;
- rgw_obj obj;
+ rgw_raw_obj obj;
store->get_bucket_instance_obj(s->bucket, obj);
- store->set_atomic(s->obj_ctx, obj);
+ store->set_prefetch_data(s->obj_ctx, obj);
op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker);
if (op_ret < 0)
return;
void RGWPutCORS::execute()
{
- rgw_obj obj;
+ rgw_raw_obj obj;
op_ret = get_params();
if (op_ret < 0)
return;
- bool is_object_op = (!s->object.empty());
- if (is_object_op) {
- store->get_bucket_instance_obj(s->bucket, obj);
- store->set_atomic(s->obj_ctx, obj);
- op_ret = store->set_attr(s->obj_ctx, obj, RGW_ATTR_CORS, cors_bl);
- } else {
- map<string, bufferlist> attrs = s->bucket_attrs;
- attrs[RGW_ATTR_CORS] = cors_bl;
- op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker);
- }
+ map<string, bufferlist> attrs = s->bucket_attrs;
+ attrs[RGW_ATTR_CORS] = cors_bl;
+ op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker);
}
int RGWDeleteCORS::verify_permission()
return;
bufferlist bl;
- rgw_obj obj;
+ rgw_raw_obj obj;
if (!cors_exist) {
dout(2) << "No CORS configuration set yet for this bucket" << dendl;
op_ret = -ENOENT;
return;
}
store->get_bucket_instance_obj(s->bucket, obj);
- store->set_atomic(s->obj_ctx, obj);
+ store->set_prefetch_data(s->obj_ctx, obj);
map<string, bufferlist> orig_attrs, attrs, rmattrs;
map<string, bufferlist>::iterator iter;
- bool is_object_op = (!s->object.empty());
-
-
- if (is_object_op) {
- /* check if obj exists, read orig attrs */
- op_ret = get_obj_attrs(store, s, obj, orig_attrs);
- if (op_ret < 0)
- return;
- } else {
- op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker);
- if (op_ret < 0)
- return;
- }
+ op_ret = get_system_obj_attrs(store, s, obj, orig_attrs, NULL, &s->bucket_info.objv_tracker);
+ if (op_ret < 0)
+ return;
/* only remove meta attrs */
for (iter = orig_attrs.begin(); iter != orig_attrs.end(); ++iter) {
attrs[name] = iter->second;
}
}
- if (is_object_op) {
- op_ret = store->set_attrs(s->obj_ctx, obj, attrs, &rmattrs);
- } else {
- op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker);
- }
+ op_ret = rgw_bucket_set_attrs(store, s->bucket_info, attrs, &s->bucket_info.objv_tracker);
}
void RGWOptionsCORS::get_response_params(string& hdrs, string& exp_hdrs, unsigned *max_age) {
obj.init_ns(s->bucket, meta_oid, mp_ns);
obj.set_in_extra_data(true);
+ rgw_raw_obj raw_obj;
+ store->obj_to_raw(obj, &raw_obj);
+
bool sorted_omap = is_v2_upload_id(upload_id) && !assume_unsorted;
int ret;
snprintf(buf, sizeof(buf), "%08d", marker);
p.append(buf);
- ret = store->omap_get_vals(obj, header, p, num_parts + 1, parts_map);
+ ret = store->omap_get_vals(raw_obj, header, p, num_parts + 1, parts_map);
} else {
- ret = store->omap_get_all(obj, header, parts_map);
+ ret = store->omap_get_all(raw_obj, header, parts_map);
}
if (ret < 0)
return ret;
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx.set_atomic(target_obj);
+ obj_ctx.obj.set_atomic(target_obj);
RGWRados::Object op_target(store, s->bucket_info, *static_cast<RGWObjectCtx *>(s->obj_ctx), target_obj);
RGWRados::Object::Write obj_op(&op_target);
rgw_obj obj(bucket, iter->name);
obj.set_instance(iter->instance);
- obj_ctx->set_atomic(obj);
+ obj_ctx->obj.set_atomic(obj);
RGWRados::Object del_target(store, s->bucket_info, *obj_ctx, obj);
RGWRados::Object::Delete del_op(&del_target);
ACLOwner& bucket_owner /* out */)
{
RGWAccessControlPolicy bacl(store->ctx());
- rgw_obj_key no_obj;
- int ret = read_policy(store, s, binfo, battrs, &bacl, binfo.bucket, no_obj);
+ int ret = read_bucket_policy(store, s, binfo, battrs, &bacl, binfo.bucket);
if (ret < 0) {
return false;
}
if (!path.obj_key.empty()) {
rgw_obj obj(binfo.bucket, path.obj_key);
- obj_ctx.set_atomic(obj);
+ obj_ctx.obj.set_atomic(obj);
RGWRados::Object del_target(store, binfo, obj_ctx, obj);
RGWRados::Object::Delete del_op(&del_target);
return 0;
}
+int RGWRados::get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref)
+{
+ get_obj_bucket_and_oid_loc(obj, ref->oid, ref->key);
+
+ int r;
+
+ if (!obj.is_in_extra_data()) {
+ r = open_pool_ctx(obj.bucket.placement.data_pool, ref->ioctx);
+ } else {
+ r = open_pool_ctx(obj.bucket.placement.get_data_extra_pool(), ref->ioctx);
+ }
+ if (r < 0)
+ return r;
+
+ ref->ioctx.locator_set_key(ref->key);
+
+ return 0;
+}
+
int RGWRados::get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool)
{
- *pool = obj.pool;
ref->oid = obj.oid;
- ref->key.clear();
+ ref->key = obj.loc;
int r;
if (ref->oid.empty()) {
- ref->oid = pool->name;
- *pool = get_zone_params().domain_root;
+ ref->oid = obj.pool.name;
+ ref->pool = get_zone_params().domain_root;
+ } else {
+ ref->pool = obj.pool;
}
- r = open_pool_ctx(pool->name, ref->ioctx);
+ if (pool) {
+ *pool = ref->pool;
+ }
+ r = open_pool_ctx(ref->pool.name, ref->ioctx);
if (r < 0)
return r;
+ ref->ioctx.locator_set_key(ref->key);
+
return 0;
}
}
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
return -EIO;
}
- r = store->get_obj_ref(obj, &ref, &pool);
+ r = store->get_obj_ref(obj, &ref);
if (r < 0)
return r;
void **handle)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
}
rgw_rados_ref ref;
- rgw_pool pool;
- ret = get_obj_ref(miter.get_location(), &ref, &pool);
+ ret = get_obj_ref(miter.get_location(), &ref);
if (ret < 0) {
return ret;
}
}
rgw_rados_ref ref;
- rgw_pool pool;
- int r = store->get_obj_ref(obj, &ref, &pool);
+ int r = store->get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
map<string, bufferlist>* rmattrs)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::obj_operate(rgw_obj& obj, ObjectWriteOperation *op)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::obj_operate(rgw_obj& obj, ObjectReadOperation *op)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
real_time unmod_since, bool high_precision_time)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj_instance, &ref, &pool);
+ int r = get_obj_ref(obj_instance, &ref);
if (r < 0) {
return r;
}
int RGWRados::bucket_index_unlink_instance(rgw_obj& obj_instance, const string& op_tag, const string& olh_tag, uint64_t olh_epoch)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj_instance, &ref, &pool);
+ int r = get_obj_ref(obj_instance, &ref);
if (r < 0) {
return r;
}
bool *is_truncated)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj_instance, &ref, &pool);
+ int r = get_obj_ref(obj_instance, &ref);
if (r < 0) {
return r;
}
int RGWRados::bucket_index_trim_olh_log(RGWObjState& state, rgw_obj& obj_instance, uint64_t ver)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj_instance, &ref, &pool);
+ int r = get_obj_ref(obj_instance, &ref);
if (r < 0) {
return r;
}
int RGWRados::bucket_index_clear_olh(RGWObjState& state, rgw_obj& obj_instance)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj_instance, &ref, &pool);
+ int r = get_obj_ref(obj_instance, &ref);
if (r < 0) {
return r;
}
}
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
}
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_obj_ref(olh_obj, &ref, &pool);
+ int r = get_obj_ref(olh_obj, &ref);
if (r < 0) {
return r;
}
RGWObjVersionTracker *objv_tracker)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::omap_get_vals(rgw_raw_obj& obj, bufferlist& header, const string& marker, uint64_t count, std::map<string, bufferlist>& m)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
- ldout(cct, 15) << "omap_set pool=" << pool << " oid=" << ref.oid << " key=" << key << dendl;
+ ldout(cct, 15) << "omap_set obj=" << obj << " key=" << key << dendl;
map<string, bufferlist> m;
m[key] = bl;
int RGWRados::omap_set(rgw_raw_obj& obj, std::map<std::string, bufferlist>& m)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::omap_del(rgw_raw_obj& obj, const std::string& key)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int r = get_raw_obj_ref(obj, &ref, &pool);
+ int r = get_raw_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
int RGWRados::bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent)
{
- rgw_pool pool;
rgw_rados_ref ref;
- int r = get_obj_ref(obj, &ref, &pool);
+ int r = get_obj_ref(obj, &ref);
if (r < 0) {
return r;
}
list<librados::AioCompletion *>& handles, bool keep_index_consistent)
{
rgw_rados_ref ref;
- rgw_pool pool;
- int ret = get_obj_ref(obj, &ref, &pool);
+ int ret = get_obj_ref(obj, &ref);
if (ret < 0) {
lderr(cct) << "ERROR: failed to get obj ref with ret=" << ret << dendl;
return ret;
class RGWGetUserHeader_CB;
struct rgw_rados_ref {
+ rgw_pool pool;
string oid;
string key;
librados::IoCtx ioctx;
void set_atomic(T& obj) {
RWLock::WLocker wl(lock);
- assert (!obj.get_object().empty());
+ assert (!obj.empty());
objs_state[obj].is_atomic = true;
}
void set_prefetch_data(T& obj) {
RWLock::WLocker wl(lock);
- assert (!obj.get_object().empty());
+ assert (!obj.empty());
objs_state[obj].prefetch_data = true;
}
void invalidate(T& obj) {
};
struct RGWObjectCtx {
+ RGWRados *store;
void *user_ctx;
RGWObjectCtxImpl<rgw_obj, RGWObjState> obj;
RGWObjectCtxImpl<rgw_raw_obj, RGWRawObjState> raw;
- explicit RGWObjectCtx(RGWRados *store) : user_ctx(NULL), obj(store), raw(store) { }
- RGWObjectCtx(RGWRados *store, void *_user_ctx) : user_ctx(_user_ctx), obj(store), raw(store) { }
+ explicit RGWObjectCtx(RGWRados *_store) : store(_store), user_ctx(NULL), obj(store), raw(store) { }
+ RGWObjectCtx(RGWRados *_store, void *_user_ctx) : store(_store), user_ctx(_user_ctx), obj(store), raw(store) { }
};
class Finisher;
uint32_t bucket_index_max_shards;
int get_obj_ioctx(const rgw_obj& obj, librados::IoCtx *ioctx);
- int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool);
- int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool);
- void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj);
- int get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool);
+ int get_obj_ref(const rgw_obj& obj, rgw_rados_ref *ref);
+ int get_system_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL);
uint64_t max_bucket_id;
int get_olh_target_state(RGWObjectCtx& rctx, rgw_obj& obj, RGWObjState *olh_state,
return MAX_BUCKET_INDEX_SHARDS_PRIME;
}
+ int get_raw_obj_ref(const rgw_raw_obj& obj, rgw_rados_ref *ref, rgw_pool *pool = NULL);
+ void obj_to_raw(const rgw_obj& obj, rgw_raw_obj *raw_obj);
+
int list_raw_objects(const rgw_pool& pool, const string& prefix_filter, int max,
RGWListRawObjsCtx& ctx, list<string>& oids,
bool *is_truncated);
int init_complete();
int replace_region_with_zonegroup();
int convert_regionmap();
- virtual int initialize();
- virtual void finalize();
+ int initialize();
+ void finalize();
void schedule_context(Context *c);
/** set up a bucket listing. handle is filled in. */
- virtual int list_buckets_init(RGWAccessHandle *handle);
+ int list_buckets_init(RGWAccessHandle *handle);
/**
* get the next bucket in the listing. obj is filled in,
* handle is updated.
*/
- virtual int list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle);
+ int list_buckets_next(RGWObjEnt& obj, RGWAccessHandle *handle);
/// list logs
int log_list_init(const string& prefix, RGWAccessHandle *handle);
* create a bucket with name bucket and the given list of attrs
* returns 0 on success, -ERR# otherwise.
*/
- virtual int init_bucket_index(rgw_bucket& bucket, int num_shards);
+ int init_bucket_index(rgw_bucket& bucket, int num_shards);
int select_bucket_placement(RGWUserInfo& user_info, const string& zonegroup_id, const string& rule,
const string& tenant_name, const string& bucket_name, rgw_bucket& bucket, string *pselected_rule_name,
RGWZonePlacementInfo *rule_info);
int set_bucket_location_by_rule(const string& location_rule, const string& tenant_name, const string& bucket_name, rgw_bucket& bucket,
RGWZonePlacementInfo *rule_info);
void create_bucket_id(string *bucket_id);
- virtual int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
+ int create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
const string& zonegroup_id,
const string& placement_rule,
const string& swift_ver_location,
ceph::real_time creation_time,
rgw_bucket *master_bucket,
bool exclusive = true);
- virtual int add_bucket_placement(std::string& new_pool);
- virtual int remove_bucket_placement(std::string& new_pool);
- virtual int list_placement_set(set<string>& names);
- virtual int create_pools(vector<string>& names, vector<int>& retcodes);
+ int add_bucket_placement(std::string& new_pool);
+ int remove_bucket_placement(std::string& new_pool);
+ int list_placement_set(set<string>& names);
+ int create_pools(vector<string>& names, vector<int>& retcodes);
RGWCoroutinesManagerRegistry *get_cr_registry() { return cr_registry; }
virtual int put_system_obj_data(void *ctx, rgw_raw_obj& obj, bufferlist& bl,
off_t ofs, bool exclusive);
- virtual int put_obj_data(void *ctx, rgw_obj& obj, const char *data,
+ int put_obj_data(void *ctx, rgw_obj& obj, const char *data,
off_t ofs, size_t len, bool exclusive);
- virtual int aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl,
+ int aio_put_obj_data(void *ctx, rgw_obj& obj, bufferlist& bl,
off_t ofs, bool exclusive, void **handle);
int put_system_obj(void *ctx, rgw_raw_obj& obj, const char *data, size_t len, bool exclusive,
return put_system_obj_impl(obj, len, mtime, attrs, flags, bl, objv_tracker, set_mtime);
}
- virtual int aio_wait(void *handle);
- virtual bool aio_completed(void *handle);
+ int aio_wait(void *handle);
+ bool aio_completed(void *handle);
int on_last_entry_in_listing(RGWBucketInfo& bucket_info,
const std::string& obj_prefix,
* err: stores any errors resulting from the get of the original object
* Returns: 0 on success, -ERR# otherwise.
*/
- virtual int copy_obj(RGWObjectCtx& obj_ctx,
+ int copy_obj(RGWObjectCtx& obj_ctx,
const rgw_user& user_id,
const string& client_id,
const string& op_id,
* bucket: the name of the bucket to delete
* Returns 0 on success, -ERR# otherwise.
*/
- virtual int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker);
+ int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker);
bool is_meta_master();
int bucket_suspended(rgw_bucket& bucket, bool *suspended);
/** Delete an object.*/
- virtual int delete_obj(RGWObjectCtx& obj_ctx,
+ int delete_obj(RGWObjectCtx& obj_ctx,
RGWBucketInfo& bucket_owner,
const rgw_obj& src_obj,
int versioning_status,
void gen_rand_obj_instance_name(rgw_obj *target);
int omap_get_vals(rgw_raw_obj& obj, bufferlist& header, const std::string& marker, uint64_t count, std::map<string, bufferlist>& m);
- virtual int omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
- virtual int omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl);
- virtual int omap_set(rgw_raw_obj& obj, map<std::string, bufferlist>& m);
- virtual int omap_del(rgw_raw_obj& obj, const std::string& key);
- virtual int update_containers_stats(map<string, RGWBucketEnt>& m);
- virtual int append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl);
+ int omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
+ int omap_set(rgw_raw_obj& obj, std::string& key, bufferlist& bl);
+ int omap_set(rgw_raw_obj& obj, map<std::string, bufferlist>& m);
+ int omap_del(rgw_raw_obj& obj, const std::string& key);
+ int update_containers_stats(map<string, RGWBucketEnt>& m);
+ int append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl);
int watch(const string& oid, uint64_t *watch_handle, librados::WatchCtx2 *ctx);
int unwatch(uint64_t watch_handle);
void add_watcher(int i);
void remove_watcher(int i);
virtual bool need_watch_notify() { return false; }
- virtual int init_watch();
- virtual void finalize_watch();
- virtual int distribute(const string& key, bufferlist& bl);
+ int init_watch();
+ void finalize_watch();
+ int distribute(const string& key, bufferlist& bl);
virtual int watch_cb(uint64_t notify_id,
uint64_t cookie,
uint64_t notifier_id,
RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
rctx->obj.set_prefetch_data(obj);
}
+ void set_prefetch_data(void *ctx, rgw_raw_obj& obj) {
+ RGWObjectCtx *rctx = static_cast<RGWObjectCtx *>(ctx);
+ rctx->raw.set_prefetch_data(obj);
+ }
int decode_policy(bufferlist& bl, ACLOwner *owner);
int get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ver, string *master_ver,
int convert_old_bucket_info(RGWObjectCtx& obj_ctx, const string& tenant_name, const string& bucket_name);
static void make_bucket_entry_name(const string& tenant_name, const string& bucket_name, string& bucket_entry);
- virtual int get_bucket_info(RGWObjectCtx& obj_ctx,
+ int get_bucket_info(RGWObjectCtx& obj_ctx,
const string& tenant_name, const string& bucket_name,
RGWBucketInfo& info,
ceph::real_time *pmtime, map<string, bufferlist> *pattrs = NULL);
- virtual int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, obj_version *pep_objv,
+ int put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, ceph::real_time mtime, obj_version *pep_objv,
map<string, bufferlist> *pattrs, bool create_entry_point);
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
{
int r = store->get_rados_handle()->ioctx_create(pool.c_str(), ctx);
if (r == -ENOENT) {
- rgw_bucket p(pool.c_str());
+ rgw_pool p(pool);
r = store->create_pool(p);
if (r < 0)
return r;
/* First, get attrset of the object we'll try to retrieve. */
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx.set_atomic(obj);
+ obj_ctx.obj.set_atomic(obj);
+ obj_ctx.obj.set_prefetch_data(obj);
RGWObjState* state = nullptr;
if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) {
rgw_obj obj(s->bucket, index);
RGWObjectCtx& obj_ctx = *static_cast<RGWObjectCtx *>(s->obj_ctx);
- obj_ctx.set_atomic(obj);
+ obj_ctx.obj.set_atomic(obj);
+ obj_ctx.obj.set_prefetch_data(obj);
RGWObjState* state = nullptr;
if (store->get_obj_state(&obj_ctx, obj, &state, false) < 0) {
int num_shards = master_log.get_sync_status().sync_info.num_shards;
for (int i = 0; i < num_shards; i++) {
- shard_objs[i] = rgw_obj(store->get_zone_params().log_pool, sync_env.shard_obj_name(i));
+ shard_objs[i] = rgw_raw_obj(store->get_zone_params().log_pool, sync_env.shard_obj_name(i));
}
RWLock::WLocker wl(ts_to_shard_lock);
uint32_t lock_duration = cct->_conf->rgw_sync_lease_period;
string lock_name = "sync_lock";
RGWRados *store = sync_env->store;
- lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, store->get_zone_params().log_pool, sync_env->status_oid(),
+ lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()),
lock_name, lock_duration, this);
lease_cr->get();
lease_stack = spawn(lease_cr, false);
yield {
set_status("writing sync status");
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_env->status_oid(), status));
+ call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()),
+ status));
}
if (retcode < 0) {
marker.next_step_marker = info.marker;
marker.timestamp = info.last_update;
RGWRados *store = sync_env->store;
- spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_env->shard_obj_name(i), marker), true);
+ spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env->shard_obj_name(i)),
+ marker), true);
}
}
yield {
set_status("changing sync state: build full sync maps");
status.state = rgw_meta_sync_info::StateBuildingFullSyncMaps;
RGWRados *store = sync_env->store;
- call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_env->status_oid(), status));
+ call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env->status_oid()),
+ status));
}
set_status("drop lock lease");
yield lease_cr->go_down();
public:
RGWReadSyncStatusCoroutine(RGWMetaSyncEnv *_sync_env,
rgw_meta_sync_status *_status) : RGWSimpleRadosReadCR(_sync_env->async_rados, _sync_env->store,
- _sync_env->store->get_zone_params().log_pool,
- _sync_env->status_oid(),
+ rgw_raw_obj(_sync_env->store->get_zone_params().log_pool, _sync_env->status_oid()),
&_status->sync_info),
sync_env(_sync_env),
sync_status(_status) {
RGWRados *store = sync_env->store;
map<uint32_t, rgw_meta_sync_marker>& markers = sync_status->sync_markers;
for (int i = 0; i < (int)data.num_shards; i++) {
- spawn(new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- sync_env->shard_obj_name(i), &markers[i]), true);
+ spawn(new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env->shard_obj_name(i)),
+ &markers[i]), true);
}
return 0;
}
set_status(string("acquiring lock (") + sync_env->status_oid() + ")");
uint32_t lock_duration = cct->_conf->rgw_sync_lease_period;
string lock_name = "sync_lock";
- lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, sync_env->store, sync_env->store->get_zone_params().log_pool, sync_env->status_oid(),
+ lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados,
+ sync_env->store,
+ rgw_raw_obj(sync_env->store->get_zone_params().log_pool, sync_env->status_oid()),
lock_name, lock_duration, this);
lease_cr->get();
lease_stack = spawn(lease_cr, false);
int shard_id = (int)iter->first;
rgw_meta_sync_marker& marker = iter->second;
marker.total_entries = entries_index->get_total_entries(shard_id);
- spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, sync_env->store, sync_env->store->get_zone_params().log_pool,
- sync_env->shard_obj_name(shard_id), marker), true);
+ spawn(new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, sync_env->store,
+ rgw_raw_obj(sync_env->store->get_zone_params().log_pool, sync_env->shard_obj_name(shard_id)),
+ marker), true);
}
}
ldout(sync_env->cct, 20) << __func__ << "(): updating marker marker_oid=" << marker_oid << " marker=" << new_marker << dendl;
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados, store, store->get_zone_params().log_pool,
- marker_oid, sync_marker);
+ return new RGWSimpleRadosWriteCR<rgw_meta_sync_marker>(sync_env->async_rados,
+ store,
+ rgw_raw_obj(store->get_zone_params().log_pool, marker_oid),
+ sync_marker);
}
};
class RGWMetaSyncShardCR : public RGWCoroutine {
RGWMetaSyncEnv *sync_env;
- const rgw_bucket& pool;
+ const rgw_pool& pool;
const std::string& period; //< currently syncing period id
RGWMetadataLog* mdlog; //< log of syncing period
uint32_t shard_id;
int total_entries = 0;
public:
- RGWMetaSyncShardCR(RGWMetaSyncEnv *_sync_env, const rgw_bucket& _pool,
+ RGWMetaSyncShardCR(RGWMetaSyncEnv *_sync_env, const rgw_pool& _pool,
const std::string& period, RGWMetadataLog* mdlog,
uint32_t _shard_id, rgw_meta_sync_marker& _marker,
const std::string& period_marker, bool *_reset_backoff)
lease_cr->put();
}
RGWRados *store = sync_env->store;
- lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, pool,
- sync_env->shard_obj_name(shard_id),
+ lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store,
+ rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
lock_name, lock_duration, this);
lease_cr->get();
lease_stack = spawn(lease_cr, false);
lost_lock = true;
break;
}
- yield call(new RGWRadosGetOmapKeysCR(sync_env->store, pool, oid, marker, &entries, max_entries));
+ yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid),
+ marker, &entries, max_entries));
if (retcode < 0) {
ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): RGWRadosGetOmapKeysCR() returned ret=" << retcode << dendl;
yield lease_cr->go_down();
using WriteMarkerCR = RGWSimpleRadosWriteCR<rgw_meta_sync_marker>;
yield call(new WriteMarkerCR(sync_env->async_rados, sync_env->store,
- pool, sync_env->shard_obj_name(shard_id),
- *temp_marker));
+ rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
+ sync_marker));
}
if (retcode < 0) {
uint32_t lock_duration = cct->_conf->rgw_sync_lease_period;
string lock_name = "sync_lock";
RGWRados *store = sync_env->store;
- lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store, pool,
- sync_env->shard_obj_name(shard_id),
+ lease_cr = new RGWContinuousLeaseCR(sync_env->async_rados, store,
+ rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
lock_name, lock_duration, this);
lease_cr->get();
lease_stack = spawn(lease_cr, false);
{
RGWMetaSyncEnv *sync_env;
- const rgw_bucket& pool;
+ const rgw_pool& pool;
const std::string& period;
RGWMetadataLog* mdlog;
uint32_t shard_id;
static constexpr bool exit_on_error = false; // retry on all errors
public:
- RGWMetaSyncShardControlCR(RGWMetaSyncEnv *_sync_env, const rgw_bucket& _pool,
+ RGWMetaSyncShardControlCR(RGWMetaSyncEnv *_sync_env, const rgw_pool& _pool,
const std::string& period, RGWMetadataLog* mdlog,
uint32_t _shard_id, const rgw_meta_sync_marker& _marker,
std::string&& period_marker)
RGWCoroutine *alloc_finisher_cr() override {
RGWRados *store = sync_env->store;
- return new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store, pool,
- sync_env->shard_obj_name(shard_id), &sync_marker);
+ return new RGWSimpleRadosReadCR<rgw_meta_sync_marker>(sync_env->async_rados, store,
+ rgw_raw_obj(pool, sync_env->shard_obj_name(shard_id)),
+ &sync_marker);
}
};
class RGWMetaSyncCR : public RGWCoroutine {
RGWMetaSyncEnv *sync_env;
- const rgw_bucket& pool;
+ const rgw_pool& pool;
RGWPeriodHistory::Cursor cursor; //< sync position in period history
RGWPeriodHistory::Cursor next; //< next period in history
rgw_meta_sync_status sync_status;
sync_status.sync_info.period = cursor.get_period().get_id();
sync_status.sync_info.realm_epoch = cursor.get_epoch();
yield call(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(sync_env->async_rados,
- sync_env->store, pool,
- sync_env->status_oid(),
+ sync_env->store,
+ rgw_raw_obj(pool, sync_env->status_oid()),
sync_status.sync_info));
}
}
int RGWRemoteMetaLog::store_sync_info()
{
- return run(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(async_rados, store, store->get_zone_params().log_pool,
- sync_env.status_oid(), sync_status.sync_info));
+ return run(new RGWSimpleRadosWriteCR<rgw_meta_sync_info>(async_rados, store,
+ rgw_raw_obj(store->get_zone_params().log_pool, sync_env.status_oid()),
+ sync_status.sync_info));
}
// return a cursor to the period at our sync position
RGWRemoteMetaLog master_log;
- map<int, rgw_obj> shard_objs;
+ map<int, rgw_raw_obj> shard_objs;
struct utime_shard {
real_time ts;
}
string oid, key;
- rgw_bucket bucket;
map<string, bufferlist> m;
set<string> obj_key;
- get_obj_bucket_and_oid_loc(obj, bucket, oid, key);
+ get_obj_bucket_and_oid_loc(obj, oid, key);
ldout(s->cct, 0) << "NOTICE: head obj oid= " << oid << dendl;
obj_key.insert(RGW_OBJ_TORRENT);
string key = RGW_OBJ_TORRENT;
rgw_obj obj(s->bucket, s->object.name);
- op_ret = store->omap_set(obj, key, bl);
+ rgw_raw_obj raw_obj;
+ store->obj_to_raw(obj, &raw_obj);
+
+ op_ret = store->omap_set(raw_obj, key, bl);
if (op_ret < 0)
{
ldout(s->cct, 0) << "ERROR: failed to omap_set() op_ret = " << op_ret << dendl;
int rgw_get_user_info_from_index(RGWRados * const store,
const string& key,
- rgw_bucket& bucket,
+ rgw_pool& pool,
RGWUserInfo& info,
RGWObjVersionTracker * const objv_tracker,
real_time * const pmtime)
RGWUID uid;
RGWObjectCtx obj_ctx(store);
- int ret = rgw_get_system_obj(store, obj_ctx, bucket, key, bl, NULL, &e.mtime);
+ int ret = rgw_get_system_obj(store, obj_ctx, pool, key, bl, NULL, &e.mtime);
if (ret < 0)
return ret;
RGWObjVersionTracker *objv_tracker)
{
RGWObjectCtx obj_ctx(store);
- rgw_obj obj(store->get_zone_params().user_uid_pool, user_id.to_str());
+ rgw_raw_obj obj(store->get_zone_params().user_uid_pool, user_id.to_str());
RGWRados::SystemObject src(store, obj_ctx, obj);
RGWRados::SystemObject::Read rop(&src);
int rgw_remove_key_index(RGWRados *store, RGWAccessKey& access_key)
{
- rgw_obj obj(store->get_zone_params().user_keys_pool, access_key.id);
+ rgw_raw_obj obj(store->get_zone_params().user_keys_pool, access_key.id);
int ret = store->delete_system_obj(obj);
return ret;
}
if (email.empty()) {
return 0;
}
- rgw_obj obj(store->get_zone_params().user_email_pool, email);
+ rgw_raw_obj obj(store->get_zone_params().user_email_pool, email);
return store->delete_system_obj(obj);
}
int rgw_remove_swift_name_index(RGWRados *store, string& swift_name)
{
- rgw_obj obj(store->get_zone_params().user_swift_pool, swift_name);
+ rgw_raw_obj obj(store->get_zone_params().user_swift_pool, swift_name);
int ret = store->delete_system_obj(obj);
return ret;
}
string buckets_obj_id;
rgw_get_buckets_obj(info.user_id, buckets_obj_id);
- rgw_obj uid_bucks(store->get_zone_params().user_uid_pool, buckets_obj_id);
+ rgw_raw_obj uid_bucks(store->get_zone_params().user_uid_pool, buckets_obj_id);
ldout(store->ctx(), 10) << "removing user buckets index" << dendl;
ret = store->delete_system_obj(uid_bucks);
if (ret < 0 && ret != -ENOENT) {
string key;
info.user_id.to_str(key);
- rgw_obj uid_obj(store->get_zone_params().user_uid_pool, key);
+ rgw_raw_obj uid_obj(store->get_zone_params().user_uid_pool, key);
ldout(store->ctx(), 10) << "removing user index: " << info.user_id << dendl;
ret = store->meta_mgr->remove_entry(user_meta_handler, key, &objv_tracker);
if (ret < 0 && ret != -ENOENT && ret != -ECANCELED) {
return rgw_delete_user(store, info, objv_tracker);
}
- void get_pool_and_oid(RGWRados *store, const string& key, rgw_bucket& bucket, string& oid) override {
+ void get_pool_and_oid(RGWRados *store, const string& key, rgw_pool& pool, string& oid) override {
oid = key;
- bucket = store->get_zone_params().user_uid_pool;
+ pool = store->get_zone_params().user_uid_pool;
}
int list_keys_init(RGWRados *store, void **phandle) override
#endif
using namespace std;
+static void populate_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
+{
+ b->tenant = t;
+ b->name = n;
+ b->marker = m;
+ b->bucket_id = id;
+ b->placement.data_pool = rgw_pool(dp);
+ b->placement.index_pool = rgw_pool(ip);
+}
+
static void init_bucket(rgw_bucket *bucket, const char *ten, const char *name)
{
- *bucket = rgw_bucket(ten, name, ".data-pool", ".index-pool", "marker.", "bucket-id", NULL);
+ populate_bucket(bucket, ten, name, ".data-pool", ".index-pool", "marker.", "bucket-id");
}
void append_head(list<rgw_obj> *objs, rgw_obj& head)
#endif
using namespace std;
+static void populate_bucket(rgw_bucket *b, const char *t, const char *n, const char *dp, const char *ip, const char *m, const char *id)
+{
+ b->tenant = t;
+ b->name = n;
+ b->marker = m;
+ b->bucket_id = id;
+ b->placement.data_pool = rgw_pool(dp);
+ b->placement.index_pool = rgw_pool(ip);
+}
+
static void init_bucket(rgw_bucket *bucket, const char *name)
{
- *bucket = rgw_bucket("", name, ".data-pool", ".index-pool", "marker", "bucket-id", NULL);
+ populate_bucket(bucket, "", name, ".data-pool", ".index-pool", "marker", "bucket-id");
}
void check_parsed_correctly(rgw_obj& obj, const string& name, const string& ns, const string& instance)