osd/OSDMap: add osd_is_valid_op_target()

Helper to check whether an osd is a given op target for a pg.  This
assumes that for EC we always send ops to the primary, while for
replicated we may target any replica.

Signed-off-by: Sage Weil <sage@redhat.com>
osd/OSD: use OSDMap helper to determine if we are correct op target

Use the new helper.  This fixes our behavior for EC pools where targetting
a different shard is not correct, while for replicated pools it may be. In
the EC case, it leaves the op hanging indefinitely in the OpTracker because
the pgid exists but as a different shard.

Fixes: #9835
Signed-off-by: Sage Weil <sage@redhat.com>
Merge pull request #2906 from ceph/wip-9835

osd: fix misdirected ec ops stuck in optracker (9835)

Reviewed-by: Samuel Just <sam.just@inktank.com>
crush/CrushWrapper: fix detach_bucket

In commit 9850227d2f0ca2f692a154de2c14a0a08e751f08 we changed the call that
changed the weight of all instances of item to one that explicitly
changes it in the parent bucket, but parent_id may not be valid at the
call site.  Move this into the conditional block to fix.

Fixes: #10095
Signed-off-by: Sage Weil <sage@redhat.com>
Merge pull request #2920 from ceph/wip-10095

crush: fix detach_bucket

Reviewed-by: Samuel Just <sjust@redhat.com>
mds: don't overwrite reply's snapbl

set_trace_dist() updates reply's snapbl, don't overwrite it. For MKSNAP
request, just need to set mdr->tracei, set_trace_dist() will set reply's
snapbl.

Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: Yan, Zheng <zyan@redhat.com>
msg/simple: ms_die_on_skipped_message

Assert if we skip an incoming seq.  The SimpleMessenger never does this,
but the kernel messenger does.  Hopefully useful for tracking down bugs
like #10057.

Signed-off-by: Sage Weil <sage@redhat.com>
librados: Fix operator= null ptr references

Fixes: #10082

dzafman-2014-11-13_10:42:58-rgw-wip-10082-testing-basic-multi

Reviewed-by: Sage Weil <sage@redhat.com>
Signed-off-by: David Zafman <dzafman@redhat.com>
Merge pull request #2916 from ceph/wip-10057

msg/simple: ms_die_on_skipped_message

Reviewed-by: Greg Farnum <greg@inktank.com>
messages: MForward: stash auth entity name

This will allow us to assess the entity name, used during auth, for a
forwarded request, which is otherwise unavailable to the receiving
party.

Fixes: #9913 (partially)
Backport: giant

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
mon: Monitor: stash auth entity name in session

Backport: giant

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
mon: Monitor: forward session entity name to leader

And populate mock session (for forwarded request) with forwarded entity
name.

Backport: giant

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
mon: Monitor: use session's entity name for audit log

Fixes: #9913
Backport: giant

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
Merge pull request #2944 from ceph/wip-9913

mon: auth entity name for forwarded messages

Reviewed-by: Sage Weil <sage@redhat.com>
mon: OSDMonitor: zero osd info on removal

Otherwise a newly added osd sharing the same id will be initiated using
a polluted entry.

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
mon: OSDMonitor: be verbose on get_trim_to epochs

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
mon: PGMap: clean at last osdmap epoch if there are no pg stats

If we have no pools we may consider we have a clean state, thus allowing
the monitor to trim maps.

Signed-off-by: Joao Eduardo Luis <joao@redhat.com>