read_op.params.attrs = &attrs;
read_op.params.obj_size = &obj_size;
- int ret = read_op.prepare(NULL, NULL);
+ int ret = read_op.prepare();
if (ret < 0) {
lderr(store->ctx()) << "ERROR: failed to stat object, returned error: " << cpp_strerror(-ret) << dendl;
return ret;
RGWRados::Object op_target(store, bucket_info, obj_ctx, obj);
RGWRados::Object::Read read_op(&op_target);
- int ret = read_op.prepare(NULL, NULL);
+ int ret = read_op.prepare();
bool needs_fixing = (ret == -ENOENT);
f->dump_bool("needs_fixing", needs_fixing);
read_op.params.attrs = &attrs;
read_op.params.obj_size = &obj_size;
- ret = read_op.prepare(NULL, NULL);
+ ret = read_op.prepare();
if (ret < 0) {
cerr << "ERROR: failed to stat object, returned error: " << cpp_strerror(-ret) << std::endl;
return 1;
read_op.params.attrs = &attrs;
read_op.params.perr = &s->err;
- return read_op.prepare(NULL, NULL);
+ return read_op.prepare();
}
static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map<string, bufferlist>& attrs,
read_op.params.obj_size = &obj_size;
read_op.params.perr = &s->err;
- op_ret = read_op.prepare(&cur_ofs, &cur_end);
+ op_ret = read_op.prepare();
+ if (op_ret < 0)
+ return op_ret;
+ op_ret = read_op.range_to_ofs(obj_size, cur_ofs, cur_end);
if (op_ret < 0)
return op_ret;
read_op.conds.if_nomatch = if_nomatch;
read_op.params.attrs = &attrs;
read_op.params.lastmod = &lastmod;
- read_op.params.read_size = &total_len;
read_op.params.obj_size = &s->obj_size;
read_op.params.perr = &s->err;
- op_ret = read_op.prepare(&new_ofs, &new_end);
- if (op_ret < 0 && op_ret != -ERANGE) // check erange error later
+ op_ret = read_op.prepare();
+ if (op_ret < 0)
goto done_err;
+ op_ret = read_op.range_to_ofs(s->obj_size, new_ofs, new_end);
+ // check erange error later
+ total_len = (new_ofs <= new_end ? new_end + 1 - new_ofs : 0);
+
cret = rgw_compression_info_from_attrset(attrs, need_decompress, cs_info);
if (cret < 0) {
lderr(s->cct) << "ERROR: failed to decode compression info, cannot decompress" << dendl;
int64_t end = -1;
real_time mtime;
- uint64_t total_len;
uint64_t obj_size;
RGWObjectCtx rctx(this);
read_op.params.attrs = &attrset;
read_op.params.lastmod = &mtime;
- read_op.params.read_size = &total_len;
read_op.params.obj_size = &obj_size;
- int ret = read_op.prepare(&ofs, &end);
+ int ret = read_op.prepare();
if (ret < 0)
return ret;
return ret;
}
- return copy_obj_data(rctx, dest_bucket_info, read_op, end, obj, obj, max_chunk_size, NULL, mtime, attrset,
+ return copy_obj_data(rctx, dest_bucket_info, read_op, obj_size - 1, obj, obj, max_chunk_size, NULL, mtime, attrset,
RGW_OBJ_CATEGORY_MAIN, 0, real_time(), NULL, NULL, NULL, NULL);
}
void *progress_data)
{
int ret;
- uint64_t total_len, obj_size;
+ uint64_t obj_size;
rgw_obj shadow_obj = dest_obj;
string shadow_oid;
}
map<string, bufferlist> src_attrs;
- int64_t ofs = 0;
- int64_t end = -1;
RGWRados::Object src_op_target(this, src_bucket_info, obj_ctx, src_obj);
RGWRados::Object::Read read_op(&src_op_target);
read_op.conds.if_nomatch = if_nomatch;
read_op.params.attrs = &src_attrs;
read_op.params.lastmod = src_mtime;
- read_op.params.read_size = &total_len;
read_op.params.obj_size = &obj_size;
read_op.params.perr = err;
- ret = read_op.prepare(&ofs, &end);
+ ret = read_op.prepare();
if (ret < 0) {
return ret;
}
}
if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
- return copy_obj_data(obj_ctx, dest_bucket_info, read_op, end, dest_obj, src_obj,
+ return copy_obj_data(obj_ctx, dest_bucket_info, read_op, obj_size - 1, dest_obj, src_obj,
max_chunk_size, mtime, real_time(), attrs, category, olh_epoch, delete_at,
version_id, ptag, petag, err);
}
write_op.meta.olh_epoch = olh_epoch;
write_op.meta.delete_at = delete_at;
- ret = write_op.write_meta(end + 1, attrs);
+ ret = write_op.write_meta(obj_size, attrs);
if (ret < 0) {
goto done_ret;
}
* obj: name/key of the object to read
* data: if get_data==true, this pointer will be set
* to an address containing the object's data/value
- * ofs: the offset of the object to read from
- * end: the point in the object to stop reading
* attrs: if non-NULL, the pointed-to map will contain
* all the attrs of the object when this function returns
* mod_ptr: if non-NULL, compares the object's mtime to *mod_ptr,
* (if get_data==false) length of the object
*/
// P3 XXX get_data is not seen used anywhere.
-int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend)
+int RGWRados::Object::Read::prepare()
{
RGWRados *store = source->get_store();
CephContext *cct = store->ctx();
bufferlist etag;
- off_t ofs = 0;
- off_t end = -1;
-
map<string, bufferlist>::iterator iter;
RGWObjState *astate;
}
}
- if (pofs)
- ofs = *pofs;
- if (pend)
- end = *pend;
+ if (params.obj_size)
+ *params.obj_size = astate->size;
+ if (params.lastmod)
+ *params.lastmod = astate->mtime;
+
+ return 0;
+}
+int RGWRados::Object::Read::range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end)
+{
if (ofs < 0) {
- ofs += astate->size;
+ ofs += obj_size;
if (ofs < 0)
ofs = 0;
- end = astate->size - 1;
+ end = obj_size - 1;
} else if (end < 0) {
- end = astate->size - 1;
+ end = obj_size - 1;
}
- int ret = 0;
-
- if (astate->size > 0) {
- if (ofs >= (off_t)astate->size) {
- ret = -ERANGE;
+ if (obj_size > 0) {
+ if (ofs >= (off_t)obj_size) {
+ return -ERANGE;
}
- if (end >= (off_t)astate->size) {
- end = astate->size - 1;
+ if (end >= (off_t)obj_size) {
+ end = obj_size - 1;
}
}
-
- if (pofs)
- *pofs = ofs;
- if (pend)
- *pend = end;
- if (params.read_size)
- *params.read_size = (ofs <= end ? end + 1 - ofs : 0);
- if (params.obj_size)
- *params.obj_size = astate->size;
- if (params.lastmod)
- *params.lastmod = astate->mtime;
-
- return ret;
+ return 0;
}
int RGWRados::SystemObject::get_state(RGWObjState **pstate, RGWObjVersionTracker *objv_tracker)
struct Params {
ceph::real_time *lastmod;
- uint64_t *read_size;
uint64_t *obj_size;
map<string, bufferlist> *attrs;
struct rgw_err *perr;
- Params() : lastmod(NULL), read_size(NULL), obj_size(NULL), attrs(NULL), perr(NULL) {}
+ Params() : lastmod(NULL), obj_size(NULL), attrs(NULL), perr(NULL) {}
} params;
explicit Read(RGWRados::Object *_source) : source(_source) {}
- int prepare(int64_t *pofs, int64_t *pend);
+ int prepare();
+ static int range_to_ofs(uint64_t obj_size, int64_t &ofs, int64_t &end);
int read(int64_t ofs, int64_t end, bufferlist& bl);
int iterate(int64_t ofs, int64_t end, RGWGetDataCB *cb);
int get_attr(const char *name, bufferlist& dest);