int RGWPutObjProcessor_Plain::complete(string& etag, map<string, bufferlist>& attrs)
{
int r = store->put_obj_meta(s->obj_ctx, obj, data.length(), NULL, attrs,
- RGW_OBJ_CATEGORY_MAIN, false, NULL, &data, NULL, NULL);
+ RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, &data, NULL, NULL);
return r;
}
store->set_atomic(s->obj_ctx, head_obj);
int r = store->put_obj_meta(s->obj_ctx, head_obj, obj_len, NULL, attrs,
- RGW_OBJ_CATEGORY_MAIN, false, NULL, &first_chunk, &manifest, NULL);
+ RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, &first_chunk, &manifest, NULL);
return r;
}
int RGWPutObjProcessor_Multipart::complete(string& etag, map<string, bufferlist>& attrs)
{
- int r = store->put_obj_meta(s->obj_ctx, obj, s->obj_size, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, false, NULL, NULL, NULL, NULL);
+ int r = store->put_obj_meta(s->obj_ctx, obj, s->obj_size, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, 0, NULL, NULL, NULL, NULL);
if (r < 0)
return r;
obj.init_ns(s->bucket, tmp_obj_name, mp_ns);
// the meta object will be indexed with 0 size, we c
- ret = store->put_obj_meta(s->obj_ctx, obj, 0, NULL, attrs, RGW_OBJ_CATEGORY_MULTIMETA, true, NULL, NULL, NULL, NULL);
+ ret = store->put_obj_meta(s->obj_ctx, obj, 0, NULL, attrs, RGW_OBJ_CATEGORY_MULTIMETA, PUT_OBJ_CREATE_EXCL, NULL, NULL, NULL, NULL);
} while (ret == -EEXIST);
}
target_obj.init(s->bucket, s->object_str);
store->set_atomic(s->obj_ctx, target_obj);
- ret = store->put_obj_meta(s->obj_ctx, target_obj, 0, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, false, NULL, NULL, NULL, NULL);
+ ret = store->put_obj_meta(s->obj_ctx, target_obj, 0, NULL, attrs, RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, NULL, NULL, NULL);
if (ret < 0)
return;
store->set_atomic(s->obj_ctx, target_obj);
ret = store->put_obj_meta(s->obj_ctx, target_obj, ofs, NULL, attrs,
- RGW_OBJ_CATEGORY_MAIN, false, NULL, NULL, &manifest, NULL);
+ RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE, NULL, NULL, &manifest, NULL);
if (ret < 0)
return;
*/
int RGWRados::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size,
time_t *mtime, map<string, bufferlist>& attrs,
- RGWObjCategory category, bool exclusive,
+ RGWObjCategory category, int flags,
map<string, bufferlist>* rmattrs,
const bufferlist *data,
RGWObjManifest *manifest,
RGWObjState *state = NULL;
- if (!exclusive) {
- r = prepare_atomic_for_write(rctx, obj, op, &state, true, ptag);
+ if (flags & PUT_OBJ_EXCL) {
+ if (!(flags & PUT_OBJ_CREATE))
+ return -EINVAL;
+ op.create(true); // exclusive create
+ } else {
+ bool reset_obj = (flags & PUT_OBJ_CREATE) != 0;
+ r = prepare_atomic_for_write(rctx, obj, op, &state, reset_obj, ptag);
if (r < 0)
return r;
- } else {
- op.create(true); // exclusive create
}
if (data) {
manifest.obj_size = total_len;
- ret = put_obj_meta(ctx, dest_obj, end + 1, NULL, attrset, category, false, NULL, &first_chunk, &manifest, &tag);
+ ret = put_obj_meta(ctx, dest_obj, end + 1, NULL, attrset, category, PUT_OBJ_CREATE, NULL, &first_chunk, &manifest, &tag);
if (mtime)
obj_stat(ctx, dest_obj, NULL, mtime, NULL, NULL, NULL);
}
manifest.obj_size = ofs;
- ret = put_obj_meta(ctx, dest_obj, end + 1, NULL, attrs, category, false, NULL, &first_chunk, &manifest, NULL);
+ ret = put_obj_meta(ctx, dest_obj, end + 1, NULL, attrs, category, PUT_OBJ_CREATE, NULL, &first_chunk, &manifest, NULL);
if (mtime)
obj_stat(ctx, dest_obj, NULL, mtime, NULL, NULL, NULL);
class ACLOwner;
class RGWGC;
+/* flags for put_obj_meta() */
+#define PUT_OBJ_CREATE 0x01
+#define PUT_OBJ_EXCL 0x02
+#define PUT_OBJ_CREATE_EXCL (PUT_OBJ_CREATE | PUT_OBJ_EXCL)
+
static inline void prepend_bucket_marker(rgw_bucket& bucket, string& orig_oid, string& oid)
{
if (bucket.marker.empty() || orig_oid.empty()) {
/** Write/overwrite an object to the bucket storage. */
virtual int put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size, time_t *mtime,
- map<std::string, bufferlist>& attrs, RGWObjCategory category, bool exclusive,
+ map<std::string, bufferlist>& attrs, RGWObjCategory category, int flags,
map<std::string, bufferlist>* rmattrs, const bufferlist *data,
RGWObjManifest *manifest, const string *ptag);
virtual int put_obj_data(void *ctx, rgw_obj& obj, const char *data,
time_t *mtime, map<std::string, bufferlist>& attrs) {
bufferlist bl;
bl.append(data, len);
- int ret = put_obj_meta(ctx, obj, len, mtime, attrs, RGW_OBJ_CATEGORY_NONE, exclusive, NULL, &bl, NULL, NULL);
+ int flags = PUT_OBJ_CREATE;
+ if (exclusive)
+ flags |= PUT_OBJ_EXCL;
+ int ret = put_obj_meta(ctx, obj, len, mtime, attrs, RGW_OBJ_CATEGORY_NONE, flags, NULL, &bl, NULL, NULL);
return ret;
}
virtual int aio_wait(void *handle);