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: v12.2.3~154^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=85791328fc563932673e2d6ad8701179fee0c3a3;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" (cherry picked from commit 3ca602e3bdaa211ae2446d4bbf62431e14d41bef) Conflicts: src/mds/MDCache.cc --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 633e6477553d..94a57ad7579a 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -3808,7 +3808,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--; + } } /** @@ -3972,10 +3975,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 b40833fd1cab..90aa21848092 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 ? @@ -7444,7 +7445,7 @@ void MDCache::check_memory_usage() static MemoryModel::snap baseline = last; // check client caps - assert(CInode::count() == 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 61a170bf6fd5..19fcb1dfb7e8 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -201,6 +201,8 @@ public: DecayRate decayrate; + int num_shadow_inodes; + int num_inodes_with_caps; unsigned max_dir_commit_size;