mon: ignore failure messages if already pending a failure

If a failure is already pending, do nothing in check_failure().

Signed-off-by: Sage Weil <sage@inktank.com>
mon: process failures when osds go down

If we see an osd go down, process any pending failure_info reports we have.
Reply, and then remove the record from the map.

This ensures that we process failures and clean up regardless of *why* or
*who* did the marking down; either way, the osd was failed.

This fixes crashes like #3477, where the failure record was removed when we
updated the pending_map, but additional failures came in, and we didn't
clean up.

Signed-off-by: Sage Weil <sage@inktank.com>
mon: kick failures when we lose leadership

If we were leader and are not anymore, kick any pending failure messages.

Signed-off-by: Sage Weil <sage@inktank.com>
objecter: separate locked and unlocked init/shutdown

We don't want to hold the lock while we register the admin socket commands
or else we create a lock cycle when we try to process them later.

Signed-off-by: Sage Weil <sage@inktank.com>
client: register admin socket commands without lock held

Avoid a lock cycle.

existing dependency Client::client_lock (11) -> AdminSocket::m_lock (16) at:
 ceph version 0.54-578-g7926ef5 (7926ef53935313501d4a7fe0e587f3e3b00b313c)
 1: (Mutex::Lock(bool)+0x41) [0x831337]
 2: (AdminSocket::register_command(std::string, AdminSocketHook*, std::string)+0x40) [0x873a32]
 3: (Client::init()+0x454) [0x6f4c24]
 4: (main()+0x637) [0x6ea399]
 5: (__libc_start_main()+0xed) [0x7fd97bbca76d]
 6: ./ceph-fuse() [0x6e9c59]

    -4> 2012-11-13 18:14:48.619714 7fd97b1a3700  0 new dependency AdminSocket::m_lock (16) -> Client::client_lock (11) creates a cycle at
 ceph version 0.54-578-g7926ef5 (7926ef53935313501d4a7fe0e587f3e3b00b313c)
 1: (Mutex::Lock(bool)+0x41) [0x831337]
 2: (Objecter::RequestStateHook::call(std::string, std::string, ceph::buffer::list&)+0x7a) [0x90627e]
 3: (AdminSocket::do_accept()+0xb1b) [0x87318f]
 4: (AdminSocket::entry()+0x2fa) [0x8725fe]
 5: (Thread::_entry_func(void*)+0x23) [0x86b335]
 6: (()+0x7e9a) [0x7fd97d279e9a]
 7: (clone()+0x6d) [0x7fd97bc9ccbd]

Signed-off-by: Sage Weil <sage@inktank.com>
rgw: relax date format check

Don't try to parse beyond the GMT or UTC. Some clients use
special date formatting. If we end up misparsing the date
it'll fail in the authorization, so don't need to be too
restrictive.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Merge remote-tracking branch 'gh/wip-asok' into next

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
mon: set default port when binding to random local ip

Fixes #3135
Signed-off-by: Sage Weil <sage@inktank.com>
rgw: update post policy parser

json parser semantics changed a little bit, so
needed to update the policy parser.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
mon: calculate failed_since relative to message receive time

Instead of looking at the current time we process the message, look at the
receive time.  This gives us a more real failure time given that messages
may be requeued.

It doesn't solve the problem when messages are forwarded between monitors
due to an election, but that's ok; this is still a net improvement.

Signed-off-by: Sage Weil <sage@inktank.com>
objecter: fix leak of out_handlers

The error paths don't use the handlers.  Make sure they get cleaned up.

Fixes: #3446
Signed-off-by: Sage Weil <sage@inktank.com>
librbd: use delete[] properly

==4986== Mismatched free() / delete / delete []
==4986==    at 0x4C2658C: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4986==    by 0x4ED8EA9: librbd::ImageCtx::~ImageCtx() (ImageCtx.cc:100)
==4986==    by 0x4EF3827: librbd::close_image(librbd::ImageCtx*) (internal.cc:1869)
==4986==    by 0x4EE8FB8: librbd::clone(librados::IoCtx&, char const*, char const*, librados::IoCtx&, char const*, unsigned long, int*, unsigned long, int) (internal.cc:900)
==4986==    by 0x4EC363C: rbd_clone2 (librbd.cc:553)
==4986==    by 0x404C85: do_clone (fsx.c:836)
==4986==    by 0x405639: test (fsx.c:1048)
==4986==    by 0x406369: main (fsx.c:1523)
==4986==  Address 0xd498b30 is 0 bytes inside a block of size 37 alloc'd
==4986==    at 0x4C26CF7: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==4986==    by 0x4ED9B4D: librbd::ImageCtx::init_layout() (ImageCtx.cc:164)
==4986==    by 0x4ED9845: librbd::ImageCtx::init() (ImageCtx.cc:142)
==4986==    by 0x4EF3449: librbd::open_image(librbd::ImageCtx*, bool) (internal.cc:1828)
==4986==    by 0x4EE89E0: librbd::clone(librados::IoCtx&, char const*, char const*, librados::IoCtx&, char const*, unsigned long, int*, unsigned long, int) (internal.cc:871)
==4986==    by 0x4EC363C: rbd_clone2 (librbd.cc:553)
==4986==    by 0x404C85: do_clone (fsx.c:836)
==4986==    by 0x405639: test (fsx.c:1048)
==4986==    by 0x406369: main (fsx.c:1523)

Signed-off-by: Sage Weil <sage@inktank.com>
PrioritizedQueue: allow remove_by_class to return removed items

Signed-off-by: Samuel Just <sam.just@inktank.com>
msg/DispatchQueue: release throttle on messages when dropping an id

Signed-off-by: Samuel Just <sam.just@inktank.com>
Merge remote-tracking branch 'gh/wip-3477' into next

Reviewed-by: Greg Farnum <greg@inktank.com>
msg/Pipe: fix leak of Authorizer

Reported-by: Joao Luis <joao.luis@inktank.com>
Signed-off-by: Sage Weil <sage@inktank.com>
Merge remote-tracking branch 'gh/next'