osd: create _delete_head function, move CEPH_OSD_OP_DELETE handling to it.

This commit is contained in:
Greg Farnum 2010-05-21 14:29:36 -07:00 committed by Yehuda Sadeh
parent e935b8ecdd
commit 233365616d
2 changed files with 29 additions and 19 deletions

View File

@ -1363,24 +1363,7 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops,
break;
case CEPH_OSD_OP_DELETE:
{ // delete
if (ctx->obs->exists)
t.remove(coll_t::build_pg_coll(info.pgid), soid); // no clones, delete!
if (ssc->snapset.clones.size()) {
snapid_t newest = *ssc->snapset.clones.rbegin();
add_interval_usage(ssc->snapset.clone_overlap[newest], info.stats);
ssc->snapset.clone_overlap.erase(newest); // ok, redundant.
}
if (ctx->obs->exists) {
info.stats.num_objects--;
info.stats.num_bytes -= oi.size;
info.stats.num_kb -= SHIFT_ROUND_UP(oi.size, 10);
oi.size = 0;
ssc->snapset.head_exists = false;
ctx->obs->exists = false;
}
info.stats.num_wr++;
}
_delete_head(ctx);
break;
@ -1694,6 +1677,31 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops,
return result;
}
inline void ReplicatedPG::_delete_head(OpContext *ctx)
{
SnapSetContext *ssc = ctx->obs->ssc;
object_info_t& oi = ctx->obs->oi;
const sobject_t& soid = oi.soid;
ObjectStore::Transaction& t = ctx->op_t;
if (ctx->obs->exists)
t.remove(coll_t::build_pg_coll(info.pgid), soid);
if (ssc->snapset.clones.size()) {
snapid_t newest = *ssc->snapset.clones.rbegin();
add_interval_usage(ssc->snapset.clone_overlap[newest], info.stats);
ssc->snapset.clone_overlap.erase(newest); // ok, redundant.
}
if (ctx->obs->exists) {
info.stats.num_objects--;
info.stats.num_bytes -= oi.size;
info.stats.num_kb -= SHIFT_ROUND_UP(oi.size, 10);
oi.size = 0;
ssc->snapset.head_exists = false;
ctx->obs->exists = false;
}
info.stats.num_wr++;
}
void ReplicatedPG::_make_clone(ObjectStore::Transaction& t,

View File

@ -583,7 +583,9 @@ public:
bool snap_trimmer();
int do_osd_ops(OpContext *ctx, vector<OSDOp>& ops,
bufferlist& odata);
private:
void _delete_head(OpContext *ctx);
public:
bool same_for_read_since(epoch_t e);
bool same_for_modify_since(epoch_t e);
bool same_for_rep_modify_since(epoch_t e);