From 17d6a993fc17d533460c5f40f3908c708e057c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 23 May 2024 18:45:17 +0200 Subject: Merging upstream version 18.2.3. Signed-off-by: Daniel Baumann --- src/mds/SnapRealm.cc | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src/mds/SnapRealm.cc') diff --git a/src/mds/SnapRealm.cc b/src/mds/SnapRealm.cc index 9d303bcb0..ac8cdf832 100644 --- a/src/mds/SnapRealm.cc +++ b/src/mds/SnapRealm.cc @@ -309,7 +309,7 @@ void SnapRealm::adjust_parent() void SnapRealm::split_at(SnapRealm *child) { - dout(10) << "split_at " << *child + dout(10) << __func__ << ": " << *child << " on " << *child->inode << dendl; if (inode->is_mdsdir() || !child->inode->is_dir()) { @@ -328,8 +328,23 @@ void SnapRealm::split_at(SnapRealm *child) // it's a dir. + if (child->inode->get_projected_parent_dir()->inode->is_stray()) { + if (child->inode->containing_realm) { + dout(10) << " moving unlinked directory inode" << dendl; + child->inode->move_to_realm(child); + } else { + /* This shouldn't happen because an unlinked directory will have caps + * issued to the caller executing rmdir (for today's clients). + */ + dout(10) << " skipping unlinked directory inode w/o caps" << dendl; + } + return; + } + // split open_children - dout(10) << " open_children are " << open_children << dendl; + if (!open_children.empty()) { + dout(10) << " open_children are " << open_children << dendl; + } for (set::iterator p = open_children.begin(); p != open_children.end(); ) { SnapRealm *realm = *p; @@ -346,17 +361,25 @@ void SnapRealm::split_at(SnapRealm *child) } // split inodes_with_caps + std::unordered_map visited; + uint64_t count = 0; + dout(20) << " reserving space for " << CDir::count() << " dirs" << dendl; + visited.reserve(CDir::count()); /* a reasonable starting poing: keep in mind there may be CInode directories without fragments in cache */ for (auto p = inodes_with_caps.begin(); !p.end(); ) { CInode *in = *p; ++p; // does inode fall within the child realm? - if (child->inode->is_ancestor_of(in)) { - dout(20) << " child gets " << *in << dendl; + if (child->inode->is_ancestor_of(in, &visited)) { + dout(25) << " child gets " << *in << dendl; in->move_to_realm(child); + ++count; } else { - dout(20) << " keeping " << *in << dendl; + dout(25) << " keeping " << *in << dendl; } } + dout(20) << " visited " << visited.size() << " directories" << dendl; + + dout(10) << __func__ << ": split " << count << " inodes" << dendl; } void SnapRealm::merge_to(SnapRealm *newparent) -- cgit v1.2.3