From f9d5743d63454e1b36053a25e5dd76be4ba5b7b6 Mon Sep 17 00:00:00 2001 From: Zhi Zhang Date: Fri, 10 Jul 2020 17:03:50 +0800 Subject: [PATCH] mds: fix hang issue when accessing a file under a lost parent directory When a directory metadata is lost, if we looked up a file under this lost directory, this request will hang forever. Fixes: https://tracker.ceph.com/issues/46129 Signed-off-by: Zhi Zhang (cherry picked from commit 778917c426d3c8611c5e5f209840a674c09fef0a) Conflicts: src/mds/CDir.h - "git cherry-picked" failed to find the right hunk; made the change manually --- src/mds/CDir.cc | 29 +++++++++++------------------ src/mds/CDir.h | 5 ----- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index ead659fcca1c9..b7e0d485f8204 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2039,20 +2039,6 @@ void CDir::_omap_fetched(bufferlist& hdrbl, map& omap, } } -void CDir::_go_bad() -{ - if (get_version() == 0) - set_version(1); - state_set(STATE_BADFRAG); - // mark complete, !fetching - mark_complete(); - state_clear(STATE_FETCHING); - auth_unpin(this); - - // kick waiters - finish_waiting(WAIT_COMPLETE, -EIO); -} - void CDir::go_bad_dentry(snapid_t last, std::string_view dname) { dout(10) << __func__ << " " << dname << dendl; @@ -2077,10 +2063,17 @@ void CDir::go_bad(bool complete) ceph_abort(); // unreachable, damaged() respawns us } - if (complete) - _go_bad(); - else - auth_unpin(this); + if (complete) { + if (get_version() == 0) + set_version(1); + + state_set(STATE_BADFRAG); + mark_complete(); + } + + state_clear(STATE_FETCHING); + auth_unpin(this); + finish_waiting(WAIT_COMPLETE, -EIO); } // ----------------------- diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 3654c6a04011f..a3c89d51aecb3 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -624,11 +624,6 @@ protected: const std::set *snaps, bool *force_dirty); - /** - * Mark this fragment as BADFRAG (common part of go_bad and go_bad_dentry) - */ - void _go_bad(); - /** * Go bad due to a damaged dentry (register with damagetable and go BADFRAG) */ -- 2.39.5