]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls: Use ceph_assert for asserts.
authorAdam C. Emerson <aemerson@redhat.com>
Thu, 23 Aug 2018 15:19:07 +0000 (11:19 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 27 Aug 2018 13:09:01 +0000 (09:09 -0400)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/cls/cephfs/cls_cephfs.cc
src/cls/cephfs/cls_cephfs_client.cc
src/cls/journal/cls_journal_client.cc
src/cls/lock/cls_lock.cc
src/cls/lua/cls_lua.cc
src/cls/lua/lua_bufferlist.cc
src/cls/rbd/cls_rbd.cc
src/cls/rbd/cls_rbd_client.cc
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc

index 81b40f431f2d2eec7a45072e0dfb6c611a531c25..7e3214b9246fe3ec4ff7101fb7c877b1b6a95c45 100644 (file)
@@ -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;
 
index bc708271df70928e2bd9b4cd6f8e4eb7d0cc88a3..988eab41b9a6158545bef12b124d78bed3418007 100644 (file)
  */
 
 
-#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);
index 753da51a14b51634171496622edf2b665fe53aba..c22a32cf3a32dba37fe0a8ca6e549a9ef8103f7f 100644 (file)
@@ -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();
   }
 
index b25c1a0c468a25186654a1b844ff4a941e75383e..12311b1a3c0e60b8b8414318a529bf4c7be9c719 100644 (file)
@@ -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;
index 12a31a56f7170af620e0a2ce8a95b3b6e60403b0..ecc5417fca46b171a076c1c845ecc78f5f08d26b 100644 (file)
@@ -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();
index c4f5da5958a2fc4d996ed6b7db40f82594d7fa9c..995b40821b0e7e560b33b2b32643bf012779bc83 100644 (file)
@@ -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;
index ed2163dbf4c431128707ac35670e08c71fd6f446..1cee8b904d6666e97597849577c32dcb21c2a190 100644 (file)
@@ -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));
index 88317f893bc3de0ab302f706cbf755c0e7596676..5e6f3181d9d4fb29c8b37716af464b018d305d29 100644 (file)
@@ -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<std::string, bufferlist> *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<string, cls::rbd::TrashImageSpec> *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<std::string> *entries)
     {
-      assert(entries);
+      ceph_assert(entries);
 
       try {
        decode(*entries, *it);
index 5db2cea1482016df00410ff614e30b63df8ea681..0b3563d83ac81e7bc2cbd43852adbc0c86bf33bc 100644 (file)
@@ -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);
index 361a08d20e4b87b03ebb432255ade14f45059f05..f2bb2b9c712e42b7b7434fcdfb0622fbfdf0fc05 100644 (file)
@@ -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<int, librados::AioCompletion*>::iterator iter = pendings.find(id);
-  assert(iter != pendings.end());
+  ceph_assert(iter != pendings.end());
   completions[id] = iter->second;
   pendings.erase(iter);