ObjectState& obs = ctx->new_obs;
object_info_t& oi = obs.oi;
- bool maybe_created = false;
-
const hobject_t& soid = oi.soid;
ObjectStore::Transaction& t = ctx->op_t;
}
write_update_size_and_usage(ctx->delta_stats, oi, ssc->snapset, ctx->modified_ranges,
op.extent.offset, op.extent.length, true);
- maybe_created = true;
+ if (!obs.exists) {
+ ctx->delta_stats.num_objects++;
+ obs.exists = true;
+ }
}
break;
{ // write full object
bufferlist nbl;
bp.copy(op.extent.length, nbl);
- if (obs.exists)
+ if (obs.exists) {
t.truncate(coll, soid, 0);
- else
- maybe_created = true;
+ } else {
+ ctx->delta_stats.num_objects++;
+ obs.exists = true;
+ }
t.write(coll, soid, op.extent.offset, op.extent.length, nbl);
interval_set<uint64_t> ch;
if (oi.size > 0)
}
break;
case CEPH_OSD_OP_CREATE:
- { // zero
+ {
int flags = le32_to_cpu(op.flags);
- if (obs.exists && (flags & CEPH_OSD_OP_FLAG_EXCL))
+ if (obs.exists && (flags & CEPH_OSD_OP_FLAG_EXCL)) {
result = -EEXIST; /* this is an exclusive create */
- else {
- t.touch(coll, soid);
- maybe_created = true;
- }
- if (osd_op.data.length()) {
- bufferlist::iterator p = osd_op.data.begin();
- string category;
- ::decode(category, p);
- if (category.size()) {
- if (obs.exists) {
- if (obs.oi.category != category)
- result = -EEXIST;
- } else {
- obs.oi.category = category;
+ } else {
+ if (osd_op.data.length()) {
+ bufferlist::iterator p = osd_op.data.begin();
+ string category;
+ ::decode(category, p);
+ if (category.size()) {
+ if (obs.exists) {
+ if (obs.oi.category != category)
+ result = -EEXIST; // category cannot be reset
+ } else {
+ obs.oi.category = category;
+ }
}
- }
+ }
+ if (result >= 0 && !obs.exists) {
+ t.touch(coll, soid);
+ ctx->delta_stats.num_objects++;
+ obs.exists = true;
+ }
}
}
break;
{
if (!obs.exists) {
t.touch(coll, obs.oi.soid);
- maybe_created = true;
+ ctx->delta_stats.num_objects++;
+ obs.exists = true;
}
if (op.clonerange.src_offset + op.clonerange.length > src_obc->obs.oi.size) {
dout(10) << " clonerange source " << osd_op.soid << " "
{
if (!obs.exists) {
t.touch(coll, soid);
- maybe_created = true;
+ ctx->delta_stats.num_objects++;
+ obs.exists = true;
}
string aname;
bp.copy(op.xattr.name_len, aname);
result = -EOPNOTSUPP;
}
- if (!obs.exists && maybe_created) {
- ctx->delta_stats.num_objects++;
- obs.exists = true;
- }
-
if (result < 0 && (op.flags & CEPH_OSD_OP_FLAG_FAILOK))
result = 0;