Question about ReplicatedBackend::sub_op_modify_reply
Hi, everyone.
I'm trying to read the source code of ceph, and I found that some code seems strange. In ReplicatedBackend::sub_op_modify_reply, there is the following code:
if (r->ack_type & CEPH_OSD_FLAG_ONDISK) {
assert(ip_op.waiting_for_commit.count(from));
ip_op.waiting_for_commit.erase(from);
if (ip_op.op) {
ostringstream ss;
ss << "sub_op_commit_rec_from_osd." << from.osd;
ip_op.op->mark_event(ss.str());
}
} else {
assert(ip_op.waiting_for_applied.count(from));
if (ip_op.op) {
ostringstream ss;
ss << "sub_op_applied_rec_from_osd." << from.osd;
ip_op.op->mark_event(ss.str());
}
}
ip_op.waiting_for_applied.erase(from);It seems that the statement "ip_op.waiting_for_applied.erase(from)" should be in the "else" clause, otherwise items in waiting_for_applied could be errorly erased when ack_type is CEPH_OSD_FLAG_ONDISK.
Why put it outside the "else" clause?
Thank you:-)
Quoted 22 lines · On Wed, 7 Dec 2016, xxhdx1985126 wrote:
Hi, everyone.
I'm trying to read the source code of ceph, and I found that some code seems strange. In
ReplicatedBackend::sub_op_modify_reply, there is the following code:if (r->ack_type & CEPH_OSD_FLAG_ONDISK) { assert(ip_op.waiting_for_commit.count(from)); ip_op.waiting_for_commit.erase(from); if (ip_op.op) { ostringstream ss; ss << "sub_op_commit_rec_from_osd." << from.osd; ip_op.op->mark_event(ss.str()); } } else { assert(ip_op.waiting_for_applied.count(from)); if (ip_op.op) { ostringstream ss; ss << "sub_op_applied_rec_from_osd." << from.osd; ip_op.op->mark_event(ss.str()); } } ip_op.waiting_for_applied.erase(from);
Quoted 3 lines
It seems that the statement "
ip_op.waiting_for_applied.erase(from)" should be in the "else" clause, otherwise items inwaiting_for_appliedcould be errorly erased whenack_typeisCEPH_OSD_FLAG_ONDISK.Why put it outside the "else" clause?
The commit/ondisk message implies applied.
sage
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 5 lines · On Fri, 9 Dec 2016, xxhdx1985126 wrote:
Thanks for the quick reply:-)
By the way, according to my understanding of the source code, the ondisk callback is trigger both when journal write complete or
syscall(SYS_syncfs, fd)complete. Is this right?
The syncfs path only happens if you're using btrfs ('parallel' mode) since with xfs we don't even write to the fs until the journaled event has committed.
s
Quoted 43 lines
Quoted 5 lines · Sage Weil
Quoted 4 lines · On Wed, 7 Dec 2016, xxhdx1985126 wrote:
Hi, everyone.
I'm trying to read the source code of ceph, and I found that some code se
ems strange.
Quoted 11 lines
Quoted 11 lines
In
ReplicatedBackend::sub_op_modify_reply, there is the following code:if (r->ack_type & CEPH_OSD_FLAG_ONDISK) { assert(ip_op.waiting_for_commit.count(from)); ip_op.waiting_for_commit.erase(from); if (ip_op.op) { ostringstream ss; ss << "sub_op_commit_rec_from_osd." << from.osd; ip_op.op->mark_event(ss.str()); } } else { assert(ip_op.waiting_for_applied.count(from));Quoted 8 lines
Quoted 8 lines
if (ip_op.op) { ostringstream ss; ss << "sub_op_applied_rec_from_osd." << from.osd; ip_op.op->mark_event(ss.str()); } } ip_op.waiting_for_applied.erase(from);It seems that the statement "
ip_op.waiting_for_applied.erase(from)" should be in the "else" clause, otherwise items in
waiting_for_appliedcould be e rrorly erased whenack_typeisCEPH_OSD_FLAG_ONDISK.Quoted 6 lines
Quoted 2 lines
Why put it outside the "else" clause?
The commit/ondisk message implies applied.
sage