obj.bucket = bucket;
int max = 1000;
- ret = rgw_get_obj(store, NULL, store->zone.domain_root,\
- bucket.name, bl, NULL);
+ ret = rgw_get_system_obj(store, NULL, store->zone.domain_root, bucket.name, bl, NULL);
bufferlist::iterator iter = bl.begin();
try {
}
if (delete_children) {
- ret = store->list_objects(bucket, max, prefix, delim, marker,\
- objs, common_prefixes,\
+ ret = store->list_objects(bucket, max, prefix, delim, marker,
+ objs, common_prefixes,
false, ns, (bool *)false, NULL);
if (ret < 0)
int put_obj_data(void *ctx, rgw_obj& obj, const char *data,
off_t ofs, size_t len, bool exclusive);
- int get_obj(void *ctx, void **handle, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end);
+ int get_obj(void *ctx, obj_version *objv, void **handle, rgw_obj& obj, bufferlist& bl, off_t ofs, off_t end);
- int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, map<string, bufferlist> *attrs, bufferlist *first_chunk);
+ int obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch, map<string, bufferlist> *attrs, bufferlist *first_chunk, obj_version *objv);
int delete_obj(void *ctx, rgw_obj& obj);
};
}
template <class T>
-int RGWCache<T>::get_obj(void *ctx, void **handle, rgw_obj& obj, bufferlist& obl, off_t ofs, off_t end)
+int RGWCache<T>::get_obj(void *ctx, obj_version *objv, void **handle, rgw_obj& obj, bufferlist& obl, off_t ofs, off_t end)
{
rgw_bucket bucket;
string oid;
normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
if (bucket.name[0] != '.' || ofs != 0)
- return T::get_obj(ctx, handle, obj, obl, ofs, end);
+ return T::get_obj(ctx, objv, handle, obj, obl, ofs, end);
string name = normal_name(obj.bucket, oid);
i.copy_all(obl);
return bl.length();
}
- int r = T::get_obj(ctx, handle, obj, obl, ofs, end);
+ int r = T::get_obj(ctx, objv, handle, obj, obl, ofs, end);
if (r < 0) {
if (r == -ENOENT) { // only update ENOENT, we'd rather retry other errors
info.status = r;
template <class T>
int RGWCache<T>::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
uint64_t *pepoch, map<string, bufferlist> *attrs,
- bufferlist *first_chunk)
+ bufferlist *first_chunk, obj_version *objv)
{
rgw_bucket bucket;
string oid;
normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
if (bucket.name[0] != '.')
- return T::obj_stat(ctx, obj, psize, pmtime, pepoch, attrs, first_chunk);
+ return T::obj_stat(ctx, obj, psize, pmtime, pepoch, attrs, first_chunk, objv);
string name = normal_name(bucket, oid);
epoch = info.epoch;
goto done;
}
- r = T::obj_stat(ctx, obj, &size, &mtime, &epoch, &info.xattrs, first_chunk);
+ r = T::obj_stat(ctx, obj, &size, &mtime, &epoch, &info.xattrs, first_chunk, objv);
if (r < 0) {
if (r == -ENOENT) {
info.status = r;
{
void *handle;
int ret = store->prepare_get_obj(s->obj_ctx, obj, NULL, NULL, &attrs, NULL,
- NULL, NULL, NULL, NULL, NULL, obj_size, &handle, &s->err);
+ NULL, NULL, NULL, NULL, NULL, obj_size, NULL, &handle, &s->err);
store->finish_get_obj(&handle);
return ret;
}
store->set_atomic(obj_ctx, part);
store->set_prefetch_data(obj_ctx, part);
ret = store->prepare_get_obj(obj_ctx, part, &cur_ofs, &cur_end, &attrs, NULL,
- NULL, NULL, NULL, NULL, NULL, &obj_size, &handle, &s->err);
+ NULL, NULL, NULL, NULL, NULL, &obj_size, NULL, &handle, &s->err);
if (ret < 0)
goto done_err;
perfcounter->inc(l_rgw_get_b, cur_end - cur_ofs);
while (cur_ofs <= cur_end) {
bufferlist bl;
- ret = store->get_obj(obj_ctx, &handle, part, bl, cur_ofs, cur_end);
+ ret = store->get_obj(obj_ctx, NULL, &handle, part, bl, cur_ofs, cur_end);
if (ret < 0)
goto done_err;
new_end = end;
ret = store->prepare_get_obj(s->obj_ctx, obj, &new_ofs, &new_end, &attrs, mod_ptr,
- unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &s->obj_size, &handle, &s->err);
+ unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &s->obj_size, NULL, &handle, &s->err);
if (ret < 0)
goto done_err;
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
- int ret = rgw_get_obj(store, NULL, pool, oid, bl);
+ int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL);
if (ret < 0)
return ret;
string oid = region_info_oid_prefix + name;
- int ret = rgw_get_obj(store, NULL, pool, oid, bl);
+ int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL);
if (ret < 0) {
lderr(cct) << "failed reading region info from " << pool << ":" << oid << ": " << cpp_strerror(-ret) << dendl;
return ret;
bufferlist bl;
string oid = zone_info_oid_prefix + name;
- int ret = rgw_get_obj(store, NULL, pool, oid, bl);
+ int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL);
if (ret < 0)
return ret;
rgw_bucket pool(pool_name.c_str());
bufferlist bl;
- int ret = rgw_get_obj(store, NULL, pool, oid, bl);
+ int ret = rgw_get_system_obj(store, NULL, pool, oid, bl, NULL);
if (ret < 0)
return ret;
rgw_obj obj(zone.domain_root, avail_pools);
- int ret = rgw_get_obj(this, NULL, zone.domain_root, avail_pools, map_bl);
+ int ret = rgw_get_system_obj(this, NULL, zone.domain_root, avail_pools, map_bl, NULL);
if (ret < 0) {
goto read_omap;
}
off_t ofs = 0;
off_t end = -1;
ret = prepare_get_obj(ctx, src_obj, &ofs, &end, &attrset,
- mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &obj_size, &handle, err);
+ mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &obj_size, NULL, &handle, err);
if (ret < 0)
return ret;
RGWObjManifest manifest;
RGWObjState *astate = NULL;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
- ret = get_obj_state(rctx, src_obj, &astate);
+ ret = get_obj_state(rctx, src_obj, &astate, NULL);
if (ret < 0)
return ret;
}
if (copy_first) {
- ret = get_obj(ctx, &handle, src_obj, first_chunk, 0, RGW_MAX_CHUNK_SIZE);
+ ret = get_obj(ctx, NULL, &handle, src_obj, first_chunk, 0, RGW_MAX_CHUNK_SIZE);
if (ret < 0)
goto done_ret;
do {
bufferlist bl;
- ret = get_obj(ctx, &handle, src_obj, bl, ofs, end);
+ ret = get_obj(ctx, NULL, &handle, src_obj, bl, ofs, end);
if (ret < 0)
return ret;
RGWObjState *state = NULL;
- int r = get_obj_state(rctx, obj, &state);
+ int r = get_obj_state(rctx, obj, &state, NULL);
if (r < 0)
return r;
tag_bl.append(tag.c_str(), tag.size() + 1);
}
-int RGWRados::get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state)
+int RGWRados::get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state, obj_version *objv)
{
RGWObjState *s = rctx->get_state(obj);
ldout(cct, 20) << "get_obj_state: rctx=" << (void *)rctx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl;
if (s->has_attrs)
return 0;
- obj_version *objv = NULL;
-
- if (bucket_is_system(obj.bucket)) {
-// objv = &s->objv;
-#warning FIXME
- }
-
int r = obj_stat(rctx, obj, &s->size, &s->mtime, &s->epoch, &s->attrset, (s->prefetch_data ? &s->data : NULL), objv);
if (r == -ENOENT) {
s->exists = false;
if (rctx) {
RGWObjState *state;
- r = get_obj_state(rctx, obj, &state);
+ r = get_obj_state(rctx, obj, &state, NULL);
if (r < 0)
return r;
if (!state->exists)
if (!rctx)
return 0;
- int r = get_obj_state(rctx, obj, pstate);
+ int r = get_obj_state(rctx, obj, pstate, NULL);
if (r < 0)
return r;
ObjectWriteOperation& op, RGWObjState **pstate,
bool reset_obj, const string *ptag)
{
- int r = get_obj_state(rctx, obj, pstate);
+ int r = get_obj_state(rctx, obj, pstate, NULL);
if (r < 0)
return r;
const char *if_nomatch,
uint64_t *total_size,
uint64_t *obj_size,
+ obj_version *objv,
void **handle,
struct rgw_err *err)
{
rctx = new_ctx;
}
- r = get_obj_state(rctx, obj, &astate);
+ r = get_obj_state(rctx, obj, &astate, objv);
if (r < 0)
goto done_err;
}
-int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj,
+int RGWRados::get_obj(void *ctx, obj_version *objv, void **handle, rgw_obj& obj,
bufferlist& bl, off_t ofs, off_t end)
{
rgw_bucket bucket;
rctx = new_ctx;
}
- int r = get_obj_state(rctx, obj, &astate);
+ int r = get_obj_state(rctx, obj, &astate, NULL);
if (r < 0)
goto done_ret;
goto done_ret;
}
+ if (objv) {
+ cls_version_check(op, *objv, VER_COND_EQ);
+ }
+
read_len = len;
if (astate) {
ldout(cct, 0) << "NOTICE: RGWRados::get_obj: raced with another process, going to the shadow obj instead" << dendl;
string loc = obj.loc();
rgw_obj shadow(bucket, astate->shadow_obj, loc, shadow_ns);
- r = get_obj(NULL, handle, shadow, bl, ofs, end);
+ r = get_obj(NULL, NULL, handle, shadow, bl, ofs, end);
goto done_ret;
}
rctx = new_ctx;
}
- int r = get_obj_state(rctx, obj, &astate);
+ int r = get_obj_state(rctx, obj, &astate, NULL);
if (r < 0)
goto done_err;
ObjectReadOperation op;
if (objv) {
-#warning FIXME
+ cls_version_read(op, objv);
}
op.getxattrs(&attrset, NULL);
op.stat(&size, &mtime, NULL);
{
bufferlist bl;
- int ret = rgw_get_obj(this, ctx, zone.domain_root, bucket_name, bl, pattrs);
+ int ret = rgw_get_system_obj(this, ctx, zone.domain_root, bucket_name, bl, NULL, pattrs);
if (ret < 0) {
if (ret != -ENOENT)
return ret;
RGWObjState *astate = NULL;
RGWRadosCtx rctx(this);
- int r = get_obj_state(&rctx, obj, &astate);
+ int r = get_obj_state(&rctx, obj, &astate, NULL);
if (r < 0)
return r;
bufferlist data;
bool prefetch_data;
bool keep_tail;
+ obj_version objv;
map<string, bufferlist> attrset;
RGWObjState() : is_atomic(false), has_attrs(0), exists(false),
Mutex bucket_id_lock;
uint64_t max_bucket_id;
- int get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state);
+ int get_obj_state(RGWRadosCtx *rctx, rgw_obj& obj, RGWObjState **state, obj_version *objv);
int append_atomic_test(RGWRadosCtx *rctx, rgw_obj& obj,
librados::ObjectOperation& op, RGWObjState **state);
int prepare_atomic_for_write_impl(RGWRadosCtx *rctx, rgw_obj& obj,
const char *if_nomatch,
uint64_t *total_size,
uint64_t *obj_size,
+ obj_version *objv,
void **handle,
struct rgw_err *err);
- virtual int get_obj(void *ctx, void **handle, rgw_obj& obj,
+ virtual int get_obj(void *ctx, obj_version *objv, void **handle, rgw_obj& obj,
bufferlist& bl, off_t ofs, off_t end);
virtual void finish_get_obj(void **handle);
return ret;
}
-int rgw_get_obj(RGWRados *rgwstore, void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, map<string, bufferlist> *pattrs)
+int rgw_get_system_obj(RGWRados *rgwstore, void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, obj_version *objv, map<string, bufferlist> *pattrs)
{
int ret;
struct rgw_err err;
rgw_obj obj(bucket, key);
do {
ret = rgwstore->prepare_get_obj(ctx, obj, NULL, NULL, pattrs, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, &handle, &err);
+ NULL, NULL, NULL, NULL, NULL, NULL, objv, &handle, &err);
if (ret < 0)
return ret;
- ret = rgwstore->get_obj(ctx, &handle, obj, bl, 0, request_len - 1);
+ ret = rgwstore->get_obj(ctx, objv, &handle, obj, bl, 0, request_len - 1);
rgwstore->finish_get_obj(&handle);
if (ret < 0)
return ret;
class RGWRados;
+struct obj_version;
+
int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive, map<string, bufferlist> *pattrs = NULL);
-int rgw_get_obj(RGWRados *rgwstore, void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, map<string, bufferlist> *pattrs = NULL);
+int rgw_get_system_obj(RGWRados *rgwstore, void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, obj_version *objv, map<string, bufferlist> *pattrs = NULL);
int rgw_tools_init(CephContext *cct);
void rgw_tools_cleanup();
bufferlist bl;
RGWUID uid;
- int ret = rgw_get_obj(store, NULL, bucket, key, bl);
+ int ret = rgw_get_system_obj(store, NULL, bucket, key, bl, NULL);
if (ret < 0)
return ret;
bufferlist bl;
RGWUID user_id;
- int ret = rgw_get_obj(store, NULL, store->zone.user_uid_pool, uid, bl);
+ int ret = rgw_get_system_obj(store, NULL, store->zone.user_uid_pool, uid, bl, NULL);
if (ret < 0)
return ret;