Skip to content

Commit

Permalink
osd: Add func has_flag in MOSDOp.
Browse files Browse the repository at this point in the history
Signed-off-by: Jianpeng Ma <[email protected]>
  • Loading branch information
majianpeng committed Mar 23, 2015
1 parent b468548 commit d9a2ca5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/messages/MOSDOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ class MOSDOp : public Message {

// flags
int get_flags() const { return flags; }
bool has_flag(__u32 flag) { return flags & flag; };

bool wants_ack() const { return flags & CEPH_OSD_FLAG_ACK; }
bool wants_ondisk() const { return flags & CEPH_OSD_FLAG_ONDISK; }
Expand Down
24 changes: 12 additions & 12 deletions src/osd/ReplicatedPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1442,7 +1442,7 @@ void ReplicatedPG::do_op(OpRequestRef& op)
bool write_ordered =
op->may_write() ||
op->may_cache() ||
(m->get_flags() & CEPH_OSD_FLAG_RWORDERED);
m->has_flag(CEPH_OSD_FLAG_RWORDERED);

dout(10) << "do_op " << *m
<< (op->may_write() ? " may_write" : "")
Expand Down Expand Up @@ -1564,23 +1564,23 @@ void ReplicatedPG::do_op(OpRequestRef& op)
m->get_object_locator().nspace);

// io blocked on obc?
if (((m->get_flags() & CEPH_OSD_FLAG_FLUSH) == 0) &&
if (!m->has_flag(CEPH_OSD_FLAG_FLUSH) &&
maybe_await_blocked_snapset(oid, op)) {
return;
}

int r = find_object_context(
oid, &obc, can_create,
m->get_flags() & CEPH_OSD_FLAG_MAP_SNAP_CLONE,
m->has_flag(CEPH_OSD_FLAG_MAP_SNAP_CLONE),
&missing_oid);

if (r == -EAGAIN) {
// If we're not the primary of this OSD, and we have
// CEPH_OSD_FLAG_LOCALIZE_READS set, we just return -EAGAIN. Otherwise,
// we have to wait for the object.
if (is_primary() ||
(!(m->get_flags() & CEPH_OSD_FLAG_BALANCE_READS) &&
!(m->get_flags() & CEPH_OSD_FLAG_LOCALIZE_READS))) {
(!(m->has_flag(CEPH_OSD_FLAG_BALANCE_READS) &&
!(m->has_flag(CEPH_OSD_FLAG_LOCALIZE_READS))))) {
// missing the specific snap we need; requeue and wait.
assert(!op->may_write()); // only happens on a read/cache
wait_for_unreadable_object(missing_oid, op);
Expand Down Expand Up @@ -1625,7 +1625,7 @@ void ReplicatedPG::do_op(OpRequestRef& op)
agent_choose_mode();
}

if ((m->get_flags() & CEPH_OSD_FLAG_IGNORE_CACHE) == 0 &&
if (!(m->has_flag(CEPH_OSD_FLAG_IGNORE_CACHE)) &&
maybe_handle_cache(op, write_ordered, obc, r, missing_oid, false, in_hit_set))
return;

Expand All @@ -1647,7 +1647,7 @@ void ReplicatedPG::do_op(OpRequestRef& op)

// io blocked on obc?
if (obc->is_blocked() &&
(m->get_flags() & CEPH_OSD_FLAG_FLUSH) == 0) {
!m->has_flag(CEPH_OSD_FLAG_FLUSH)) {
wait_for_blocked_object(obc->obs.oi.soid, op);
return;
}
Expand Down Expand Up @@ -1781,7 +1781,7 @@ void ReplicatedPG::do_op(OpRequestRef& op)
if (ctx->snapset_obc && !ctx->snapset_obc->obs.exists)
ctx->snapset_obc = ObjectContextRef();

if (m->get_flags() & CEPH_OSD_FLAG_SKIPRWLOCKS) {
if (m->has_flag(CEPH_OSD_FLAG_SKIPRWLOCKS)) {
dout(20) << __func__ << ": skipping rw locks" << dendl;
} else if (m->get_flags() & CEPH_OSD_FLAG_FLUSH) {
dout(20) << __func__ << ": part of flush, will ignore write lock" << dendl;
Expand All @@ -1808,7 +1808,7 @@ void ReplicatedPG::do_op(OpRequestRef& op)
return;
}

if (m->get_flags() & CEPH_OSD_FLAG_IGNORE_CACHE) {
if (m->has_flag(CEPH_OSD_FLAG_IGNORE_CACHE)) {
ctx->ignore_cache = true;
}

Expand Down Expand Up @@ -2267,7 +2267,7 @@ void ReplicatedPG::execute_ctx(OpContext *ctx)

if (op->may_write() || op->may_cache()) {
// snap
if (!(m->get_flags() & CEPH_OSD_FLAG_ENFORCE_SNAPC) &&
if (!(m->has_flag(CEPH_OSD_FLAG_ENFORCE_SNAPC)) &&
pool.info.is_pool_snaps_mode()) {
// use pool's snapc
ctx->snapc = pool.snapc;
Expand All @@ -2276,7 +2276,7 @@ void ReplicatedPG::execute_ctx(OpContext *ctx)
ctx->snapc.seq = m->get_snap_seq();
ctx->snapc.snaps = m->get_snaps();
}
if ((m->get_flags() & CEPH_OSD_FLAG_ORDERSNAP) &&
if ((m->has_flag(CEPH_OSD_FLAG_ORDERSNAP)) &&
ctx->snapc.seq < obc->ssc->snapset.seq) {
dout(10) << " ORDERSNAP flag set and snapc seq " << ctx->snapc.seq
<< " < snapset seq " << obc->ssc->snapset.seq
Expand Down Expand Up @@ -7583,7 +7583,7 @@ void ReplicatedPG::issue_repop(RepGather *repop, utime_t now)
const hobject_t& soid = ctx->obs->oi.soid;
if (ctx->op &&
((static_cast<MOSDOp *>(
ctx->op->get_req()))->get_flags() & CEPH_OSD_FLAG_PARALLELEXEC)) {
ctx->op->get_req()))->has_flag(CEPH_OSD_FLAG_PARALLELEXEC))) {
// replicate original op for parallel execution on replica
assert(0 == "broken implementation, do not use");
}
Expand Down

0 comments on commit d9a2ca5

Please sign in to comment.