os/FileStore: do not loop in sync_entry on shutdown

Normally we repeat a sync if the journal is full and asks for it or if we
have pending sync waiters.  This isn't for correctness: it's to move things
along quickly.

If we are shutting down *and* the journal is full, however, we currently
can get stuck in a loop where we repeatedly sync.  However, the journal
never gets unfull because we aren't expiring anything.

We tried to fix this in 682b9daacb1960eb60b5f0e9b40d4a3a3e9afd5b but that
didn't work because we don't tell the journal to stop before we shut down
the filestore sync thread.

I'm pretty sure there is another issue in the journal code as

 full_state == FULL_FULL
 submit_manager.op_seq = 14761
 apply_manager.committing_seq = 14761
 apply_manager.committed_seq = 14761

which seems odd.  But I have no longs.  Meanwhile, this fixes the hang.

Fixes: #9545
Signed-off-by: Sage Weil <sage@redhat.com>
shared_cache::add: do not delete value if existed

The method contract specifies that we do not want to delete
value if we are not inserting it, so do not initialize val
at the top of the function to take over value.  No current
users appear to trip over this problem (FDCache and
map_cache).

Signed-off-by: Samuel Just <sam.just@inktank.com>
shared_cache: add purge and tests

purge detaches the lru shared_ptr currently associated from
the key from the lru even if there are still references.

Signed-off-by: Samuel Just <sam.just@inktank.com>
FDCache: purge hoid on clear

We no longer require that a lock on the FD be held for the duration of an
operation, only while accessing the actual index.  We cannot, therefore, assume
that a racing read during lfn_unlink (backfill or scrub) does not still have a
reference to the fd.  We want to remove the fd from the cache to prevent
subsequent operations from finding it while allowing such a racing read to
complete with its existing fd.

Fixes: #9480
Signed-off-by: Samuel Just <sam.just@inktank.com>
ReplicatedPG: writeout hit_set object with correct prior_version

Fixes: #9875
Backport: giant, firefly
Signed-off-by: Samuel Just <sam.just@inktank.com>
Merge pull request #2798 from athanatos/wip-9875

ReplicatedPG: writeout hit_set object with correct prior_version

Reviewed-by: Sage Weil <sage@redhat.com>
Merge pull request #2799 from athanatos/wip-9480

Wip 9480

Reviewed-by: Sage Weil <sage@redhat.com>
os/LevelDBStore, RocksDBStore: fix race handling for get store size

If we get ENOENT, skip this file, instead of adding in undefined stat
values.

Backport: firefly
Signed-off-by: Sage Weil <sage@redhat.com>
Merge pull request #2800 from ceph/wip-enoent-race

os/LevelDBStore, RocksDBStore: fix race handling for get store size

Reviewed-by: Joao Eduardo Luis <joao@redhat.com>
Merge pull request #2630 from ceph/wip-9545

os/FileStore: do not loop in sync_entry on shutdown

Reviewed-by: Samuel Just <sam.just@inktank.com>
Merge remote-tracking branch 'gh/giant'

Conflicts:
	src/test/common/test_shared_cache.cc