When the crawler or a datasync thread encountered an error,
it's possible that the crawler gets notified by a datasync
thread and bails out resulting in the unregister of the
particular dir_root. The other datasync threads might
still hold the same syncm object and tries to open the
handles during which the following assert is hit.
ceph_assert(it != m_registered.end());
The above assert is removed and the error is handled.
Fixes: https://tracker.ceph.com/issues/73452
Signed-off-by: Kotresh HR <khiremat@redhat.com>
{
std::scoped_lock locker(m_lock);
auto it = m_registered.find(dir_root);
- ceph_assert(it != m_registered.end());
+ if (it == m_registered.end()) {
+ dout(5) << ": open handle came after unregister, this is from datasync threads"
+ << " on crawl or datasync error - returning EINVAL " << dendl;
+ ceph_close(m_local_mount, fh->c_fd);
+ ceph_close(fh->p_mnt, fh->p_fd);
+ return -EINVAL;
+ }
fh->r_fd_dir_root = it->second.fd;
}