From bfe58833d47701c6b6756907284b1c1f9af86276 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Wed, 4 Mar 2015 21:23:51 +0100 Subject: [PATCH 01/20] itest/msgr/test_msgr.cc: prefer ++operator for non-primitive iter Signed-off-by: Danny Al-Gaaf --- src/test/msgr/test_msgr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/msgr/test_msgr.cc b/src/test/msgr/test_msgr.cc index fb6c5a78b76..4dcf756cd95 100644 --- a/src/test/msgr/test_msgr.cc +++ b/src/test/msgr/test_msgr.cc @@ -667,7 +667,7 @@ class SyntheticDispatcher : public Dispatcher { Mutex::Locker l(lock); list c = conn_sent[con]; for (list::iterator it = c.begin(); - it != c.end(); it++) + it != c.end(); ++it) sent.erase(*it); conn_sent.erase(con); got_remote_reset = true; From 5393f32bbf6cb7e29aeb301931698ecc92816e84 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 03:45:45 +0100 Subject: [PATCH 02/20] TestErasureCodeShec_thread.cc: use static_cast instead of c-style Signed-off-by: Danny Al-Gaaf --- src/test/erasure-code/TestErasureCodeShec_thread.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/erasure-code/TestErasureCodeShec_thread.cc b/src/test/erasure-code/TestErasureCodeShec_thread.cc index fdd6bfeee3b..eaefa760a8e 100644 --- a/src/test/erasure-code/TestErasureCodeShec_thread.cc +++ b/src/test/erasure-code/TestErasureCodeShec_thread.cc @@ -99,7 +99,7 @@ int main(int argc, char **argv) void* thread1(void* pParam) { - TestParam* param = (TestParam*) pParam; + TestParam* param = static_cast(pParam); time_t start, end; int r; From 48d27ba1ed4149f8ab00c9ffddd06c134ff074f4 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 03:47:31 +0100 Subject: [PATCH 03/20] osd/ReplicatedPG.cc: use static_cast instead of c-style cast Signed-off-by: Danny Al-Gaaf --- src/osd/ReplicatedPG.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 057564c37a1..3b6184118d2 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -7528,7 +7528,7 @@ void ReplicatedPG::eval_repop(RepGather *repop) waiting_for_ack[repop->v].begin(); i != waiting_for_ack[repop->v].end(); ++i) { - MOSDOp *m = (MOSDOp*)i->first->get_req(); + MOSDOp *m = static_cast(i->first->get_req()); MOSDOpReply *reply = new MOSDOpReply(m, 0, get_osdmap()->get_epoch(), 0, true); reply->set_reply_versions(repop->ctx->at_version, i->second); From 51bec737d95706ebab9f9a6152c9546555157df6 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 03:48:01 +0100 Subject: [PATCH 04/20] rgw: use static_cast instead of c-style cast Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_op.cc | 40 ++++++++++++++++++++-------------------- src/rgw/rgw_rest_log.cc | 6 +++--- src/rgw/rgw_swift.cc | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index c2a0f6a7d9c..f3a3622023a 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -254,13 +254,13 @@ static int get_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx, return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs, policy, instance_obj); } - return get_obj_policy_from_attr(cct, store, *(RGWObjectCtx *)ctx, bucket_info, bucket_attrs, + return get_obj_policy_from_attr(cct, store, *static_cast(ctx), bucket_info, bucket_attrs, policy, obj); } static int get_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map& attrs) { - RGWRados::Object op_target(store, s->bucket_info, *(RGWObjectCtx *)s->obj_ctx, obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), obj); RGWRados::Object::Read read_op(&op_target); read_op.params.attrs = &attrs; @@ -272,7 +272,7 @@ static int get_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map static int get_system_obj_attrs(RGWRados *store, struct req_state *s, rgw_obj& obj, map& attrs, uint64_t *obj_size, RGWObjVersionTracker *objv_tracker) { - RGWRados::SystemObject src(store, *(RGWObjectCtx *)s->obj_ctx, obj); + RGWRados::SystemObject src(store, *static_cast(s->obj_ctx), obj); RGWRados::SystemObject::Read rop(&src); rop.stat_params.attrs = &attrs; @@ -339,7 +339,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu int ret = 0; rgw_obj_key obj; RGWUserInfo bucket_owner_info; - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); string bi = s->info.args.get(RGW_SYS_PARAM_PREFIX "bucket-instance"); if (!bi.empty()) { @@ -885,7 +885,7 @@ void RGWGetObj::execute() perfcounter->inc(l_rgw_get); int64_t new_ofs, new_end; - RGWRados::Object op_target(store, s->bucket_info, *(RGWObjectCtx *)s->obj_ctx, obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), obj); RGWRados::Object::Read read_op(&op_target); ret = get_params(); @@ -1309,7 +1309,7 @@ void RGWCreateBucket::execute() } /* we need to make sure we read bucket info, it's not read before for this specific request */ - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); ret = store->get_bucket_info(obj_ctx, s->bucket_name_str, s->bucket_info, NULL, &s->bucket_attrs); if (ret < 0 && ret != -ENOENT) return; @@ -1640,8 +1640,8 @@ RGWPutObjProcessor *RGWPutObj::select_processor(RGWObjectCtx& obj_ctx, bool *is_ if (!multipart) { processor = new RGWPutObjProcessor_Atomic(obj_ctx, s->bucket_info, s->bucket, s->object.name, part_size, s->req_id, s->bucket_info.versioning_enabled()); - ((RGWPutObjProcessor_Atomic *)processor)->set_olh_epoch(olh_epoch); - ((RGWPutObjProcessor_Atomic *)processor)->set_version_id(version_id); + (static_cast(processor))->set_olh_epoch(olh_epoch); + (static_cast(processor))->set_version_id(version_id); } else { processor = new RGWPutObjProcessor_Multipart(obj_ctx, s->bucket_info, part_size, s); } @@ -1772,7 +1772,7 @@ void RGWPutObj::execute() supplied_md5[sizeof(supplied_md5) - 1] = '\0'; } - processor = select_processor(*(RGWObjectCtx *)s->obj_ctx, &multipart); + processor = select_processor(*static_cast(s->obj_ctx), &multipart); ret = processor->prepare(store, NULL); if (ret < 0) @@ -1805,7 +1805,7 @@ void RGWPutObj::execute() /* restart processing with different oid suffix */ dispose_processor(processor); - processor = select_processor(*(RGWObjectCtx *)s->obj_ctx, &multipart); + processor = select_processor(*static_cast(s->obj_ctx), &multipart); string oid_rand; char buf[33]; @@ -1955,7 +1955,7 @@ void RGWPostObj::execute() goto done; } - processor = select_processor(*(RGWObjectCtx *)s->obj_ctx); + processor = select_processor(*static_cast(s->obj_ctx)); ret = processor->prepare(store, NULL); if (ret < 0) @@ -2169,7 +2169,7 @@ void RGWDeleteObj::execute() ret = -EINVAL; rgw_obj obj(s->bucket, s->object); if (!s->object.empty()) { - RGWObjectCtx *obj_ctx = (RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); obj_ctx->set_atomic(obj); @@ -2251,7 +2251,7 @@ int RGWCopyObj::verify_permission() } map src_attrs; - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); ret = store->get_bucket_info(obj_ctx, src_bucket_name, src_bucket_info, NULL, &src_attrs); if (ret < 0) @@ -2376,7 +2376,7 @@ void RGWCopyObj::execute() rgw_obj src_obj(src_bucket, src_object); rgw_obj dst_obj(dest_bucket, dest_object); - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); obj_ctx.set_atomic(src_obj); obj_ctx.set_atomic(dst_obj); @@ -2756,7 +2756,7 @@ void RGWInitMultipart::execute() obj.set_in_extra_data(true); obj.index_hash_source = s->object.name; - RGWRados::Object op_target(store, s->bucket_info, *(RGWObjectCtx *)s->obj_ctx, obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), obj); op_target.set_versioning_disabled(true); /* no versioning for multipart meta */ RGWRados::Object::Write obj_op(&op_target); @@ -3068,11 +3068,11 @@ void RGWCompleteMultipart::execute() store->gen_rand_obj_instance_name(&target_obj); } - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); obj_ctx.set_atomic(target_obj); - RGWRados::Object op_target(store, s->bucket_info, *(RGWObjectCtx *)s->obj_ctx, target_obj); + RGWRados::Object op_target(store, s->bucket_info, *static_cast(s->obj_ctx), target_obj); RGWRados::Object::Write obj_op(&op_target); obj_op.meta.manifest = &manifest; @@ -3087,7 +3087,7 @@ void RGWCompleteMultipart::execute() return; // remove the upload obj - int r = store->delete_obj(*(RGWObjectCtx *)s->obj_ctx, s->bucket_info, meta_obj, 0); + int r = store->delete_obj(*static_cast(s->obj_ctx), s->bucket_info, meta_obj, 0); if (r < 0) { ldout(store->ctx(), 0) << "WARNING: failed to remove object " << meta_obj << dendl; } @@ -3133,7 +3133,7 @@ void RGWAbortMultipart::execute() int max_parts = 1000; - RGWObjectCtx *obj_ctx = (RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); meta_obj.init_ns(s->bucket, meta_oid, mp_ns); meta_obj.set_in_extra_data(true); @@ -3306,7 +3306,7 @@ void RGWDeleteMultiObj::execute() vector::iterator iter; RGWMultiDelXMLParser parser; int num_processed = 0; - RGWObjectCtx *obj_ctx = (RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx *obj_ctx = static_cast(s->obj_ctx); ret = get_params(); if (ret < 0) { diff --git a/src/rgw/rgw_rest_log.cc b/src/rgw/rgw_rest_log.cc index b10fbefe034..7e3707f8ad0 100644 --- a/src/rgw/rgw_rest_log.cc +++ b/src/rgw/rgw_rest_log.cc @@ -276,7 +276,7 @@ void RGWOp_BILog_List::execute() { RGWBucketInfo bucket_info; unsigned max_entries; - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); if (bucket_name.empty() && bucket_instance.empty()) { dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl; @@ -368,7 +368,7 @@ void RGWOp_BILog_Info::execute() { bucket_instance = s->info.args.get("bucket-instance"); RGWBucketInfo bucket_info; - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); if (bucket_name.empty() && bucket_instance.empty()) { dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl; @@ -422,7 +422,7 @@ void RGWOp_BILog_Delete::execute() { RGWBucketInfo bucket_info; - RGWObjectCtx& obj_ctx = *(RGWObjectCtx *)s->obj_ctx; + RGWObjectCtx& obj_ctx = *static_cast(s->obj_ctx); http_ret = 0; if ((bucket_name.empty() && bucket_instance.empty()) || diff --git a/src/rgw/rgw_swift.cc b/src/rgw/rgw_swift.cc index 737710d10a0..831307e2361 100644 --- a/src/rgw/rgw_swift.cc +++ b/src/rgw/rgw_swift.cc @@ -550,7 +550,7 @@ int authenticate_temp_url(RGWRados *store, req_state *s) /* need to get user info of bucket owner */ RGWBucketInfo bucket_info; - int ret = store->get_bucket_info(*(RGWObjectCtx *)s->obj_ctx, s->bucket_name_str, bucket_info, NULL); + int ret = store->get_bucket_info(*static_cast(s->obj_ctx), s->bucket_name_str, bucket_info, NULL); if (ret < 0) return -EPERM; From a3d0c80bdafbbfb6951d2df7de2bebbfcf29e088 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 05:06:32 +0100 Subject: [PATCH 05/20] TestErasureCodeShec_all.cc: fix sprintf specifier Signed-off-by: Danny Al-Gaaf --- src/test/erasure-code/TestErasureCodeShec_all.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/erasure-code/TestErasureCodeShec_all.cc b/src/test/erasure-code/TestErasureCodeShec_all.cc index eeedc8e8809..db2a1b2163f 100644 --- a/src/test/erasure-code/TestErasureCodeShec_all.cc +++ b/src/test/erasure-code/TestErasureCodeShec_all.cc @@ -275,9 +275,9 @@ int main(int argc, char **argv) for (unsigned int k = 1; k <= 12; k++) { for (unsigned int m = 1; (m <= k) && (k + m <= 20); m++) { for (unsigned int c = 1; c <= m; c++) { - sprintf(param[i].sk, "%d", k); - sprintf(param[i].sm, "%d", m); - sprintf(param[i].sc, "%d", c); + sprintf(param[i].sk, "%u", k); + sprintf(param[i].sm, "%u", m); + sprintf(param[i].sc, "%u", c); param[i].k = param[i].sk; param[i].m = param[i].sm; From ab4e37f314886e329fc0e0498ab49fbc470fdcdd Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 05:07:46 +0100 Subject: [PATCH 06/20] mds/MDS.cc: add missing asserts to check return values Change existing asserts in set_up_admin_socket() to check (VAR == 0). Signed-off-by: Danny Al-Gaaf --- src/mds/MDS.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 265a35599a4..77727ae9356 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -572,63 +572,66 @@ void MDS::set_up_admin_socket() asok_hook = new MDSSocketHook(this); r = admin_socket->register_command("status", "status", asok_hook, "high-level status of MDS"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("dump_ops_in_flight", "dump_ops_in_flight", asok_hook, "show the ops currently in flight"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("ops", "ops", asok_hook, "show the ops currently in flight"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("dump_historic_ops", "dump_historic_ops", asok_hook, "show slowest recent ops"); + assert(r == 0); r = admin_socket->register_command("scrub_path", "scrub_path name=path,type=CephString", asok_hook, "scrub an inode and output results"); + assert(r == 0); r = admin_socket->register_command("flush_path", "flush_path name=path,type=CephString", asok_hook, "flush an inode (and its dirfrags)"); + assert(r == 0); r = admin_socket->register_command("export dir", "export dir " "name=path,type=CephString " "name=rank,type=CephInt", asok_hook, "migrate a subtree to named MDS"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("session evict", "session evict name=client_id,type=CephString", asok_hook, "Evict a CephFS client"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("osdmap barrier", "osdmap barrier name=target_epoch,type=CephInt", asok_hook, "Wait until the MDS has this OSD map epoch"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("session ls", "session ls", asok_hook, "Enumerate connected CephFS clients"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("flush journal", "flush journal", asok_hook, "Flush the journal to the backing store"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("force_readonly", "force_readonly", asok_hook, "Force MDS to read-only mode"); - assert(0 == r); + assert(r == 0); r = admin_socket->register_command("get subtrees", "get subtrees", asok_hook, "Return the subtree map"); - assert(0 == r); + assert(r == 0); } void MDS::clean_up_admin_socket() From 921c08fce503e171199f8f8b9208dcdf75ac41c4 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 05:26:48 +0100 Subject: [PATCH 07/20] rgw_main.cc: fix null-deref in case get_storage() fails Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_main.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index f4ef88e027c..f09296f38e5 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -1068,10 +1068,9 @@ int main(int argc, const char **argv) g_conf->rgw_enable_gc_threads, g_conf->rgw_enable_quota_threads); if (!store) { derr << "Couldn't init storage provider (RADOS)" << dendl; - r = EIO; + return EIO; } - if (!r) - r = rgw_perf_start(g_ceph_context); + r = rgw_perf_start(g_ceph_context); rgw_rest_init(g_ceph_context, store->region); From de7bcfd8d0e578207cbd9237bc166937fdadcd62 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:04:37 +0100 Subject: [PATCH 08/20] rgw/rgw_op.cc: fix potential null-deref in strcmp() Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_op.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index f3a3622023a..dc12a880ca9 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -523,6 +523,12 @@ int RGWOp::init_quota() static bool validate_cors_rule_method(RGWCORSRule *rule, const char *req_meth) { uint8_t flags = 0; + + if (!req_meth) { + dout(5) << "req_meth is null" << dendl; + return false; + } + if (strcmp(req_meth, "GET") == 0) flags = RGW_CORS_GET; else if (strcmp(req_meth, "POST") == 0) flags = RGW_CORS_POST; else if (strcmp(req_meth, "PUT") == 0) flags = RGW_CORS_PUT; @@ -628,11 +634,12 @@ bool RGWOp::generate_cors_headers(string& origin, string& method, string& header req_meth = s->info.method; } - if (req_meth) + if (req_meth) { method = req_meth; - /* CORS 6.2.5. */ - if (!validate_cors_rule_method(rule, req_meth)) { - return false; + /* CORS 6.2.5. */ + if (!validate_cors_rule_method(rule, req_meth)) { + return false; + } } /* CORS 6.2.4. */ From 54aa23a699ed7fe1b7dbf42b39136184eae50dd4 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:15:26 +0100 Subject: [PATCH 09/20] ErasureCodeShec::minimum_to_decode: reduce scope of variables Signed-off-by: Danny Al-Gaaf --- src/erasure-code/shec/ErasureCodeShec.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/erasure-code/shec/ErasureCodeShec.cc b/src/erasure-code/shec/ErasureCodeShec.cc index 2ad82ec0e29..6f2c1945329 100644 --- a/src/erasure-code/shec/ErasureCodeShec.cc +++ b/src/erasure-code/shec/ErasureCodeShec.cc @@ -86,11 +86,6 @@ int ErasureCodeShec::minimum_to_decode(const set &want_to_decode, const set &available_chunks, set *minimum_chunks) { - int erased[k + m]; - int avails[k + m]; - int minimum[k + m]; - int dm_ids[k]; - if (!minimum_chunks) return -EINVAL; for (set::iterator it = available_chunks.begin(); it != available_chunks.end(); ++it){ @@ -101,6 +96,11 @@ int ErasureCodeShec::minimum_to_decode(const set &want_to_decode, want_to_decode.begin(), want_to_decode.end())) { *minimum_chunks = want_to_decode; } else { + int erased[k + m]; + int avails[k + m]; + int minimum[k + m]; + int dm_ids[k]; + for (int i = 0; i < k + m; i++) { erased[i] = 0; if (available_chunks.find(i) == available_chunks.end()) { From 0d78f4402fb711210867c33ef2fd6074d7fc84c2 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:16:06 +0100 Subject: [PATCH 10/20] librbd/ObjectMap.cc: reduce scope of variable, prevent redef Signed-off-by: Danny Al-Gaaf --- src/librbd/ObjectMap.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librbd/ObjectMap.cc b/src/librbd/ObjectMap.cc index 4aa3c3b6592..7d758d9a965 100644 --- a/src/librbd/ObjectMap.cc +++ b/src/librbd/ObjectMap.cc @@ -52,11 +52,11 @@ int ObjectMap::lock() } } - int r; bool broke_lock = false; CephContext *cct = m_image_ctx.cct; std::string oid(object_map_name(m_image_ctx.id, CEPH_NOSNAP)); while (true) { + int r; ldout(cct, 10) << &m_image_ctx << " locking object map" << dendl; r = rados::cls::lock::lock(&m_image_ctx.md_ctx, oid, RBD_LOCK_NAME, LOCK_EXCLUSIVE, "", "", "", @@ -73,9 +73,9 @@ int ObjectMap::lock() lockers_t lockers; ClsLockType lock_type; std::string lock_tag; - int r = rados::cls::lock::get_lock_info(&m_image_ctx.md_ctx, oid, - RBD_LOCK_NAME, &lockers, - &lock_type, &lock_tag); + r = rados::cls::lock::get_lock_info(&m_image_ctx.md_ctx, oid, + RBD_LOCK_NAME, &lockers, + &lock_type, &lock_tag); if (r == -ENOENT) { continue; } else if (r < 0) { From e11f9d2c71a63d50f45f59352da167f9830cc151 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:18:04 +0100 Subject: [PATCH 11/20] librbd/internal.cc: reduce scope of some variables Signed-off-by: Danny Al-Gaaf --- src/librbd/internal.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 9551332f892..40b6be03198 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -1886,9 +1886,9 @@ reprotect_and_return_err: vector snap_protection; vector snap_flags; { - int r; RWLock::WLocker l(ictx->snap_lock); { + int r; RWLock::WLocker l2(ictx->parent_lock); ictx->lockers.clear(); if (ictx->old_format) { @@ -2512,11 +2512,11 @@ reprotect_and_return_err: } uint64_t object_size; - uint64_t overlap; uint64_t overlap_objects; ::SnapContext snapc; { + uint64_t overlap; RWLock::RLocker l(ictx->snap_lock); RWLock::RLocker l2(ictx->parent_lock); From 0a5e6af484fe278869266cb72168e4b218ee5c3c Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:20:46 +0100 Subject: [PATCH 12/20] rgw_rados.cc: remove unused string vars Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_rados.cc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 57ca5c198a7..090503da7c7 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -3216,8 +3216,6 @@ int RGWRados::put_system_obj_impl(rgw_obj& obj, uint64_t size, time_t *mtime, op.mtime(&set_mtime); op.write_full(data); - string etag; - string content_type; bufferlist acl_bl; for (map::iterator iter = attrs.begin(); iter != attrs.end(); ++iter) { @@ -4351,7 +4349,6 @@ int RGWRados::Object::Delete::delete_obj() index_op.set_bilog_flags(params.bilog_flags); - string tag; r = index_op.prepare(CLS_RGW_OP_DEL); if (r < 0) return r; @@ -4441,7 +4438,6 @@ int RGWRados::delete_obj_index(rgw_obj& obj) std::string oid, key; get_obj_bucket_and_oid_loc(obj, bucket, oid, key); - string tag; RGWRados::Bucket bop(this, bucket); RGWRados::Bucket::UpdateIndex index_op(&bop, obj, NULL); @@ -4845,7 +4841,6 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj, RGWRados::Bucket bop(this, bucket); RGWRados::Bucket::UpdateIndex index_op(&bop, obj, state); - string tag; if (state) { r = index_op.prepare(CLS_RGW_OP_ADD); if (r < 0) From 649f0f3e7e2bfa569804fbe9e10d38d7b15bca85 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:21:35 +0100 Subject: [PATCH 13/20] rgw_rados.cc: reduce scope of variable Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_rados.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 090503da7c7..cb2ed4bd049 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4914,7 +4914,6 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) CephContext *cct = store->ctx(); bufferlist etag; - time_t ctime; off_t ofs = 0; off_t end = -1; @@ -4950,7 +4949,7 @@ int RGWRados::Object::Read::prepare(int64_t *pofs, int64_t *pend) /* Convert all times go GMT to make them compatible */ if (conds.mod_ptr || conds.unmod_ptr) { - ctime = astate->mtime; + time_t ctime = astate->mtime; if (conds.mod_ptr) { ldout(cct, 10) << "If-Modified-Since: " << *conds.mod_ptr << " Last-Modified: " << ctime << dendl; From 828fc737f1e0579a29f5bda6bf5dc6762c0a4545 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:22:18 +0100 Subject: [PATCH 14/20] objectstore/store_test.cc: reduce scope of variable Signed-off-by: Danny Al-Gaaf --- src/test/objectstore/store_test.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/objectstore/store_test.cc b/src/test/objectstore/store_test.cc index d3ce80ce0ab..7f355d5b2f8 100644 --- a/src/test/objectstore/store_test.cc +++ b/src/test/objectstore/store_test.cc @@ -700,14 +700,13 @@ public: void getattrs() { ghobject_t obj; - int retry; { Mutex::Locker locker(lock); if (!can_unlink()) return ; wait_for_ready(); - retry = 10; + int retry = 10; do { obj = get_uniform_random_object(); if (!--retry) From ff760bee2687c18504ec6fef9b76bb70550cbafd Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:22:53 +0100 Subject: [PATCH 15/20] ObjectStoreTransactionBenchmark.cc: reduce scope of var Signed-off-by: Danny Al-Gaaf --- src/test/objectstore/ObjectStoreTransactionBenchmark.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc index a82efb7e1ff..1c6f76c04ed 100644 --- a/src/test/objectstore/ObjectStoreTransactionBenchmark.cc +++ b/src/test/objectstore/ObjectStoreTransactionBenchmark.cc @@ -192,9 +192,10 @@ class PerfCase { } uint64_t rados_write_4k(int times) { - uint64_t start_time = 0, ticks = 0; + uint64_t ticks = 0; uint64_t len = Kib *4; for (int i = 0; i < times; i++) { + uint64_t start_time = 0; { Transaction t; ghobject_t oid = create_object(); From 16c92378d1fa7b40708dce68078acfacee80c124 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:23:16 +0100 Subject: [PATCH 16/20] TestErasureCodeShec_thread.cc: reduce scope of var Signed-off-by: Danny Al-Gaaf --- src/test/erasure-code/TestErasureCodeShec_thread.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/erasure-code/TestErasureCodeShec_thread.cc b/src/test/erasure-code/TestErasureCodeShec_thread.cc index eaefa760a8e..4f59f0001d9 100644 --- a/src/test/erasure-code/TestErasureCodeShec_thread.cc +++ b/src/test/erasure-code/TestErasureCodeShec_thread.cc @@ -102,7 +102,6 @@ void* thread1(void* pParam) TestParam* param = static_cast(pParam); time_t start, end; - int r; ErasureCodePluginRegistry &instance = ErasureCodePluginRegistry::instance(); @@ -136,6 +135,7 @@ void* thread1(void* pParam) while (kTestSec >= (end - start)) { //init + int r; ErasureCodeShec* shec = new ErasureCodeShecReedSolomonVandermonde( tcache, ErasureCodeShec::MULTIPLE); From 6f79e4a61664881bd3b2e6b1b7f19dfe4b2807ee Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:35:27 +0100 Subject: [PATCH 17/20] rgw_quota.cc: init variables in constructor Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_quota.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 910da2fffb7..85536bf8bfb 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -47,7 +47,7 @@ protected: uint64_t added_bytes; uint64_t removed_bytes; public: - StatsAsyncTestSet() {} + StatsAsyncTestSet() : objs_delta(0), added_bytes(0), removed_bytes(0) {} bool update(RGWQuotaCacheStats *entry) { if (entry->async_refresh_time.sec() == 0) return false; From 778e0ef10d91c66c3b2c5abd115cf44c9c43b45f Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:36:15 +0100 Subject: [PATCH 18/20] src/msg/xio/*: reduce scope of some vars Signed-off-by: Danny Al-Gaaf --- src/msg/xio/XioMessenger.cc | 12 ++++++------ src/msg/xio/XioPortal.h | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/msg/xio/XioMessenger.cc b/src/msg/xio/XioMessenger.cc index 3fdb36e7453..f084cfeb0cb 100644 --- a/src/msg/xio/XioMessenger.cc +++ b/src/msg/xio/XioMessenger.cc @@ -138,8 +138,8 @@ static int on_msg(struct xio_session *session, ldout(cct,25) << "on_msg session " << session << " xcon " << xcon << dendl; - static uint32_t nreqs; if (unlikely(XioPool::trace_mempool)) { + static uint32_t nreqs; if (unlikely((++nreqs % 65536) == 0)) { xp_stats.dump(__func__, nreqs); } @@ -525,7 +525,7 @@ xio_count_buffers(buffer::list& bl, int& req_size, int& msg_off, int& req_off) const std::list& buffers = bl.buffers(); list::const_iterator pb; - size_t size, off, count; + size_t size, off; int result; int first = 1; @@ -541,7 +541,7 @@ xio_count_buffers(buffer::list& bl, int& req_size, int& msg_off, int& req_off) size = pb->length(); first = 0; } - count = size - off; + size_t count = size - off; if (!count) continue; if (req_size + count > MAX_XIO_BUF_SIZE) { count = MAX_XIO_BUF_SIZE - req_size; @@ -573,7 +573,7 @@ xio_place_buffers(buffer::list& bl, XioMsg *xmsg, struct xio_msg*& req, const std::list& buffers = bl.buffers(); list::const_iterator pb; struct xio_iovec_ex* iov; - size_t size, off, count; + size_t size, off; const char *data = NULL; int first = 1; @@ -589,7 +589,7 @@ xio_place_buffers(buffer::list& bl, XioMsg *xmsg, struct xio_msg*& req, data = pb->c_str(); // is c_str() efficient? first = 0; } - count = size - off; + size_t count = size - off; if (!count) continue; if (req_size + count > MAX_XIO_BUF_SIZE) { count = MAX_XIO_BUF_SIZE - req_size; @@ -755,9 +755,9 @@ int XioMessenger::_send_message_impl(Message* m, XioConnection* xcon) { int code = 0; - static uint32_t nreqs; Mutex::Locker l(xcon->lock); if (unlikely(XioPool::trace_mempool)) { + static uint32_t nreqs; if (unlikely((++nreqs % 65536) == 0)) { xp_stats.dump(__func__, nreqs); } diff --git a/src/msg/xio/XioPortal.h b/src/msg/xio/XioPortal.h index aaa26f92632..ea644a9f987 100644 --- a/src/msg/xio/XioPortal.h +++ b/src/msg/xio/XioPortal.h @@ -208,11 +208,10 @@ public: // and push them in FIFO order to front of the input queue, // and mark the connection as flow-controlled XioSubmit::Queue requeue_q; - XioSubmit *xs; XioMsg *xmsg; while (q_iter != send_q.end()) { - xs = &(*q_iter); + XioSubmit *xs = &(*q_iter); // skip retires and anything for other connections if ((xs->type != XioSubmit::OUTGOING_MSG) || (xs->xcon != xcon)) @@ -424,20 +423,18 @@ public: void shutdown() { - XioPortal *portal; int nportals = portals.size(); for (int p_ix = 0; p_ix < nportals; ++p_ix) { - portal = portals[p_ix]; + XioPortal *portal = portals[p_ix]; portal->shutdown(); } } void join() { - XioPortal *portal; int nportals = portals.size(); for (int p_ix = 0; p_ix < nportals; ++p_ix) { - portal = portals[p_ix]; + XioPortal *portal = portals[p_ix]; portal->join(); } } From db175fb93802995f1625612818680e45d8650c9a Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 06:47:57 +0100 Subject: [PATCH 19/20] rgw_rados: don't assign value to parameter Fix for cppcheck issue: Assignment of function parameter has no effect outside the function. Remove assignment to need_to_wait before exit. Signed-off-by: Danny Al-Gaaf --- src/rgw/rgw_rados.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index cb2ed4bd049..2f7c7af1b30 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -975,6 +975,8 @@ int RGWPutObjProcessor_Aio::drain_pending() int RGWPutObjProcessor_Aio::throttle_data(void *handle, bool need_to_wait) { + bool _wait = need_to_wait; + if (handle) { struct put_obj_aio_info info; info.handle = handle; @@ -988,7 +990,7 @@ int RGWPutObjProcessor_Aio::throttle_data(void *handle, bool need_to_wait) if (r < 0) return r; - need_to_wait = false; + _wait = false; } /* resize window in case messages are draining too fast */ @@ -997,13 +999,10 @@ int RGWPutObjProcessor_Aio::throttle_data(void *handle, bool need_to_wait) } /* now throttle. Note that need_to_wait should only affect the first IO operation */ - if (pending.size() > max_chunks || - need_to_wait) { + if (pending.size() > max_chunks || _wait) { int r = wait_pending_front(); if (r < 0) return r; - - need_to_wait = false; } return 0; } From faa7937f2fa36725603b4a24e2661e39da4f3fdc Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Thu, 5 Mar 2015 07:15:30 +0100 Subject: [PATCH 20/20] tools/rados/rados.cc: init some vars in constructor Signed-off-by: Danny Al-Gaaf --- src/tools/rados/rados.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 4b96ac5ae4a..48ebfef6db9 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -501,7 +501,7 @@ public: librados::AioCompletion *completion; LoadGenOp() {} - LoadGenOp(LoadGen *_lg) : lg(_lg), completion(NULL) {} + LoadGenOp(LoadGen *_lg) : id(0), type(0), off(0), len(0), lg(_lg), completion(NULL) {} }; int max_op; @@ -543,6 +543,7 @@ public: min_op_len = 1024; target_throughput = 5 * 1024 * 1024; // B/sec max_op_len = 2 * 1024 * 1024; + max_ops = 0; max_backlog = target_throughput * 2; run_length = 60;