rgw: bucket index creation and init in a single operation

This commit is contained in:
Yehuda Sadeh 2012-01-12 16:22:20 -08:00
parent 876d829af7
commit 05d8ecbe1c
2 changed files with 8 additions and 24 deletions

View File

@ -469,7 +469,9 @@ int RGWRados::create_bucket(string& owner, rgw_bucket& bucket,
string dir_oid = dir_oid_prefix;
dir_oid.append(bucket.marker);
r = io_ctx.create(dir_oid, true);
librados::ObjectWriteOperation op;
op.create(true);
r = cls_rgw_init_index(io_ctx, op, dir_oid);
if (r < 0 && r != -EEXIST)
return r;
@ -479,12 +481,6 @@ int RGWRados::create_bucket(string& owner, rgw_bucket& bucket,
ret = store_bucket_info(info, &attrs, exclusive);
if (ret == -EEXIST)
return ret;
if (r != -EEXIST) {
r = cls_rgw_init_index(bucket, dir_oid);
if (r < 0)
return r;
}
}
return ret;
@ -2115,23 +2111,11 @@ int RGWRados::pool_list(rgw_bucket& bucket, string start, uint32_t num, map<stri
return m.size();
}
int RGWRados::cls_rgw_init_index(rgw_bucket& bucket, string& oid)
int RGWRados::cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid)
{
if (bucket_is_system(bucket))
return 0;
if (bucket.marker.empty()) {
dout(0) << "ERROR: empty marker for cls_rgw bucket operation" << dendl;
return -EIO;
}
librados::IoCtx io_ctx;
int r = open_bucket_ctx(bucket, io_ctx);
if (r < 0)
return r;
bufferlist in, out;
r = io_ctx.exec(oid, "rgw", "bucket_init_index", in, out);
bufferlist in;
op.exec("rgw", "bucket_init_index", in);
int r = io_ctx.operate(oid, &op);
return r;
}

View File

@ -327,7 +327,7 @@ public:
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info);
virtual int put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive);
int cls_rgw_init_index(rgw_bucket& bucket, string& oid);
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,
string& name, string& locator);
int cls_obj_complete_op(rgw_bucket& bucket, uint8_t op, string& tag, uint64_t epoch,