osdmap: uninline a bunch of stuff

This will conflict with wip-lpg, yay.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: use shared_ptr for addrs, addr vectors

We share a lot of identical addresses between map versions because they
don't tend to change very often.  Instead of having a separate copy for
every map, use shared_ptr and share references.  Also use a reference for
the entire addr vector(s) in case no addrs differ at all.

Create new encode/decode macros for vector< shared_ptr<T> >.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: dedup addrs and addr vectors between maps

Compare two maps.  If an addrs matches, share the reference.  If all
addrs match, share the entire vector.

This leads to roughly 70% drop in memory utilization for the set of
thrashed maps I'm working with.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmaptool: kludge to load a range of maps into memory

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: use shared_ptr for CrushWrapper

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: dedup crush map

If the encoded crush map is identical between two versions, share the
reference.

Signed-off-by: Sage Weil <sage@newdream.net>
buffer: make contents_equal() more efficient

Iterate both lists in parallel in terms of buffers, and use memcmp() to
do the comparison.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: drop obsolete PG_ROLE_* constants

There are cruft from the old primary/chain/splay replication code.  All
current code says <0 is stray, 0 is primary, and >0 is replica.  That is,
the role is the acting vector position, or -1 if not in the vector.

Signed-off-by: Sage Weil <sage@newdream.net>
osd: dedup osdmaps when added to the in-memory cache

When we add an OSDMap to our in-memory cache, dedup against an existing map
at a nearby epoch.

Signed-off-by: Sage Weil <sage@newdream.net>
osd: make map dedup optional

On by default.  This trades CPU for memory.  Some might have unlimited RAM
and not care.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: use shared_ptr<> for pg_temp

This will let us dedup later.

Signed-off-by: Sage Weil <sage@newdream.net>
osdmap: dedup pg_temp

We only deal with the case where the entire map is identical, since the
individual items are too small to make the pointer overhead worthwhile.
Too bad.  A in-memory btree-like structure would work better for this.

Signed-off-by: Sage Weil <sage@newdream.net>
common/: added templated simple lru implementations

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
OSD.cc: track osdmap refs using an LRU

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
simple_cache.hpp: add pinning

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
OSD: use map bl cache pinning during handle_osd_map

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
osdmap: fix addr dedup check

Compare *every* address for a match, or else note that it is (or might be)
different.  Previously, we falsely took diff==0 to mean that all addrs
were definitely equal, which was not necessarily the case.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Merge branch 'wip-osdmap'

Conflicts:
	src/mon/PGMonitor.cc
	src/osd/OSDMap.h