From: Kefu Chai Date: Fri, 25 Aug 2017 06:13:14 +0000 (+0800) Subject: mon/OSDMonitor: check creating_pgs.last_scan_epoch instead when sending creates X-Git-Tag: v13.0.1~1182^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17248%2Fhead;p=ceph.git mon/OSDMonitor: check creating_pgs.last_scan_epoch instead when sending creates we cannot be sure that the creating_pgs_by_osd_epoch is in sync with creating_pgs.pgs even if mapping.get_epoch() is less or equal to creating_pgs_epoch. because, 1) the access to mapping.epoch is not protected by lock, 2) even worse, the mapping might be not finished yet when we are trying to send pg-creates to subscribers. so instead of comparing creating_pgs_epoch with mapping's epoch, we should compare it with creating_pgs.last_scan_epoch. the former is updated once the creating_pgs_by_osd_epoch is updated with the latest mapping's epoch and creating_pgs.pgs; the latter is updated with current osdmap's epoch when creating_pgs is being updated with the inc osd map. if we are using a creating_pgs_epoch in sync, creating_pgs_epoch should be creating_pgs.last_scan_epoch + 1. Fixes: http://tracker.ceph.com/issues/20785 Signed-off-by: Kefu Chai --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 96a6af543508b..ac8ce7e852925 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -3261,8 +3261,7 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons dout(30) << __func__ << " osd." << osd << " next=" << next << " " << creating_pgs_by_osd_epoch << dendl; std::lock_guard l(creating_pgs_lock); - if (creating_pgs_epoch == 0 || - creating_pgs_epoch < mapping.get_epoch()) { + if (creating_pgs_epoch <= creating_pgs.last_scan_epoch) { dout(20) << __func__ << " not using stale creating_pgs@" << creating_pgs_epoch << dendl; // the subscribers will be updated when the mapping is completed anyway