From b290909ec1765662cfbda67ff0227be0166d1f17 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 13 Aug 2018 09:56:04 +0800 Subject: [PATCH] tools/cephfs: make cephfs-data-scan prints the max used ino Fixes: http://tracker.ceph.com/issues/26925 Signed-off-by: "Yan, Zheng" (cherry picked from commit e943ff0b8f22ac346b82d3f45351695aa8944121) Conflicts: doc/cephfs/disaster-recovery-experts.rst - luminous does not have this file --- src/tools/cephfs/DataScan.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index d7cd221dac862..457833c5f357f 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -898,7 +898,7 @@ int DataScan::scan_links() return -EINVAL; } - interval_set used_inos; + interval_set used_inos; map remote_links; struct link_info_t { @@ -1030,6 +1030,28 @@ int DataScan::scan_links() } } } + + map max_ino_map; + { + auto prev_max_ino = (uint64_t)1 << 40; + for (auto p = used_inos.begin(); p != used_inos.end(); ++p) { + auto cur_max = p.get_start() + p.get_len() - 1; + if (cur_max < prev_max_ino) + continue; // system inodes + + if ((prev_max_ino >> 40) != (cur_max >> 40)) { + unsigned rank = (prev_max_ino >> 40) - 1; + max_ino_map[rank] = prev_max_ino; + } else if ((p.get_start() >> 40) != (cur_max >> 40)) { + unsigned rank = (p.get_start() >> 40) - 1; + max_ino_map[rank] = ((uint64_t)(rank + 2) << 40) - 1; + } + prev_max_ino = cur_max; + } + unsigned rank = (prev_max_ino >> 40) - 1; + max_ino_map[rank] = prev_max_ino; + } + used_inos.clear(); for (auto& p : dup_primaries) { @@ -1104,6 +1126,10 @@ int DataScan::scan_links() return r; } + for (auto& p : max_ino_map) { + std::cout << "mds." << p.first << " max used ino " << p.second << std::endl; + } + return 0; } -- 2.39.5