From: Adam C. Emerson Date: Thu, 23 Aug 2018 15:21:13 +0000 (-0400) Subject: tools: Use ceph_assert for asserts. X-Git-Tag: v14.0.1~475^2~23 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9526eb38a93728bfabe0ae8913451819dc7e5e7e;p=ceph.git tools: Use ceph_assert for asserts. Signed-off-by: Adam C. Emerson --- diff --git a/src/perf_histogram.h b/src/perf_histogram.h index 06ebaf805bfef..9c5e1c1323423 100644 --- a/src/perf_histogram.h +++ b/src/perf_histogram.h @@ -74,13 +74,13 @@ class PerfHistogram : public PerfHistogramCommon { public: /// Initialize new histogram object PerfHistogram(std::initializer_list axes_config) { - assert(axes_config.size() == DIM && + ceph_assert(axes_config.size() == DIM && "Invalid number of axis configuration objects"); int i = 0; for (const auto &ac : axes_config) { - assert(ac.m_buckets > 0 && "Must have at least one bucket on axis"); - assert(ac.m_quant_size > 0 && + ceph_assert(ac.m_buckets > 0 && "Must have at least one bucket on axis"); + ceph_assert(ac.m_quant_size > 0 && "Quantization unit must be non-zero positive integer value"); m_axes_config[i++] = ac; @@ -178,8 +178,8 @@ protected: static_assert(sizeof...(T) == DIM, "Incorrect number of arguments"); return get_raw_index_internal<0>( [](int64_t bucket, const axis_config_d &ac) { - assert(bucket >= 0 && "Bucket index can not be negative"); - assert(bucket < ac.m_buckets && "Bucket index too large"); + ceph_assert(bucket >= 0 && "Bucket index can not be negative"); + ceph_assert(bucket < ac.m_buckets && "Bucket index too large"); return bucket; }, 0, buckets...); diff --git a/src/tools/RadosDump.cc b/src/tools/RadosDump.cc index 902ffa439f4f5..420cd9fc61391 100644 --- a/src/tools/RadosDump.cc +++ b/src/tools/RadosDump.cc @@ -53,7 +53,7 @@ int RadosDump::get_header(header *h) int RadosDump::get_footer(footer *f) { - assert(f != NULL); + ceph_assert(f != NULL); bufferlist ebl; auto ebliter = ebl.cbegin(); @@ -161,6 +161,6 @@ void RadosDump::write_super() superbl.clear(); sh.encode(superbl); - assert(super_header::FIXED_LENGTH == superbl.length()); + ceph_assert(super_header::FIXED_LENGTH == superbl.length()); superbl.write_fd(file_fd); } diff --git a/src/tools/ceph-client-debug.cc b/src/tools/ceph-client-debug.cc index 44f860e6a732f..7a43c9c2a6d26 100644 --- a/src/tools/ceph-client-debug.cc +++ b/src/tools/ceph-client-debug.cc @@ -63,15 +63,15 @@ int lookup_trace(ceph_mount_info *client, inodeno_t const ino) } else { if (!inode->dentries.empty()) { Dentry *dn = *(inode->dentries.begin()); - assert(dn->dir); - assert(dn->dir->parent_inode); + ceph_assert(dn->dir); + ceph_assert(dn->dir->parent_inode); r = lookup_trace(client, dn->dir->parent_inode->ino); if (r) { return r; } } else { // We reached the root of the tree - assert(inode->ino == CEPH_INO_ROOT); + ceph_assert(inode->ino == CEPH_INO_ROOT); } } diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 685763094e6f4..0496025291ec7 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -130,14 +130,14 @@ class StoreTool } bool exists(const string &prefix) { - assert(!prefix.empty()); + ceph_assert(!prefix.empty()); KeyValueDB::WholeSpaceIterator iter = db->get_wholespace_iterator(); iter->seek_to_first(prefix); return (iter->valid() && (iter->raw_key().first == prefix)); } bool exists(const string &prefix, const string &key) { - assert(!prefix.empty()); + ceph_assert(!prefix.empty()); if (key.empty()) { return exists(prefix); @@ -149,7 +149,7 @@ class StoreTool } bufferlist get(const string &prefix, const string &key, bool &exists) { - assert(!prefix.empty() && !key.empty()); + ceph_assert(!prefix.empty() && !key.empty()); map result; std::set keys; @@ -176,9 +176,9 @@ class StoreTool } bool set(const string &prefix, const string &key, bufferlist &val) { - assert(!prefix.empty()); - assert(!key.empty()); - assert(val.length() > 0); + ceph_assert(!prefix.empty()); + ceph_assert(!key.empty()); + ceph_assert(val.length() > 0); KeyValueDB::Transaction tx = db->get_transaction(); tx->set(prefix, key, val); @@ -188,8 +188,8 @@ class StoreTool } bool rm(const string& prefix, const string& key) { - assert(!prefix.empty()); - assert(!key.empty()); + ceph_assert(!prefix.empty()); + ceph_assert(!key.empty()); KeyValueDB::Transaction tx = db->get_transaction(); tx->rmkey(prefix, key); @@ -199,7 +199,7 @@ class StoreTool } bool rm_prefix(const string& prefix) { - assert(!prefix.empty()); + ceph_assert(!prefix.empty()); KeyValueDB::Transaction tx = db->get_transaction(); tx->rmkeys_by_prefix(prefix); diff --git a/src/tools/ceph_monstore_tool.cc b/src/tools/ceph_monstore_tool.cc index f100b1e5017a4..05ac4b1e69ad6 100644 --- a/src/tools/ceph_monstore_tool.cc +++ b/src/tools/ceph_monstore_tool.cc @@ -49,7 +49,7 @@ public: return fd != -1; } MonitorDBStore::TransactionRef cur() { - assert(valid()); + ceph_assert(valid()); return t; } unsigned num() { return idx; } @@ -133,7 +133,7 @@ int parse_cmd_args( // and that's what 'desc_all' is all about. // - assert(desc != NULL); + ceph_assert(desc != NULL); po::options_description desc_all; desc_all.add(*desc); @@ -285,7 +285,7 @@ int update_osdmap(MonitorDBStore& store, version_t ver, bool copy, fullmap.encode(inc.fullmap); } } - assert(osdmap.have_crc()); + ceph_assert(osdmap.have_crc()); inc.full_crc = osdmap.get_crc(); bl.clear(); // be consistent with OSDMonitor::update_from_paxos() @@ -347,7 +347,7 @@ int rewrite_transaction(MonitorDBStore& store, int version, // (good_version, last_committed] // with the good crush map. // XXX: may need to break this into several paxos versions? - assert(good_version < last_committed); + ceph_assert(good_version < last_committed); for (version_t v = good_version + 1; v <= last_committed; v++) { cout << "rewriting epoch #" << v << "/" << last_committed << std::endl; r = update_osdmap(store, v, false, crush, t); diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 6295ec852d0f4..ce8b6f086be08 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -306,7 +306,7 @@ static int get_fd_data(int fd, bufferlist &bl) total += bytes; } while(true); - assert(bl.length() == total); + ceph_assert(bl.length() == total); return 0; } @@ -320,7 +320,7 @@ int get_log(ObjectStore *fs, __u8 struct_ver, return -ENOENT; } ostringstream oss; - assert(struct_ver > 0); + ceph_assert(struct_ver > 0); PGLog::read_log_and_missing( fs, ch, pgid.make_pgmeta_oid(), @@ -401,7 +401,7 @@ int mark_pg_for_removal(ObjectStore *fs, spg_t pgid, ObjectStore::Transaction *t cerr << __func__ << " error on read_info " << cpp_strerror(r) << std::endl; return r; } - assert(struct_v >= 8); + ceph_assert(struct_v >= 8); // new omap key cout << "setting '_remove' omap key" << std::endl; map values; @@ -485,7 +485,7 @@ int write_pg(ObjectStore::Transaction &t, epoch_t epoch, pg_info_t &info, map km; if (!divergent.empty()) { - assert(missing.get_items().empty()); + ceph_assert(missing.get_items().empty()); PGLog::write_log_and_missing_wo_missing( t, &km, log, coll, info.pgid.make_pgmeta_oid(), divergent, true); } else { @@ -508,8 +508,8 @@ int do_trim_pg_log(ObjectStore *store, const coll_t &coll, struct stat st; auto ch = store->open_collection(coll); int r = store->stat(ch, oid, &st); - assert(r == 0); - assert(st.st_size == 0); + ceph_assert(r == 0); + ceph_assert(st.st_size == 0); cerr << "Log bounds are: " << "(" << info.log_tail << "," << info.last_update << "]" << std::endl; @@ -520,7 +520,7 @@ int do_trim_pg_log(ObjectStore *store, const coll_t &coll, return 0; } - assert(info.last_update.version > max_entries); + ceph_assert(info.last_update.version > max_entries); version_t trim_to = info.last_update.version - max_entries; size_t trim_at_once = g_ceph_context->_conf->osd_pg_log_trim_max; eversion_t new_tail; @@ -745,7 +745,7 @@ int ObjectStoreTool::export_files(ObjectStore *store, coll_t coll) for (vector::iterator i = objects.begin(); i != objects.end(); ++i) { - assert(!i->hobj.is_meta()); + ceph_assert(!i->hobj.is_meta()); if (i->is_pgmeta() || i->hobj.is_temp() || !i->is_no_gen()) { continue; } @@ -869,7 +869,7 @@ int ObjectStoreTool::do_export(ObjectStore *fs, coll_t coll, spg_t pgid, if (debug) { Formatter *formatter = Formatter::create("json-pretty"); - assert(formatter); + ceph_assert(formatter); dump_log(formatter, cerr, log, missing); delete formatter; } @@ -1039,7 +1039,7 @@ int get_attrs( cerr << "\tsetting " << clone.hobj << " snaps " << snaps << std::endl; OSDriver::OSTransaction _t(driver.get_transaction(t)); - assert(!snaps.empty()); + ceph_assert(!snaps.empty()); snap_mapper.add_oid(clone.hobj, snaps, &_t); } } else { @@ -1196,7 +1196,7 @@ int ObjectStoreTool::get_object(ObjectStore *store, cerr << "ERROR: Export contains temporary object '" << ob.hoid << "'" << std::endl; return -EFAULT; } - assert(g_ceph_context); + ceph_assert(g_ceph_context); auto ch = store->open_collection(coll); if (ob.hoid.hobj.nspace != g_ceph_context->_conf->osd_hit_set_namespace) { @@ -1735,7 +1735,7 @@ int ObjectStoreTool::do_import(ObjectStore *store, OSDSuperblock& sb, bool ok = user_pgid.parse(pgidstr.c_str()); // This succeeded in main() already - assert(ok); + ceph_assert(ok); if (pgid != user_pgid) { if (pgid.pool() != user_pgid.pool()) { cerr << "Can't specify a different pgid pool, must be " << pgid.pool() << std::endl; @@ -1902,7 +1902,7 @@ int ObjectStoreTool::do_import(ObjectStore *store, OSDSuperblock& sb, ms.missing.filter_objects([&](const hobject_t &obj) { if (obj.nspace == g_ceph_context->_conf->osd_hit_set_namespace) return false; - assert(!obj.is_temp()); + ceph_assert(!obj.is_temp()); object_t oid = obj.oid; object_locator_t loc(obj); pg_t raw_pgid = curmap.object_locator_to_pg(oid, loc); @@ -2284,7 +2284,7 @@ int do_get_omap(ObjectStore *store, coll_t coll, ghobject_t &ghobj, string key) return -ENOENT; } - assert(out.size() == 1); + ceph_assert(out.size() == 1); bufferlist bl = out.begin()->second; string value(bl.c_str(), bl.length()); @@ -3575,7 +3575,7 @@ int main(int argc, char **argv) throw std::runtime_error(ss.str()); } vector::iterator i = array.begin(); - assert(i != array.end()); + ceph_assert(i != array.end()); if (i->type() != json_spirit::str_type) { ss << "Object '" << object << "' must be a JSON array with the first element a string"; @@ -4115,7 +4115,7 @@ int main(int argc, char **argv) if (op == "export-remove") { ret = initiate_new_remove_pg(fs, pgid); // Export succeeded, so pgid is there - assert(ret == 0); + ceph_assert(ret == 0); cerr << "Remove successful" << std::endl; } } @@ -4172,7 +4172,7 @@ int main(int argc, char **argv) cout << "Finished trimming pg log" << std::endl; goto out; } else { - assert(!"Should have already checked for valid --op"); + ceph_assert(!"Should have already checked for valid --op"); } } else { cerr << "PG '" << pgid << "' not found" << std::endl; diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index bd8f2c29960fb..8cc946047362d 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -213,7 +213,7 @@ int DataScan::main(const std::vector &args) } } auto fs = fsmap->get_filesystem(fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); // Default to output to metadata pool if (driver == NULL) { @@ -628,7 +628,7 @@ int DataScan::forall_objects( } } else if (untagged_only) { - assert(obj_name_offset == 0); + ceph_assert(obj_name_offset == 0); dout(20) << "OSD matched oid " << oid << dendl; } @@ -944,7 +944,7 @@ int DataScan::scan_links() continue; } else { // parse_oid can only do 0 or -EINVAL - assert(r == 0); + ceph_assert(r == 0); } if (!valid_ino(dir_ino)) { @@ -1302,7 +1302,7 @@ int MetadataTool::read_fnode( inodeno_t ino, frag_t frag, fnode_t *fnode, uint64_t *last_version) { - assert(fnode != NULL); + ceph_assert(fnode != NULL); object_t frag_oid = InodeStore::get_object_name(ino, frag, ""); bufferlist fnode_bl; @@ -1325,7 +1325,7 @@ int MetadataTool::read_fnode( int MetadataTool::read_dentry(inodeno_t parent_ino, frag_t frag, const std::string &dname, InodeStore *inode) { - assert(inode != NULL); + ceph_assert(inode != NULL); std::string key; @@ -1709,7 +1709,7 @@ int MetadataDriver::find_or_create_dirfrag( frag_t fragment, bool *created) { - assert(created != NULL); + ceph_assert(created != NULL); fnode_t existing_fnode; *created = false; @@ -1737,13 +1737,13 @@ int MetadataDriver::find_or_create_dirfrag( librados::ObjectWriteOperation op; if (read_version) { - assert(r == -EINVAL); + ceph_assert(r == -EINVAL); // Case A: We must assert that the version isn't changed since we saw the object // was unreadable, to avoid the possibility of two data-scan processes // both creating the frag. op.assert_version(read_version); } else { - assert(r == -ENOENT); + ceph_assert(r == -ENOENT); // Case B: The object didn't exist in read_fnode, so while creating it we must // use an exclusive create to correctly populate *creating with // whether we created it ourselves or someone beat us to it. @@ -1825,7 +1825,7 @@ int MetadataDriver::init( { if (metadata_pool_name.empty()) { auto fs = fsmap->get_filesystem(fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); int64_t const metadata_pool_id = fs->mds_map.get_metadata_pool(); dout(4) << "resolving metadata pool " << metadata_pool_id << dendl; @@ -1980,7 +1980,7 @@ void MetadataTool::build_file_dentry( inodeno_t ino, uint64_t file_size, time_t file_mtime, const file_layout_t &layout, InodeStore *out) { - assert(out != NULL); + ceph_assert(out != NULL); out->inode.mode = 0500 | S_IFREG; out->inode.size = file_size; @@ -2008,7 +2008,7 @@ void MetadataTool::build_dir_dentry( inodeno_t ino, const frag_info_t &fragstat, const file_layout_t &layout, InodeStore *out) { - assert(out != NULL); + ceph_assert(out != NULL); out->inode.mode = 0755 | S_IFDIR; out->inode.dirstat = fragstat; diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index 98ab43537eaa4..11d32523f416e 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -44,7 +44,7 @@ int Dumper::init(mds_role_t role_, const std::string &type) } auto fs = fsmap->get_filesystem(role.fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); if (type == "mdlog") { JournalPointer jp(role.rank, fs->mds_map.get_metadata_pool()); @@ -87,7 +87,7 @@ int Dumper::dump(const char *dump_file) int r = 0; auto fs = fsmap->get_filesystem(role.fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); Journaler journaler("dumper", ino, fs->mds_map.get_metadata_pool(), CEPH_FS_ONDISK_MAGIC, objecter, 0, 0, @@ -201,7 +201,7 @@ int Dumper::undump(const char *dump_file, bool force) cout << "undump " << dump_file << std::endl; auto fs = fsmap->get_filesystem(role.fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); int r = 0; // try get layout info from cluster @@ -361,7 +361,7 @@ int Dumper::undump(const char *dump_file, bool force) * prezeroing behaviour */ { uint32_t const object_size = h.layout.object_size; - assert(object_size > 0); + ceph_assert(object_size > 0); uint64_t last_obj = h.write_pos / object_size; uint64_t purge_count = 2; /* When the length is zero, the last_obj should be zeroed diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index a2b5395b08ce4..2d62846b27dee 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -142,7 +142,7 @@ int JournalTool::main(std::vector &argv) } auto fs = fsmap->get_filesystem(role_selector.get_ns()); - assert(fs != nullptr); + ceph_assert(fs != nullptr); int64_t const pool_id = fs->mds_map.get_metadata_pool(); dout(4) << "JournalTool: resolving pool " << pool_id << dendl; std::string pool_name; @@ -154,7 +154,7 @@ int JournalTool::main(std::vector &argv) dout(4) << "JournalTool: creating IoCtx.." << dendl; r = rados.ioctx_create(pool_name.c_str(), input); - assert(r == 0); + ceph_assert(r == 0); output.dup(input); // Execution @@ -262,7 +262,7 @@ int JournalTool::main_header(std::vector &argv) derr << "Header could not be read!" << dendl; return -ENOENT; } else { - assert(js.header != NULL); + ceph_assert(js.header != NULL); } if (argv.size() == 0) { @@ -291,7 +291,7 @@ int JournalTool::main_header(std::vector &argv) std::string const value_str = *arg; arg = argv.erase(arg); - assert(argv.empty()); + ceph_assert(argv.empty()); std::string parse_err; uint64_t new_val = strict_strtoll(value_str.c_str(), 0, &parse_err); @@ -389,7 +389,7 @@ int JournalTool::main_event(std::vector &argv) nullptr)) { dout(1) << "Using alternate pool " << arg_str << dendl; int r = rados.ioctx_create(arg_str.c_str(), output); - assert(r == 0); + ceph_assert(r == 0); other_pool = true; } else { cerr << "Unknown argument: '" << *arg << "'" << std::endl; @@ -653,7 +653,7 @@ int JournalTool::recover_dentries( bool const dry_run, std::set *consumed_inos) { - assert(consumed_inos != NULL); + ceph_assert(consumed_inos != NULL); int r = 0; @@ -1082,7 +1082,7 @@ int JournalTool::erase_region(JournalScanner const &js, uint64_t const pos, uint stream.write(entry, &log_data, pos); dout(4) << "erase_region data length " << log_data.length() << dendl; - assert(log_data.length() == length); + ceph_assert(log_data.length() == length); // Write log stream region to RADOS // FIXME: get object size somewhere common to scan_events @@ -1134,7 +1134,7 @@ void JournalTool::encode_fullbit_as_inode( const bool bare, bufferlist *out_bl) { - assert(out_bl != NULL); + ceph_assert(out_bl != NULL); // Compose InodeStore InodeStore new_inode; diff --git a/src/tools/cephfs/MDSUtility.cc b/src/tools/cephfs/MDSUtility.cc index e9af80897b794..3519c16984a7b 100644 --- a/src/tools/cephfs/MDSUtility.cc +++ b/src/tools/cephfs/MDSUtility.cc @@ -42,7 +42,7 @@ MDSUtility::~MDSUtility() delete monc; delete messenger; delete fsmap; - assert(waiting_for_mds_map == NULL); + ceph_assert(waiting_for_mds_map == NULL); } @@ -94,7 +94,7 @@ int MDSUtility::init() Mutex init_lock("MDSUtility:init"); Cond cond; bool done = false; - assert(!fsmap->get_epoch()); + ceph_assert(!fsmap->get_epoch()); lock.Lock(); waiting_for_mds_map = new C_SafeCond(&init_lock, &cond, &done, NULL); lock.Unlock(); diff --git a/src/tools/cephfs/PgFiles.cc b/src/tools/cephfs/PgFiles.cc index 166e861269c98..2abca72233504 100644 --- a/src/tools/cephfs/PgFiles.cc +++ b/src/tools/cephfs/PgFiles.cc @@ -99,7 +99,7 @@ void PgFiles::hit_dir(std::string const &path) void PgFiles::hit_file(std::string const &path, const struct ceph_statx &stx) { - assert(S_ISREG(stx.stx_mode)); + ceph_assert(S_ISREG(stx.stx_mode)); dout(20) << "Hitting file '" << path << "'" << dendl; diff --git a/src/tools/cephfs/Resetter.cc b/src/tools/cephfs/Resetter.cc index b1d3658a05e9d..bd048c2e45935 100644 --- a/src/tools/cephfs/Resetter.cc +++ b/src/tools/cephfs/Resetter.cc @@ -35,7 +35,7 @@ int Resetter::init(mds_role_t role_, const std::string &type, bool hard) } auto fs = fsmap->get_filesystem(role.fscid); - assert(nullptr != fs); + ceph_assert(nullptr != fs); is_mdlog = false; if (type == "mdlog") { @@ -77,7 +77,7 @@ int Resetter::reset() int r; auto fs = fsmap->get_filesystem(role.fscid); - assert(fs != nullptr); + ceph_assert(fs != nullptr); Journaler journaler("resetter", ino, fs->mds_map.get_metadata_pool(), @@ -194,7 +194,7 @@ int Resetter::reset_hard() int Resetter::_write_reset_event(Journaler *journaler) { - assert(journaler != NULL); + ceph_assert(journaler != NULL); LogEvent *le = new EResetJournal; diff --git a/src/tools/cephfs/TableTool.cc b/src/tools/cephfs/TableTool.cc index ed768d37ee636..e779b4b665e9d 100644 --- a/src/tools/cephfs/TableTool.cc +++ b/src/tools/cephfs/TableTool.cc @@ -45,7 +45,7 @@ void TableTool::usage() */ int TableTool::apply_role_fn(std::function fptr, Formatter *f) { - assert(f != NULL); + ceph_assert(f != NULL); int r = 0; @@ -107,8 +107,8 @@ public: int load_and_dump(librados::IoCtx *io, Formatter *f) { - assert(io != NULL); - assert(f != NULL); + ceph_assert(io != NULL); + ceph_assert(f != NULL); // Attempt read bufferlist table_bl; @@ -200,8 +200,8 @@ public: int load_and_dump(librados::IoCtx *io, Formatter *f) { - assert(io != NULL); - assert(f != NULL); + ceph_assert(io != NULL); + ceph_assert(f != NULL); // Read in the header bufferlist header_bl; @@ -334,7 +334,7 @@ int TableTool::main(std::vector &argv) } auto fs = fsmap->get_filesystem(role_selector.get_ns()); - assert(fs != nullptr); + ceph_assert(fs != nullptr); int64_t const pool_id = fs->mds_map.get_metadata_pool(); dout(4) << "resolving pool " << pool_id << dendl; std::string pool_name; diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index 67e2a1d073f04..2080c7ba9a85a 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -61,7 +61,7 @@ static int get_fd_data(int fd, bufferlist &bl) total += bytes; } while(true); - assert(bl.length() == total); + ceph_assert(bl.length() == total); return 0; } @@ -1101,7 +1101,7 @@ int main(int argc, const char **argv) return 0; } int ruleno = crush.get_rule_id(rule_name); - assert(ruleno >= 0); + ceph_assert(ruleno >= 0); int r = crush.remove_rule(ruleno); if (r < 0) { cerr << "fail to remove rule " << rule_name << std::endl; diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index 594c71d1d27d7..54977423a00e4 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -359,7 +359,7 @@ int main(int argc, const char **argv) if (r > 0) { print_inc_upmaps(pending_inc, upmap_fd); r = osdmap.apply_incremental(pending_inc); - assert(r == 0); + ceph_assert(r == 0); } } if (upmap) { @@ -388,7 +388,7 @@ int main(int argc, const char **argv) print_inc_upmaps(pending_inc, upmap_fd); if (upmap_save) { int r = osdmap.apply_incremental(pending_inc); - assert(r == 0); + ceph_assert(r == 0); modified = true; } } else { diff --git a/src/tools/rados/PoolDump.cc b/src/tools/rados/PoolDump.cc index 405f455e8d349..747e9c62dbc41 100644 --- a/src/tools/rados/PoolDump.cc +++ b/src/tools/rados/PoolDump.cc @@ -30,7 +30,7 @@ using namespace librados; */ int PoolDump::dump(IoCtx *io_ctx) { - assert(io_ctx != NULL); + ceph_assert(io_ctx != NULL); int r = 0; write_super(); diff --git a/src/tools/rados/RadosImport.cc b/src/tools/rados/RadosImport.cc index ba4698cef4e83..afc04cf309e6a 100644 --- a/src/tools/rados/RadosImport.cc +++ b/src/tools/rados/RadosImport.cc @@ -180,7 +180,7 @@ int RadosImport::get_object_rados(librados::IoCtx &ioctx, bufferlist &bl, bool n omap_hdr_section oh; omap_section os; - assert(g_ceph_context); + ceph_assert(g_ceph_context); if (ob.hoid.hobj.nspace == g_ceph_context->_conf->osd_hit_set_namespace) { cout << "Skipping internal object " << ob.hoid << std::endl; skip_object(bl); @@ -262,7 +262,7 @@ int RadosImport::get_object_rados(librados::IoCtx &ioctx, bufferlist &bl, bool n << std::endl; return ret; } - assert(alignment != 0); + ceph_assert(alignment != 0); } } @@ -297,7 +297,7 @@ int RadosImport::get_object_rados(librados::IoCtx &ioctx, bufferlist &bl, bool n cerr << "Discontiguous object data in export" << std::endl; return -EFAULT; } - assert(ds.databl.length() == ds.len); + ceph_assert(ds.databl.length() == ds.len); databl.claim_append(ds.databl); in_offset += ds.len; if (databl.length() >= alignment) { @@ -313,7 +313,7 @@ int RadosImport::get_object_rados(librados::IoCtx &ioctx, bufferlist &bl, bool n out_offset += rndlen; bufferlist n; if (databl.length() > rndlen) { - assert(databl.length() - rndlen < alignment); + ceph_assert(databl.length() - rndlen < alignment); n.substr_of(databl, rndlen, databl.length() - rndlen); } databl = n; @@ -378,7 +378,7 @@ int RadosImport::get_object_rados(librados::IoCtx &ioctx, bufferlist &bl, bool n case TYPE_OBJECT_END: done = true; if (need_align && databl.length() > 0) { - assert(databl.length() < alignment); + ceph_assert(databl.length() < alignment); dout(10) << "END write offset=" << out_offset << " len=" << databl.length() << dendl; if (dry_run || skipping) break; diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 9936ff5d437e1..bd59ead47a025 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -1533,7 +1533,7 @@ static void dump_shard(const shard_info_t& shard, || shard.has_obj_size_info_mismatch()) && !shard.has_info_missing()) { map::iterator k = (const_cast(shard)).attrs.find(OI_ATTR); - assert(k != shard.attrs.end()); // Can't be missing + ceph_assert(k != shard.attrs.end()); // Can't be missing if (!shard.has_info_corrupted()) { object_info_t oi; bufferlist bl; @@ -1552,7 +1552,7 @@ static void dump_shard(const shard_info_t& shard, || inc.has_snapset_inconsistency()) && !shard.has_snapset_missing()) { map::iterator k = (const_cast(shard)).attrs.find(SS_ATTR); - assert(k != shard.attrs.end()); // Can't be missing + ceph_assert(k != shard.attrs.end()); // Can't be missing if (!shard.has_snapset_corrupted()) { SnapSet ss; bufferlist bl; @@ -1571,7 +1571,7 @@ static void dump_shard(const shard_info_t& shard, || inc.has_hinfo_inconsistency()) && !shard.has_hinfo_missing()) { map::iterator k = (const_cast(shard)).attrs.find(ECUtil::get_hinfo_key()); - assert(k != shard.attrs.end()); // Can't be missing + ceph_assert(k != shard.attrs.end()); // Can't be missing if (!shard.has_hinfo_corrupted()) { ECUtil::HashInfo hi; bufferlist bl; @@ -1660,7 +1660,7 @@ static void dump_inconsistent(const inconsistent_obj_t& inc, object_info_t oi; bufferlist bl; auto k = shard.attrs.find(OI_ATTR); - assert(k != shard.attrs.end()); // Can't be missing + ceph_assert(k != shard.attrs.end()); // Can't be missing auto bliter = k->second.cbegin(); decode(oi, bliter); // Can't be corrupted f.open_object_section("selected_object_info"); @@ -1798,7 +1798,7 @@ static int do_get_inconsistent_cmd(const std::vector &nargs, } // It must be the same interval every time. EAGAIN would // occur if interval changes. - assert(start.name.empty() || first_interval == interval); + ceph_assert(start.name.empty() || first_interval == interval); if (start.name.empty()) { first_interval = interval; formatter.open_object_section("info"); @@ -2237,7 +2237,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, cout << "selected snap " << snapid << " '" << name << "'" << std::endl; } - assert(!nargs.empty()); + ceph_assert(!nargs.empty()); // list pools? if (strcmp(nargs[0], "lspools") == 0) { diff --git a/src/tools/rbd/Utils.cc b/src/tools/rbd/Utils.cc index e436a876ab6af..96e5eb17fd5f2 100644 --- a/src/tools/rbd/Utils.cc +++ b/src/tools/rbd/Utils.cc @@ -495,7 +495,7 @@ int get_image_options(const boost::program_options::variables_map &vm, if (format_specified) { int r = g_conf().set_val("rbd_default_format", stringify(format)); - assert(r == 0); + ceph_assert(r == 0); opts->set(RBD_IMAGE_OPTION_FORMAT, format); } } @@ -539,7 +539,7 @@ int get_journal_options(const boost::program_options::variables_map &vm, opts->set(RBD_IMAGE_OPTION_JOURNAL_ORDER, order); int r = g_conf().set_val("rbd_journal_order", stringify(order)); - assert(r == 0); + ceph_assert(r == 0); } if (vm.count(at::JOURNAL_SPLAY_WIDTH)) { opts->set(RBD_IMAGE_OPTION_JOURNAL_SPLAY_WIDTH, @@ -548,7 +548,7 @@ int get_journal_options(const boost::program_options::variables_map &vm, int r = g_conf().set_val("rbd_journal_splay_width", stringify( vm[at::JOURNAL_SPLAY_WIDTH].as())); - assert(r == 0); + ceph_assert(r == 0); } if (vm.count(at::JOURNAL_POOL)) { opts->set(RBD_IMAGE_OPTION_JOURNAL_POOL, @@ -556,7 +556,7 @@ int get_journal_options(const boost::program_options::variables_map &vm, int r = g_conf().set_val("rbd_journal_pool", vm[at::JOURNAL_POOL].as()); - assert(r == 0); + ceph_assert(r == 0); } return 0; @@ -757,7 +757,7 @@ void calc_sparse_extent(const bufferptr &bp, bool *zeroed) { if (sparse_size == 0) { // sparse writes are disabled -- write the full extent - assert(buffer_offset == 0); + ceph_assert(buffer_offset == 0); *write_length = buffer_length; *zeroed = false; return; @@ -775,7 +775,7 @@ void calc_sparse_extent(const bufferptr &bp, if (original_offset == buffer_offset) { *zeroed = extent_is_zero; } else if (*zeroed != extent_is_zero) { - assert(*write_length > 0); + ceph_assert(*write_length > 0); return; } diff --git a/src/tools/rbd/action/Create.cc b/src/tools/rbd/action/Create.cc index 5a695d314adb2..5f950e30bd96d 100644 --- a/src/tools/rbd/action/Create.cc +++ b/src/tools/rbd/action/Create.cc @@ -56,12 +56,12 @@ struct thick_provision_writer { { // If error cases occur, the code is aborted, because // constructor cannot return error value. - assert(g_ceph_context != nullptr); + ceph_assert(g_ceph_context != nullptr); bl.append_zero(block_size); librbd::image_info_t info; int r = image->stat(info, sizeof(info)); - assert(r >= 0); + ceph_assert(r >= 0); uint64_t order; if (info.order == 0) { order = g_conf().get_val("rbd_default_order"); @@ -180,9 +180,9 @@ int thick_write(const std::string &image_name,librados::IoCtx &io_ctx, // To prevent writesame from discarding data, thick_write sets // the rbd_discard_on_zeroed_write_same option to false. - assert(g_ceph_context != nullptr); + ceph_assert(g_ceph_context != nullptr); r = g_conf().set_val("rbd_discard_on_zeroed_write_same", "false"); - assert(r == 0); + ceph_assert(r == 0); r = utils::open_image(io_ctx, image_name, false, &image); if (r < 0) { return r; diff --git a/src/tools/rbd/action/Device.cc b/src/tools/rbd/action/Device.cc index 175bc0c30dcdb..74137de7c1138 100644 --- a/src/tools/rbd/action/Device.cc +++ b/src/tools/rbd/action/Device.cc @@ -7,6 +7,8 @@ #include +#include "include/assert.h" + namespace rbd { namespace action { @@ -109,7 +111,7 @@ const DeviceOperations *get_device_operations(const po::variables_map &vm) { case DEVICE_TYPE_NBD: return &nbd_operations; default: - assert(0); + ceph_assert(0); return nullptr; } } diff --git a/src/tools/rbd/action/Diff.cc b/src/tools/rbd/action/Diff.cc index a215e8a0121ee..3729469c50dad 100644 --- a/src/tools/rbd/action/Diff.cc +++ b/src/tools/rbd/action/Diff.cc @@ -35,7 +35,7 @@ static int diff_cb(uint64_t ofs, size_t len, int exists, void *arg) om->f->dump_string("exists", exists ? "true" : "false"); om->f->close_section(); } else { - assert(om->t); + ceph_assert(om->t); *(om->t) << ofs << len << (exists ? "data" : "zero") << TextTable::endrow; } return 0; diff --git a/src/tools/rbd/action/Export.cc b/src/tools/rbd/action/Export.cc index 8e9f80306c002..710eeddeaed77 100644 --- a/src/tools/rbd/action/Export.cc +++ b/src/tools/rbd/action/Export.cc @@ -353,7 +353,7 @@ public: return; } - assert(m_bufferlist.length() == static_cast(r)); + ceph_assert(m_bufferlist.length() == static_cast(r)); if (m_fd != STDOUT_FILENO) { if (m_bufferlist.is_zero()) { return; diff --git a/src/tools/rbd/action/Import.cc b/src/tools/rbd/action/Import.cc index 8f1f6078538d2..df724787eb3fe 100644 --- a/src/tools/rbd/action/Import.cc +++ b/src/tools/rbd/action/Import.cc @@ -265,13 +265,13 @@ static int do_image_io(ImportDiffContext *idiffctx, bool discard, size_t sparse_ bool zeroed = false; utils::calc_sparse_extent(bp, sparse_size, buffer_offset, buffer_length, &write_length, &zeroed); - assert(write_length > 0); + ceph_assert(write_length > 0); bufferlist write_bl; if (!zeroed) { bufferptr write_ptr(bp, buffer_offset, write_length); write_bl.push_back(write_ptr); - assert(write_bl.length() == write_length); + ceph_assert(write_bl.length() == write_length); } C_ImportDiff *ctx = new C_ImportDiff(idiffctx, write_bl, @@ -787,7 +787,7 @@ static int do_import_v1(int fd, librbd::Image &image, uint64_t size, bufferlist write_bl; bufferptr write_ptr(blkptr, buffer_offset, write_length); write_bl.push_back(write_ptr); - assert(write_bl.length() == write_length); + ceph_assert(write_bl.length() == write_length); C_Import *ctx = new C_Import(*throttle, image, write_bl, image_pos + buffer_offset); @@ -834,7 +834,7 @@ static int do_import(librados::Rados &rados, librbd::RBD &rbd, utils::ProgressContext pc("Importing image", no_progress); std::map imagemetas; - assert(imgname); + ceph_assert(imgname); uint64_t order; if (opts.get(RBD_IMAGE_OPTION_ORDER, &order) != 0) { @@ -878,7 +878,7 @@ static int do_import(librados::Rados &rados, librbd::RBD &rbd, << std::endl; goto done; } - assert(bdev_size >= 0); + ceph_assert(bdev_size >= 0); size = (uint64_t) bdev_size; } #ifdef HAVE_POSIX_FADVISE diff --git a/src/tools/rbd/action/Journal.cc b/src/tools/rbd/action/Journal.cc index 0b27d53405a24..fb4d142c2cc9d 100644 --- a/src/tools/rbd/action/Journal.cc +++ b/src/tools/rbd/action/Journal.cc @@ -809,7 +809,7 @@ public: << std::endl; return false; } - assert(entry_size > 0); + ceph_assert(entry_size > 0); // Read entry. r = bl.read_fd(m_fd, entry_size); if (r < 0) { diff --git a/src/tools/rbd/action/MergeDiff.cc b/src/tools/rbd/action/MergeDiff.cc index a996af767e600..406b23b4d022f 100644 --- a/src/tools/rbd/action/MergeDiff.cc +++ b/src/tools/rbd/action/MergeDiff.cc @@ -336,7 +336,7 @@ static int do_merge_diff(const char *first, const char *second, continue; } } - assert(f_off >= s_off); + ceph_assert(f_off >= s_off); if (f_off < s_off + s_len && f_len) { uint64_t delta = s_off + s_len - f_off; @@ -363,7 +363,7 @@ static int do_merge_diff(const char *first, const char *second, continue; } } - assert(f_off >= s_off + s_len); + ceph_assert(f_off >= s_off + s_len); if (s_len) { r = accept_diff_body(sd, pd, s_tag, s_off, s_len); if (r < 0) { @@ -374,7 +374,7 @@ static int do_merge_diff(const char *first, const char *second, s_len = 0; s_tag = 0; } else { - assert(f_end && s_end); + ceph_assert(f_end && s_end); } continue; } diff --git a/src/tools/rbd_ggate/Driver.cc b/src/tools/rbd_ggate/Driver.cc index e2b3e3a110317..752ef56f8cc12 100644 --- a/src/tools/rbd_ggate/Driver.cc +++ b/src/tools/rbd_ggate/Driver.cc @@ -147,7 +147,7 @@ int Driver::send(Request *req) { if (ggate_drv_req_cmd(req->req) == GGATE_DRV_CMD_READ && ggate_drv_req_error(req->req) == 0) { - assert(req->bl.length() == ggate_drv_req_length(req->req)); + ceph_assert(req->bl.length() == ggate_drv_req_length(req->req)); // TODO: avoid copying? req->bl.copy(0, ggate_drv_req_length(req->req), static_cast(ggate_drv_req_buf(req->req))); diff --git a/src/tools/rbd_ggate/Server.cc b/src/tools/rbd_ggate/Server.cc index ca4863fd85146..3beeec3fec0b9 100644 --- a/src/tools/rbd_ggate/Server.cc +++ b/src/tools/rbd_ggate/Server.cc @@ -26,7 +26,7 @@ void Server::run() { dout(10) << dendl; int r = start(); - assert(r == 0); + ceph_assert(r == 0); dout(20) << "entering run loop" << dendl; @@ -55,7 +55,7 @@ void Server::stop() { { Mutex::Locker locker(m_lock); - assert(m_stopping); + ceph_assert(m_stopping); } m_reader_thread.join(); @@ -75,7 +75,7 @@ void Server::io_finish(IOContext *ctx) { dout(20) << ctx << dendl; Mutex::Locker locker(m_lock); - assert(ctx->item.is_on_list()); + ceph_assert(ctx->item.is_on_list()); ctx->item.remove_myself(); m_io_finished.push_back(&ctx->item); @@ -104,7 +104,7 @@ Server::IOContext *Server::wait_io_finish() { void Server::wait_clean() { dout(20) << dendl; - assert(!m_reader_thread.is_started()); + ceph_assert(!m_reader_thread.is_started()); Mutex::Locker locker(m_lock); diff --git a/src/tools/rbd_ggate/main.cc b/src/tools/rbd_ggate/main.cc index a2d6dbca7524a..c8ae885835707 100644 --- a/src/tools/rbd_ggate/main.cc +++ b/src/tools/rbd_ggate/main.cc @@ -67,8 +67,8 @@ static void handle_signal(int signum) { derr << "*** Got signal " << sig_str(signum) << " ***" << dendl; - assert(signum == SIGINT || signum == SIGTERM); - assert(drv); + ceph_assert(signum == SIGINT || signum == SIGTERM); + ceph_assert(drv); drv->shut_down(); } @@ -219,7 +219,7 @@ static int do_map(int argc, const char *argv[]) shutdown_async_signal_handler(); r = image.update_unwatch(handle); - assert(r == 0); + ceph_assert(r == 0); done: image.close(); diff --git a/src/tools/rbd_mirror/ClusterWatcher.cc b/src/tools/rbd_mirror/ClusterWatcher.cc index 2924cbef174bf..e0c06d5ce7fe4 100644 --- a/src/tools/rbd_mirror/ClusterWatcher.cc +++ b/src/tools/rbd_mirror/ClusterWatcher.cc @@ -36,7 +36,7 @@ ClusterWatcher::ClusterWatcher(RadosRef cluster, Mutex &lock, const ClusterWatcher::PoolPeers& ClusterWatcher::get_pool_peers() const { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); return m_pool_peers; } diff --git a/src/tools/rbd_mirror/ImageDeleter.cc b/src/tools/rbd_mirror/ImageDeleter.cc index b95c544f1cfae..e8439f273ca40 100644 --- a/src/tools/rbd_mirror/ImageDeleter.cc +++ b/src/tools/rbd_mirror/ImageDeleter.cc @@ -106,7 +106,7 @@ public: bool call(std::string_view command, const cmdmap_t& cmdmap, std::string_view format, bufferlist& out) override { Commands::const_iterator i = commands.find(command); - assert(i != commands.end()); + ceph_assert(i != commands.end()); Formatter *f = Formatter::create(format); stringstream ss; bool r = i->second->call(f, &ss); @@ -179,7 +179,7 @@ void ImageDeleter::shut_down(Context* on_finish) { template void ImageDeleter::shut_down_trash_watcher(Context* on_finish) { dout(10) << dendl; - assert(m_trash_watcher); + ceph_assert(m_trash_watcher); auto ctx = new FunctionContext([this, on_finish](int r) { delete m_trash_watcher; m_trash_watcher = nullptr; @@ -209,7 +209,7 @@ void ImageDeleter::cancel_all_deletions(Context* on_finish) { { Mutex::Locker locker(m_lock); // wake up any external state machines waiting on deletions - assert(m_in_flight_delete_queue.empty()); + ceph_assert(m_in_flight_delete_queue.empty()); for (auto& queue : {&m_delete_queue, &m_retry_delete_queue}) { for (auto& info : *queue) { notify_on_delete(info->image_id, -ECANCELED); @@ -279,7 +279,7 @@ void ImageDeleter::enqueue_failed_delete(DeleteInfoRef* delete_info, template typename ImageDeleter::DeleteInfoRef ImageDeleter::find_delete_info(const std::string &image_id) { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); DeleteQueue delete_queues[] = {m_in_flight_delete_queue, m_retry_delete_queue, m_delete_queue}; @@ -369,7 +369,7 @@ void ImageDeleter::remove_images() { DeleteInfoRef delete_info = m_delete_queue.front(); m_delete_queue.pop_front(); - assert(delete_info); + ceph_assert(delete_info); remove_image(delete_info); } } @@ -377,7 +377,7 @@ void ImageDeleter::remove_images() { template void ImageDeleter::remove_image(DeleteInfoRef delete_info) { dout(10) << "info=" << *delete_info << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); m_in_flight_delete_queue.push_back(delete_info); m_async_op_tracker.start_op(); @@ -400,10 +400,10 @@ void ImageDeleter::handle_remove_image(DeleteInfoRef delete_info, { Mutex::Locker locker(m_lock); - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); auto it = std::find(m_in_flight_delete_queue.begin(), m_in_flight_delete_queue.end(), delete_info); - assert(it != m_in_flight_delete_queue.end()); + ceph_assert(it != m_in_flight_delete_queue.end()); m_in_flight_delete_queue.erase(it); } @@ -428,8 +428,8 @@ void ImageDeleter::handle_remove_image(DeleteInfoRef delete_info, template void ImageDeleter::schedule_retry_timer() { - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (!m_running || m_timer_ctx != nullptr || m_retry_delete_queue.empty()) { return; } @@ -445,25 +445,25 @@ void ImageDeleter::schedule_retry_timer() { template void ImageDeleter::cancel_retry_timer() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); if (m_timer_ctx != nullptr) { bool canceled = m_threads->timer->cancel_event(m_timer_ctx); m_timer_ctx = nullptr; - assert(canceled); + ceph_assert(canceled); } } template void ImageDeleter::handle_retry_timer() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); Mutex::Locker locker(m_lock); - assert(m_timer_ctx != nullptr); + ceph_assert(m_timer_ctx != nullptr); m_timer_ctx = nullptr; - assert(m_running); - assert(!m_retry_delete_queue.empty()); + ceph_assert(m_running); + ceph_assert(!m_retry_delete_queue.empty()); // move all ready-to-ready items back to main queue utime_t now = ceph_clock_now(); diff --git a/src/tools/rbd_mirror/ImageMap.cc b/src/tools/rbd_mirror/ImageMap.cc index 5797fee7add1d..568f425940f2b 100644 --- a/src/tools/rbd_mirror/ImageMap.cc +++ b/src/tools/rbd_mirror/ImageMap.cc @@ -63,9 +63,9 @@ ImageMap::ImageMap(librados::IoCtx &ioctx, Threads *threads, template ImageMap::~ImageMap() { - assert(m_async_op_tracker.empty()); - assert(m_timer_task == nullptr); - assert(m_rebalance_task == nullptr); + ceph_assert(m_async_op_tracker.empty()); + ceph_assert(m_timer_task == nullptr); + ceph_assert(m_rebalance_task == nullptr); } template @@ -148,8 +148,8 @@ template void ImageMap::process_updates() { dout(20) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_timer_task == nullptr); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_timer_task == nullptr); Updates map_updates; std::set map_removals; @@ -170,7 +170,7 @@ void ImageMap::process_updates() { case image_map::ACTION_TYPE_NONE: continue; case image_map::ACTION_TYPE_MAP_UPDATE: - assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); + ceph_assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); map_updates.emplace_back(global_image_id, info.instance_id, info.mapped_time); break; @@ -178,11 +178,11 @@ void ImageMap::process_updates() { map_removals.emplace(global_image_id); break; case image_map::ACTION_TYPE_ACQUIRE: - assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); + ceph_assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); acquire_updates.emplace_back(global_image_id, info.instance_id); break; case image_map::ACTION_TYPE_RELEASE: - assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); + ceph_assert(info.instance_id != image_map::UNMAPPED_INSTANCE_ID); release_updates.emplace_back(global_image_id, info.instance_id); break; } @@ -205,7 +205,7 @@ void ImageMap::schedule_update_task() { template void ImageMap::schedule_update_task(const Mutex &timer_lock) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); schedule_rebalance_task(); @@ -221,7 +221,7 @@ void ImageMap::schedule_update_task(const Mutex &timer_lock) { } m_timer_task = new FunctionContext([this](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_timer_task = nullptr; process_updates(); @@ -237,7 +237,7 @@ void ImageMap::schedule_update_task(const Mutex &timer_lock) { template void ImageMap::rebalance() { - assert(m_rebalance_task == nullptr); + ceph_assert(m_rebalance_task == nullptr); { Mutex::Locker locker(m_lock); @@ -258,7 +258,7 @@ void ImageMap::rebalance() { template void ImageMap::schedule_rebalance_task() { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); CephContext *cct = reinterpret_cast(m_ioctx.cct()); @@ -275,7 +275,7 @@ void ImageMap::schedule_rebalance_task() { } m_rebalance_task = new FunctionContext([this](int _) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_rebalance_task = nullptr; rebalance(); @@ -289,7 +289,7 @@ void ImageMap::schedule_rebalance_task() { template void ImageMap::schedule_action(const std::string &global_image_id) { dout(20) << "global_image_id=" << global_image_id << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); m_global_image_ids.emplace(global_image_id); } @@ -376,7 +376,7 @@ void ImageMap::update_images_added( const std::set &global_image_ids) { dout(5) << "peer_uuid=" << peer_uuid << ", " << "global_image_ids=[" << global_image_ids << "]" << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); for (auto const &global_image_id : global_image_ids) { auto result = m_peer_map[global_image_id].insert(peer_uuid); @@ -394,7 +394,7 @@ void ImageMap::update_images_removed( const std::set &global_image_ids) { dout(5) << "peer_uuid=" << peer_uuid << ", " << "global_image_ids=[" << global_image_ids << "]" << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Updates to_remove; for (auto const &global_image_id : global_image_ids) { @@ -529,7 +529,7 @@ void ImageMap::init(Context *on_finish) { if (policy_type == "none" || policy_type == "simple") { m_policy.reset(image_map::SimplePolicy::create(m_ioctx)); } else { - assert(false); // not really needed as such, but catch it. + ceph_assert(false); // not really needed as such, but catch it. } dout(20) << "mapping policy=" << policy_type << dendl; @@ -550,7 +550,7 @@ void ImageMap::shut_down(Context *on_finish) { { Mutex::Locker locker(m_lock); - assert(!m_shutting_down); + ceph_assert(!m_shutting_down); m_shutting_down = true; m_policy.reset(); diff --git a/src/tools/rbd_mirror/ImageReplayer.cc b/src/tools/rbd_mirror/ImageReplayer.cc index 6377540ccd902..59b660a7366fc 100644 --- a/src/tools/rbd_mirror/ImageReplayer.cc +++ b/src/tools/rbd_mirror/ImageReplayer.cc @@ -198,7 +198,7 @@ public: bool call(std::string_view command, const cmdmap_t& cmdmap, std::string_view format, bufferlist& out) override { auto i = commands.find(command); - assert(i != commands.end()); + ceph_assert(i != commands.end()); Formatter *f = Formatter::create(format); stringstream ss; bool r = i->second->call(f, &ss); @@ -291,16 +291,16 @@ template ImageReplayer::~ImageReplayer() { unregister_admin_socket_hook(); - assert(m_event_preprocessor == nullptr); - assert(m_replay_status_formatter == nullptr); - assert(m_local_image_ctx == nullptr); - assert(m_local_replay == nullptr); - assert(m_remote_journaler == nullptr); - assert(m_replay_handler == nullptr); - assert(m_on_start_finish == nullptr); - assert(m_on_stop_finish == nullptr); - assert(m_bootstrap_request == nullptr); - assert(m_in_flight_status_updates == 0); + ceph_assert(m_event_preprocessor == nullptr); + ceph_assert(m_replay_status_formatter == nullptr); + ceph_assert(m_local_image_ctx == nullptr); + ceph_assert(m_local_replay == nullptr); + ceph_assert(m_remote_journaler == nullptr); + ceph_assert(m_replay_handler == nullptr); + ceph_assert(m_on_start_finish == nullptr); + ceph_assert(m_on_stop_finish == nullptr); + ceph_assert(m_bootstrap_request == nullptr); + ceph_assert(m_in_flight_status_updates == 0); delete m_journal_listener; } @@ -362,10 +362,10 @@ void ImageReplayer::start(Context *on_finish, bool manual) m_delete_requested = false; if (on_finish != nullptr) { - assert(m_on_start_finish == nullptr); + ceph_assert(m_on_start_finish == nullptr); m_on_start_finish = on_finish; } - assert(m_on_stop_finish == nullptr); + ceph_assert(m_on_stop_finish == nullptr); } } @@ -430,7 +430,7 @@ void ImageReplayer::prepare_remote_image() { } // TODO need to support multiple remote images - assert(!m_peers.empty()); + ceph_assert(!m_peers.empty()); m_remote_image = {*m_peers.begin()}; Context *ctx = create_context_callback< @@ -446,7 +446,7 @@ template void ImageReplayer::handle_prepare_remote_image(int r) { dout(10) << "r=" << r << dendl; - assert(r < 0 ? m_remote_journaler == nullptr : m_remote_journaler != nullptr); + ceph_assert(r < 0 ? m_remote_journaler == nullptr : m_remote_journaler != nullptr); if (r < 0 && !m_local_image_id.empty() && m_local_image_tag_owner == librbd::Journal<>::LOCAL_MIRROR_UUID) { // local image is primary -- fall-through @@ -542,7 +542,7 @@ void ImageReplayer::handle_bootstrap(int r) { return; } - assert(m_local_journal == nullptr); + ceph_assert(m_local_journal == nullptr); { RWLock::RLocker snap_locker(m_local_image_ctx->snap_lock); if (m_local_image_ctx->journal != nullptr) { @@ -624,7 +624,7 @@ void ImageReplayer::handle_start_replay(int r) { dout(10) << "r=" << r << dendl; if (r < 0) { - assert(m_local_replay == nullptr); + ceph_assert(m_local_replay == nullptr); derr << "error starting external replay on local image " << m_local_image_id << ": " << cpp_strerror(r) << dendl; on_start_fail(r, "error starting replay on local image"); @@ -634,7 +634,7 @@ void ImageReplayer::handle_start_replay(int r) { Context *on_finish(nullptr); { Mutex::Locker locker(m_lock); - assert(m_state == STATE_STARTING); + ceph_assert(m_state == STATE_STARTING); m_state = STATE_REPLAYING; std::swap(m_on_start_finish, on_finish); } @@ -678,7 +678,7 @@ void ImageReplayer::on_start_fail(int r, const std::string &desc) Context *ctx = new FunctionContext([this, r, desc](int _r) { { Mutex::Locker locker(m_lock); - assert(m_state == STATE_STARTING); + ceph_assert(m_state == STATE_STARTING); m_state = STATE_STOPPING; if (r < 0 && r != -ECANCELED && r != -EREMOTEIO && r != -ENOENT) { derr << "start failed: " << cpp_strerror(r) << dendl; @@ -701,7 +701,7 @@ template bool ImageReplayer::on_start_interrupted() { Mutex::Locker locker(m_lock); - assert(m_state == STATE_STARTING); + ceph_assert(m_state == STATE_STARTING); if (m_on_stop_finish == nullptr) { return false; } @@ -738,7 +738,7 @@ void ImageReplayer::stop(Context *on_finish, bool manual, int r, shut_down_replay = true; } - assert(m_on_stop_finish == nullptr); + ceph_assert(m_on_stop_finish == nullptr); std::swap(m_on_stop_finish, on_finish); m_stop_requested = true; m_manual_stop = manual; @@ -866,8 +866,8 @@ void ImageReplayer::on_flush_local_replay_flush_start(Context *on_flush) on_flush_local_replay_flush_finish(on_flush, r); }); - assert(m_lock.is_locked()); - assert(m_state == STATE_REPLAYING); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_state == STATE_REPLAYING); m_local_replay->flush(ctx); } @@ -1004,7 +1004,7 @@ void ImageReplayer::handle_replay_flush(int r) { { Mutex::Locker locker(m_lock); - assert(m_state == STATE_REPLAY_FLUSHING); + ceph_assert(m_state == STATE_REPLAY_FLUSHING); m_state = STATE_REPLAYING; } @@ -1141,10 +1141,10 @@ void ImageReplayer::preprocess_entry() { dout(20) << "delaying replay by " << delay << " sec" << dendl; Mutex::Locker timer_locker(m_threads->timer_lock); - assert(m_delayed_preprocess_task == nullptr); + ceph_assert(m_delayed_preprocess_task == nullptr); m_delayed_preprocess_task = new FunctionContext( [this](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_delayed_preprocess_task = nullptr; m_threads->work_queue->queue( create_context_callback::preprocess_entry() { template void ImageReplayer::handle_preprocess_entry_ready(int r) { dout(20) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); if (!m_event_preprocessor->is_required(m_event_entry)) { process_entry(); @@ -1208,7 +1208,7 @@ void ImageReplayer::process_entry() { template void ImageReplayer::handle_process_entry_ready(int r) { dout(20) << dendl; - assert(r == 0); + ceph_assert(r == 0); bool update_status = false; { @@ -1237,7 +1237,7 @@ void ImageReplayer::handle_process_entry_safe(const ReplayEntry& replay_entry derr << "failed to commit journal event: " << cpp_strerror(r) << dendl; handle_replay_complete(r, "failed to commit journal event"); } else { - assert(m_remote_journaler != nullptr); + ceph_assert(m_remote_journaler != nullptr); m_remote_journaler->committed(replay_entry); } m_event_replay_tracker.finish_op(); @@ -1261,7 +1261,7 @@ bool ImageReplayer::update_mirror_image_status(bool force, template bool ImageReplayer::start_mirror_image_status_update(bool force, bool restarting) { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (!force && !is_stopped_()) { if (!is_running_()) { @@ -1286,7 +1286,7 @@ void ImageReplayer::finish_mirror_image_status_update() { Context *on_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_in_flight_status_updates > 0); + ceph_assert(m_in_flight_status_updates > 0); if (--m_in_flight_status_updates > 0) { dout(15) << "waiting on " << m_in_flight_status_updates << " in-flight " << "updates" << dendl; @@ -1376,7 +1376,7 @@ void ImageReplayer::send_mirror_status_update(const OptionalState &opt_state) }); std::string desc; - assert(m_replay_status_formatter != nullptr); + ceph_assert(m_replay_status_formatter != nullptr); if (!m_replay_status_formatter->get_or_send_update(&desc, on_req_finish)) { dout(20) << "waiting for replay status" << dendl; @@ -1410,7 +1410,7 @@ void ImageReplayer::send_mirror_status_update(const OptionalState &opt_state) } break; default: - assert(!"invalid state"); + ceph_assert(!"invalid state"); } { @@ -1428,11 +1428,11 @@ void ImageReplayer::send_mirror_status_update(const OptionalState &opt_state) librados::ObjectWriteOperation op; librbd::cls_client::mirror_image_status_set(&op, m_global_image_id, status); - assert(m_local_ioctx); + ceph_assert(m_local_ioctx); librados::AioCompletion *aio_comp = create_rados_callback< ImageReplayer, &ImageReplayer::handle_mirror_status_update>(this); int r = m_local_ioctx->aio_operate(RBD_MIRRORING, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -1488,7 +1488,7 @@ void ImageReplayer::reschedule_update_status_task(int new_interval) { start_mirror_image_status_update(false, restarting)) { m_update_status_task = new FunctionContext( [this](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_update_status_task = nullptr; queue_mirror_image_status_update(boost::none); @@ -1515,7 +1515,7 @@ void ImageReplayer::shut_down(int r) { if (m_delayed_preprocess_task != nullptr) { canceled_delayed_preprocess_task = m_threads->timer->cancel_event( m_delayed_preprocess_task); - assert(canceled_delayed_preprocess_task); + ceph_assert(canceled_delayed_preprocess_task); m_delayed_preprocess_task = nullptr; } } @@ -1528,7 +1528,7 @@ void ImageReplayer::shut_down(int r) { { Mutex::Locker locker(m_lock); - assert(m_state == STATE_STOPPING); + ceph_assert(m_state == STATE_STOPPING); // if status updates are in-flight, wait for them to complete // before proceeding @@ -1659,7 +1659,7 @@ void ImageReplayer::handle_shut_down(int r) { } if (m_delete_requested && !m_local_image_id.empty()) { - assert(m_remote_image.image_id.empty()); + ceph_assert(m_remote_image.image_id.empty()); dout(0) << "remote image no longer exists: scheduling deletion" << dendl; unregister_asok_hook = true; std::swap(delete_requested, m_delete_requested); @@ -1701,8 +1701,8 @@ void ImageReplayer::handle_shut_down(int r) { std::swap(on_start, m_on_start_finish); std::swap(on_stop, m_on_stop_finish); m_stop_requested = false; - assert(m_delayed_preprocess_task == nullptr); - assert(m_state == STATE_STOPPING); + ceph_assert(m_delayed_preprocess_task == nullptr); + ceph_assert(m_state == STATE_STOPPING); m_state = STATE_STOPPED; } diff --git a/src/tools/rbd_mirror/ImageSync.cc b/src/tools/rbd_mirror/ImageSync.cc index 5e6a802eb5487..fca5dadc7c43d 100644 --- a/src/tools/rbd_mirror/ImageSync.cc +++ b/src/tools/rbd_mirror/ImageSync.cc @@ -66,9 +66,9 @@ ImageSync::ImageSync(I *local_image_ctx, I *remote_image_ctx, template ImageSync::~ImageSync() { - assert(m_image_copy_request == nullptr); - assert(m_image_copy_prog_ctx == nullptr); - assert(m_update_sync_ctx == nullptr); + ceph_assert(m_image_copy_request == nullptr); + ceph_assert(m_image_copy_prog_ctx == nullptr); + ceph_assert(m_update_sync_ctx == nullptr); } template @@ -208,7 +208,7 @@ void ImageSync::send_copy_image() { int r = 0; { RWLock::RLocker snap_locker(m_remote_image_ctx->snap_lock); - assert(!m_client_meta->sync_points.empty()); + ceph_assert(!m_client_meta->sync_points.empty()); auto &sync_point = m_client_meta->sync_points.front(); snap_id_end = m_remote_image_ctx->get_snap_id( cls::rbd::UserSnapshotNamespace(), sync_point.snap_name); @@ -311,7 +311,7 @@ void ImageSync::handle_copy_image_update_progress(uint64_t object_no, template void ImageSync::send_update_sync_point() { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); m_update_sync_ctx = nullptr; diff --git a/src/tools/rbd_mirror/ImageSyncThrottler.cc b/src/tools/rbd_mirror/ImageSyncThrottler.cc index 271a913c4dee1..a3fc8330fdcec 100644 --- a/src/tools/rbd_mirror/ImageSyncThrottler.cc +++ b/src/tools/rbd_mirror/ImageSyncThrottler.cc @@ -42,8 +42,8 @@ ImageSyncThrottler::~ImageSyncThrottler() { g_ceph_context->_conf.remove_observer(this); Mutex::Locker locker(m_lock); - assert(m_inflight_ops.empty()); - assert(m_queue.empty()); + ceph_assert(m_inflight_ops.empty()); + ceph_assert(m_queue.empty()); } template @@ -57,7 +57,7 @@ void ImageSyncThrottler::start_op(const std::string &id, Context *on_start) { dout(20) << "duplicate for already started op " << id << dendl; } else if (m_max_concurrent_syncs == 0 || m_inflight_ops.size() < m_max_concurrent_syncs) { - assert(m_queue.empty()); + ceph_assert(m_queue.empty()); m_inflight_ops.insert(id); dout(20) << "ready to start sync for " << id << " [" << m_inflight_ops.size() << "/" << m_max_concurrent_syncs << "]" diff --git a/src/tools/rbd_mirror/InstanceReplayer.cc b/src/tools/rbd_mirror/InstanceReplayer.cc index 57f70b1c59a06..a2165965f5d23 100644 --- a/src/tools/rbd_mirror/InstanceReplayer.cc +++ b/src/tools/rbd_mirror/InstanceReplayer.cc @@ -44,9 +44,9 @@ InstanceReplayer::InstanceReplayer( template InstanceReplayer::~InstanceReplayer() { - assert(m_image_state_check_task == nullptr); - assert(m_async_op_tracker.empty()); - assert(m_image_replayers.empty()); + ceph_assert(m_image_state_check_task == nullptr); + ceph_assert(m_async_op_tracker.empty()); + ceph_assert(m_image_replayers.empty()); } template @@ -77,7 +77,7 @@ void InstanceReplayer::shut_down() { C_SaferCond shut_down_ctx; shut_down(&shut_down_ctx); int r = shut_down_ctx.wait(); - assert(r == 0); + ceph_assert(r == 0); } template @@ -86,7 +86,7 @@ void InstanceReplayer::shut_down(Context *on_finish) { Mutex::Locker locker(m_lock); - assert(m_on_shut_down == nullptr); + ceph_assert(m_on_shut_down == nullptr); m_on_shut_down = on_finish; Context *ctx = new FunctionContext( @@ -105,7 +105,7 @@ void InstanceReplayer::add_peer(std::string peer_uuid, Mutex::Locker locker(m_lock); auto result = m_peers.insert(Peer(peer_uuid, io_ctx)).second; - assert(result); + ceph_assert(result); } template @@ -137,7 +137,7 @@ void InstanceReplayer::acquire_image(InstanceWatcher *instance_watcher, Mutex::Locker locker(m_lock); - assert(m_on_shut_down == nullptr); + ceph_assert(m_on_shut_down == nullptr); auto it = m_image_replayers.find(global_image_id); if (it == m_image_replayers.end()) { @@ -152,7 +152,7 @@ void InstanceReplayer::acquire_image(InstanceWatcher *instance_watcher, image_replayer)).first; // TODO only a single peer is currently supported - assert(m_peers.size() == 1); + ceph_assert(m_peers.size() == 1); auto peer = *m_peers.begin(); image_replayer->add_peer(peer.peer_uuid, peer.io_ctx); start_image_replayer(image_replayer); @@ -174,7 +174,7 @@ void InstanceReplayer::release_image(const std::string &global_image_id, dout(10) << "global_image_id=" << global_image_id << dendl; Mutex::Locker locker(m_lock); - assert(m_on_shut_down == nullptr); + ceph_assert(m_on_shut_down == nullptr); auto it = m_image_replayers.find(global_image_id); if (it == m_image_replayers.end()) { @@ -202,7 +202,7 @@ void InstanceReplayer::remove_peer_image(const std::string &global_image_id, << "peer_mirror_uuid=" << peer_mirror_uuid << dendl; Mutex::Locker locker(m_lock); - assert(m_on_shut_down == nullptr); + ceph_assert(m_on_shut_down == nullptr); auto it = m_image_replayers.find(global_image_id); if (it != m_image_replayers.end()) { @@ -295,7 +295,7 @@ void InstanceReplayer::flush() template void InstanceReplayer::start_image_replayer( ImageReplayer *image_replayer) { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); std::string global_image_id = image_replayer->get_global_image_id(); if (!image_replayer->is_stopped()) { @@ -416,7 +416,7 @@ template void InstanceReplayer::handle_wait_for_ops(int r) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); Mutex::Locker locker(m_lock); stop_image_replayers(); @@ -426,7 +426,7 @@ template void InstanceReplayer::stop_image_replayers() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_threads->work_queue, create_context_callback, @@ -443,19 +443,19 @@ template void InstanceReplayer::handle_stop_image_replayers(int r) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); Context *on_finish = nullptr; { Mutex::Locker locker(m_lock); for (auto &it : m_image_replayers) { - assert(it.second->is_stopped()); + ceph_assert(it.second->is_stopped()); it.second->destroy(); } m_image_replayers.clear(); - assert(m_on_shut_down != nullptr); + ceph_assert(m_on_shut_down != nullptr); std::swap(on_finish, m_on_shut_down); } on_finish->complete(r); @@ -471,18 +471,18 @@ void InstanceReplayer::cancel_image_state_check_task() { dout(10) << m_image_state_check_task << dendl; bool canceled = m_threads->timer->cancel_event(m_image_state_check_task); - assert(canceled); + ceph_assert(canceled); m_image_state_check_task = nullptr; } template void InstanceReplayer::schedule_image_state_check_task() { - assert(m_threads->timer_lock.is_locked()); - assert(m_image_state_check_task == nullptr); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_image_state_check_task == nullptr); m_image_state_check_task = new FunctionContext( [this](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_image_state_check_task = nullptr; schedule_image_state_check_task(); queue_start_image_replayers(); diff --git a/src/tools/rbd_mirror/InstanceWatcher.cc b/src/tools/rbd_mirror/InstanceWatcher.cc index 2d58d6bc70073..7347816cf6eb0 100644 --- a/src/tools/rbd_mirror/InstanceWatcher.cc +++ b/src/tools/rbd_mirror/InstanceWatcher.cc @@ -71,7 +71,7 @@ struct C_RemoveInstanceRequest : public Context { void finish(int r) override { dout(10) << "C_RemoveInstanceRequest: " << this << " " << __func__ << ": r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); on_finish->complete(r); } @@ -101,10 +101,10 @@ struct InstanceWatcher::C_NotifyInstanceRequest : public Context { << ": instance_watcher=" << instance_watcher << ", instance_id=" << instance_id << ", request_id=" << request_id << dendl; - assert(instance_watcher->m_lock.is_locked()); + ceph_assert(instance_watcher->m_lock.is_locked()); if (!send_to_leader) { - assert((!instance_id.empty())); + ceph_assert((!instance_id.empty())); notifier.reset(new librbd::watcher::Notifier( instance_watcher->m_work_queue, instance_watcher->m_ioctx, @@ -114,13 +114,13 @@ struct InstanceWatcher::C_NotifyInstanceRequest : public Context { instance_watcher->m_notify_op_tracker.start_op(); auto result = instance_watcher->m_notify_ops.insert( std::make_pair(instance_id, this)).second; - assert(result); + ceph_assert(result); } void send() { dout(10) << "C_NotifyInstanceRequest: " << this << " " << __func__ << dendl; - assert(instance_watcher->m_lock.is_locked()); + ceph_assert(instance_watcher->m_lock.is_locked()); if (canceling) { dout(10) << "C_NotifyInstanceRequest: " << this << " " << __func__ @@ -140,13 +140,13 @@ struct InstanceWatcher::C_NotifyInstanceRequest : public Context { if (instance_watcher->m_leader_instance_id != instance_id) { auto count = instance_watcher->m_notify_ops.erase( std::make_pair(instance_id, this)); - assert(count > 0); + ceph_assert(count > 0); instance_id = instance_watcher->m_leader_instance_id; auto result = instance_watcher->m_notify_ops.insert( std::make_pair(instance_id, this)).second; - assert(result); + ceph_assert(result); notifier.reset(new librbd::watcher::Notifier( instance_watcher->m_work_queue, @@ -163,7 +163,7 @@ struct InstanceWatcher::C_NotifyInstanceRequest : public Context { void cancel() { dout(10) << "C_NotifyInstanceRequest: " << this << " " << __func__ << dendl; - assert(instance_watcher->m_lock.is_locked()); + ceph_assert(instance_watcher->m_lock.is_locked()); canceling = true; instance_watcher->unsuspend_notify_request(this); @@ -235,7 +235,7 @@ struct InstanceWatcher::C_NotifyInstanceRequest : public Context { Mutex::Locker locker(instance_watcher->m_lock); auto result = instance_watcher->m_notify_ops.erase( std::make_pair(instance_id, this)); - assert(result > 0); + ceph_assert(result > 0); instance_watcher->m_notify_op_tracker.finish_op(); } @@ -294,7 +294,7 @@ void InstanceWatcher::get_instances(librados::IoCtx &io_ctx, librados::AioCompletion *aio_comp = create_rados_callback(ctx); int r = io_ctx.aio_operate(RBD_MIRROR_LEADER, aio_comp, &op, &ctx->out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -331,11 +331,11 @@ InstanceWatcher::InstanceWatcher(librados::IoCtx &io_ctx, template InstanceWatcher::~InstanceWatcher() { - assert(m_notify_ops.empty()); - assert(m_notify_op_tracker.empty()); - assert(m_suspended_ops.empty()); - assert(m_inflight_sync_reqs.empty()); - assert(m_image_sync_throttler == nullptr); + ceph_assert(m_notify_ops.empty()); + ceph_assert(m_notify_op_tracker.empty()); + ceph_assert(m_suspended_ops.empty()); + ceph_assert(m_inflight_sync_reqs.empty()); + ceph_assert(m_image_sync_throttler == nullptr); m_instance_lock->destroy(); } @@ -352,7 +352,7 @@ void InstanceWatcher::init(Context *on_finish) { Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; m_ret_val = 0; @@ -364,7 +364,7 @@ void InstanceWatcher::shut_down() { C_SaferCond shut_down_ctx; shut_down(&shut_down_ctx); int r = shut_down_ctx.wait(); - assert(r == 0); + ceph_assert(r == 0); } template @@ -373,7 +373,7 @@ void InstanceWatcher::shut_down(Context *on_finish) { Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; m_ret_val = 0; @@ -386,7 +386,7 @@ void InstanceWatcher::remove(Context *on_finish) { Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; m_ret_val = 0; @@ -402,7 +402,7 @@ void InstanceWatcher::notify_image_acquire( Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); if (instance_id == m_instance_id) { handle_image_acquire(global_image_id, on_notify_ack); @@ -426,7 +426,7 @@ void InstanceWatcher::notify_image_release( Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); if (instance_id == m_instance_id) { handle_image_release(global_image_id, on_notify_ack); @@ -450,7 +450,7 @@ void InstanceWatcher::notify_peer_image_removed( << "peer_mirror_uuid=" << peer_mirror_uuid << dendl; Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); if (instance_id == m_instance_id) { handle_peer_image_removed(global_image_id, peer_mirror_uuid, on_notify_ack); @@ -472,7 +472,7 @@ void InstanceWatcher::notify_sync_request(const std::string &sync_id, Mutex::Locker locker(m_lock); - assert(m_inflight_sync_reqs.count(sync_id) == 0); + ceph_assert(m_inflight_sync_reqs.count(sync_id) == 0); uint64_t request_id = ++m_request_seq; @@ -504,7 +504,7 @@ bool InstanceWatcher::cancel_sync_request(const std::string &sync_id) { return false; } - assert(sync_ctx->req != nullptr); + ceph_assert(sync_ctx->req != nullptr); sync_ctx->req->cancel(); return true; } @@ -544,13 +544,13 @@ template void InstanceWatcher::notify_sync_complete(const Mutex&, const std::string &sync_id) { dout(10) << "sync_id=" << sync_id << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); auto it = m_inflight_sync_reqs.find(sync_id); - assert(it != m_inflight_sync_reqs.end()); + ceph_assert(it != m_inflight_sync_reqs.end()); auto sync_ctx = it->second; - assert(sync_ctx->req == nullptr); + ceph_assert(sync_ctx->req == nullptr); m_inflight_sync_reqs.erase(it); m_work_queue->queue(sync_ctx, 0); @@ -564,8 +564,8 @@ void InstanceWatcher::handle_notify_sync_request(C_SyncRequest *sync_ctx, Context *on_start = nullptr; { Mutex::Locker locker(m_lock); - assert(sync_ctx->req != nullptr); - assert(sync_ctx->on_start != nullptr); + ceph_assert(sync_ctx->req != nullptr); + ceph_assert(sync_ctx->on_start != nullptr); if (sync_ctx->req->canceling) { r = -ECANCELED; @@ -608,7 +608,7 @@ void InstanceWatcher::handle_acquire_leader() { Mutex::Locker locker(m_lock); - assert(m_image_sync_throttler == nullptr); + ceph_assert(m_image_sync_throttler == nullptr); m_image_sync_throttler = ImageSyncThrottler::create(); m_leader_instance_id = m_instance_id; @@ -621,7 +621,7 @@ void InstanceWatcher::handle_release_leader() { Mutex::Locker locker(m_lock); - assert(m_image_sync_throttler != nullptr); + ceph_assert(m_image_sync_throttler != nullptr); m_leader_instance_id.clear(); @@ -660,7 +660,7 @@ void InstanceWatcher::cancel_notify_requests( template void InstanceWatcher::register_instance() { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); dout(10) << dendl; @@ -670,7 +670,7 @@ void InstanceWatcher::register_instance() { InstanceWatcher, &InstanceWatcher::handle_register_instance>(this); int r = m_ioctx.aio_operate(RBD_MIRROR_LEADER, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -699,7 +699,7 @@ template void InstanceWatcher::create_instance_object() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); librados::ObjectWriteOperation op; op.create(true); @@ -708,7 +708,7 @@ void InstanceWatcher::create_instance_object() { InstanceWatcher, &InstanceWatcher::handle_create_instance_object>(this); int r = m_ioctx.aio_operate(m_oid, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -734,7 +734,7 @@ template void InstanceWatcher::register_watch() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -765,7 +765,7 @@ template void InstanceWatcher::acquire_lock() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -801,7 +801,7 @@ template void InstanceWatcher::release_lock() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -827,7 +827,7 @@ template void InstanceWatcher::unregister_watch() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -851,7 +851,7 @@ void InstanceWatcher::handle_unregister_watch(int r) { template void InstanceWatcher::remove_instance_object() { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); dout(10) << dendl; @@ -862,7 +862,7 @@ void InstanceWatcher::remove_instance_object() { InstanceWatcher, &InstanceWatcher::handle_remove_instance_object>(this); int r = m_ioctx.aio_operate(m_oid, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -887,7 +887,7 @@ template void InstanceWatcher::unregister_instance() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); librados::ObjectWriteOperation op; librbd::cls_client::mirror_instances_remove(&op, m_instance_id); @@ -895,7 +895,7 @@ void InstanceWatcher::unregister_instance() { InstanceWatcher, &InstanceWatcher::handle_unregister_instance>(this); int r = m_ioctx.aio_operate(RBD_MIRROR_LEADER, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -915,7 +915,7 @@ template void InstanceWatcher::wait_for_notify_ops() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); for (auto op : m_notify_ops) { op.second->cancel(); @@ -932,13 +932,13 @@ template void InstanceWatcher::handle_wait_for_notify_ops(int r) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); Context *on_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_notify_ops.empty()); + ceph_assert(m_notify_ops.empty()); std::swap(on_finish, m_on_finish); r = m_ret_val; @@ -950,7 +950,7 @@ template void InstanceWatcher::get_instance_locker() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -980,7 +980,7 @@ template void InstanceWatcher::break_instance_lock() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -1010,10 +1010,10 @@ template void InstanceWatcher::suspend_notify_request(C_NotifyInstanceRequest *req) { dout(10) << req << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); auto result = m_suspended_ops.insert(req).second; - assert(result); + ceph_assert(result); } template @@ -1021,7 +1021,7 @@ bool InstanceWatcher::unsuspend_notify_request( C_NotifyInstanceRequest *req) { dout(10) << req << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); auto result = m_suspended_ops.erase(req); if (result == 0) { @@ -1036,7 +1036,7 @@ template void InstanceWatcher::unsuspend_notify_requests() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); std::set suspended_ops; std::swap(m_suspended_ops, suspended_ops); @@ -1087,7 +1087,7 @@ void InstanceWatcher::complete_request(const std::string &instance_id, Mutex::Locker locker(m_lock); Request request(instance_id, request_id); auto it = m_requests.find(request); - assert(it != m_requests.end()); + ceph_assert(it != m_requests.end()); on_notify_ack = it->on_notify_ack; m_requests.erase(it); } diff --git a/src/tools/rbd_mirror/Instances.cc b/src/tools/rbd_mirror/Instances.cc index c1646f42ea065..c7cea7094df00 100644 --- a/src/tools/rbd_mirror/Instances.cc +++ b/src/tools/rbd_mirror/Instances.cc @@ -42,7 +42,7 @@ void Instances::init(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; get_instances(); } @@ -52,7 +52,7 @@ void Instances::shut_down(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; Context *ctx = new FunctionContext( @@ -71,7 +71,7 @@ void Instances::unblock_listener() { dout(5) << dendl; Mutex::Locker locker(m_lock); - assert(m_listener_blocked); + ceph_assert(m_listener_blocked); m_listener_blocked = false; InstanceIds added_instance_ids; @@ -185,7 +185,7 @@ template void Instances::get_instances() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_context_callback< Instances, &Instances::handle_get_instances>(this); @@ -215,7 +215,7 @@ template void Instances::wait_for_ops() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_threads->work_queue, create_context_callback< @@ -228,7 +228,7 @@ template void Instances::handle_wait_for_ops(int r) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); Context *on_finish = nullptr; { @@ -240,7 +240,7 @@ void Instances::handle_wait_for_ops(int r) { template void Instances::remove_instances(const utime_t& time) { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); InstanceIds instance_ids; for (auto& instance_pair : m_instances) { @@ -254,7 +254,7 @@ void Instances::remove_instances(const utime_t& time) { instance_ids.push_back(instance_pair.first); } } - assert(!instance_ids.empty()); + ceph_assert(!instance_ids.empty()); dout(10) << "instance_ids=" << instance_ids << dendl; Context* ctx = new FunctionContext([this, instance_ids](int r) { @@ -279,7 +279,7 @@ void Instances::handle_remove_instances( Mutex::Locker locker(m_lock); dout(10) << "r=" << r << ", instance_ids=" << instance_ids << dendl; - assert(r == 0); + ceph_assert(r == 0); // fire removed notification now that instaces have been blacklisted m_threads->work_queue->queue( @@ -292,8 +292,8 @@ void Instances::handle_remove_instances( template void Instances::cancel_remove_task() { - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (m_timer_task == nullptr) { return; @@ -302,7 +302,7 @@ void Instances::cancel_remove_task() { dout(10) << dendl; bool canceled = m_threads->timer->cancel_event(m_timer_task); - assert(canceled); + ceph_assert(canceled); m_timer_task = nullptr; } @@ -342,7 +342,7 @@ void Instances::schedule_remove_task(const utime_t& time) { // schedule a time to fire when the oldest instance should be removed m_timer_task = new FunctionContext( [this, oldest_time](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); Mutex::Locker locker(m_lock); m_timer_task = nullptr; diff --git a/src/tools/rbd_mirror/LeaderWatcher.cc b/src/tools/rbd_mirror/LeaderWatcher.cc index 5c4287add83fd..0e7cd20405ba6 100644 --- a/src/tools/rbd_mirror/LeaderWatcher.cc +++ b/src/tools/rbd_mirror/LeaderWatcher.cc @@ -40,9 +40,9 @@ LeaderWatcher::LeaderWatcher(Threads *threads, librados::IoCtx &io_ctx, template LeaderWatcher::~LeaderWatcher() { - assert(m_status_watcher == nullptr); - assert(m_instances == nullptr); - assert(m_timer_task == nullptr); + ceph_assert(m_status_watcher == nullptr); + ceph_assert(m_instances == nullptr); + ceph_assert(m_timer_task == nullptr); delete m_leader_lock; } @@ -65,7 +65,7 @@ void LeaderWatcher::init(Context *on_finish) { Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; create_leader_object(); @@ -75,7 +75,7 @@ template void LeaderWatcher::create_leader_object() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); librados::ObjectWriteOperation op; op.create(false); @@ -83,7 +83,7 @@ void LeaderWatcher::create_leader_object() { librados::AioCompletion *aio_comp = create_rados_callback< LeaderWatcher, &LeaderWatcher::handle_create_leader_object>(this); int r = m_ioctx.aio_operate(m_oid, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -112,7 +112,7 @@ template void LeaderWatcher::register_watch() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -130,7 +130,7 @@ void LeaderWatcher::handle_register_watch(int r) { Mutex::Locker locker(m_lock); derr << "error registering leader watcher for " << m_oid << " object: " << cpp_strerror(r) << dendl; - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(on_finish, m_on_finish); } else { Mutex::Locker locker(m_lock); @@ -146,7 +146,7 @@ void LeaderWatcher::shut_down() { C_SaferCond shut_down_ctx; shut_down(&shut_down_ctx); int r = shut_down_ctx.wait(); - assert(r == 0); + ceph_assert(r == 0); } template @@ -156,7 +156,7 @@ void LeaderWatcher::shut_down(Context *on_finish) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(m_on_shut_down_finish == nullptr); + ceph_assert(m_on_shut_down_finish == nullptr); m_on_shut_down_finish = on_finish; cancel_timer_task(); shut_down_leader_lock(); @@ -166,7 +166,7 @@ template void LeaderWatcher::shut_down_leader_lock() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -192,7 +192,7 @@ template void LeaderWatcher::unregister_watch() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -226,11 +226,11 @@ template void LeaderWatcher::handle_wait_for_tasks() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(m_on_shut_down_finish != nullptr); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_on_shut_down_finish != nullptr); - assert(!m_timer_op_tracker.empty()); + ceph_assert(!m_timer_op_tracker.empty()); m_timer_op_tracker.finish_op(); auto ctx = new FunctionContext([this](int r) { @@ -238,7 +238,7 @@ void LeaderWatcher::handle_wait_for_tasks() { { // ensure lock isn't held when completing shut down Mutex::Locker locker(m_lock); - assert(m_on_shut_down_finish != nullptr); + ceph_assert(m_on_shut_down_finish != nullptr); on_finish = m_on_shut_down_finish; } on_finish->complete(0); @@ -255,7 +255,7 @@ bool LeaderWatcher::is_leader() const { template bool LeaderWatcher::is_leader(Mutex &lock) const { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); bool leader = m_leader_lock->is_leader(); dout(10) << leader << dendl; @@ -271,7 +271,7 @@ bool LeaderWatcher::is_releasing_leader() const { template bool LeaderWatcher::is_releasing_leader(Mutex &lock) const { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); bool releasing = m_leader_lock->is_releasing_leader(); dout(10) << releasing << dendl; @@ -323,8 +323,8 @@ void LeaderWatcher::list_instances(std::vector *instance_ids) { template void LeaderWatcher::cancel_timer_task() { - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (m_timer_task == nullptr) { return; @@ -332,7 +332,7 @@ void LeaderWatcher::cancel_timer_task() { dout(10) << m_timer_task << dendl; bool canceled = m_threads->timer->cancel_event(m_timer_task); - assert(canceled); + ceph_assert(canceled); m_timer_task = nullptr; } @@ -341,8 +341,8 @@ void LeaderWatcher::schedule_timer_task(const std::string &name, int delay_factor, bool leader, TimerCallback timer_callback, bool shutting_down) { - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (!shutting_down && m_on_shut_down_finish != nullptr) { return; @@ -352,7 +352,7 @@ void LeaderWatcher::schedule_timer_task(const std::string &name, m_timer_task = new FunctionContext( [this, leader, timer_callback](int r) { - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); m_timer_task = nullptr; if (m_timer_op_tracker.empty()) { @@ -384,9 +384,9 @@ void LeaderWatcher::execute_timer_task(bool leader, TimerCallback timer_callback) { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(m_timer_op_tracker.empty()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_timer_op_tracker.empty()); if (is_leader(m_lock) != leader) { return; @@ -412,7 +412,7 @@ void LeaderWatcher::handle_post_acquire_leader_lock(int r, } Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; m_ret_val = 0; @@ -424,7 +424,7 @@ void LeaderWatcher::handle_pre_release_leader_lock(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; m_ret_val = 0; @@ -442,7 +442,7 @@ void LeaderWatcher::handle_post_release_leader_lock(int r, } Mutex::Locker locker(m_lock); - assert(m_on_finish == nullptr); + ceph_assert(m_on_finish == nullptr); m_on_finish = on_finish; notify_lock_released(); @@ -452,9 +452,9 @@ template void LeaderWatcher::break_leader_lock() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(!m_timer_op_tracker.empty()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(!m_timer_op_tracker.empty()); if (m_locker.cookie.empty()) { get_locker(); @@ -474,7 +474,7 @@ void LeaderWatcher::handle_break_leader_lock(int r) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(!m_timer_op_tracker.empty()); + ceph_assert(!m_timer_op_tracker.empty()); if (m_leader_lock->is_shutdown()) { dout(10) << "canceling due to shutdown" << dendl; @@ -499,8 +499,8 @@ void LeaderWatcher::schedule_get_locker(bool reset_leader, uint32_t delay_factor) { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); if (reset_leader) { m_locker = {}; @@ -515,9 +515,9 @@ template void LeaderWatcher::get_locker() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(!m_timer_op_tracker.empty()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(!m_timer_op_tracker.empty()); C_GetLocker *get_locker_ctx = new C_GetLocker(this); Context *ctx = create_async_context_callback(m_work_queue, get_locker_ctx); @@ -532,7 +532,7 @@ void LeaderWatcher::handle_get_locker(int r, Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker mutex_locker(m_lock); - assert(!m_timer_op_tracker.empty()); + ceph_assert(!m_timer_op_tracker.empty()); if (m_leader_lock->is_shutdown()) { dout(10) << "canceling due to shutdown" << dendl; @@ -601,8 +601,8 @@ template void LeaderWatcher::schedule_acquire_leader_lock(uint32_t delay_factor) { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); schedule_timer_task("acquire leader lock", delay_factor * @@ -612,9 +612,9 @@ void LeaderWatcher::schedule_acquire_leader_lock(uint32_t delay_factor) { template void LeaderWatcher::acquire_leader_lock() { - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(!m_timer_op_tracker.empty()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(!m_timer_op_tracker.empty()); ++m_acquire_attempts; dout(10) << "acquire_attempts=" << m_acquire_attempts << dendl; @@ -631,7 +631,7 @@ void LeaderWatcher::handle_acquire_leader_lock(int r) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(!m_timer_op_tracker.empty()); + ceph_assert(!m_timer_op_tracker.empty()); if (m_leader_lock->is_shutdown()) { dout(10) << "canceling due to shutdown" << dendl; @@ -667,7 +667,7 @@ template void LeaderWatcher::release_leader_lock() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -695,8 +695,8 @@ template void LeaderWatcher::init_status_watcher() { dout(10) << dendl; - assert(m_lock.is_locked()); - assert(m_status_watcher == nullptr); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_status_watcher == nullptr); m_status_watcher = MirrorStatusWatcher::create(m_ioctx, m_work_queue); @@ -722,7 +722,7 @@ void LeaderWatcher::handle_init_status_watcher(int r) { schedule_acquire_leader_lock(0); } - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(on_finish, m_on_finish); } @@ -733,8 +733,8 @@ template void LeaderWatcher::shut_down_status_watcher() { dout(10) << dendl; - assert(m_lock.is_locked()); - assert(m_status_watcher != nullptr); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_status_watcher != nullptr); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback, @@ -763,8 +763,8 @@ template void LeaderWatcher::init_instances() { dout(10) << dendl; - assert(m_lock.is_locked()); - assert(m_instances == nullptr); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_instances == nullptr); m_instances = Instances::create(m_threads, m_ioctx, m_instance_id, m_instances_listener); @@ -786,7 +786,7 @@ void LeaderWatcher::handle_init_instances(int r) { m_instances->destroy(); m_instances = nullptr; - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(m_on_finish, on_finish); } else { Mutex::Locker locker(m_lock); @@ -801,8 +801,8 @@ template void LeaderWatcher::shut_down_instances() { dout(10) << dendl; - assert(m_lock.is_locked()); - assert(m_instances != nullptr); + ceph_assert(m_lock.is_locked()); + ceph_assert(m_instances != nullptr); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback, @@ -814,7 +814,7 @@ void LeaderWatcher::shut_down_instances() { template void LeaderWatcher::handle_shut_down_instances(int r) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); Context *on_finish = nullptr; { @@ -823,7 +823,7 @@ void LeaderWatcher::handle_shut_down_instances(int r) { m_instances->destroy(); m_instances = nullptr; - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(m_on_finish, on_finish); } on_finish->complete(r); @@ -833,7 +833,7 @@ template void LeaderWatcher::notify_listener() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_async_context_callback( m_work_queue, create_context_callback< @@ -875,7 +875,7 @@ template void LeaderWatcher::notify_lock_acquired() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_context_callback< LeaderWatcher, &LeaderWatcher::handle_notify_lock_acquired>(this); @@ -899,7 +899,7 @@ void LeaderWatcher::handle_notify_lock_acquired(int r) { m_ret_val = r; } - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(m_on_finish, on_finish); // listener should be ready for instance add/remove events now @@ -912,7 +912,7 @@ template void LeaderWatcher::notify_lock_released() { dout(10) << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); Context *ctx = create_context_callback< LeaderWatcher, &LeaderWatcher::handle_notify_lock_released>(this); @@ -935,7 +935,7 @@ void LeaderWatcher::handle_notify_lock_released(int r) { << dendl; } - assert(m_on_finish != nullptr); + ceph_assert(m_on_finish != nullptr); std::swap(m_on_finish, on_finish); } on_finish->complete(r); @@ -945,9 +945,9 @@ template void LeaderWatcher::notify_heartbeat() { dout(10) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_lock.is_locked()); - assert(!m_timer_op_tracker.empty()); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_lock.is_locked()); + ceph_assert(!m_timer_op_tracker.empty()); if (!is_leader(m_lock)) { dout(5) << "not leader, canceling" << dendl; @@ -971,7 +971,7 @@ void LeaderWatcher::handle_notify_heartbeat(int r) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(!m_timer_op_tracker.empty()); + ceph_assert(!m_timer_op_tracker.empty()); m_timer_op_tracker.finish_op(); if (m_leader_lock->is_shutdown()) { diff --git a/src/tools/rbd_mirror/Mirror.cc b/src/tools/rbd_mirror/Mirror.cc index 404f99bf1bc40..fc6a114f42b73 100644 --- a/src/tools/rbd_mirror/Mirror.cc +++ b/src/tools/rbd_mirror/Mirror.cc @@ -181,7 +181,7 @@ public: bool call(std::string_view command, const cmdmap_t& cmdmap, std::string_view format, bufferlist& out) override { Commands::const_iterator i = commands.find(command); - assert(i != commands.end()); + ceph_assert(i != commands.end()); Formatter *f = Formatter::create(format); stringstream ss; bool r = i->second->call(f, &ss); @@ -374,7 +374,7 @@ void Mirror::release_leader() void Mirror::update_pool_replayers(const PoolPeers &pool_peers) { dout(20) << "enter" << dendl; - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); // remove stale pool replayers before creating new pool replayers for (auto it = m_pool_replayers.begin(); it != m_pool_replayers.end();) { diff --git a/src/tools/rbd_mirror/MirrorStatusWatcher.cc b/src/tools/rbd_mirror/MirrorStatusWatcher.cc index ed752ba04dffc..b935bc5cd0f09 100644 --- a/src/tools/rbd_mirror/MirrorStatusWatcher.cc +++ b/src/tools/rbd_mirror/MirrorStatusWatcher.cc @@ -47,7 +47,7 @@ void MirrorStatusWatcher::init(Context *on_finish) { librados::AioCompletion *aio_comp = create_rados_callback(on_finish); int r = m_ioctx.aio_operate(RBD_MIRRORING, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/PoolReplayer.cc b/src/tools/rbd_mirror/PoolReplayer.cc index 3f25b5f659c7f..e64f87370c076 100644 --- a/src/tools/rbd_mirror/PoolReplayer.cc +++ b/src/tools/rbd_mirror/PoolReplayer.cc @@ -205,7 +205,7 @@ public: bool call(std::string_view command, const cmdmap_t& cmdmap, std::string_view format, bufferlist& out) override { auto i = commands.find(command); - assert(i != commands.end()); + ceph_assert(i != commands.end()); Formatter *f = Formatter::create(format); stringstream ss; bool r = i->second->call(f, &ss); @@ -270,7 +270,7 @@ bool PoolReplayer::is_running() const { template void PoolReplayer::init() { - assert(!m_pool_replayer_thread.is_started()); + ceph_assert(!m_pool_replayer_thread.is_started()); // reset state m_stopping = false; @@ -389,10 +389,10 @@ void PoolReplayer::shut_down() { m_instance_watcher.reset(); m_instance_replayer.reset(); - assert(!m_image_map); - assert(!m_image_deleter); - assert(!m_local_pool_watcher); - assert(!m_remote_pool_watcher); + ceph_assert(!m_image_map); + ceph_assert(!m_image_deleter); + ceph_assert(!m_local_pool_watcher); + ceph_assert(!m_remote_pool_watcher); m_local_rados.reset(); m_remote_rados.reset(); } @@ -489,7 +489,7 @@ int PoolReplayer::init_rados(const std::string &cluster_name, cct->_conf.complain_about_parse_errors(cct); r = (*rados_ref)->init_with_context(cct); - assert(r == 0); + ceph_assert(r == 0); cct->put(); r = (*rados_ref)->connect(); @@ -737,7 +737,7 @@ void PoolReplayer::init_image_map(Context *on_finish) { dout(5) << dendl; Mutex::Locker locker(m_lock); - assert(!m_image_map); + ceph_assert(!m_image_map); m_image_map.reset(ImageMap::create(m_local_io_ctx, m_threads, m_instance_watcher->get_instance_id(), m_image_map_listener)); @@ -769,7 +769,7 @@ void PoolReplayer::init_local_pool_watcher(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(!m_local_pool_watcher); + ceph_assert(!m_local_pool_watcher); m_local_pool_watcher.reset(PoolWatcher::create( m_threads, m_local_io_ctx, m_local_pool_watcher_listener)); @@ -803,7 +803,7 @@ void PoolReplayer::init_remote_pool_watcher(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(!m_remote_pool_watcher); + ceph_assert(!m_remote_pool_watcher); m_remote_pool_watcher.reset(PoolWatcher::create( m_threads, m_remote_io_ctx, m_remote_pool_watcher_listener)); @@ -835,7 +835,7 @@ void PoolReplayer::init_image_deleter(Context *on_finish) { dout(10) << dendl; Mutex::Locker locker(m_lock); - assert(!m_image_deleter); + ceph_assert(!m_image_deleter); on_finish = new FunctionContext([this, on_finish](int r) { handle_init_image_deleter(r, on_finish); @@ -889,7 +889,7 @@ void PoolReplayer::handle_shut_down_image_deleter( { Mutex::Locker locker(m_lock); - assert(m_image_deleter); + ceph_assert(m_image_deleter); m_image_deleter.reset(); } @@ -928,7 +928,7 @@ void PoolReplayer::handle_shut_down_pool_watchers( { Mutex::Locker locker(m_lock); - assert(m_local_pool_watcher); + ceph_assert(m_local_pool_watcher); m_local_pool_watcher.reset(); if (m_remote_pool_watcher) { @@ -955,7 +955,7 @@ void PoolReplayer::wait_for_update_ops(Context *on_finish) { template void PoolReplayer::handle_wait_for_update_ops(int r, Context *on_finish) { dout(10) << "r=" << r << dendl; - assert(r == 0); + ceph_assert(r == 0); shut_down_image_map(on_finish); } @@ -987,7 +987,7 @@ void PoolReplayer::handle_shut_down_image_map(int r, Context *on_finish) { } Mutex::Locker locker(m_lock); - assert(m_image_map); + ceph_assert(m_image_map); m_image_map.reset(); m_instance_replayer->release_all(on_finish); @@ -1028,7 +1028,7 @@ void PoolReplayer::handle_remove_image(const std::string &mirror_uuid, const std::string &global_image_id, const std::string &instance_id, Context* on_finish) { - assert(!mirror_uuid.empty()); + ceph_assert(!mirror_uuid.empty()); dout(5) << "mirror_uuid=" << mirror_uuid << ", " << "global_image_id=" << global_image_id << ", " << "instance_id=" << instance_id << dendl; @@ -1045,7 +1045,7 @@ void PoolReplayer::handle_instances_added(const InstanceIds &instance_ids) { return; } - assert(m_image_map); + ceph_assert(m_image_map); m_image_map->update_instances_added(instance_ids); } @@ -1058,7 +1058,7 @@ void PoolReplayer::handle_instances_removed( return; } - assert(m_image_map); + ceph_assert(m_image_map); m_image_map->update_instances_removed(instance_ids); } diff --git a/src/tools/rbd_mirror/PoolWatcher.cc b/src/tools/rbd_mirror/PoolWatcher.cc index e619ea61cac52..9b975b9cc0004 100644 --- a/src/tools/rbd_mirror/PoolWatcher.cc +++ b/src/tools/rbd_mirror/PoolWatcher.cc @@ -95,7 +95,7 @@ void PoolWatcher::init(Context *on_finish) { Mutex::Locker locker(m_lock); m_on_init_finish = on_finish; - assert(!m_refresh_in_progress); + ceph_assert(!m_refresh_in_progress); m_refresh_in_progress = true; } @@ -111,7 +111,7 @@ void PoolWatcher::shut_down(Context *on_finish) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(!m_shutting_down); + ceph_assert(!m_shutting_down); m_shutting_down = true; if (m_timer_ctx != nullptr) { m_threads->timer->cancel_event(m_timer_ctx); @@ -129,8 +129,8 @@ template void PoolWatcher::register_watcher() { { Mutex::Locker locker(m_lock); - assert(m_image_ids_invalid); - assert(m_refresh_in_progress); + ceph_assert(m_image_ids_invalid); + ceph_assert(m_refresh_in_progress); } // if the watch registration is in-flight, let the watcher @@ -155,8 +155,8 @@ void PoolWatcher::handle_register_watcher(int r) { { Mutex::Locker locker(m_lock); - assert(m_image_ids_invalid); - assert(m_refresh_in_progress); + ceph_assert(m_image_ids_invalid); + ceph_assert(m_refresh_in_progress); if (r < 0) { m_refresh_in_progress = false; } @@ -210,8 +210,8 @@ void PoolWatcher::refresh_images() { { Mutex::Locker locker(m_lock); - assert(m_image_ids_invalid); - assert(m_refresh_in_progress); + ceph_assert(m_image_ids_invalid); + ceph_assert(m_refresh_in_progress); // clear all pending notification events since we need to perform // a full image list refresh @@ -237,8 +237,8 @@ void PoolWatcher::handle_refresh_images(int r) { Context *on_init_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_image_ids_invalid); - assert(m_refresh_in_progress); + ceph_assert(m_image_ids_invalid); + ceph_assert(m_refresh_in_progress); if (r >= 0) { m_pending_image_ids = std::move(m_refresh_image_ids); @@ -269,7 +269,7 @@ void PoolWatcher::handle_refresh_images(int r) { m_async_op_tracker.finish_op(); if (on_init_finish != nullptr) { - assert(r == -EBLACKLISTED); + ceph_assert(r == -EBLACKLISTED); on_init_finish->complete(r); } } @@ -285,7 +285,7 @@ void PoolWatcher::get_mirror_uuid() { librados::AioCompletion *aio_comp = create_rados_callback< PoolWatcher, &PoolWatcher::handle_get_mirror_uuid>(this); int r = m_remote_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -298,8 +298,8 @@ void PoolWatcher::handle_get_mirror_uuid(int r) { Context *on_init_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_image_ids_invalid); - assert(m_refresh_in_progress); + ceph_assert(m_image_ids_invalid); + ceph_assert(m_refresh_in_progress); m_refresh_in_progress = false; m_pending_mirror_uuid = ""; @@ -413,13 +413,13 @@ void PoolWatcher::handle_image_updated(const std::string &remote_image_id, template void PoolWatcher::process_refresh_images() { - assert(m_threads->timer_lock.is_locked()); - assert(m_timer_ctx != nullptr); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_timer_ctx != nullptr); m_timer_ctx = nullptr; { Mutex::Locker locker(m_lock); - assert(!m_refresh_in_progress); + ceph_assert(!m_refresh_in_progress); m_refresh_in_progress = true; m_deferred_refresh = false; } @@ -435,7 +435,7 @@ void PoolWatcher::process_refresh_images() { template void PoolWatcher::schedule_listener() { - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); m_pending_updates = true; if (m_shutting_down || m_image_ids_invalid || m_notify_listener_in_progress) { return; @@ -462,7 +462,7 @@ void PoolWatcher::notify_listener() { ImageIds removed_image_ids; { Mutex::Locker locker(m_lock); - assert(m_notify_listener_in_progress); + ceph_assert(m_notify_listener_in_progress); // if the mirror uuid is updated, treat it as the removal of all // images in the pool @@ -486,7 +486,7 @@ void PoolWatcher::notify_listener() { { Mutex::Locker locker(m_lock); - assert(m_notify_listener_in_progress); + ceph_assert(m_notify_listener_in_progress); // if the watch failed while we didn't own the lock, we are going // to need to perform a full refresh diff --git a/src/tools/rbd_mirror/ServiceDaemon.cc b/src/tools/rbd_mirror/ServiceDaemon.cc index 5b8a87ca136a3..f3b549b860c10 100644 --- a/src/tools/rbd_mirror/ServiceDaemon.cc +++ b/src/tools/rbd_mirror/ServiceDaemon.cc @@ -208,7 +208,7 @@ void ServiceDaemon::schedule_update_status() { template void ServiceDaemon::update_status() { dout(20) << dendl; - assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_threads->timer_lock.is_locked()); ceph::JSONFormatter f; { diff --git a/src/tools/rbd_mirror/image_deleter/RemoveRequest.cc b/src/tools/rbd_mirror/image_deleter/RemoveRequest.cc index c2bc347199d2a..b537f719765b2 100644 --- a/src/tools/rbd_mirror/image_deleter/RemoveRequest.cc +++ b/src/tools/rbd_mirror/image_deleter/RemoveRequest.cc @@ -46,7 +46,7 @@ void RemoveRequest::get_snap_context() { RemoveRequest, &RemoveRequest::handle_get_snap_context>(this); m_out_bl.clear(); int r = m_io_ctx.aio_operate(header_oid, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_deleter/TrashMoveRequest.cc b/src/tools/rbd_mirror/image_deleter/TrashMoveRequest.cc index f7939480a2b53..4e9a4beac1b28 100644 --- a/src/tools/rbd_mirror/image_deleter/TrashMoveRequest.cc +++ b/src/tools/rbd_mirror/image_deleter/TrashMoveRequest.cc @@ -45,7 +45,7 @@ void TrashMoveRequest::get_mirror_image_id() { &TrashMoveRequest::handle_get_mirror_image_id>(this); m_out_bl.clear(); int r = m_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -122,7 +122,7 @@ void TrashMoveRequest::disable_mirror_image() { TrashMoveRequest, &TrashMoveRequest::handle_disable_mirror_image>(this); int r = m_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -294,7 +294,7 @@ void TrashMoveRequest::remove_mirror_image() { TrashMoveRequest, &TrashMoveRequest::handle_remove_mirror_image>(this); int r = m_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_deleter/TrashWatcher.cc b/src/tools/rbd_mirror/image_deleter/TrashWatcher.cc index 0bba325098231..cb4f78d94611e 100644 --- a/src/tools/rbd_mirror/image_deleter/TrashWatcher.cc +++ b/src/tools/rbd_mirror/image_deleter/TrashWatcher.cc @@ -48,7 +48,7 @@ void TrashWatcher::init(Context *on_finish) { Mutex::Locker locker(m_lock); m_on_init_finish = on_finish; - assert(!m_trash_list_in_progress); + ceph_assert(!m_trash_list_in_progress); m_trash_list_in_progress = true; } @@ -63,7 +63,7 @@ void TrashWatcher::shut_down(Context *on_finish) { Mutex::Locker timer_locker(m_threads->timer_lock); Mutex::Locker locker(m_lock); - assert(!m_shutting_down); + ceph_assert(!m_shutting_down); m_shutting_down = true; if (m_timer_ctx != nullptr) { m_threads->timer->cancel_event(m_timer_ctx); @@ -112,7 +112,7 @@ void TrashWatcher::create_trash() { dout(20) << dendl; { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); } librados::ObjectWriteOperation op; @@ -122,7 +122,7 @@ void TrashWatcher::create_trash() { auto aio_comp = create_rados_callback< TrashWatcher, &TrashWatcher::handle_create_trash>(this); int r = m_io_ctx.aio_operate(RBD_TRASH, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -131,7 +131,7 @@ void TrashWatcher::handle_create_trash(int r) { dout(20) << "r=" << r << dendl; { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); } if (r < 0 && r != -EEXIST) { @@ -153,7 +153,7 @@ template void TrashWatcher::register_watcher() { { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); } // if the watch registration is in-flight, let the watcher @@ -178,7 +178,7 @@ void TrashWatcher::handle_register_watcher(int r) { { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); if (r < 0) { m_trash_list_in_progress = false; } @@ -237,7 +237,7 @@ void TrashWatcher::trash_list(bool initial_request) { { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); } librados::ObjectReadOperation op; @@ -247,7 +247,7 @@ void TrashWatcher::trash_list(bool initial_request) { TrashWatcher, &TrashWatcher::handle_trash_list>(this); m_out_bl.clear(); int r = m_io_ctx.aio_operate(RBD_TRASH, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -264,7 +264,7 @@ void TrashWatcher::handle_trash_list(int r) { Context *on_init_finish = nullptr; { Mutex::Locker locker(m_lock); - assert(m_trash_list_in_progress); + ceph_assert(m_trash_list_in_progress); if (r >= 0) { for (auto& image : images) { add_image(image.first, image.second); @@ -324,13 +324,13 @@ template void TrashWatcher::process_trash_list() { dout(5) << dendl; - assert(m_threads->timer_lock.is_locked()); - assert(m_timer_ctx != nullptr); + ceph_assert(m_threads->timer_lock.is_locked()); + ceph_assert(m_timer_ctx != nullptr); m_timer_ctx = nullptr; { Mutex::Locker locker(m_lock); - assert(!m_trash_list_in_progress); + ceph_assert(!m_trash_list_in_progress); m_trash_list_in_progress = true; } @@ -350,7 +350,7 @@ void TrashWatcher::add_image(const std::string& image_id, return; } - assert(m_lock.is_locked()); + ceph_assert(m_lock.is_locked()); auto& deferment_end_time = spec.deferment_end_time; dout(10) << "image_id=" << image_id << ", " << "deferment_end_time=" << deferment_end_time << dendl; diff --git a/src/tools/rbd_mirror/image_map/LoadRequest.cc b/src/tools/rbd_mirror/image_map/LoadRequest.cc index 18b2f615713e0..7387b476cc0ff 100644 --- a/src/tools/rbd_mirror/image_map/LoadRequest.cc +++ b/src/tools/rbd_mirror/image_map/LoadRequest.cc @@ -52,7 +52,7 @@ void LoadRequest::image_map_list() { m_out_bl.clear(); int r = m_ioctx.aio_operate(RBD_MIRROR_LEADER, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_map/Policy.cc b/src/tools/rbd_mirror/image_map/Policy.cc index 0fefa6e3fa619..cf08065617d89 100644 --- a/src/tools/rbd_mirror/image_map/Policy.cc +++ b/src/tools/rbd_mirror/image_map/Policy.cc @@ -53,19 +53,19 @@ void Policy::init( RWLock::WLocker map_lock(m_map_lock); for (auto& it : image_mapping) { - assert(!it.second.instance_id.empty()); + ceph_assert(!it.second.instance_id.empty()); auto map_result = m_map[it.second.instance_id].emplace(it.first); - assert(map_result.second); + ceph_assert(map_result.second); auto image_state_result = m_image_states.emplace( it.first, ImageState{it.second.instance_id, it.second.mapped_time}); - assert(image_state_result.second); + ceph_assert(image_state_result.second); // ensure we (re)send image acquire actions to the instance auto& image_state = image_state_result.first->second; auto start_action = set_state(&image_state, StateTransition::STATE_INITIALIZING, false); - assert(start_action); + ceph_assert(start_action); } } @@ -117,7 +117,7 @@ void Policy::add_instances(const InstanceIds &instance_ids, RWLock::WLocker map_lock(m_map_lock); for (auto& instance : instance_ids) { - assert(!instance.empty()); + ceph_assert(!instance.empty()); m_map.emplace(instance, std::set{}); } @@ -146,7 +146,7 @@ void Policy::add_instances(const InstanceIds &instance_ids, << "]" << dendl; for (auto& global_image_id : shuffle_global_image_ids) { auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; if (set_state(&image_state, StateTransition::STATE_SHUFFLING, false)) { @@ -164,7 +164,7 @@ void Policy::remove_instances(const InstanceIds &instance_ids, void Policy::remove_instances(const RWLock& lock, const InstanceIds &instance_ids, GlobalImageIds* global_image_ids) { - assert(m_map_lock.is_wlocked()); + ceph_assert(m_map_lock.is_wlocked()); dout(5) << "instance_ids=" << instance_ids << dendl; for (auto& instance_id : instance_ids) { @@ -184,7 +184,7 @@ void Policy::remove_instances(const RWLock& lock, << "global_image_ids=[" << instance_global_image_ids << "]"<< dendl; for (auto& global_image_id : instance_global_image_ids) { auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; if (is_state_scheduled(image_state, @@ -204,11 +204,11 @@ ActionType Policy::start_action(const std::string &global_image_id) { RWLock::WLocker map_lock(m_map_lock); auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; auto& transition = image_state.transition; - assert(transition.action_type != ACTION_TYPE_NONE); + ceph_assert(transition.action_type != ACTION_TYPE_NONE); dout(5) << "global_image_id=" << global_image_id << ", " << "state=" << image_state.state << ", " @@ -225,7 +225,7 @@ bool Policy::finish_action(const std::string &global_image_id, int r) { RWLock::WLocker map_lock(m_map_lock); auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; auto& transition = image_state.transition; @@ -247,7 +247,7 @@ bool Policy::finish_action(const std::string &global_image_id, int r) { StateTransition::transit(image_state.state, &image_state.transition); if (transition.finish_state) { // in-progress state machine complete - assert(StateTransition::is_idle(*transition.finish_state)); + ceph_assert(StateTransition::is_idle(*transition.finish_state)); image_state.state = *transition.finish_state; image_state.transition = {}; } @@ -255,7 +255,7 @@ bool Policy::finish_action(const std::string &global_image_id, int r) { if (StateTransition::is_idle(image_state.state) && image_state.next_state) { // advance to pending state machine bool start_action = set_state(&image_state, *image_state.next_state, false); - assert(start_action); + ceph_assert(start_action); } // image state may get purged in execute_policy_action() @@ -282,8 +282,8 @@ void Policy::execute_policy_action( break; case StateTransition::POLICY_ACTION_REMOVE: if (image_state->state == StateTransition::STATE_UNASSOCIATED) { - assert(image_state->instance_id == UNMAPPED_INSTANCE_ID); - assert(!image_state->next_state); + ceph_assert(image_state->instance_id == UNMAPPED_INSTANCE_ID); + ceph_assert(!image_state->next_state); m_image_states.erase(global_image_id); } break; @@ -291,7 +291,7 @@ void Policy::execute_policy_action( } void Policy::map(const std::string& global_image_id, ImageState* image_state) { - assert(m_map_lock.is_wlocked()); + ceph_assert(m_map_lock.is_wlocked()); std::string instance_id = image_state->instance_id; if (instance_id != UNMAPPED_INSTANCE_ID && !is_dead_instance(instance_id)) { @@ -302,7 +302,7 @@ void Policy::map(const std::string& global_image_id, ImageState* image_state) { } instance_id = do_map(m_map, global_image_id); - assert(!instance_id.empty()); + ceph_assert(!instance_id.empty()); dout(5) << "global_image_id=" << global_image_id << ", " << "instance_id=" << instance_id << dendl; @@ -310,12 +310,12 @@ void Policy::map(const std::string& global_image_id, ImageState* image_state) { image_state->mapped_time = ceph_clock_now(); auto ins = m_map[instance_id].emplace(global_image_id); - assert(ins.second); + ceph_assert(ins.second); } void Policy::unmap(const std::string &global_image_id, ImageState* image_state) { - assert(m_map_lock.is_wlocked()); + ceph_assert(m_map_lock.is_wlocked()); std::string instance_id = image_state->instance_id; if (instance_id == UNMAPPED_INSTANCE_ID) { @@ -325,7 +325,7 @@ void Policy::unmap(const std::string &global_image_id, dout(5) << "global_image_id=" << global_image_id << ", " << "instance_id=" << instance_id << dendl; - assert(!instance_id.empty()); + ceph_assert(!instance_id.empty()); m_map[instance_id].erase(global_image_id); image_state->instance_id = UNMAPPED_INSTANCE_ID; image_state->mapped_time = {}; @@ -338,10 +338,10 @@ void Policy::unmap(const std::string &global_image_id, } bool Policy::is_image_shuffling(const std::string &global_image_id) { - assert(m_map_lock.is_locked()); + ceph_assert(m_map_lock.is_locked()); auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; // avoid attempting to re-shuffle a pending shuffle @@ -353,14 +353,14 @@ bool Policy::is_image_shuffling(const std::string &global_image_id) { } bool Policy::can_shuffle_image(const std::string &global_image_id) { - assert(m_map_lock.is_locked()); + ceph_assert(m_map_lock.is_locked()); CephContext *cct = reinterpret_cast(m_ioctx.cct()); int migration_throttle = cct->_conf.get_val( "rbd_mirror_image_policy_migration_throttle"); auto it = m_image_states.find(global_image_id); - assert(it != m_image_states.end()); + ceph_assert(it != m_image_states.end()); auto& image_state = it->second; utime_t last_shuffled_time = image_state.mapped_time; @@ -386,8 +386,8 @@ bool Policy::set_state(ImageState* image_state, StateTransition::State state, image_state->next_state = boost::none; StateTransition::transit(image_state->state, &image_state->transition); - assert(image_state->transition.action_type != ACTION_TYPE_NONE); - assert(!image_state->transition.finish_state); + ceph_assert(image_state->transition.action_type != ACTION_TYPE_NONE); + ceph_assert(!image_state->transition.finish_state); return true; } diff --git a/src/tools/rbd_mirror/image_map/Policy.h b/src/tools/rbd_mirror/image_map/Policy.h index 55f0974229f54..590fdbfed88a1 100644 --- a/src/tools/rbd_mirror/image_map/Policy.h +++ b/src/tools/rbd_mirror/image_map/Policy.h @@ -51,7 +51,7 @@ protected: typedef std::map > InstanceToImageMap; bool is_dead_instance(const std::string instance_id) { - assert(m_map_lock.is_locked()); + ceph_assert(m_map_lock.is_locked()); return m_dead_instances.find(instance_id) != m_dead_instances.end(); } diff --git a/src/tools/rbd_mirror/image_map/SimplePolicy.cc b/src/tools/rbd_mirror/image_map/SimplePolicy.cc index 71cbd1e34691a..f26805819e581 100644 --- a/src/tools/rbd_mirror/image_map/SimplePolicy.cc +++ b/src/tools/rbd_mirror/image_map/SimplePolicy.cc @@ -27,7 +27,7 @@ size_t SimplePolicy::calc_images_per_instance(const InstanceToImageMap& map, ++nr_instances; } } - assert(nr_instances > 0); + ceph_assert(nr_instances > 0); size_t images_per_instance = image_count / nr_instances; if (images_per_instance == 0) { @@ -68,7 +68,7 @@ std::string SimplePolicy::do_map(const InstanceToImageMap& map, const std::string &global_image_id) { auto min_it = map.end(); for (auto it = map.begin(); it != map.end(); ++it) { - assert(it->second.find(global_image_id) == it->second.end()); + ceph_assert(it->second.find(global_image_id) == it->second.end()); if (Policy::is_dead_instance(it->first)) { continue; } else if (min_it == map.end()) { @@ -78,7 +78,7 @@ std::string SimplePolicy::do_map(const InstanceToImageMap& map, } } - assert(min_it != map.end()); + ceph_assert(min_it != map.end()); dout(20) << "global_image_id=" << global_image_id << " maps to instance_id=" << min_it->first << dendl; return min_it->first; diff --git a/src/tools/rbd_mirror/image_map/StateTransition.cc b/src/tools/rbd_mirror/image_map/StateTransition.cc index 76c66f9fa5a7f..6e7746fc84bea 100644 --- a/src/tools/rbd_mirror/image_map/StateTransition.cc +++ b/src/tools/rbd_mirror/image_map/StateTransition.cc @@ -84,7 +84,7 @@ const StateTransition::TransitionTable StateTransition::s_transition_table { void StateTransition::transit(State state, Transition* transition) { auto it = s_transition_table.find({state, transition->action_type}); - assert(it != s_transition_table.end()); + ceph_assert(it != s_transition_table.end()); *transition = it->second; } diff --git a/src/tools/rbd_mirror/image_map/Types.h b/src/tools/rbd_mirror/image_map/Types.h index 3ccfb940d15aa..eae5a3f4279a7 100644 --- a/src/tools/rbd_mirror/image_map/Types.h +++ b/src/tools/rbd_mirror/image_map/Types.h @@ -87,7 +87,7 @@ struct PolicyMetaUnknown { } void encode(bufferlist& bl) const { - assert(false); + ceph_assert(false); } void decode(__u8 version, bufferlist::const_iterator& it) { diff --git a/src/tools/rbd_mirror/image_map/UpdateRequest.cc b/src/tools/rbd_mirror/image_map/UpdateRequest.cc index f011f7c5c7849..799c5670f97d9 100644 --- a/src/tools/rbd_mirror/image_map/UpdateRequest.cc +++ b/src/tools/rbd_mirror/image_map/UpdateRequest.cc @@ -68,7 +68,7 @@ void UpdateRequest::update_image_map() { librados::AioCompletion *aio_comp = create_rados_callback< UpdateRequest, &UpdateRequest::handle_update_image_map>(this); int r = m_ioctx.aio_operate(RBD_MIRROR_LEADER, aio_comp, &op); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc index fde07e804449b..149a72460e46d 100644 --- a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc @@ -72,7 +72,7 @@ BootstrapRequest::BootstrapRequest( template BootstrapRequest::~BootstrapRequest() { - assert(m_remote_image_ctx == nullptr); + ceph_assert(m_remote_image_ctx == nullptr); } template @@ -168,7 +168,7 @@ void BootstrapRequest::handle_open_remote_image(int r) { if (r < 0) { derr << ": failed to open remote image: " << cpp_strerror(r) << dendl; - assert(m_remote_image_ctx == nullptr); + ceph_assert(m_remote_image_ctx == nullptr); finish(r); return; } @@ -291,18 +291,18 @@ void BootstrapRequest::handle_open_local_image(int r) { dout(20) << ": r=" << r << dendl; if (r == -ENOENT) { - assert(*m_local_image_ctx == nullptr); + ceph_assert(*m_local_image_ctx == nullptr); dout(10) << ": local image missing" << dendl; unregister_client(); return; } else if (r == -EREMOTEIO) { - assert(*m_local_image_ctx == nullptr); + ceph_assert(*m_local_image_ctx == nullptr); dout(10) << "local image is primary -- skipping image replay" << dendl; m_ret_val = r; close_remote_image(); return; } else if (r < 0) { - assert(*m_local_image_ctx == nullptr); + ceph_assert(*m_local_image_ctx == nullptr); derr << ": failed to open local image: " << cpp_strerror(r) << dendl; m_ret_val = r; close_remote_image(); @@ -398,7 +398,7 @@ void BootstrapRequest::register_client() { update_progress("REGISTER_CLIENT"); - assert(m_local_image_id.empty()); + ceph_assert(m_local_image_id.empty()); librbd::journal::MirrorPeerClientMeta mirror_peer_client_meta; mirror_peer_client_meta.state = librbd::journal::MIRROR_PEER_STATE_REPLAYING; @@ -436,7 +436,7 @@ void BootstrapRequest::update_client_image() { dout(20) << dendl; update_progress("UPDATE_CLIENT_IMAGE"); - assert(m_local_image_id.empty()); + ceph_assert(m_local_image_id.empty()); m_local_image_id = librbd::util::generate_image_id(m_local_io_ctx); librbd::journal::MirrorPeerClientMeta client_meta{m_local_image_id}; @@ -663,7 +663,7 @@ void BootstrapRequest::image_sync() { if (m_canceled) { m_ret_val = -ECANCELED; } else { - assert(m_image_sync == nullptr); + ceph_assert(m_image_sync == nullptr); Context *ctx = create_context_callback< BootstrapRequest, &BootstrapRequest::handle_image_sync>(this); diff --git a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc index 453471a0a9e62..f57b196257b71 100644 --- a/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/CreateImageRequest.cc @@ -103,7 +103,7 @@ void CreateImageRequest::get_parent_global_image_id() { m_out_bl.clear(); int r = m_remote_parent_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -150,7 +150,7 @@ void CreateImageRequest::get_local_parent_image_id() { m_out_bl.clear(); int r = m_local_parent_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_replayer/EventPreprocessor.cc b/src/tools/rbd_mirror/image_replayer/EventPreprocessor.cc index 6627215e24c73..6314eb7dd35ac 100644 --- a/src/tools/rbd_mirror/image_replayer/EventPreprocessor.cc +++ b/src/tools/rbd_mirror/image_replayer/EventPreprocessor.cc @@ -39,7 +39,7 @@ EventPreprocessor::EventPreprocessor(I &local_image_ctx, template EventPreprocessor::~EventPreprocessor() { - assert(!m_in_progress); + ceph_assert(!m_in_progress); } template @@ -53,7 +53,7 @@ bool EventPreprocessor::is_required(const EventEntry &event_entry) { template void EventPreprocessor::preprocess(EventEntry *event_entry, Context *on_finish) { - assert(!m_in_progress); + ceph_assert(!m_in_progress); m_in_progress = true; m_event_entry = event_entry; m_on_finish = on_finish; diff --git a/src/tools/rbd_mirror/image_replayer/GetMirrorImageIdRequest.cc b/src/tools/rbd_mirror/image_replayer/GetMirrorImageIdRequest.cc index a224862a82ee6..74e9753738324 100644 --- a/src/tools/rbd_mirror/image_replayer/GetMirrorImageIdRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/GetMirrorImageIdRequest.cc @@ -41,7 +41,7 @@ void GetMirrorImageIdRequest::get_image_id() { &GetMirrorImageIdRequest::handle_get_image_id>( this); int r = m_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_replayer/IsPrimaryRequest.cc b/src/tools/rbd_mirror/image_replayer/IsPrimaryRequest.cc index b83c07148ccce..54636fdb369ba 100644 --- a/src/tools/rbd_mirror/image_replayer/IsPrimaryRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/IsPrimaryRequest.cc @@ -46,7 +46,7 @@ void IsPrimaryRequest::send_get_mirror_state() { IsPrimaryRequest, &IsPrimaryRequest::handle_get_mirror_state>(this); int r = m_image_ctx->md_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc index eabce81cb994d..d405e32433600 100644 --- a/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/OpenLocalImageRequest.cc @@ -244,7 +244,7 @@ template void OpenLocalImageRequest::handle_close_image(int r) { dout(20) << dendl; - assert(r == 0); + ceph_assert(r == 0); finish(m_ret_val); } diff --git a/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.cc b/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.cc index 3462dc8354ad2..8e0ea8373d9ab 100644 --- a/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/PrepareLocalImageRequest.cc @@ -70,7 +70,7 @@ void PrepareLocalImageRequest::get_local_image_name() { PrepareLocalImageRequest, &PrepareLocalImageRequest::handle_get_local_image_name>(this); int r = m_io_ctx.aio_operate(RBD_DIRECTORY, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -106,7 +106,7 @@ void PrepareLocalImageRequest::get_mirror_state() { PrepareLocalImageRequest, &PrepareLocalImageRequest::handle_get_mirror_state>(this); int r = m_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc b/src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc index b47b13f1bbca5..cc3ade36ab41c 100644 --- a/src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/PrepareRemoteImageRequest.cc @@ -46,7 +46,7 @@ void PrepareRemoteImageRequest::get_remote_mirror_uuid() { PrepareRemoteImageRequest, &PrepareRemoteImageRequest::handle_get_remote_mirror_uuid>(this); int r = m_remote_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } @@ -111,7 +111,7 @@ void PrepareRemoteImageRequest::get_client() { settings.max_fetch_bytes = g_ceph_context->_conf.get_val( "rbd_mirror_journal_max_fetch_bytes"); - assert(*m_remote_journaler == nullptr); + ceph_assert(*m_remote_journaler == nullptr); *m_remote_journaler = new Journaler(m_threads->work_queue, m_threads->timer, &m_threads->timer_lock, m_remote_io_ctx, *m_remote_image_id, m_local_mirror_uuid, diff --git a/src/tools/rbd_mirror/image_replayer/ReplayStatusFormatter.cc b/src/tools/rbd_mirror/image_replayer/ReplayStatusFormatter.cc index 42c9be929ffd4..f514d7495effb 100644 --- a/src/tools/rbd_mirror/image_replayer/ReplayStatusFormatter.cc +++ b/src/tools/rbd_mirror/image_replayer/ReplayStatusFormatter.cc @@ -89,7 +89,7 @@ bool ReplayStatusFormatter::get_or_send_update(std::string *description, { Mutex::Locker locker(m_lock); - assert(m_on_finish == on_finish); + ceph_assert(m_on_finish == on_finish); m_on_finish = nullptr; } @@ -162,7 +162,7 @@ void ReplayStatusFormatter::send_update_tag_cache(uint64_t master_tag_tid, std::swap(m_on_finish, on_finish); } - assert(on_finish); + ceph_assert(on_finish); on_finish->complete(0); return; } diff --git a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc index 82c2e19b2fa38..ffe2eca9f37f4 100644 --- a/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.cc @@ -38,7 +38,7 @@ SyncPointCreateRequest::SyncPointCreateRequest(I *remote_image_ctx, : m_remote_image_ctx(remote_image_ctx), m_mirror_uuid(mirror_uuid), m_journaler(journaler), m_client_meta(client_meta), m_on_finish(on_finish), m_client_meta_copy(*client_meta) { - assert(m_client_meta->sync_points.size() < 2); + ceph_assert(m_client_meta->sync_points.size() < 2); // initialize the updated client meta with the new sync point m_client_meta_copy.sync_points.emplace_back(); diff --git a/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc b/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc index 78589d983e754..2cfed5e6b44b1 100644 --- a/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc +++ b/src/tools/rbd_mirror/image_sync/SyncPointPruneRequest.cc @@ -120,7 +120,7 @@ template void SyncPointPruneRequest::handle_remove_snap(int r) { dout(20) << ": r=" << r << dendl; - assert(!m_snap_names.empty()); + ceph_assert(!m_snap_names.empty()); std::string snap_name = m_snap_names.front(); m_snap_names.pop_front(); diff --git a/src/tools/rbd_mirror/pool_watcher/RefreshImagesRequest.cc b/src/tools/rbd_mirror/pool_watcher/RefreshImagesRequest.cc index fe919711c683f..14b1e7f44e803 100644 --- a/src/tools/rbd_mirror/pool_watcher/RefreshImagesRequest.cc +++ b/src/tools/rbd_mirror/pool_watcher/RefreshImagesRequest.cc @@ -39,7 +39,7 @@ void RefreshImagesRequest::mirror_image_list() { RefreshImagesRequest, &RefreshImagesRequest::handle_mirror_image_list>(this); int r = m_remote_io_ctx.aio_operate(RBD_MIRRORING, aio_comp, &op, &m_out_bl); - assert(r == 0); + ceph_assert(r == 0); aio_comp->release(); } diff --git a/src/tools/rbd_nbd/rbd-nbd.cc b/src/tools/rbd_nbd/rbd-nbd.cc index 64f13a691336a..1f2e72c0cdb00 100644 --- a/src/tools/rbd_nbd/rbd-nbd.cc +++ b/src/tools/rbd_nbd/rbd-nbd.cc @@ -132,7 +132,7 @@ static int parse_args(vector& args, std::ostream *err_msg, static void handle_signal(int signum) { - assert(signum == SIGINT || signum == SIGTERM); + ceph_assert(signum == SIGINT || signum == SIGTERM); derr << "*** Got signal " << sig_str(signum) << " ***" << dendl; dout(20) << __func__ << ": " << "sending NBD_DISCONNECT" << dendl; if (ioctl(nbd, NBD_DISCONNECT) < 0) { @@ -202,7 +202,7 @@ private: void io_finish(IOContext *ctx) { Mutex::Locker l(lock); - assert(ctx->item.is_on_list()); + ceph_assert(ctx->item.is_on_list()); ctx->item.remove_myself(); io_finished.push_back(&ctx->item); cond.Signal(); @@ -225,7 +225,7 @@ private: void wait_clean() { - assert(!reader_thread.is_started()); + ceph_assert(!reader_thread.is_started()); Mutex::Locker l(lock); while(!io_pending.empty()) cond.Wait(lock); @@ -884,7 +884,7 @@ static int do_map(int argc, const char *argv[], Config *cfg) } r = image.update_unwatch(handle); - assert(r == 0); + ceph_assert(r == 0); } close_nbd: diff --git a/src/tools/scratchtoolpp.cc b/src/tools/scratchtoolpp.cc index 9d6077461bdba..26a35bebce708 100644 --- a/src/tools/scratchtoolpp.cc +++ b/src/tools/scratchtoolpp.cc @@ -114,7 +114,7 @@ int main(int argc, const char **argv) r = io_ctx.write(oid, bl, bl.length(), 0); uint64_t objver = io_ctx.get_last_version(); - assert(objver > 0); + ceph_assert(objver > 0); cout << "io_ctx.write returned " << r << " last_ver=" << objver << std::endl; uint64_t stat_size; @@ -176,19 +176,19 @@ int main(int argc, const char **argv) // test assert_version r = io_ctx.read(oid, bl, 0, 1); - assert(r >= 0); + ceph_assert(r >= 0); uint64_t v = io_ctx.get_last_version(); cout << oid << " version is " << v << std::endl; - assert(v > 0); + ceph_assert(v > 0); io_ctx.set_assert_version(v); r = io_ctx.read(oid, bl, 0, 1); - assert(r >= 0); + ceph_assert(r >= 0); io_ctx.set_assert_version(v - 1); r = io_ctx.read(oid, bl, 0, 1); - assert(r == -ERANGE); + ceph_assert(r == -ERANGE); io_ctx.set_assert_version(v + 1); r = io_ctx.read(oid, bl, 0, 1); - assert(r == -EOVERFLOW); + ceph_assert(r == -EOVERFLOW); r = io_ctx.exec(oid, "crypto", "sha1", bl, bl2); cout << "exec returned " << r << std::endl; @@ -243,13 +243,13 @@ int main(int argc, const char **argv) bufferlist val; val.append("foo"); r = io_ctx.setxattr(oid, "foo", val); - assert(r >= 0); + ceph_assert(r >= 0); { ObjectReadOperation o; o.cmpxattr("foo", CEPH_OSD_CMPXATTR_OP_EQ, val); r = io_ctx.operate(oid, &o, &bl2); cout << " got " << r << " wanted >= 0" << std::endl; - assert(r >= 0); + ceph_assert(r >= 0); } val.append("..."); { @@ -257,7 +257,7 @@ int main(int argc, const char **argv) o.cmpxattr("foo", CEPH_OSD_CMPXATTR_OP_EQ, val); r = io_ctx.operate(oid, &o, &bl2); cout << " got " << r << " wanted " << -ECANCELED << " (-ECANCELED)" << std::endl; - assert(r == -ECANCELED); + ceph_assert(r == -ECANCELED); } io_ctx.locator_set_key(string());