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>
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>
Make sure rados_shutdown() get called also in error case.
CID 717106 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "cl" going out of scope leaks the
storage it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CID 727984 (#5 of 5): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "cb_args" going out of scope leaks the storage
it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CID 717107 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "store" going out of scope leaks the
storage it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CID 1019589 (#1 of 1): Resource leak (RESOURCE_LEAK)
leaked_storage: Variable "t" going out of scope leaks the
storage it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
CID 1019590 (#1 of 1): Resource leak (RESOURCE_LEAK):
leaked_storage: Variable "rmt" going out of scope leaks the
storage it points to.
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
The condition was reversed. Rewrite it so it's clear that we're
ignoring -ENOENT only when m_ignore_enoent is set.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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'.
Fixes: #3064
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
These need to apply to the entire ObjectOperation, not just a subop,
so use a new enum and a new aio_operate() call that takes them.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
r is just a local variable, changing it has no effect.
Set the per-operation return value if provided when a decoding
error occurs.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Some plana have non-world-readable crap in /usr/local/samba. Avoid
/usr/local entirely for that and any similar landmines.
Signed-off-by: Sage Weil <sage@inktank.com>
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>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Should fix: "fd" is passed to a parameter that cannot be negative.
CID 1019566 Improper use of negative value (NEGATIVE_RETURNS, CWE-394)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Call AioCompletion::release() if the completion is no longer
needed to free the resources.
CID 727976 Resource leak (CWE-404)
CID 727977 Resource leak (CWE-404)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix SyntheticClient::chunk_file(): check return value of
describe_layout() and handle the error.
CID 966615 Unchecked return value (CWE-252)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix memory leak in read_random: call delete[] on buf before
call new[] again in the for-loop.
CID 717071 Resource leak (CWE-404)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix memory leak in read_random: call delete[] on buf before
call new[] again in the for-loop.
CID 717070 Resource leak (CWE-404)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix possible NULL pointer dereference. Change return value of
CInode::get_dirfrag() to return NULL instead of 0 since it's a
pointer returned.
CID 716991 Dereference null return value (CWE-478)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Check for result of get_inode() for NULL before use the pointer.
716990 Dereference null return value (CWE-476)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
The default switch can't get executed since the switch value
can only have the two values already checked.
CID 716894 Dead default in switch (CWE-561)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>