From: Kefu Chai Date: Wed, 16 Mar 2016 13:15:35 +0000 (+0800) Subject: osd: populate the trim_thru epoch using MOSDMap.oldest_map X-Git-Tag: v0.94.8~37^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ac0340ad30329df7919ce82938ad49d0a2e2d160;p=ceph.git osd: populate the trim_thru epoch using MOSDMap.oldest_map instead of filling MOSDMap with the local oldest_map, we share the maximum MOSDMap.oldest_map received so far with peers. That way one OSD's failure to trim won't prevent it from sharing with others that they are allowed to trim. Fixes: #13990 Signed-off-by: Kefu Chai (cherry picked from commit 9789c29fe0f82b236703f7ae4d356251fde3a46f) Conflict: use atomic_t instead of std::atomic<> --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index ba1186d10e23..f3e5e8ef53dc 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -210,6 +210,7 @@ OSDService::OSDService(OSD *osd) : pg_epoch_lock("OSDService::pg_epoch_lock"), publish_lock("OSDService::publish_lock"), pre_publish_lock("OSDService::pre_publish_lock"), + max_oldest_map(0), peer_map_epoch_lock("OSDService::peer_map_epoch_lock"), sched_scrub_lock("OSDService::sched_scrub_lock"), scrubs_pending(0), scrubs_active(0), @@ -1031,7 +1032,7 @@ MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to, OSDSuperblock& sblock) { MOSDMap *m = new MOSDMap(monc->get_fsid()); - m->oldest_map = sblock.oldest_map; + m->oldest_map = max_oldest_map.read(); m->newest_map = sblock.newest_map; for (epoch_t e = to; e > since; e--) { @@ -1071,7 +1072,7 @@ void OSDService::send_incremental_map(epoch_t since, Connection *con, if (since < sblock.oldest_map) { // just send latest full map MOSDMap *m = new MOSDMap(monc->get_fsid()); - m->oldest_map = sblock.oldest_map; + m->oldest_map = max_oldest_map.read(); m->newest_map = sblock.newest_map; get_map_bl(to, m->maps[to]); send_map(m, con); @@ -1939,6 +1940,7 @@ int OSD::init() service.init(); service.publish_map(osdmap); service.publish_superblock(superblock); + service.max_oldest_map.set(superblock.oldest_map); osd_lock.Unlock(); @@ -6207,6 +6209,10 @@ void OSD::handle_osd_map(MOSDMap *m) logger->inc(l_osd_mape, last - first + 1); if (first <= osdmap->get_epoch()) logger->inc(l_osd_mape_dup, osdmap->get_epoch() - first + 1); + if (service.max_oldest_map.read() < m->oldest_map) { + service.max_oldest_map.set(m->oldest_map); + assert(service.max_oldest_map.read() >= superblock.oldest_map); + } // make sure there is something new, here, before we bother flushing the queues and such if (last <= osdmap->get_epoch()) { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 3cc8df05d84e..517e5e6d6ac6 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -387,6 +387,7 @@ public: int get_nodeid() const { return whoami; } + atomic_t max_oldest_map; OSDMapRef osdmap; OSDMapRef get_osdmap() { Mutex::Locker l(publish_lock);