import time
+import logging
from cephfs_test_case import CephFSTestCase
from teuthology.exceptions import CommandFailedError
from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
+log = logging.getLogger(__name__)
+
class OpenFileTable(CephFSTestCase):
CLIENTS_REQUIRED = 1
MDSS_REQUIRED = 1
+ def _check_oft_counter(self, name, count):
+ perf_dump = self.fs.mds_asok(['perf', 'dump'])
+ if perf_dump['oft'][name] == count:
+ return True
+ return False
+
def test_max_items_per_obj(self):
"""
The maximum number of openfiles omap objects keys are now equal to
# Now close the file
self.mount_a.kill_background(p)
+
+ def test_perf_counters(self):
+ """
+ Opening a file should increment omap_total_updates by 1.
+ """
+
+ self.set_conf("mds", "osd_deep_scrub_large_omap_object_key_threshold", "1")
+ self.fs.mds_restart()
+ self.fs.wait_for_daemons()
+
+ perf_dump = self.fs.mds_asok(['perf', 'dump'])
+ omap_total_updates_0 = perf_dump['oft']['omap_total_updates']
+ log.info("omap_total_updates_0:{}".format(omap_total_updates_0))
+
+ # Open the file
+ p = self.mount_a.open_background("omap_counter_test_file")
+ self.wait_until_true(lambda: self._check_oft_counter('omap_total_updates', 2), timeout=30)
+
+ perf_dump = self.fs.mds_asok(['perf', 'dump'])
+ omap_total_updates_1 = perf_dump['oft']['omap_total_updates']
+ log.info("omap_total_updates_1:{}".format(omap_total_updates_1))
+
+ self.assertTrue((omap_total_updates_1 - omap_total_updates_0) == 2)
+
+ # Now close the file
+ self.mount_a.kill_background(p)
+ # Ensure that the file does not exist any more
+ self.wait_until_true(lambda: self._check_oft_counter('omap_total_removes', 1), timeout=30)
+ self.wait_until_true(lambda: self._check_oft_counter('omap_total_kv_pairs', 1), timeout=30)
+
+ perf_dump = self.fs.mds_asok(['perf', 'dump'])
+ omap_total_removes = perf_dump['oft']['omap_total_removes']
+ omap_total_kv_pairs = perf_dump['oft']['omap_total_kv_pairs']
+ log.info("omap_total_removes:{}".format(omap_total_removes))
+ log.info("omap_total_kv_pairs:{}".format(omap_total_kv_pairs))
+ self.assertTrue(omap_total_removes == 1)
+ self.assertTrue(omap_total_kv_pairs == 1)
#include "common/config.h"
#include "common/errno.h"
+enum {
+ l_oft_first = 1000000,
+ l_oft_omap_total_objs,
+ l_oft_omap_total_kv_pairs,
+ l_oft_omap_total_updates,
+ l_oft_omap_total_removes,
+ l_oft_last
+};
+
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_mds
#undef dout_prefix
return *_dout << "mds." << mds->get_nodeid() << ".openfiles ";
}
+OpenFileTable::OpenFileTable(MDSRank *m) : mds(m) {
+ PerfCountersBuilder b(mds->cct, "oft", l_oft_first, l_oft_last);
+
+ b.add_u64(l_oft_omap_total_objs, "omap_total_objs");
+ b.add_u64(l_oft_omap_total_kv_pairs, "omap_total_kv_pairs");
+ b.add_u64(l_oft_omap_total_updates, "omap_total_updates");
+ b.add_u64(l_oft_omap_total_removes, "omap_total_removes");
+ logger.reset(b.create_perf_counters());
+ mds->cct->get_perfcounters_collection()->add(logger.get());
+ logger->set(l_oft_omap_total_objs, 0);
+ logger->set(l_oft_omap_total_kv_pairs, 0);
+ logger->set(l_oft_omap_total_updates, 0);
+ logger->set(l_oft_omap_total_removes, 0);
+}
+
+OpenFileTable::~OpenFileTable() {
+ if (logger) {
+ mds->cct->get_perfcounters_collection()->remove(logger.get());
+ }
+}
+
void OpenFileTable::get_ref(CInode *in)
{
do {
loaded_dirfrags.clear();
}
+ size_t total_items = 0;
{
- size_t total_items = 0;
unsigned used_objs = 1;
std::vector<unsigned> objs_to_write;
bool journaled = false;
ceph_assert(!gather.has_subs());
}
+ uint64_t total_updates = 0;
+ uint64_t total_removes = 0;
+
for (unsigned omap_idx = 0; omap_idx < omap_updates.size(); omap_idx++) {
auto& ctl = omap_updates[omap_idx];
ceph_assert(ctl.to_update.empty() && ctl.to_remove.empty());
ctl.write_size = 0;
first = false;
}
+ total_updates++;
}
for (auto& key : ctl.journaled_remove) {
ctl.write_size = 0;
first = false;
}
+ total_removes++;
}
for (unsigned i = 0; i < ctl.journal_idx; ++i) {
} else {
submit_ops_func();
}
+ logger->set(l_oft_omap_total_objs, omap_num_objs);
+ logger->set(l_oft_omap_total_kv_pairs, total_items);
+ logger->inc(l_oft_omap_total_updates, total_updates);
+ logger->inc(l_oft_omap_total_removes, total_removes);
}
class C_IO_OFT_Load : public MDSIOContextBase {
class OpenFileTable
{
public:
- explicit OpenFileTable(MDSRank *m) : mds(m) {}
+ explicit OpenFileTable(MDSRank *m);
+ ~OpenFileTable();
void add_inode(CInode *in);
void remove_inode(CInode *in);
std::map<uint64_t, vector<inodeno_t> > logseg_destroyed_inos;
std::set<inodeno_t> destroyed_inos_set;
+
+ std::unique_ptr<PerfCounters> logger;
};
#endif