From: Yan, Zheng Date: Thu, 26 Oct 2017 08:21:41 +0000 (+0800) Subject: mds: fix inode count check in MDCache::check_memory_usage() X-Git-Tag: v13.0.1~294^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ca602e3bdaa211ae2446d4bbf62431e14d41bef;p=ceph.git mds: fix inode count check in MDCache::check_memory_usage() Fixes: http://tracker.ceph.com/issues/21928 Signed-off-by: "Yan, Zheng" --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index d07da8a7aba..94b1eb2fed2 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3816,7 +3816,10 @@ void CInode::validate_disk_state(CInode::validated_data *results, } ~ValidationContinuation() override { - delete shadow_in; + if (shadow_in) { + delete shadow_in; + in->mdcache->num_shadow_inodes--; + } } /** @@ -3980,10 +3983,11 @@ next: assert(in->is_dir()); if (in->is_base()) { - shadow_in = new CInode(in->mdcache); - in->mdcache->create_unlinked_system_inode(shadow_in, - in->inode.ino, - in->inode.mode); + if (!shadow_in) { + shadow_in = new CInode(in->mdcache); + in->mdcache->create_unlinked_system_inode(shadow_in, in->inode.ino, in->inode.mode); + in->mdcache->num_shadow_inodes++; + } shadow_in->fetch(get_internal_callback(INODE)); return false; } else { diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 17068a64ca2..5c04df4e1d5 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -183,6 +183,7 @@ MDCache::MDCache(MDSRank *m, PurgeQueue &purge_queue_) : strays[i] = NULL; } + num_shadow_inodes = 0; num_inodes_with_caps = 0; max_dir_commit_size = g_conf->mds_dir_max_commit_size ? @@ -7418,7 +7419,7 @@ void MDCache::check_memory_usage() static MemoryModel::snap baseline = last; // check client caps - assert(CInode::count() == inode_map.size() + snap_inode_map.size()); + assert(CInode::count() == inode_map.size() + snap_inode_map.size() + num_shadow_inodes); double caps_per_inode = 0.0; if (CInode::count()) caps_per_inode = (double)Capability::count() / (double)CInode::count(); diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index a2ab48751a0..9429d39422c 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -202,6 +202,8 @@ public: DecayRate decayrate; + int num_shadow_inodes; + int num_inodes_with_caps; unsigned max_dir_commit_size;