Skip to content

Commit

Permalink
cephfs_mirror: check m_instance_watcher and m_mirror_watcher before u…
Browse files Browse the repository at this point in the history
…sing them

Fixes the crash:
```
std::scoped_lock<std::mutex>::scoped_lock (__m=..., this=<optimized out>, this=<optimized out>, __m=...) at /usr/include/c++/11/mutex:655
cephfs::mirror::MirrorWatcher::is_failed (this=0x0) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/MirrorWatcher.h:56
cephfs::mirror::FSMirror::is_failed (this=0x557478284340) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/FSMirror.h:52
cephfs::mirror::Mirror::update_fs_mirrors (this=0x5574773c3e60) at /usr/src/debug/ceph-19.0.0-1578.g3d482f42.el9.x86_64/src/tools/cephfs_mirror/Mirror.cc:515

```

Fixes: https://tracker.ceph.com/issues/64751
Signed-off-by: Jos Collin <jcollin@redhat.com>
  • Loading branch information
joscollin committed Mar 19, 2024
1 parent d7353ad commit 5b8b9c2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/tools/cephfs_mirror/FSMirror.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@ class FSMirror {

bool is_failed() {
std::scoped_lock locker(m_lock);
return m_init_failed ||
m_instance_watcher->is_failed() ||
m_mirror_watcher->is_failed();
bool failed = m_init_failed;
if (m_instance_watcher) {
failed |= m_instance_watcher->is_failed();
}
if (m_mirror_watcher) {
failed |= m_mirror_watcher->is_failed();
}
return failed;
}

utime_t get_failed_ts() {
Expand Down

0 comments on commit 5b8b9c2

Please sign in to comment.