Fix read performance regression in ObjectCacher

The regression was introduced in commit
4fc9fffc494abedac0a9b1ce44706343f18466f1.  The problem is that the cache
thinks it's full (when it's not), so it defers the read.  This change
frees up cache space if necessary and only defers the read if enough
space cannot be freed.

Fixes: 9513
Signed-off-by: Adam Crume <adamcrume@gmail.com>
mount.ceph.c: ensure '\0' terminated string

Reserve last char in array for '\0' to ensure termination
of the string.

Fix for:

CID 1128383 (#1 of 1): Buffer not null terminated (BUFFER_SIZE_WARNING)
 buffer_size_warning: Calling strncpy with a maximum size argument
 of 1000 bytes on destination array secret of size 1000 bytes might
 leave the destination string unterminated.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
osd/OSDMap.cc: prefer ++operator for non-primitive iterators

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
osd/ReplicatedBackend.cc: prefer ++operator for non-primitive iterators

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
mds/flock.cc: reduce scope of some variables

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
SyntheticClient.cc: reduce scope of variables

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ErasureCodeIsa.cc: reduce scope of variables

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test/librbd/fsx.c: fix potential unterminated string handling

In case of strncpy() make sure string is '\0' terminated. Before
usage of strcat() check if the destination has enough free space
to concat the char and to terminate the string to prevent illegal
memory access.

Fix for:

CID 1219459 (2 of 2): Buffer not null terminated (BUFFER_SIZE_WARNING)
 buffer_size_warning: Calling strncpy with a maximum size argument of
 1024 bytes on destination array goodfile of size 1024 bytes might
 leave the destination string unterminated.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rados_list_parallel.cc: cleanup before return from run()

Fix for another case of:

CID 717112 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable io_ctx going out of scope leaks
 the storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test/librados/c_write_operations.cc: free ressources

Release completion as soon as no longer needed.

Fix for:

CID 1219593 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable completion going out of scope
 leaks the storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_log.cc: fix use-after-free

Fix for:

CID 1054876 (#1 of 1): Use after free (USE_AFTER_FREE)
 pass_freed_arg: Passing freed pointer bucket_obj as an
 argument to put_bucket_obj

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
test_rgw_admin_log.cc: refactor to use calloc()

Refactor code to use calloc() instead of malloc() to make
sure the char* TEST_BUCKET_OBJECT_SIZE memory is set to
zero before call put_bucket_obj().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
rados: Parse command-line arguments strictly

Many integers were parsed with functions that silently ignored junk at
the end of the string.  Extra characters now cause errors.

Fixes: 8983
Signed-off-by: Adam Crume <adamcrume@gmail.com>
rgw: set length for keystone token validation request

Fixes: #7796
Backport: giany, firefly
Need to set content length to this request, as the server might not
handle a chunked request (even though we don't send anything).

Tested-by: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
ceph_erasure_code_benchmark: fix parameter handling

Make sure k and m paramter are valid to prevent crash. Fix typo.

Fix for the following CID and other possible invalid combinations
of k/m parameter:

CID 1219466 (#1 of 1): Division or modulo by zero (DIVIDE_BY_ZERO)
 divide_by_zero: In expression rand() % (k + m), modulo by expression
 k + m which may be zero has undefined behavior.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Merge pull request #2675 from ceph/wip-coverity-20141003

Fix issues from SCA and Coverity

Reviewed-by: Sage Weil <sage@redhat.com>
test: Fix rmpool in test_rados_tool.sh

Signed-off-by: Adam Crume <adamcrume@gmail.com>
rados: Add tests for CLI strict parsing

Fixes: 8983
Signed-off-by: Adam Crume <adamcrume@gmail.com>
librados: Fix function prototypes in librados.h

Fixes: 9716
Signed-off-by: Adam Crume <adamcrume@gmail.com>
Merge pull request #2672 from ceph/wip-9513

Fix read performance regression in ObjectCacher

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>