In a scenario where a truncation that followed a write got to
the osd before the preceding write, we shouldn't write beyond
that truncation when the write is handled in the osd.
case CEPH_OSD_OP_WRITE:
{ // write
+ __u32 seq = oi.truncate_seq;
+ if (seq && (seq > op.extent.truncate_seq) &&
+ (op.extent.offset + op.extent.length > oi.size)) {
+ op.extent.length = (op.extent.offset > oi.size ? 0 : oi.size - op.extent.offset);
+ }
+
if (op.extent.length) {
bufferlist nbl;
bp.copy(op.extent.length, nbl);
oi.truncate_seq = op.extent.truncate_seq;
oi.truncate_size = op.extent.truncate_size;
} else {
+ dout(10) << " seq " << op.extent.truncate_seq << " > old_seq " << old_seq
+ << " already truncated" << dendl;
// object was already truncated, no-op.
}
}