osdc/Objecter: move mapping into struct, helper

Move the common bits of Op and LingerOp into op_target_t and separate the
actual mapping calculation into calc_target().  This hugely simplifies
recal_*op_target() by mostly just shuffling all of the same logic into
that helper.

There is one functional change in this patch: recalc_linger_op() now is
aware of the tiering logic that was previously only handled in
recalc_op_target().

Signed-off-by: Sage Weil <sage@inktank.com>
librados: Rollback interface additions

Add C interface rados_ioctx_snap_rollback() and indicate that rados_rollback()
is deprecated.

Add C++ interface IoCtx::snap_rollback() and indicate that IoCtx::rollback()
is deprecated.

Modify snapshot test case to use new function names.

Signed-off-by: David Zafman <david.zafman@inktank.com>
librados: Add ObjectWriteOperation::snap_rollback() for pool snapshots

snap_rollback() is the same as selfmanaged_snap_rollback() but we want an
independent interface for pool snapshots.  Should really take snapname
for consistency with other pool snapshot interfaces.

Signed-off-by: David Zafman <david.zafman@inktank.com>
test: Fix ceph_test_rados to not core dump with invalid arguments

Signed-off-by: David Zafman <david.zafman@inktank.com>
test: Add --pool-snaps option to ceph_test_rados

Fixes: #7940

Signed-off-by: David Zafman <david.zafman@inktank.com>
test/librados/TestCase: add Param option that can set up a cache pool

Signed-off-by: Sage Weil <sage@inktank.com>
ceph_test_rados_api_watch_notify: test over cache pool

Signed-off-by: Sage Weil <sage@inktank.com>
osd/ReplicatedPG: handle missing hit_set on HITSET_GET rados op

Fixes: #8081
Signed-off-by: Sage Weil <sage@inktank.com>
mds: fix typo in Server::do_rename_rollback()

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
osd/ReplicatedPG: handle misdirected do_command

We can get a query on a pg we still have but are no longer primary for.  If
that happens, do not reply.  The client will resend to the correct OSD
assuming it has the map.  Send them the latest incremental so that we know
they know there is something new.  We don't know the exact epoch they have,
unfortunately, because MCommand doesn't include it, but a newer inc is
enough to make them request the right incrementals from a mon.  Eventually
they will figure it out and Objecter will resend the request to the
correct target.

It is possible we should include epoch in the MCommand message so that we
can do this mapping "correctly" (as in, the same way MOSDOp does).  That
makes MCommand less general, though... a PG-specific command message might
be the most precise thing.  Another day...

Fixes: #8085
Signed-off-by: Sage Weil <sage@inktank.com>
mds: do file recover after authpin inode

MDCache::do_file_recover may call Locker::evel_gather, which may change
filelock to stable state. So we should authpin the inode (for unstable
lock state) first.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
mds: don't issue/revoke caps before client has caps

If early reply is not allowed, MDS does not send reply to client immediately
after Locker::issue_new_caps adds new caps. So MDS can revoke the caps before
sending reply to client.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
osd/ReplicatedPG: handle dup ops earlier in do_op

Current the dup op checks happen in execute_ctx, long after we handle
cache ops or get the obc and (potentially) return ENOENT.  That means that
object deletions and cache ops both aren't properly idempotent.

This is easy to fix by moving the check earlier in do_op.

Fixes: #8089
Signed-off-by: Sage Weil <sage@inktank.com>
ceph_test_rados_api_*: fix build warnings, memset ranges

Signed-off-by: Sage Weil <sage@inktank.com>
mds: don't modify inode when calculating client ranges

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Merge pull request #1668 from ceph/wip-librados-tests

ceph_test_rados_api_*: fix build warnings and memset ranges

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Use cpp_strerror() wherever possible, and use autoconf for portability

strerror_r is not portable; on Gnu libc it returns char * and sometimes
does not fill in the supplied buffer.  Use autoconf to test which
version this platform uses and adapt.

Clean up the random calls to strerror and strerror_r (along with all
their private little one-use buffers) and regularize the code to use
cpp_strerror almost everywhere.  Where changed, any negation of the
error code is also removed, since cpp_strerror() will do that.

Note: some tools were using their own calls to strerror/strerror_r, so
will now get a (%d) in their output that wasn't there before; hence
the change to test/cli/monmaptool/print-nonexistent.t

Fixes: #8041
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Merge pull request #1672 from ceph/wip-strerror

Use cpp_strerror() wherever possible, and use autoconf for portability

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Merge pull request #1661 from ceph/wip-objecter

objecter: make linger watch the correct pool/object

Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
ceph_test_stress_watch: test over cache pool

Signed-off-by: Sage Weil <sage@inktank.com>