From 92e0fac0a8356b743687b1ee29e9d0ac8cf30358 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 28 Jun 2011 21:47:01 -0700 Subject: [PATCH] mds: fix snaprealm split for dir inode The snaprealm root directory inode belongs to the snaprealm, at least currently. This make split_at() consistent with the non-directory case at the top of the method, and prevents a crash later down the line when we try to tear down the parent snaprealm and we aren't part of it. Fixes: #1238 Signed-off-by: Sage Weil --- src/mds/snap.cc | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/mds/snap.cc b/src/mds/snap.cc index 026fcd3e8f18a..7444ac66dec68 100644 --- a/src/mds/snap.cc +++ b/src/mds/snap.cc @@ -367,8 +367,8 @@ void SnapRealm::split_at(SnapRealm *child) << " on " << *child->inode << dendl; if (!child->inode->is_dir()) { + // it's not a dir. if (child->inode->containing_realm) { - // it's not a dir: // - no open children. // - only need to move this child's inode's caps. child->inode->move_to_realm(child); @@ -406,16 +406,21 @@ void SnapRealm::split_at(SnapRealm *child) ++p; // does inode fall within the child realm? - CInode *t = in; bool under_child = false; - while (t->get_parent_dn()) { - t = t->get_parent_dn()->get_dir()->get_inode(); - if (t == child->inode) { - under_child = true; - break; + + if (in == child->inode) { + under_child = true; + } else { + CInode *t = in; + while (t->get_parent_dn()) { + t = t->get_parent_dn()->get_dir()->get_inode(); + if (t == child->inode) { + under_child = true; + break; + } + if (t == in) + break; } - if (t == in) - break; } if (under_child) { dout(20) << " child gets " << *in << dendl; -- 2.39.5