Sage Weil [Fri, 17 May 2013 00:58:48 +0000 (17:58 -0700)]
mon: clear pg delta after some period
If we have not pg_map updates, the delta doesn't update, and can get stuck
with the velocity right before activity stopped. This is confusing, and
can cause incorrect health warnings about in-progress recovery.
To fix this, zero the delta if there is no activity for
'mon delta reset interval' seconds.
Fixes: #5077 Signed-off-by: Sage Weil <sage@inktank.com>
Samuel Just [Tue, 14 May 2013 23:35:48 +0000 (16:35 -0700)]
FileJournal: adjust write_pos prior to unlocking write_lock
In committed_thru, we use write_pos to reset the header.start value in cases
where seq is past the end of our journalq. It is therefore important that the
journalq be updated atomically with write_pos (that is, under the write_lock).
The call to align_bl() is moved into do_write in order to ensure that write_pos
is adjusted correctly prior to write_bl().
Also, we adjust pos at the end of write_bl() such that pos \in [get_top(),
header.max_size) after write_bl().
Fixes: #5020 Signed-off-by: Samuel Just <sam.just@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
Loic Dachary [Tue, 14 May 2013 08:52:40 +0000 (10:52 +0200)]
update op added to a waiting queue or discarded
The decision to discard an op happens either in OSD or in PG.
The operation queue goes to a single OpWQ object if waiting_map does not impose a delay op_queue.
The decision to add an op to a waiting queue regardless of its type is updated.
The decision to add a CEPH_MSG_OSD_OP to a waiting queue is described in full.
Danny Al-Gaaf [Tue, 14 May 2013 17:20:29 +0000 (19:20 +0200)]
rgw/rgw_user.cc: fix possible NULL pointer dereference
CID 1019559 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer "usr" to function
"RGWUser::get_store()", which dereferences it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Tue, 14 May 2013 17:15:23 +0000 (19:15 +0200)]
mds/Server.cc: fix possible NULL pointer dereference
Assert if straydn is NULL.
CID 1019554 (#2 of 2): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer "straydn" to function
"MDSCacheObject::is_auth() const", which dereferences it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Tue, 14 May 2013 17:07:29 +0000 (19:07 +0200)]
mds/Server.cc: fix possible NULL pointer dereference
Assert of straydn is NULL here.
CID 1019558 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer "straydn" to function
"CDentry::get_dir() const", which dereferences it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Tue, 14 May 2013 17:02:20 +0000 (19:02 +0200)]
mds/Server.cc: fix possible NULL pointer dereference
Assert if destdn == NULL.
CID 1019557 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer "destdn" to function
"CDentry::get_dir() const", which dereferences it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Tue, 14 May 2013 15:02:56 +0000 (17:02 +0200)]
src/dupstore.cc: check return value of list_collections()
CID 1019545 (#1 of 1): Unchecked return value (CHECKED_RETURN)
check_return: Calling function "ObjectStore::list_collections
(std::vector<coll_t, std::allocator<coll_t> > &)" without
checking return value (as is done elsewhere 5 out of 6 times).
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Tue, 14 May 2013 14:50:57 +0000 (16:50 +0200)]
mds/Server.cc: fix possible NULL pointer dereference
CID 1019555 (#1 of 1): Dereference after null check (FORWARD_NULL)
var_deref_model: Passing null pointer "in" to function
"Server::_need_force_journal(CInode *, bool)", which dereferences it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 14:19:46 +0000 (16:19 +0200)]
src/rbd.cc: use 64-bits to shift 'order'
CID 1019568 (#1 of 1): Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
overflow_before_widen: Potentially overflowing expression "1 << *order" with
type "int" (32 bits, signed) is evaluated using 32-bit arithmetic before being
used in a context which expects an expression of type "uint64_t" (64 bits,
unsigned). To avoid overflow, cast the left operand to "uint64_t" before
performing the left shift.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 14:02:04 +0000 (16:02 +0200)]
mon/Monitor.cc: init 'timecheck_acks' with '0' in constructor
CID 1019623 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member "timecheck_acks" is not
initialized in this constructor nor in any functions that it calls.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 13:37:24 +0000 (15:37 +0200)]
mon/Monitor.h: init 'crc' in constructor with '0'
CID 1019624 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member "crc" is not initialized
in this constructor nor in any functions that it calls.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CID 1019626 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member "flags" is not initialized
in this constructor nor in any functions that it calls.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 12:36:53 +0000 (14:36 +0200)]
test/test_cors.cc: initialize key_type in constructor
CID 1019635 (#1 of 1): Uninitialized pointer field (UNINIT_CTOR)
uninit_member: Non-static class member "kt" is not initialized in
this constructor nor in any functions that it calls.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 11:52:32 +0000 (13:52 +0200)]
test_filejournal.cc: cleanup memory in destructor
CID 716885 (#1 of 1): Resource leak in object (CTOR_DTOR_LEAK)
alloc_new: Allocating memory by calling "new C_SafeCond(&this->lock,
&this->cond, &this->done, NULL)".
ctor_dtor_leak: The constructor allocates field "c" of "C_Sync" but
the destructor and whatever functions it calls do not free it.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Danny Al-Gaaf [Mon, 13 May 2013 11:40:03 +0000 (13:40 +0200)]
librbd/test_librbd.cc: free memory in test_list_children()
CID 719581 (#7 of 7): Resource leak (RESOURCE_LEAK)
CID 719581 (#6 of 7): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "pools" going out of scope leaks the
storage it points to.
CID 719582 (#6-7 of 7): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "children" going out of scope leaks
the storage it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Josh Durgin [Sun, 12 May 2013 21:53:26 +0000 (14:53 -0700)]
librbd: add options to enable balanced or localized reads for snapshots
Since snapshots never change, it's safe to read from replicas for them.
A common use for this would be reading from a parent snapshot shared by
many clones.
Convert LibrbdWriteback and AioRead to use the ObjectOperation api
so we can set flags. Fortunately the external wrapper holds no data,
so its lifecycle doesn't need to be managed.
Include a simple workunit that sets the flags in various combinations
and looks for their presence in the logs from 'rbd export'.
Josh Durgin [Sun, 12 May 2013 21:43:13 +0000 (14:43 -0700)]
librados: add sparse_read() to the C++ bindings for an ObjectOperation
This will allow it to be used with general aio_operate() so we don't have
to add new versions of each operation when we want to add new per-op
arguments, like flags, namespaces, or explicit snapshot contexts/ids.
Josh Durgin [Sun, 12 May 2013 21:39:58 +0000 (14:39 -0700)]
Objecter, librados: use only ObjectOperation form of sparse_read internally
This will be used when exposing an ObjectOperation version of sparse_read()
to the librados user, and there's no reason to duplicate code for creating
and handling it. Add a wrapper Context for handling the lifecycle of the
::ObjectOperation.
This cleans up the synchronous version of sparse_read quite a bit by
using the general operate_read() instead of duplicating decoding and
a bunch of sync boilerplate.
Move handling the decoding of a sparse_read into the Objecter, with
the rest of the decoding of rados operations. librados shouldn't be
the only user of the Objecter that can understand sparse_reads.
Danny Al-Gaaf [Sat, 11 May 2013 17:51:02 +0000 (19:51 +0200)]
osd/OSD.h: fix try_stop_deletion
Fix try_stop_deletion(): The comment above the while loop says "If we are
in DELETING_DIR or DELETED_DIR", but the while loop checks for DELETING_DIR
twice. Change one check to DELETED_DIR otherwise on state get missed.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Josh Durgin [Fri, 10 May 2013 22:59:10 +0000 (15:59 -0700)]
Throttle: move start_op() to C_SimpleThrottle constructor
This is done by all callers right before constructing this.
Since C_SimpleThrottle is already responsible for calling ->end_op(),
it makes sense to call start_op() there too.
Josh Durgin [Fri, 10 May 2013 22:54:51 +0000 (15:54 -0700)]
librbd: run copy in parallel
Instead of using read_iterate(), loop over each period of objects in
the source, read from them asynchronously, and then asynchronously
write to the destination.
The callbacks make this a bit more complex, but it can perform much
better.
Josh Durgin [Fri, 10 May 2013 22:45:57 +0000 (15:45 -0700)]
librbd: move completion release into rbd_ctx_cb()
All the users of rbd_ctx_cb() do this separately right now, but
there's no reason to keep the completion around after the nested
completion has been called. Also declare rbd_ctx_cb() in the header
so it can be used before its definition.
Josh Durgin [Fri, 10 May 2013 00:12:33 +0000 (17:12 -0700)]
librbd: parallelize and simplify flatten
Flattening reads the logical child object from the parent image, and
then does a copyup operation if the data is non-zero. This is
equivalent to doing a zero-length write to each object in the
child image. Do this instead, so that we can easily control how
many are in flight, and eliminate some code as well.
Since we no longer read from the parent within the flatten function,
the buffer is not needed. It would be leaked in some error conditions,
but since's it's unecessary we can just get rid of it.
Josh Durgin [Fri, 10 May 2013 00:05:20 +0000 (17:05 -0700)]
librbd: only send non-zero copyup data
If the parent image is logically zero for the range of a child object,
it's equivalent to the object not existing. Save some I/O and network
bandwidth and don't send the useless zeroes.
Danny Al-Gaaf [Fri, 10 May 2013 11:44:50 +0000 (13:44 +0200)]
rados_sync.cc: remove dead and not needed code
The first if handles all chars < 32, the last 2 if's check for
'\n' (10) and '\r' (13). This code will never be reached and
is already covered. Remove unneeded code.
Sage Weil [Fri, 10 May 2013 21:14:52 +0000 (14:14 -0700)]
mds: be more explicit about path_traverse completion
Coverity turned up
CID 717085 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable "c" going out of scope leaks the storage it points to.
from _find_ino_dir(), but for all r > 0 cases fin is consumed. Make this
a bit more explicit by using the helper in the mdr-only case, and by
asserting it is zero in the return 2 path. Hopefully coverity will notice.
Josh Durgin [Mon, 6 May 2013 23:51:12 +0000 (16:51 -0700)]
Throttle: add a simpler throttle that just blocks above a threshold
This is convenient to use to turn synchronous calls into asynchronous
calls with a limited number of operations in flight concurrently.
It assumes the caller will wait for all operations to complete at the
end.