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>
Since origin and meth are already checked to be true there is
no need to check again in s->cio->print() after the initial check.
1019551 Logically dead code (CWE-561)
1019552 Logically dead code (CWE-561)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix undead code. Get error code from write_fd() before check
the result against < 0.
CID 1019550 Logically dead code (CWE-561)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
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.
CID 1019549 Logically dead code (CWE-561)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Check result of ceph_getxattr() before pass it as parameter to
strncmp(). Make sure it's not negative.
CID 739411 Argument cannot be negative (CWE-687)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix switch handling for case KEY_TYPE_SWIFT, add break after the
case to prevent fall through into KEY_TYPE_S3 case.
CID 1019563 Missing break in switch (CWE-484)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix switch handling for case SYNCLIENT_MODE_OVERLOAD_OSD_0, add break
after the case to prevent fall through into next case.
CID 716958 Missing break in switch (CWE-484)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Fix switch handling for case OP_SPLIT_COLLECTION2, add break after
the case to prevent fall through into default case.
CID 1019562 Missing break in switch (CWE-484)
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
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.
Signed-off-by: Sage Weil <sage@inktank.com>
Speed up deletions when resizing down or removing an image by keeping
up 10 operations in flight by default.
Refs: #2256
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
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.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>