From: Adam C. Emerson Date: Thu, 23 Aug 2018 15:19:07 +0000 (-0400) Subject: cls: Use ceph_assert for asserts. X-Git-Tag: v14.0.1~475^2~29 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cbd42dc2d909a0fc891be70089f26d61e59f7fa9;p=ceph.git cls: Use ceph_assert for asserts. Signed-off-by: Adam C. Emerson --- diff --git a/src/cls/cephfs/cls_cephfs.cc b/src/cls/cephfs/cls_cephfs.cc index 81b40f431f2d2..7e3214b9246fe 100644 --- a/src/cls/cephfs/cls_cephfs.cc +++ b/src/cls/cephfs/cls_cephfs.cc @@ -85,8 +85,8 @@ static int set_if_greater(cls_method_context_t hctx, static int accumulate_inode_metadata(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { - assert(in != NULL); - assert(out != NULL); + ceph_assert(in != NULL); + ceph_assert(out != NULL); int r = 0; diff --git a/src/cls/cephfs/cls_cephfs_client.cc b/src/cls/cephfs/cls_cephfs_client.cc index bc708271df709..988eab41b9a61 100644 --- a/src/cls/cephfs/cls_cephfs_client.cc +++ b/src/cls/cephfs/cls_cephfs_client.cc @@ -13,10 +13,12 @@ */ -#include "cls_cephfs_client.h" + #include "include/rados/librados.hpp" #include "mds/CInode.h" +#include "cls_cephfs_client.h" + #define XATTR_CEILING "scan_ceiling" #define XATTR_MAX_MTIME "scan_max_mtime" #define XATTR_MAX_SIZE "scan_max_size" @@ -72,8 +74,8 @@ int ClsCephFSClient::fetch_inode_accumulate_result( file_layout_t *layout, AccumulateResult *result) { - assert(backtrace != NULL); - assert(result != NULL); + ceph_assert(backtrace != NULL); + ceph_assert(result != NULL); librados::ObjectReadOperation op; @@ -163,7 +165,7 @@ void ClsCephFSClient::build_tag_filter( const std::string &scrub_tag, bufferlist *out_bl) { - assert(out_bl != NULL); + ceph_assert(out_bl != NULL); // Leading part of bl is un-versioned string naming the filter encode(std::string("cephfs.inode_tag"), *out_bl); diff --git a/src/cls/journal/cls_journal_client.cc b/src/cls/journal/cls_journal_client.cc index 753da51a14b51..c22a32cf3a32d 100644 --- a/src/cls/journal/cls_journal_client.cc +++ b/src/cls/journal/cls_journal_client.cc @@ -52,7 +52,7 @@ struct C_ClientList : public C_AioExec { librados::AioCompletion *rados_completion = librados::Rados::aio_create_completion(this, rados_callback, NULL); int r = ioctx.aio_operate(oid, rados_completion, &op, &outbl); - assert(r == 0); + ceph_assert(r == 0); rados_completion->release(); } @@ -113,7 +113,7 @@ struct C_ImmutableMetadata : public C_AioExec { librados::AioCompletion *rados_completion = librados::Rados::aio_create_completion(this, rados_callback, NULL); int r = ioctx.aio_operate(oid, rados_completion, &op, &outbl); - assert(r == 0); + ceph_assert(r == 0); rados_completion->release(); } @@ -153,7 +153,7 @@ struct C_MutableMetadata : public C_AioExec { librados::AioCompletion *rados_completion = librados::Rados::aio_create_completion(this, rados_callback, NULL); int r = ioctx.aio_operate(oid, rados_completion, &op, &outbl); - assert(r == 0); + ceph_assert(r == 0); rados_completion->release(); } diff --git a/src/cls/lock/cls_lock.cc b/src/cls/lock/cls_lock.cc index b25c1a0c468a2..12311b1a3c0e6 100644 --- a/src/cls/lock/cls_lock.cc +++ b/src/cls/lock/cls_lock.cc @@ -148,7 +148,7 @@ static int lock_obj(cls_method_context_t hctx, entity_inst_t inst; r = cls_get_request_origin(hctx, &inst); id.locker = inst.name; - assert(r == 0); + ceph_assert(r == 0); /* check this early, before we check fail_if_exists, otherwise we might * remove the locker entry and not check it later */ @@ -287,7 +287,7 @@ static int unlock_op(cls_method_context_t hctx, entity_inst_t inst; int r = cls_get_request_origin(hctx, &inst); - assert(r == 0); + ceph_assert(r == 0); return remove_lock(hctx, op.name, inst.name, op.cookie); } @@ -457,7 +457,7 @@ int assert_locked(cls_method_context_t hctx, bufferlist *in, bufferlist *out) entity_inst_t inst; r = cls_get_request_origin(hctx, &inst); - assert(r == 0); + ceph_assert(r == 0); locker_id_t id; id.cookie = op.cookie; @@ -529,7 +529,7 @@ int set_cookie(cls_method_context_t hctx, bufferlist *in, bufferlist *out) entity_inst_t inst; r = cls_get_request_origin(hctx, &inst); - assert(r == 0); + ceph_assert(r == 0); locker_id_t id; id.cookie = op.cookie; diff --git a/src/cls/lua/cls_lua.cc b/src/cls/lua/cls_lua.cc index 12a31a56f7170..ecc5417fca46b 100644 --- a/src/cls/lua/cls_lua.cc +++ b/src/cls/lua/cls_lua.cc @@ -70,8 +70,8 @@ static clslua_hctx *__clslua_get_hctx(lua_State *L) lua_gettable(L, LUA_REGISTRYINDEX); /* check cls_lua assumptions */ - assert(!lua_isnil(L, -1)); - assert(lua_type(L, -1) == LUA_TLIGHTUSERDATA); + ceph_assert(!lua_isnil(L, -1)); + ceph_assert(lua_type(L, -1) == LUA_TLIGHTUSERDATA); /* cast and cleanup stack */ clslua_hctx *hctx = (struct clslua_hctx *)lua_touserdata(L, -1); @@ -118,7 +118,7 @@ static int clslua_pcall(lua_State *L) lua_insert(L, 1); lua_call(L, nargs, LUA_MULTRET); struct clslua_err *err = clslua_checkerr(L); - assert(err); + ceph_assert(err); if (err->error) { err->error = false; lua_pushinteger(L, err->ret); @@ -187,7 +187,7 @@ static int clslua_register(lua_State *L) /* get table of registered handlers */ lua_pushlightuserdata(L, &clslua_registered_handle_reg_key); lua_gettable(L, LUA_REGISTRYINDEX); - assert(lua_type(L, -1) == LUA_TTABLE); + ceph_assert(lua_type(L, -1) == LUA_TTABLE); /* lookup function argument */ lua_pushvalue(L, 1); @@ -215,7 +215,7 @@ static void clslua_check_registered_handler(lua_State *L) /* get table of registered handlers */ lua_pushlightuserdata(L, &clslua_registered_handle_reg_key); lua_gettable(L, LUA_REGISTRYINDEX); - assert(lua_type(L, -1) == LUA_TTABLE); + ceph_assert(lua_type(L, -1) == LUA_TTABLE); /* lookup function argument */ lua_pushvalue(L, -2); @@ -239,7 +239,7 @@ static int clslua_opresult(lua_State *L, int ok, int ret, int nargs, { struct clslua_err *err = clslua_checkerr(L); - assert(err); + ceph_assert(err); if (err->error) { CLS_ERR("error: cls_lua state machine: unexpected error"); ceph_abort(); diff --git a/src/cls/lua/lua_bufferlist.cc b/src/cls/lua/lua_bufferlist.cc index c4f5da5958a2f..995b40821b0e7 100644 --- a/src/cls/lua/lua_bufferlist.cc +++ b/src/cls/lua/lua_bufferlist.cc @@ -139,8 +139,8 @@ static int bl_concat(lua_State *L) static int bl_gc(lua_State *L) { struct bufferlist_wrap *blw = to_blwrap(L); - assert(blw); - assert(blw->bl); + ceph_assert(blw); + ceph_assert(blw->bl); if (blw->gc) delete blw->bl; return 0; diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index ed2163dbf4c43..1cee8b904d666 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -87,7 +87,7 @@ static int snap_read_header(cls_method_context_t hctx, bufferlist& bl) return -EINVAL; header = (struct rbd_obj_header_ondisk *)bl.c_str(); - assert(header); + ceph_assert(header); if ((snap_count != header->snap_count) || (snap_names_len != header->snap_names_len)) { @@ -4497,7 +4497,7 @@ int image_status_set(cls_method_context_t hctx, const string &global_image_id, ondisk_status.last_update = ceph_clock_now(); int r = cls_get_request_origin(hctx, &ondisk_status.origin); - assert(r == 0); + ceph_assert(r == 0); bufferlist bl; encode(ondisk_status, bl, cls_get_features(hctx)); diff --git a/src/cls/rbd/cls_rbd_client.cc b/src/cls/rbd/cls_rbd_client.cc index 88317f893bc3d..5e6f3181d9d4f 100644 --- a/src/cls/rbd/cls_rbd_client.cc +++ b/src/cls/rbd/cls_rbd_client.cc @@ -90,13 +90,13 @@ namespace librbd { rados::cls::lock::locker_info_t> *lockers, bool *exclusive_lock, std::string *lock_tag, ::SnapContext *snapc, ParentInfo *parent) { - assert(size); - assert(features); - assert(incompatible_features); - assert(lockers); - assert(exclusive_lock); - assert(snapc); - assert(parent); + ceph_assert(size); + ceph_assert(features); + ceph_assert(incompatible_features); + ceph_assert(lockers); + ceph_assert(exclusive_lock); + ceph_assert(snapc); + ceph_assert(parent); try { uint8_t order; @@ -1018,8 +1018,8 @@ namespace librbd { int get_stripe_unit_count_finish(bufferlist::const_iterator *it, uint64_t *stripe_unit, uint64_t *stripe_count) { - assert(stripe_unit); - assert(stripe_count); + ceph_assert(stripe_unit); + ceph_assert(stripe_count); try { decode(*stripe_unit, *it); @@ -1098,7 +1098,7 @@ namespace librbd { int get_create_timestamp_finish(bufferlist::const_iterator *it, utime_t *timestamp) { - assert(timestamp); + ceph_assert(timestamp); try { decode(*timestamp, *it); @@ -1131,7 +1131,7 @@ namespace librbd { int get_access_timestamp_finish(bufferlist::const_iterator *it, utime_t *timestamp) { - assert(timestamp); + ceph_assert(timestamp); try { decode(*timestamp, *it); @@ -1164,7 +1164,7 @@ namespace librbd { int get_modify_timestamp_finish(bufferlist::const_iterator *it, utime_t *timestamp) { - assert(timestamp); + ceph_assert(timestamp); try { decode(*timestamp, *it); @@ -1567,7 +1567,7 @@ namespace librbd { int metadata_list_finish(bufferlist::const_iterator *it, std::map *pairs) { - assert(pairs); + ceph_assert(pairs); try { decode(*pairs, *it); } catch (const buffer::error &err) { @@ -1579,7 +1579,7 @@ namespace librbd { int metadata_get(librados::IoCtx *ioctx, const std::string &oid, const std::string &key, string *s) { - assert(s); + ceph_assert(s); bufferlist in, out; encode(key, in); int r = ioctx->exec(oid, "rbd", "metadata_get", in, out); @@ -2640,7 +2640,7 @@ namespace librbd { int trash_list_finish(bufferlist::const_iterator *it, map *entries) { - assert(entries); + ceph_assert(entries); try { decode(*entries, *it); @@ -2678,7 +2678,7 @@ namespace librbd { int trash_get_finish(bufferlist::const_iterator *it, cls::rbd::TrashImageSpec *trash_spec) { - assert(trash_spec); + ceph_assert(trash_spec); try { decode(*trash_spec, *it); } catch (const buffer::error &err) { @@ -2749,7 +2749,7 @@ namespace librbd { int namespace_list_finish(bufferlist::const_iterator *it, std::list *entries) { - assert(entries); + ceph_assert(entries); try { decode(*entries, *it); diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 5db2cea148201..0b3563d83ac81 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -2945,7 +2945,7 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64 string user_key; bool truncated_status = false; - assert(truncated != nullptr); + ceph_assert(truncated != nullptr); if (!by_user) { usage_record_prefix_by_time(end, end_key); diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index 361a08d20e4b8..f2bb2b9c712e4 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -21,7 +21,7 @@ private: T *data; int *ret_code; public: - ClsBucketIndexOpCtx(T* _data, int *_ret_code) : data(_data), ret_code(_ret_code) { assert(data); } + ClsBucketIndexOpCtx(T* _data, int *_ret_code) : data(_data), ret_code(_ret_code) { ceph_assert(data); } ~ClsBucketIndexOpCtx() override {} void handle_completion(int r, bufferlist& outbl) override { if (r >= 0) { @@ -42,7 +42,7 @@ void BucketIndexAioManager::do_completion(int id) { Mutex::Locker l(lock); map::iterator iter = pendings.find(id); - assert(iter != pendings.end()); + ceph_assert(iter != pendings.end()); completions[id] = iter->second; pendings.erase(iter);