From c0555ca1b79b36b116c1589402387a6166aafb82 Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 23 Aug 2018 11:18:54 -0400 Subject: [PATCH] client: Use ceph_assert for asserts. Signed-off-by: Adam C. Emerson --- src/ceph_fuse.cc | 6 +- src/client/Client.cc | 266 +++++++++++++++++----------------- src/client/Client.h | 2 +- src/client/Delegation.cc | 4 +- src/client/Dentry.h | 16 +- src/client/Inode.cc | 16 +- src/client/Inode.h | 6 +- src/client/MetaRequest.cc | 4 +- src/client/MetaRequest.h | 2 +- src/client/SyntheticClient.cc | 32 ++-- src/client/SyntheticClient.h | 4 +- src/client/fuse_ll.cc | 8 +- 12 files changed, 183 insertions(+), 183 deletions(-) diff --git a/src/ceph_fuse.cc b/src/ceph_fuse.cc index b959db3cebfda..5ac18116f12cd 100644 --- a/src/ceph_fuse.cc +++ b/src/ceph_fuse.cc @@ -54,7 +54,7 @@ static void fuse_usage() if (fuse_parse_cmdline(&args, nullptr, nullptr, nullptr) == -1) { derr << "fuse_parse_cmdline failed." << dendl; } - assert(args.allocated); + ceph_assert(args.allocated); fuse_opt_free_args(&args); } @@ -108,7 +108,7 @@ int main(int argc, const char **argv, const char *envp[]) { if (fuse_parse_cmdline(&fargs, nullptr, nullptr, nullptr) == -1) { derr << "fuse_parse_cmdline failed." << dendl; } - assert(fargs.allocated); + ceph_assert(fargs.allocated); fuse_opt_free_args(&fargs); exit(0); } else { @@ -176,7 +176,7 @@ int main(int argc, const char **argv, const char *envp[]) { void *entry() override { #if defined(__linux__) int ver = get_linux_version(); - assert(ver != 0); + ceph_assert(ver != 0); bool client_try_dentry_invalidate = g_conf().get_val( "client_try_dentry_invalidate"); bool can_invalidate_dentries = diff --git a/src/client/Client.cc b/src/client/Client.cc index 14e628d370ca0..fd420acef4e5b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -156,7 +156,7 @@ bool Client::CommandHook::call(std::string_view command, else if (command == "status") m_client->dump_status(f.get()); else - assert(0 == "bad command registered"); + ceph_assert(0 == "bad command registered"); m_client->client_lock.Unlock(); f->close_section(); f->flush(out); @@ -188,13 +188,13 @@ void Client::_assign_faked_ino(Inode *in) last_used_faked_ino = 0; it = free_faked_inos.lower_bound(last_used_faked_ino + 1); } - assert(it != free_faked_inos.end()); + ceph_assert(it != free_faked_inos.end()); if (last_used_faked_ino < it.get_start()) { - assert(it.get_len() > 0); + ceph_assert(it.get_len() > 0); last_used_faked_ino = it.get_start(); } else { ++last_used_faked_ino; - assert(it.get_start() + it.get_len() > last_used_faked_ino); + ceph_assert(it.get_start() + it.get_len() > last_used_faked_ino); } in->faked_ino = last_used_faked_ino; free_faked_inos.erase(in->faked_ino); @@ -281,7 +281,7 @@ Client::Client(Messenger *m, MonClient *mc, Objecter *objecter_) Client::~Client() { - assert(!client_lock.is_locked()); + ceph_assert(!client_lock.is_locked()); // It is necessary to hold client_lock, because any inode destruction // may call into ObjectCacher, which asserts that it's lock (which is @@ -314,10 +314,10 @@ void Client::tear_down_cache() // empty lru trim_cache(); - assert(lru.lru_get_size() == 0); + ceph_assert(lru.lru_get_size() == 0); // close root ino - assert(inode_map.size() <= 1 + root_parents.size()); + ceph_assert(inode_map.size() <= 1 + root_parents.size()); if (root && inode_map.size() == 1 + root_parents.size()) { delete root; root = 0; @@ -328,7 +328,7 @@ void Client::tear_down_cache() _reset_faked_inos(); } - assert(inode_map.empty()); + ceph_assert(inode_map.empty()); } inodeno_t Client::get_root_ino() @@ -415,7 +415,7 @@ void Client::dump_cache(Formatter *f) void Client::dump_status(Formatter *f) { - assert(client_lock.is_locked_by_me()); + ceph_assert(client_lock.is_locked_by_me()); ldout(cct, 1) << __func__ << dendl; @@ -448,7 +448,7 @@ int Client::init() objectcacher->start(); client_lock.Lock(); - assert(!initialized); + ceph_assert(!initialized); messenger->add_dispatcher_tail(this); client_lock.Unlock(); @@ -560,7 +560,7 @@ void Client::shutdown() objectcacher->stop(); // outside of client_lock! this does a join. client_lock.Lock(); - assert(initialized); + ceph_assert(initialized); initialized = false; timer.shutdown(); client_lock.Unlock(); @@ -976,7 +976,7 @@ void Client::update_dentry_lease(Dentry *dn, LeaseStat *dlease, utime_t from, Me utime_t dttl = from; dttl += (float)dlease->duration_ms / 1000.0; - assert(dn); + ceph_assert(dn); if (dlease->mask & CEPH_LOCK_DN) { if (dttl > dn->lease_ttl) { @@ -1060,20 +1060,20 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session, } dir_result_t *dirp = request->dirp; - assert(dirp); + ceph_assert(dirp); // the extra buffer list is only set for readdir and lssnap replies auto p = reply->get_extra_bl().cbegin(); if (!p.end()) { // snapdir? if (request->head.op == CEPH_MDS_OP_LSSNAP) { - assert(diri); + ceph_assert(diri); diri = open_snapdir(diri); } // only open dir if we're actually adding stuff to it! Dir *dir = diri->open_dir(); - assert(dir); + ceph_assert(dir); // dirstat DirStat dst(p, features); @@ -1088,7 +1088,7 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session, frag_t fg = (unsigned)request->head.args.readdir.frag; unsigned readdir_offset = dirp->next_offset; string readdir_start = dirp->last_name; - assert(!readdir_start.empty() || readdir_offset == 2); + ceph_assert(!readdir_start.empty() || readdir_offset == 2); unsigned last_hash = 0; if (hash_order) { @@ -1148,7 +1148,7 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session, // replace incorrect dentry unlink(olddn, true, true); // keep dir, dentry dn = link(dir, dname, in, olddn); - assert(dn == olddn); + ceph_assert(dn == olddn); } else { // keep existing dn dn = olddn; @@ -1175,17 +1175,17 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session, dirp->start_shared_gen == diri->shared_gen) { if (dirp->cache_index == dir->readdir_cache.size()) { if (i == 0) { - assert(!dirp->inode->is_complete_and_ordered()); + ceph_assert(!dirp->inode->is_complete_and_ordered()); dir->readdir_cache.reserve(dirp->cache_index + numdn); } dir->readdir_cache.push_back(dn); } else if (dirp->cache_index < dir->readdir_cache.size()) { if (dirp->inode->is_complete_and_ordered()) - assert(dir->readdir_cache[dirp->cache_index] == dn); + ceph_assert(dir->readdir_cache[dirp->cache_index] == dn); else dir->readdir_cache[dirp->cache_index] = dn; } else { - assert(0 == "unexpected readdir buffer idx"); + ceph_assert(0 == "unexpected readdir buffer idx"); } dirp->cache_index++; } @@ -1223,7 +1223,7 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session) auto p = reply->get_trace_bl().cbegin(); if (request->got_unsafe) { ldout(cct, 10) << "insert_trace -- already got unsafe; ignoring" << dendl; - assert(p.end()); + ceph_assert(p.end()); return NULL; } @@ -1242,7 +1242,7 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session) // rename Dentry *od = request->old_dentry(); ldout(cct, 10) << " unlinking rename src dn " << od << " for traceless reply" << dendl; - assert(od); + ceph_assert(od); unlink(od, true, true); // keep dir, dentry } else if (op == CEPH_MDS_OP_RMDIR || op == CEPH_MDS_OP_UNLINK) { @@ -1299,7 +1299,7 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session) if ((wanted & CEPH_CAP_XATTR_SHARED) && !(ist.xattr_version > 0 && ist.xattrbl.length() > 0)) - assert(0 == "MDS reply does not contain xattrs"); + ceph_assert(0 == "MDS reply does not contain xattrs"); } in = add_update_inode(&ist, request->sent_stamp, session, @@ -1340,7 +1340,7 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session) // fake it for snap lookup vinodeno_t vino = ist.vino; vino.snapid = CEPH_SNAPDIR; - assert(inode_map.count(vino)); + ceph_assert(inode_map.count(vino)); diri = inode_map[vino]; string dname = request->path.last_dentry(); @@ -1491,7 +1491,7 @@ out: void Client::connect_mds_targets(mds_rank_t mds) { ldout(cct, 10) << __func__ << " for mds." << mds << dendl; - assert(mds_sessions.count(mds)); + ceph_assert(mds_sessions.count(mds)); const MDSMap::mds_info_t& info = mdsmap->get_mds_info(mds); for (set::const_iterator q = info.export_targets.begin(); q != info.export_targets.end(); @@ -1580,7 +1580,7 @@ int Client::verify_reply_trace(int r, &target, perms); } else { // if the dentry is not linked, just do our best. see #5021. - assert(0 == "how did this happen? i want logs!"); + ceph_assert(0 == "how did this happen? i want logs!"); } } else { Inode *in = request->inode(); @@ -1732,8 +1732,8 @@ int Client::make_request(MetaRequest *request, } if (!request->reply) { - assert(request->aborted()); - assert(!request->got_unsafe); + ceph_assert(request->aborted()); + ceph_assert(!request->got_unsafe); r = request->get_abort_code(); request->item.remove_myself(); unregister_request(request); @@ -1749,7 +1749,7 @@ int Client::make_request(MetaRequest *request, request->success = true; // kick dispatcher (we've got it!) - assert(request->dispatch_cond); + ceph_assert(request->dispatch_cond); request->dispatch_cond->Signal(); ldout(cct, 20) << "sendrecv kickback on tid " << tid << " " << request->dispatch_cond << dendl; request->dispatch_cond = 0; @@ -1985,7 +1985,7 @@ void Client::populate_metadata(const std::string &mount_root) void Client::update_metadata(std::string const &k, std::string const &v) { Mutex::Locker l(client_lock); - assert(initialized); + ceph_assert(initialized); auto it = metadata.find(k); if (it != metadata.end()) { @@ -2003,7 +2003,7 @@ MetaSession *Client::_open_mds_session(mds_rank_t mds) auto em = mds_sessions.emplace(std::piecewise_construct, std::forward_as_tuple(mds), std::forward_as_tuple(mds, messenger->connect_to_mds(addrs), addrs)); - assert(em.second); /* not already present */ + ceph_assert(em.second); /* not already present */ MetaSession *session = &em.first->second; // Maybe skip sending a request to open if this MDS daemon @@ -2139,7 +2139,7 @@ void Client::handle_client_session(MClientSession *m) bool Client::_any_stale_sessions() const { - assert(client_lock.is_locked_by_me()); + ceph_assert(client_lock.is_locked_by_me()); for (const auto &it : mds_sessions) { if (it.second.state == MetaSession::STATE_STALE) { @@ -2268,7 +2268,7 @@ void Client::handle_client_request_forward(MClientRequestForward *fwd) } MetaRequest *request = mds_requests[tid]; - assert(request); + ceph_assert(request); // reset retry counter request->retry_attempt = 0; @@ -2352,7 +2352,7 @@ void Client::handle_client_reply(MClientReply *reply) } } - assert(request->reply == NULL); + ceph_assert(request->reply == NULL); request->reply = reply; insert_trace(request, session); @@ -2362,7 +2362,7 @@ void Client::handle_client_reply(MClientReply *reply) session->unsafe_requests.push_back(&request->unsafe_item); if (is_dir_operation(request)) { Inode *dir = request->inode(); - assert(dir); + ceph_assert(dir); dir->unsafe_ops.push_back(&request->unsafe_dir_item); } if (request->target) { @@ -2871,8 +2871,8 @@ void Client::kick_requests_closed(MetaSession *session) } } } - assert(session->requests.empty()); - assert(session->unsafe_requests.empty()); + ceph_assert(session->requests.empty()); + ceph_assert(session->unsafe_requests.empty()); } @@ -2895,7 +2895,7 @@ void Client::handle_lease(MClientLease *m) { ldout(cct, 10) << __func__ << " " << *m << dendl; - assert(m->get_action() == CEPH_MDS_LEASE_REVOKE); + ceph_assert(m->get_action() == CEPH_MDS_LEASE_REVOKE); mds_rank_t mds = mds_rank_t(m->get_source().num()); MetaSession *session = _get_mds_session(mds, m->get_connection().get()); @@ -2944,7 +2944,7 @@ void Client::put_inode(Inode *in, int n) ldout(cct, 10) << __func__ << " deleting " << *in << dendl; bool unclean = objectcacher->release_set(&in->oset); - assert(!unclean); + ceph_assert(!unclean); inode_map.erase(in->vino()); if (use_faked_inos()) _release_faked_ino(in); @@ -2964,9 +2964,9 @@ void Client::close_dir(Dir *dir) { Inode *in = dir->parent_inode; ldout(cct, 15) << __func__ << " dir " << dir << " on " << in << dendl; - assert(dir->is_empty()); - assert(in->dir == dir); - assert(in->dentries.size() < 2); // dirs can't be hard-linked + ceph_assert(dir->is_empty()); + ceph_assert(in->dir == dir); + ceph_assert(in->dentries.size() < 2); // dirs can't be hard-linked if (!in->dentries.empty()) in->get_first_parent()->put(); // unpin dentry @@ -2991,7 +2991,7 @@ Dentry* Client::link(Dir *dir, const string& name, Inode *in, Dentry *dn) ldout(cct, 15) << "link dir " << dir->parent_inode << " '" << name << "' to inode " << in << " dn " << dn << " (new dn)" << dendl; } else { - assert(!dn->inode); + ceph_assert(!dn->inode); ldout(cct, 15) << "link dir " << dir->parent_inode << " '" << name << "' to inode " << in << " dn " << dn << " (old dn)" << dendl; } @@ -3002,7 +3002,7 @@ Dentry* Client::link(Dir *dir, const string& name, Inode *in, Dentry *dn) if (in->is_dir() && !in->dentries.empty()) { tmp_ref = in; // prevent unlink below from freeing the inode. Dentry *olddn = in->get_first_parent(); - assert(olddn->dir != dir || olddn->name != name); + ceph_assert(olddn->dir != dir || olddn->name != name); Inode *old_diri = olddn->dir->parent_inode; old_diri->dir_release_count++; clear_dir_complete_and_ordered(old_diri, true); @@ -3057,7 +3057,7 @@ private: public: C_Client_FlushComplete(Client *c, Inode *in) : client(c), inode(in) { } void finish(int r) override { - assert(client->client_lock.is_locked_by_me()); + ceph_assert(client->client_lock.is_locked_by_me()); if (r != 0) { client_t const whoami = client->whoami; // For the benefit of ldout prefix ldout(client->cct, 1) << "I/O error from flush on inode " << inode @@ -3547,7 +3547,7 @@ void Client::queue_cap_snap(Inode *in, SnapContext& old_snapc) (used & CEPH_CAP_FILE_WR) || (dirty & CEPH_CAP_ANY_WR)) { const auto &capsnapem = in->cap_snaps.emplace(std::piecewise_construct, std::make_tuple(old_snapc.seq), std::make_tuple(in)); - assert(capsnapem.second); /* element inserted */ + ceph_assert(capsnapem.second); /* element inserted */ CapSnap &capsnap = capsnapem.first->second; capsnap.context = old_snapc; capsnap.issued = in->caps_issued(); @@ -3616,10 +3616,10 @@ void Client::_flushed_cap_snap(Inode *in, snapid_t seq) void Client::flush_snaps(Inode *in, bool all_again) { ldout(cct, 10) << "flush_snaps on " << *in << " all_again " << all_again << dendl; - assert(in->cap_snaps.size()); + ceph_assert(in->cap_snaps.size()); // pick auth mds - assert(in->auth_cap); + ceph_assert(in->auth_cap); MetaSession *session = in->auth_cap->session; int mseq = in->auth_cap->mseq; @@ -3681,7 +3681,7 @@ void Client::flush_snaps(Inode *in, bool all_again) m->inline_data = in->inline_data; } - assert(!session->flushing_caps_tids.empty()); + ceph_assert(!session->flushing_caps_tids.empty()); m->set_oldest_flush_tid(*session->flushing_caps_tids.begin()); session->con->send_message2(m); @@ -3747,7 +3747,7 @@ public: } void finish(int r) override { // _async_invalidate takes the lock when it needs to, call this back from outside of lock. - assert(!client->client_lock.is_locked_by_me()); + ceph_assert(!client->client_lock.is_locked_by_me()); client->_async_invalidate(ino, offset, length); } }; @@ -3829,7 +3829,7 @@ bool Client::_flush(Inode *in, Context *onfinish) void Client::_flush_range(Inode *in, int64_t offset, uint64_t size) { - assert(client_lock.is_locked()); + ceph_assert(client_lock.is_locked()); if (!in->oset.dirty_or_tx) { ldout(cct, 10) << " nothing to flush" << dendl; return; @@ -3849,9 +3849,9 @@ void Client::_flush_range(Inode *in, int64_t offset, uint64_t size) void Client::flush_set_callback(ObjectCacher::ObjectSet *oset) { // Mutex::Locker l(client_lock); - assert(client_lock.is_locked()); // will be called via dispatch() -> objecter -> ... + ceph_assert(client_lock.is_locked()); // will be called via dispatch() -> objecter -> ... Inode *in = static_cast(oset->parent); - assert(in); + ceph_assert(in); _flushed(in); } @@ -3887,12 +3887,12 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id int flags, const UserPerm& cap_perms) { if (!in->is_any_caps()) { - assert(in->snaprealm == 0); + ceph_assert(in->snaprealm == 0); in->snaprealm = get_snap_realm(realm); in->snaprealm->inodes_with_caps.push_back(&in->snaprealm_item); ldout(cct, 15) << __func__ << " first one, opened snaprealm " << in->snaprealm << dendl; } else { - assert(in->snaprealm); + ceph_assert(in->snaprealm); if ((flags & CEPH_CAP_FLAG_AUTH) && realm != inodeno_t(-1) && in->snaprealm->ino != realm) { in->snaprealm_item.remove_myself(); @@ -3917,8 +3917,8 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id * don't remove caps. */ if (ceph_seq_cmp(seq, cap.seq) <= 0) { - assert(&cap == in->auth_cap); - assert(cap.cap_id == cap_id); + ceph_assert(&cap == in->auth_cap); + ceph_assert(cap.cap_id == cap_id); seq = cap.seq; mseq = cap.mseq; issued |= cap.issued; @@ -3995,7 +3995,7 @@ void Client::remove_cap(Cap *cap, bool queue_release) in.auth_cap = NULL; } size_t n = in.caps.erase(mds); - assert(n == 1); + ceph_assert(n == 1); cap = nullptr; if (!in.is_any_caps()) { @@ -4079,7 +4079,7 @@ private: public: explicit C_Client_Remount(Client *c) : client(c) {} void finish(int r) override { - assert(r == 0); + ceph_assert(r == 0); client->_do_remount(); } }; @@ -4114,7 +4114,7 @@ void Client::_trim_negative_child_dentries(InodeRef& in) for (auto p = dir->dentries.begin(); p != dir->dentries.end(); ) { Dentry *dn = p->second; ++p; - assert(!dn->inode); + ceph_assert(!dn->inode); if (dn->lru_is_expireable()) unlink(dn, true, false); // keep dir, drop dentry } @@ -4212,7 +4212,7 @@ int Client::mark_caps_flushing(Inode *in, ceph_tid_t* ptid) MetaSession *session = in->auth_cap->session; int flushing = in->dirty_caps; - assert(flushing); + ceph_assert(flushing); ceph_tid_t flush_tid = ++last_flush_tid; in->flushing_cap_tids[flush_tid] = flushing; @@ -4290,7 +4290,7 @@ void Client::flush_caps(Inode *in, MetaSession *session, bool sync) { ldout(cct, 10) << __func__ << " " << in << " mds." << session->mds_num << dendl; Cap *cap = in->auth_cap; - assert(cap->session == session); + ceph_assert(cap->session == session); for (map::iterator p = in->flushing_cap_tids.begin(); p != in->flushing_cap_tids.end(); @@ -4312,7 +4312,7 @@ void Client::wait_sync_caps(Inode *in, ceph_tid_t want) { while (in->flushing_caps) { map::iterator it = in->flushing_cap_tids.begin(); - assert(it != in->flushing_cap_tids.end()); + ceph_assert(it != in->flushing_cap_tids.end()); if (it->first > want) break; ldout(cct, 10) << __func__ << " on " << *in << " flushing " @@ -4366,7 +4366,7 @@ void Client::early_kick_flushing_caps(MetaSession *session) for (xlist::iterator p = session->flushing_caps.begin(); !p.end(); ++p) { Inode *in = *p; - assert(in->auth_cap); + ceph_assert(in->auth_cap); // if flushing caps were revoked, we re-send the cap flush in client reconnect // stage. This guarantees that MDS processes the cap flush message before issuing @@ -4616,11 +4616,11 @@ void Client::handle_snap(MClientSnap *m) SnapRealm *realm = 0; if (m->head.op == CEPH_SNAP_OP_SPLIT) { - assert(m->head.split); + ceph_assert(m->head.split); SnapRealmInfo info; auto p = m->bl.cbegin(); decode(info, p); - assert(info.ino() == m->head.split); + ceph_assert(info.ino() == m->head.split); // flush, then move, ino's. realm = get_snap_realm(info.ino()); @@ -4871,7 +4871,7 @@ void Client::handle_cap_export(MetaSession *session, Inode *in, MClientCaps *m) void Client::handle_cap_trunc(MetaSession *session, Inode *in, MClientCaps *m) { mds_rank_t mds = session->mds_num; - assert(in->caps.count(mds)); + ceph_assert(in->caps.count(mds)); ldout(cct, 10) << __func__ << " on ino " << *in << " size " << in->size << " -> " << m->get_size() @@ -4954,7 +4954,7 @@ void Client::handle_cap_flush_ack(MetaSession *session, Inode *in, Cap *cap, MCl void Client::handle_cap_flushsnap_ack(MetaSession *session, Inode *in, MClientCaps *m) { mds_rank_t mds = session->mds_num; - assert(in->caps.count(mds)); + ceph_assert(in->caps.count(mds)); snapid_t follows = m->get_snap_follows(); if (in->cap_snaps.count(follows)) { @@ -5004,7 +5004,7 @@ public: } void finish(int r) override { // _async_dentry_invalidate is responsible for its own locking - assert(!client->client_lock.is_locked_by_me()); + ceph_assert(!client->client_lock.is_locked_by_me()); client->_async_dentry_invalidate(dirino, ino, name); } }; @@ -5456,8 +5456,8 @@ int Client::resolve_mds( const std::string &mds_spec, std::vector *targets) { - assert(fsmap); - assert(targets != nullptr); + ceph_assert(fsmap); + ceph_assert(targets != nullptr); mds_role_t role; std::stringstream ss; @@ -5521,7 +5521,7 @@ int Client::resolve_mds( */ int Client::authenticate() { - assert(client_lock.is_locked_by_me()); + ceph_assert(client_lock.is_locked_by_me()); if (monclient->is_authenticated()) { return 0; @@ -5568,16 +5568,16 @@ int Client::fetch_fsmap(bool user) monclient->renew_subs(); wait_on_list(waiting_for_fsmap); } - assert(fsmap_user); - assert(fsmap_user->get_epoch() >= fsmap_latest); + ceph_assert(fsmap_user); + ceph_assert(fsmap_user->get_epoch() >= fsmap_latest); } else { if (!fsmap || fsmap->get_epoch() < fsmap_latest) { monclient->sub_want("fsmap", fsmap_latest, CEPH_SUBSCRIBE_ONETIME); monclient->renew_subs(); wait_on_list(waiting_for_fsmap); } - assert(fsmap); - assert(fsmap->get_epoch() >= fsmap_latest); + ceph_assert(fsmap); + ceph_assert(fsmap->get_epoch() >= fsmap_latest); } ldout(cct, 10) << __func__ << " finished waiting for FSMap version " << fsmap_latest << dendl; @@ -5788,7 +5788,7 @@ int Client::mount(const std::string &mount_root, const UserPerm& perms, break; } - assert(root); + ceph_assert(root); _ll_get(root); mounted = true; @@ -5954,7 +5954,7 @@ void Client::_unmount(bool abort) Inode *in = p.second; if (!in) { ldout(cct, 0) << "null inode_map entry ino " << p.first << dendl; - assert(in); + ceph_assert(in); } // prevent inode from getting freed @@ -5999,8 +5999,8 @@ void Client::_unmount(bool abort) dump_cache(NULL); } } - assert(lru.lru_get_size() == 0); - assert(inode_map.empty()); + ceph_assert(lru.lru_get_size() == 0); + ceph_assert(inode_map.empty()); // stop tracing if (!cct->_conf->client_trace.empty()) { @@ -6048,7 +6048,7 @@ void Client::tick() { if (cct->_conf->client_debug_inject_tick_delay > 0) { sleep(cct->_conf->client_debug_inject_tick_delay); - assert(0 == cct->_conf.set_val("client_debug_inject_tick_delay", "0")); + ceph_assert(0 == cct->_conf.set_val("client_debug_inject_tick_delay", "0")); cct->_conf.apply_changes(nullptr); } @@ -6057,7 +6057,7 @@ void Client::tick() cct->_conf->client_tick_interval, new FunctionContext([this](int) { // Called back via Timer, which takes client_lock for us - assert(client_lock.is_locked_by_me()); + ceph_assert(client_lock.is_locked_by_me()); tick(); })); utime_t now = ceph_clock_now(); @@ -6303,7 +6303,7 @@ int Client::path_walk(const filepath& origpath, InodeRef *end, cur = root; else cur = cwd; - assert(cur); + ceph_assert(cur); ldout(cct, 10) << __func__ << " " << path << dendl; @@ -7769,7 +7769,7 @@ void Client::_readdir_next_frag(dir_result_t *dirp) void Client::_readdir_rechoose_frag(dir_result_t *dirp) { - assert(dirp->inode); + ceph_assert(dirp->inode); if (dirp->hash_order()) return; @@ -7792,8 +7792,8 @@ void Client::_readdir_drop_dirp_buffer(dir_result_t *dirp) int Client::_readdir_get_frag(dir_result_t *dirp) { - assert(dirp); - assert(dirp->inode); + ceph_assert(dirp); + ceph_assert(dirp->inode); // get the current frag. frag_t fg; @@ -7854,7 +7854,7 @@ struct dentry_off_lt { int Client::_readdir_cache_cb(dir_result_t *dirp, add_dirent_cb_t cb, void *p, int caps, bool getref) { - assert(client_lock.is_locked()); + ceph_assert(client_lock.is_locked()); ldout(cct, 10) << __func__ << " " << dirp << " on " << dirp->inode->ino << " last_name " << dirp->last_name << " offset " << hex << dirp->offset << dec << dendl; @@ -7963,7 +7963,7 @@ int Client::readdir_r_cb(dir_result_t *d, add_dirent_cb_t cb, void *p, if (dirp->offset == 0) { ldout(cct, 15) << " including ." << dendl; - assert(diri->dentries.size() < 2); // can't have multiple hard-links to a dir + ceph_assert(diri->dentries.size() < 2); // can't have multiple hard-links to a dir uint64_t next_off = 1; int r; @@ -8111,7 +8111,7 @@ int Client::readdir_r_cb(dir_result_t *d, add_dirent_cb_t cb, void *p, if (diri->dir_ordered_count == dirp->ordered_count) { ldout(cct, 10) << " marking (I_COMPLETE|I_DIR_ORDERED) on " << *diri << dendl; if (diri->dir) { - assert(diri->dir->readdir_cache.size() >= dirp->cache_index); + ceph_assert(diri->dir->readdir_cache.size() >= dirp->cache_index); diri->dir->readdir_cache.resize(dirp->cache_index); } diri->flags |= I_COMPLETE | I_DIR_ORDERED; @@ -8385,9 +8385,9 @@ int Client::open(const char *relpath, int flags, const UserPerm& perms, r = _open(in.get(), flags, mode, &fh, perms); if (r >= 0) { // allocate a integer file descriptor - assert(fh); + ceph_assert(fh); r = get_fd(); - assert(fd_map.count(r) == 0); + ceph_assert(fd_map.count(r) == 0); fd_map[r] = fh; } @@ -8452,7 +8452,7 @@ int Client::_lookup_ino(inodeno_t ino, const UserPerm& perms, Inode **inode) if (r == 0 && inode != NULL) { vinodeno_t vino(ino, CEPH_NOSNAP); unordered_map::iterator p = inode_map.find(vino); - assert(p != inode_map.end()); + ceph_assert(p != inode_map.end()); *inode = p->second; _ll_get(*inode); } @@ -8523,7 +8523,7 @@ int Client::lookup_parent(Inode *ino, const UserPerm& perms, Inode **parent) */ int Client::_lookup_name(Inode *ino, Inode *parent, const UserPerm& perms) { - assert(parent->is_dir()); + ceph_assert(parent->is_dir()); ldout(cct, 3) << __func__ << " enter(" << ino->ino << ")" << dendl; if (unmounting) @@ -8547,7 +8547,7 @@ int Client::lookup_name(Inode *ino, Inode *parent, const UserPerm& perms) Fh *Client::_create_fh(Inode *in, int flags, int cmode, const UserPerm& perms) { - assert(in); + ceph_assert(in); Fh *f = new Fh(in, flags, cmode, perms); ldout(cct, 10) << __func__ << " " << in->ino << " mode " << cmode << dendl; @@ -8592,7 +8592,7 @@ int Client::_release_fh(Fh *f) check_caps(in, 0); } } else { - assert(in->snap_cap_refs > 0); + ceph_assert(in->snap_cap_refs > 0); in->snap_cap_refs--; } @@ -8832,7 +8832,7 @@ void Client::lock_fh_pos(Fh *f) while (f->pos_locked || f->pos_waiters.front() != &cond) cond.Wait(client_lock); ldout(cct, 10) << __func__ << " UNBLOCKING on " << f << dendl; - assert(f->pos_waiters.front() == &cond); + ceph_assert(f->pos_waiters.front() == &cond); f->pos_waiters.pop_front(); } @@ -8956,7 +8956,7 @@ int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl) if (r < 0) { goto done; } - assert(in->inline_version > 0); + ceph_assert(in->inline_version > 0); } retry: @@ -9035,7 +9035,7 @@ retry: } success: - assert(r >= 0); + ceph_assert(r >= 0); if (movepos) { // adjust fd pos f->pos = start_pos + r; @@ -9205,7 +9205,7 @@ int Client::_read_sync(Fh *f, uint64_t off, uint64_t len, bufferlist *bl, */ void Client::_sync_write_commit(Inode *in) { - assert(unsafe_sync_write > 0); + ceph_assert(unsafe_sync_write > 0); unsafe_sync_write--; put_cap_ref(in, CEPH_CAP_FILE_BUFFER); @@ -9328,7 +9328,7 @@ int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, return -ENOSPC; } - assert(in->snapid == CEPH_NOSNAP); + ceph_assert(in->snapid == CEPH_NOSNAP); // was Fh opened as writeable? if ((f->mode & CEPH_FILE_MODE_WR) == 0) @@ -9371,7 +9371,7 @@ int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, int r = _getattr(in, CEPH_STAT_CAP_INLINE_DATA, f->actor_perms, true); if (r < 0) return r; - assert(in->inline_version > 0); + ceph_assert(in->inline_version > 0); } // copy into fresh buffer (since our write may be resub, async) @@ -9767,7 +9767,7 @@ void Client::_getcwd(string& dir, const UserPerm& perms) Inode *in = cwd.get(); while (in != root) { - assert(in->dentries.size() < 2); // dirs can't be hard-linked + ceph_assert(in->dentries.size() < 2); // dirs can't be hard-linked // A cwd or ancester is unlinked if (in->dentries.empty()) { @@ -9859,12 +9859,12 @@ int Client::statfs(const char *path, struct statvfs *stbuf, // Usually quota_root will == root_ancestor, but if the mount root has no // quota but we can see a parent of it that does have a quota, we'll // respect that one instead. - assert(root != nullptr); + ceph_assert(root != nullptr); Inode *quota_root = root->quota.is_enable() ? root : get_quota_root(root, perms); // get_quota_root should always give us something // because client quotas are always enabled - assert(quota_root != nullptr); + ceph_assert(quota_root != nullptr); if (quota_root && cct->_conf->client_quota_df && quota_root->quota.max_bytes) { @@ -10154,7 +10154,7 @@ void Client::_update_lock_state(struct flock *fl, uint64_t owner, lock_state->remove_lock(filelock, activated_locks); } else { bool r = lock_state->add_lock(filelock, false, false, NULL); - assert(r); + ceph_assert(r); } } @@ -10254,7 +10254,7 @@ int Client::test_dentry_handling(bool can_invalidate) can_invalidate_dentries = can_invalidate; if (can_invalidate_dentries) { - assert(dentry_invalidate_cb); + ceph_assert(dentry_invalidate_cb); ldout(cct, 1) << "using dentry_invalidate_cb" << dendl; r = 0; } else if (remount_cb) { @@ -10541,7 +10541,7 @@ int Client::ll_lookup(Inode *parent, const char *name, struct stat *attr, goto out; } - assert(in); + ceph_assert(in); fill_stat(in, attr); _ll_get(in.get()); @@ -10566,8 +10566,8 @@ int Client::ll_lookup_inode( if (r) { return r; } - assert(inode != NULL); - assert(*inode != NULL); + ceph_assert(inode != NULL); + ceph_assert(*inode != NULL); // Num2: Request the parent inode, so that we can look up the name Inode *parent; @@ -10583,7 +10583,7 @@ int Client::ll_lookup_inode( } // FIXME: I don't think this works; lookup_parent() returns 0 if the parent // is already in cache - assert(parent != NULL); + ceph_assert(parent != NULL); // Num3: Finally, get the name (dentry) of the requested inode r = _lookup_name(*inode, parent, perms); @@ -10629,7 +10629,7 @@ int Client::ll_lookupx(Inode *parent, const char *name, Inode **out, stx->stx_ino = 0; stx->stx_mask = 0; } else { - assert(in); + ceph_assert(in); fill_statx(in, mask, stx); _ll_get(in.get()); } @@ -10666,7 +10666,7 @@ int Client::ll_walk(const char* name, Inode **out, struct ceph_statx *stx, *out = NULL; return rc; } else { - assert(in); + ceph_assert(in); fill_statx(in, mask, stx); _ll_get(in.get()); *out = in.get(); @@ -10679,7 +10679,7 @@ void Client::_ll_get(Inode *in) if (in->ll_ref == 0) { in->get(); if (in->is_dir() && !in->dentries.empty()) { - assert(in->dentries.size() == 1); // dirs can't be hard-linked + ceph_assert(in->dentries.size() == 1); // dirs can't be hard-linked in->get_first_parent()->get(); // pin dentry } if (in->snapid != CEPH_NOSNAP) @@ -10695,13 +10695,13 @@ int Client::_ll_put(Inode *in, int num) ldout(cct, 20) << __func__ << " " << in << " " << in->ino << " " << num << " -> " << in->ll_ref << dendl; if (in->ll_ref == 0) { if (in->is_dir() && !in->dentries.empty()) { - assert(in->dentries.size() == 1); // dirs can't be hard-linked + ceph_assert(in->dentries.size() == 1); // dirs can't be hard-linked in->get_first_parent()->put(); // unpin dentry } if (in->snapid != CEPH_NOSNAP) { auto p = ll_snap_ref.find(in->snapid); - assert(p != ll_snap_ref.end()); - assert(p->second > 0); + ceph_assert(p != ll_snap_ref.end()); + ceph_assert(p->second > 0); if (--p->second == 0) ll_snap_ref.erase(p); } @@ -10908,7 +10908,7 @@ int Client::ll_setattrx(Inode *in, struct ceph_statx *stx, int mask, InodeRef target(in); int res = _ll_setattrx(in, stx, mask, perms, &target); if (res == 0) { - assert(in == target.get()); + ceph_assert(in == target.get()); fill_statx(in, in->caps_issued(), stx); } @@ -10930,7 +10930,7 @@ int Client::ll_setattr(Inode *in, struct stat *attr, int mask, InodeRef target(in); int res = _ll_setattrx(in, &stx, mask, perms, &target); if (res == 0) { - assert(in == target.get()); + ceph_assert(in == target.get()); fill_stat(in, attr); } @@ -12835,7 +12835,7 @@ int Client::ll_fsyncdir(dir_result_t *dirp) int Client::ll_open(Inode *in, int flags, Fh **fhp, const UserPerm& perms) { - assert(!(flags & O_CREAT)); + ceph_assert(!(flags & O_CREAT)); Mutex::Locker lock(client_lock); @@ -12911,7 +12911,7 @@ int Client::_ll_create(Inode *parent, const char *name, mode_t mode, if (r < 0) goto out; - assert(*in); + ceph_assert(*in); ldout(cct, 20) << "_ll_create created = " << created << dendl; if (!created) { @@ -12922,7 +12922,7 @@ int Client::_ll_create(Inode *parent, const char *name, mode_t mode, if (r < 0) { if (*fhp) { int release_r = _release_fh(*fhp); - assert(release_r == 0); // during create, no async data ops should have happened + ceph_assert(release_r == 0); // during create, no async data ops should have happened } goto out; } @@ -12970,7 +12970,7 @@ int Client::ll_create(Inode *parent, const char *name, mode_t mode, int r = _ll_create(parent, name, mode, flags, &in, CEPH_STAT_CAP_INODE_ALL, fhp, perms); if (r >= 0) { - assert(in); + ceph_assert(in); // passing an Inode in outp requires an additional ref if (outp) { @@ -12999,7 +12999,7 @@ int Client::ll_createx(Inode *parent, const char *name, mode_t mode, int r = _ll_create(parent, name, mode, oflags, &in, caps, fhp, perms); if (r >= 0) { - assert(in); + ceph_assert(in); // passing an Inode in outp requires an additional ref if (outp) { @@ -13518,7 +13518,7 @@ public: } void finish(int r) override { Mutex::Locker l(client->client_lock); - assert(req->head.op == CEPH_MDS_OP_SETFILELOCK); + ceph_assert(req->head.op == CEPH_MDS_OP_SETFILELOCK); client->_interrupt_filelock(req); client->put_request(req); } @@ -13637,7 +13637,7 @@ int Client::get_file_extent_osds(int fd, loff_t off, loff_t *len, vector& o vector extents; Striper::file_to_extents(cct, in->ino, &in->layout, off, 1, in->truncate_size, extents); - assert(extents.size() == 1); + ceph_assert(extents.size() == 1); objecter->with_osdmap([&](const OSDMap& o) { pg_t pg = o.object_locator_to_pg(extents[0].oid, extents[0].oloc); @@ -13700,7 +13700,7 @@ int Client::get_file_stripe_address(int fd, loff_t offset, vector extents; Striper::file_to_extents(cct, in->ino, &in->layout, offset, 1, in->truncate_size, extents); - assert(extents.size() == 1); + ceph_assert(extents.size() == 1); // now we have the object and its 'layout' return objecter->with_osdmap([&](const OSDMap& o) { @@ -13893,7 +13893,7 @@ bool Client::check_quota_condition(Inode *in, const UserPerm& perms, std::function test) { while (true) { - assert(in != NULL); + ceph_assert(in != NULL); if (test(*in)) { return true; } @@ -13937,7 +13937,7 @@ bool Client::is_quota_bytes_approaching(Inode *in, const UserPerm& perms) return true; } - assert(in.size >= in.reported_size); + ceph_assert(in.size >= in.reported_size); const uint64_t space = in.quota.max_bytes - in.rstat.rbytes; const uint64_t size = in.size - in.reported_size; return (space >> 4) < size; @@ -13972,7 +13972,7 @@ int Client::check_pool_perm(Inode *in, int need) wait_on_list(waiting_for_pool_perm); } else { have = it->second; - assert(have & POOL_CHECKED); + ceph_assert(have & POOL_CHECKED); break; } } @@ -14146,7 +14146,7 @@ out: void Client::set_filer_flags(int flags) { Mutex::Locker l(client_lock); - assert(flags == 0 || + ceph_assert(flags == 0 || flags == CEPH_OSD_FLAG_LOCALIZE_READS); objecter->add_global_op_flags(flags); } @@ -14154,7 +14154,7 @@ void Client::set_filer_flags(int flags) void Client::clear_filer_flags(int flags) { Mutex::Locker l(client_lock); - assert(flags == CEPH_OSD_FLAG_LOCALIZE_READS); + ceph_assert(flags == CEPH_OSD_FLAG_LOCALIZE_READS); objecter->clear_global_op_flag(flags); } @@ -14211,7 +14211,7 @@ void intrusive_ptr_release(Inode *in) mds_rank_t Client::_get_random_up_mds() const { - assert(client_lock.is_locked_by_me()); + ceph_assert(client_lock.is_locked_by_me()); std::set up; mdsmap->get_up_mds_set(up); @@ -14245,7 +14245,7 @@ int StandaloneClient::init() objecter->init(); client_lock.Lock(); - assert(!is_initialized()); + ceph_assert(!is_initialized()); messenger->add_dispatcher_tail(objecter); messenger->add_dispatcher_tail(this); diff --git a/src/client/Client.h b/src/client/Client.h index 55643e959687f..482e45df1dd89 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -180,7 +180,7 @@ struct dir_result_t { if (hash) v |= HASH; else - assert((v & HASH) != HASH); + ceph_assert((v & HASH) != HASH); return v; } static unsigned fpos_high(uint64_t p) { diff --git a/src/client/Delegation.cc b/src/client/Delegation.cc index c628cf66df014..4761d9882c53d 100644 --- a/src/client/Delegation.cc +++ b/src/client/Delegation.cc @@ -17,7 +17,7 @@ public: Client *client = in->client; // Called back via Timer, which takes client_lock for us - assert(client->client_lock.is_locked_by_me()); + ceph_assert(client->client_lock.is_locked_by_me()); lsubdout(client->cct, client, 0) << __func__ << ": delegation return timeout for inode 0x" << @@ -57,7 +57,7 @@ int ceph_deleg_caps_for_type(unsigned type) break; default: // Should never happen - assert(false); + ceph_assert(false); } return caps; } diff --git a/src/client/Dentry.h b/src/client/Dentry.h index 1583267d6f565..ffbb5104b49b9 100644 --- a/src/client/Dentry.h +++ b/src/client/Dentry.h @@ -15,12 +15,12 @@ public: dir(_dir), name(_name), inode_xlist_link(this) { auto r = dir->dentries.insert(make_pair(name, this)); - assert(r.second); + ceph_assert(r.second); dir->num_null_dentries++; } ~Dentry() { - assert(ref == 0); - assert(dir == nullptr); + ceph_assert(ref == 0); + ceph_assert(dir == nullptr); } /* @@ -28,13 +28,13 @@ public: * ref >1 -> pinned in lru */ void get() { - assert(ref > 0); + ceph_assert(ref > 0); if (++ref == 2) lru_pin(); //cout << "dentry.get on " << this << " " << name << " now " << ref << std::endl; } void put() { - assert(ref > 0); + ceph_assert(ref > 0); if (--ref == 1) lru_unpin(); //cout << "dentry.put on " << this << " " << name << " now " << ref << std::endl; @@ -59,15 +59,15 @@ public: if (inode->ll_ref) put(); // ll_ref -> dn pin } - assert(inode_xlist_link.get_list() == &inode->dentries); + ceph_assert(inode_xlist_link.get_list() == &inode->dentries); inode_xlist_link.remove_myself(); inode.reset(); dir->num_null_dentries++; } void detach(void) { - assert(!inode); + ceph_assert(!inode); auto p = dir->dentries.find(name); - assert(p != dir->dentries.end()); + ceph_assert(p != dir->dentries.end()); dir->dentries.erase(p); dir->num_null_dentries--; dir = nullptr; diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 6e76fcfddaab0..432530bd21019 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -26,13 +26,13 @@ Inode::~Inode() if (!oset.objects.empty()) { lsubdout(client->cct, client, 0) << __func__ << ": leftover objects on inode 0x" << std::hex << ino << std::dec << dendl; - assert(oset.objects.empty()); + ceph_assert(oset.objects.empty()); } if (!delegations.empty()) { lsubdout(client->cct, client, 0) << __func__ << ": leftover delegations on inode 0x" << std::hex << ino << std::dec << dendl; - assert(delegations.empty()); + ceph_assert(delegations.empty()); } } @@ -91,7 +91,7 @@ void Inode::make_long_path(filepath& p) { if (!dentries.empty()) { Dentry *dn = get_first_parent(); - assert(dn->dir && dn->dir->parent_inode); + ceph_assert(dn->dir && dn->dir->parent_inode); dn->dir->parent_inode->make_long_path(p); p.push_dentry(dn->name); } else if (snapdir_parent) { @@ -117,7 +117,7 @@ void Inode::make_nosnap_relative_path(filepath& p) p.push_dentry(empty); } else if (!dentries.empty()) { Dentry *dn = get_first_parent(); - assert(dn->dir && dn->dir->parent_inode); + ceph_assert(dn->dir && dn->dir->parent_inode); dn->dir->parent_inode->make_nosnap_relative_path(p); p.push_dentry(dn->name); } else { @@ -135,7 +135,7 @@ bool Inode::put_open_ref(int mode) { //cout << "open_by_mode[" << mode << "] " << open_by_mode[mode] << " -> " << (open_by_mode[mode]-1) << std::endl; auto& ref = open_by_mode.at(mode); - assert(ref > 0); + ceph_assert(ref > 0); if (--ref == 0) return true; return false; @@ -164,7 +164,7 @@ int Inode::put_cap_ref(int cap) int c = 1 << n; if (cap_refs[c] <= 0) { lderr(client->cct) << "put_cap_ref " << ccap_string(c) << " went negative on " << *this << dendl; - assert(cap_refs[c] > 0); + ceph_assert(cap_refs[c] > 0); } if (--cap_refs[c] == 0) last |= c; @@ -359,7 +359,7 @@ Dir *Inode::open_dir() if (!dir) { dir = new Dir(this); lsubdout(client->cct, client, 15) << "open_dir " << dir << " on " << this << dendl; - assert(dentries.size() < 2); // dirs can't be hard-linked + ceph_assert(dentries.size() < 2); // dirs can't be hard-linked if (!dentries.empty()) get_first_parent()->get(); // pin dentry get(); // pin inode @@ -391,7 +391,7 @@ int Inode::_put(int n) { _ref -= n; lsubdout(client->cct, client, 15) << "inode.put on " << this << " " << ino << '.' << snapid << " now " << _ref << dendl; - assert(_ref >= 0); + ceph_assert(_ref >= 0); return _ref; } diff --git a/src/client/Inode.h b/src/client/Inode.h index ca724d0531297..b3b5b6e4be0b6 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -174,7 +174,7 @@ struct Inode { int which = dir_layout.dl_dir_hash; if (!which) which = CEPH_STR_HASH_LINUX; - assert(ceph_str_hash_valid(which)); + ceph_assert(ceph_str_hash_valid(which)); return ceph_str_hash(which, dn.data(), dn.length()); } @@ -231,7 +231,7 @@ struct Inode { list waitfor_deleg; Dentry *get_first_parent() { - assert(!dentries.empty()); + ceph_assert(!dentries.empty()); return *dentries.begin(); } @@ -249,7 +249,7 @@ struct Inode { ll_ref++; } void ll_put(int n=1) { - assert(ll_ref >= n); + ceph_assert(ll_ref >= n); ll_ref -= n; } diff --git a/src/client/MetaRequest.cc b/src/client/MetaRequest.cc index b6574def51721..8a71b2753d7e3 100644 --- a/src/client/MetaRequest.cc +++ b/src/client/MetaRequest.cc @@ -61,7 +61,7 @@ MetaRequest::~MetaRequest() } void MetaRequest::set_dentry(Dentry *d) { - assert(_dentry == NULL); + ceph_assert(_dentry == NULL); _dentry = d; _dentry->get(); } @@ -70,7 +70,7 @@ Dentry *MetaRequest::dentry() { } void MetaRequest::set_old_dentry(Dentry *d) { - assert(_old_dentry == NULL); + ceph_assert(_old_dentry == NULL); _old_dentry = d; _old_dentry->get(); } diff --git a/src/client/MetaRequest.h b/src/client/MetaRequest.h index 0697683f0f489..d7eb374cadd87 100644 --- a/src/client/MetaRequest.h +++ b/src/client/MetaRequest.h @@ -98,7 +98,7 @@ public: */ void abort(int rc) { - assert(rc != 0); + ceph_assert(rc != 0); abort_rc = rc; } diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index 6979dc7bb97b6..ed74923a7291d 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -940,17 +940,17 @@ int SyntheticClient::run() int SyntheticClient::start_thread() { - assert(!thread_id); + ceph_assert(!thread_id); pthread_create(&thread_id, NULL, synthetic_client_thread_entry, this); - assert(thread_id); + ceph_assert(thread_id); ceph_pthread_setname(thread_id, "client"); return 0; } int SyntheticClient::join_thread() { - assert(thread_id); + ceph_assert(thread_id); void *rv; pthread_join(thread_id, &rv); return 0; @@ -2747,7 +2747,7 @@ int SyntheticClient::random_walk(int num_req) else { r = client->open(get_random_sub(), O_RDONLY, perms); if (r > 0) { - assert(open_files.count(r) == 0); + ceph_assert(open_files.count(r) == 0); open_files.insert(r); } } @@ -2900,18 +2900,18 @@ void SyntheticClient::foo() char buffer[8192]; client->unlink(fn, perms); int handle = client->open(fn, O_CREAT|O_RDWR, perms, S_IRWXU); - assert(handle>=0); + ceph_assert(handle>=0); int r=client->write(handle,buffer,8192); - assert(r>=0); + ceph_assert(r>=0); r=client->close(handle); - assert(r>=0); + ceph_assert(r>=0); handle = client->open(fn, O_RDWR, perms); // open the same file, it must have some data already - assert(handle>=0); + ceph_assert(handle>=0); r=client->read(handle,buffer,8192); - assert(r==8192); // THIS ASSERTION FAILS with disabled cache + ceph_assert(r==8192); // THIS ASSERTION FAILS with disabled cache r=client->close(handle); - assert(r>=0); + ceph_assert(r>=0); return; } @@ -3208,7 +3208,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) client->mkdir(base, 0755, process_perms); ifstream f(find); - assert(f.is_open()); + ceph_assert(f.is_open()); int dirnum = 0; @@ -3237,7 +3237,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) if (filename == ".") continue; // remove leading ./ - assert(filename[0] == '.' && filename[1] == '/'); + ceph_assert(filename[0] == '.' && filename[1] == '/'); filename = filename.substr(2); // new leading dir? @@ -3251,7 +3251,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) } // parse the mode - assert(modestring.length() == 10); + ceph_assert(modestring.length() == 10); mode_t mode = 0; switch (modestring[0]) { case 'd': mode |= S_IFDIR; break; @@ -3274,7 +3274,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) if (S_ISLNK(mode)) { // target vs destination int pos = filename.find(" -> "); - assert(pos > 0); + ceph_assert(pos > 0); string link; if (base[0] != '-') { link = base; @@ -3302,7 +3302,7 @@ void SyntheticClient::import_find(const char *base, const char *find, bool data) client->mkdir(f.c_str(), mode, perms); } else { int fd = client->open(f.c_str(), O_WRONLY|O_CREAT, perms, mode & 0777); - assert(fd > 0); + ceph_assert(fd > 0); if (data) { client->write(fd, "", 0, size); } else { @@ -3359,7 +3359,7 @@ int SyntheticClient::chunk_file(string &filename) inode_t inode{}; inode.ino = st.st_ino; ret = client->fdescribe_layout(fd, &inode.layout); - assert(ret == 0); // otherwise fstat did a bad thing + ceph_assert(ret == 0); // otherwise fstat did a bad thing uint64_t pos = 0; bufferlist from_before; diff --git a/src/client/SyntheticClient.h b/src/client/SyntheticClient.h index d1deff113c8a2..faec7e26d8add 100644 --- a/src/client/SyntheticClient.h +++ b/src/client/SyntheticClient.h @@ -133,7 +133,7 @@ class SyntheticClient { filepath n1; const char *get_random_subdir() { - assert(!subdirs.empty()); + ceph_assert(!subdirs.empty()); int r = ((rand() % subdirs.size()) + (rand() % subdirs.size())) / 2; // non-uniform distn set::iterator it = subdirs.begin(); while (r--) ++it; @@ -144,7 +144,7 @@ class SyntheticClient { } filepath n2; const char *get_random_sub() { - assert(!contents.empty()); + ceph_assert(!contents.empty()); int r = ((rand() % contents.size()) + (rand() % contents.size())) / 2; // non-uniform distn if (cwd.depth() && cwd.last_dentry().length()) r += cwd.last_dentry().c_str()[0]; // slightly permuted diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 8027b2fcafdbf..de5950810b9a8 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -105,7 +105,7 @@ public: static int getgroups(fuse_req_t req, gid_t **sgids) { #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8) - assert(sgids); + ceph_assert(sgids); int c = fuse_req_getgroups(req, 0, NULL); if (c < 0) { return c; @@ -1148,7 +1148,7 @@ int CephFuse::Handle::init(int argc, const char *argv[]) return EINVAL; } - assert(args.allocated); // Checking fuse has realloc'd args so we can free newargv + ceph_assert(args.allocated); // Checking fuse has realloc'd args so we can free newargv free(newargv); return 0; } @@ -1217,7 +1217,7 @@ uint64_t CephFuse::Handle::fino_snap(uint64_t fino) } else { Mutex::Locker l(stag_lock); uint64_t stag = FINO_STAG(fino); - assert(stag_snap_map.count(stag)); + ceph_assert(stag_snap_map.count(stag)); return stag_snap_map[stag]; } } @@ -1280,7 +1280,7 @@ uint64_t CephFuse::Handle::make_fake_ino(inodeno_t ino, snapid_t snapid) } } if (stag == first) - assert(0 == "run out of stag"); + ceph_assert(0 == "run out of stag"); inodeno_t fino = MAKE_FINO(ino, stag); //cout << "make_fake_ino " << ino << "." << snapid << " -> " << fino << std::endl; -- 2.39.5