From: Sage Weil Date: Mon, 9 Nov 2009 21:17:29 +0000 (-0800) Subject: osd: log misdirected ops; reply with -ENXIO X-Git-Tag: v0.18~128^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b051a2fd4a8f3959b86a836b50b7d46aedd057c9;p=ceph.git osd: log misdirected ops; reply with -ENXIO This is more helpful than assert(0). It's still bad (it means the client and osd calculated different pg mappings) though, but this makes it easier to identify and fix. --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 8520eb038f17..28b5c0c77928 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -3628,6 +3628,22 @@ void OSD::reply_op_error(MOSDOp *op, int err) delete op; } +void OSD::handle_misdirected_op(PG *pg, MOSDOp *op) +{ + if (op->get_map_epoch() < pg->info.history.same_primary_since) { + dout(7) << *pg << " changed after " << op->get_map_epoch() << ", dropping" << dendl; + delete op; + } else { + dout(7) << *pg << " misdirected op in " << op->get_map_epoch() << dendl; + stringstream ss; + ss << op->get_source_inst() << " misdirected " << op->get_reqid() + << " " << pg->info.pgid << " to osd" << whoami + << " not " << pg->acting; + logclient.log(LOG_WARN, ss); + reply_op_error(op, -ENXIO); + } +} + void OSD::handle_op(MOSDOp *op) { // require same or newer map @@ -3722,10 +3738,8 @@ void OSD::handle_op(MOSDOp *op) // modify if (!pg->is_primary() || !pg->same_for_modify_since(op->get_map_epoch())) { - dout(7) << *pg << " changed for write after " << op->get_map_epoch() << ", dropping" << dendl; - assert(op->get_map_epoch() < osdmap->get_epoch()); + handle_misdirected_op(pg, op); pg->unlock(); - delete op; return; } @@ -3739,10 +3753,8 @@ void OSD::handle_op(MOSDOp *op) } else { // read if (!pg->same_for_read_since(op->get_map_epoch())) { - dout(7) << *pg << " changed for read after " << op->get_map_epoch() << ", dropping" << dendl; - assert(op->get_map_epoch() < osdmap->get_epoch()); + handle_misdirected_op(pg, op); pg->unlock(); - delete op; return; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index cfff8e7fed2d..9ab63f953486 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -834,6 +834,7 @@ protected: int shutdown(); void reply_op_error(MOSDOp *op, int r); + void handle_misdirected_op(PG *pg, MOSDOp *op); void handle_scrub(class MOSDScrub *m); void handle_osd_ping(class MOSDPing *m);