Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/ceph/ceph_debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/math64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/ktime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/ceph/libceph.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ceph/mon_client.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/ceph/auth.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/ceph/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include "super.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #ifdef CONFIG_DEBUG_FS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "mds_client.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "metric.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int mdsmap_show(struct seq_file *s, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct ceph_fs_client *fsc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	struct ceph_mdsmap *mdsmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	if (!fsc->mdsc || !fsc->mdsc->mdsmap)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	mdsmap = fsc->mdsc->mdsmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	seq_printf(s, "epoch %d\n", mdsmap->m_epoch);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	seq_printf(s, "root %d\n", mdsmap->m_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	seq_printf(s, "max_mds %d\n", mdsmap->m_max_mds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	seq_printf(s, "session_timeout %d\n", mdsmap->m_session_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	seq_printf(s, "session_autoclose %d\n", mdsmap->m_session_autoclose);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	for (i = 0; i < mdsmap->possible_max_rank; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		struct ceph_entity_addr *addr = &mdsmap->m_info[i].addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		int state = mdsmap->m_info[i].state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		seq_printf(s, "\tmds%d\t%s\t(%s)\n", i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			       ceph_pr_addr(addr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 			       ceph_mds_state_name(state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50)  * mdsc debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static int mdsc_show(struct seq_file *s, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	struct ceph_fs_client *fsc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	struct ceph_mds_client *mdsc = fsc->mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct ceph_mds_request *req;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	struct rb_node *rp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int pathlen = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	u64 pathbase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	char *path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	mutex_lock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	for (rp = rb_first(&mdsc->request_tree); rp; rp = rb_next(rp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		req = rb_entry(rp, struct ceph_mds_request, r_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		if (req->r_request && req->r_session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			seq_printf(s, "%lld\tmds%d\t", req->r_tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 				   req->r_session->s_mds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		else if (!req->r_request)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			seq_printf(s, "%lld\t(no request)\t", req->r_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			seq_printf(s, "%lld\t(no session)\t", req->r_tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		seq_printf(s, "%s", ceph_mds_op_name(req->r_op));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		if (test_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			seq_puts(s, "\t(unsafe)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			seq_puts(s, "\t");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		if (req->r_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			seq_printf(s, " #%llx", ceph_ino(req->r_inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		} else if (req->r_dentry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			path = ceph_mdsc_build_path(req->r_dentry, &pathlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 						    &pathbase, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			if (IS_ERR(path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 			spin_lock(&req->r_dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			seq_printf(s, " #%llx/%pd (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 				   ceph_ino(d_inode(req->r_dentry->d_parent)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 				   req->r_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				   path ? path : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			spin_unlock(&req->r_dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			ceph_mdsc_free_path(path, pathlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		} else if (req->r_path1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			seq_printf(s, " #%llx/%s", req->r_ino1.ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 				   req->r_path1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			seq_printf(s, " #%llx", req->r_ino1.ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		if (req->r_old_dentry) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 						    &pathbase, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			if (IS_ERR(path))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 				path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			spin_lock(&req->r_old_dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			seq_printf(s, " #%llx/%pd (%s)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 				   req->r_old_dentry_dir ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 				   ceph_ino(req->r_old_dentry_dir) : 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 				   req->r_old_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 				   path ? path : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			spin_unlock(&req->r_old_dentry->d_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			ceph_mdsc_free_path(path, pathlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		} else if (req->r_path2 && req->r_op != CEPH_MDS_OP_SYMLINK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			if (req->r_ino2.ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 				seq_printf(s, " #%llx/%s", req->r_ino2.ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 					   req->r_path2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 				seq_printf(s, " %s", req->r_path2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		seq_puts(s, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	mutex_unlock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) #define CEPH_METRIC_SHOW(name, total, avg, min, max, sq) {		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	s64 _total, _avg, _min, _max, _sq, _st;				\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	_avg = ktime_to_us(avg);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	_min = ktime_to_us(min == KTIME_MAX ? 0 : min);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	_max = ktime_to_us(max);					\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	_total = total - 1;						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	_sq = _total > 0 ? DIV64_U64_ROUND_CLOSEST(sq, _total) : 0;	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	_st = int_sqrt64(_sq);						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	_st = ktime_to_us(_st);						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	seq_printf(s, "%-14s%-12lld%-16lld%-16lld%-16lld%lld\n",	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		   name, total, _avg, _min, _max, _st);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int metric_show(struct seq_file *s, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	struct ceph_fs_client *fsc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	struct ceph_mds_client *mdsc = fsc->mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct ceph_client_metric *m = &mdsc->metric;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int nr_caps = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	s64 total, sum, avg, min, max, sq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	sum = percpu_counter_sum(&m->total_inodes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	seq_printf(s, "item                               total\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	seq_printf(s, "------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	seq_printf(s, "%-35s%lld / %lld\n", "opened files  / total inodes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		   atomic64_read(&m->opened_files), sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	seq_printf(s, "%-35s%lld / %lld\n", "pinned i_caps / total inodes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		   atomic64_read(&m->total_caps), sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	seq_printf(s, "%-35s%lld / %lld\n", "opened inodes / total inodes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		   percpu_counter_sum(&m->opened_inodes), sum);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	seq_printf(s, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	seq_printf(s, "item          total       avg_lat(us)     min_lat(us)     max_lat(us)     stdev(us)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	seq_printf(s, "-----------------------------------------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	spin_lock(&m->read_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	total = m->total_reads;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	sum = m->read_latency_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	min = m->read_latency_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	max = m->read_latency_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	sq = m->read_latency_sq_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	spin_unlock(&m->read_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	CEPH_METRIC_SHOW("read", total, avg, min, max, sq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	spin_lock(&m->write_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	total = m->total_writes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	sum = m->write_latency_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	min = m->write_latency_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	max = m->write_latency_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	sq = m->write_latency_sq_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	spin_unlock(&m->write_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	CEPH_METRIC_SHOW("write", total, avg, min, max, sq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	spin_lock(&m->metadata_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	total = m->total_metadatas;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	sum = m->metadata_latency_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	avg = total > 0 ? DIV64_U64_ROUND_CLOSEST(sum, total) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	min = m->metadata_latency_min;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	max = m->metadata_latency_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	sq = m->metadata_latency_sq_sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	spin_unlock(&m->metadata_latency_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	CEPH_METRIC_SHOW("metadata", total, avg, min, max, sq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	seq_printf(s, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	seq_printf(s, "item          total           miss            hit\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	seq_printf(s, "-------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	seq_printf(s, "%-14s%-16lld%-16lld%lld\n", "d_lease",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		   atomic64_read(&m->total_dentries),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		   percpu_counter_sum(&m->d_lease_mis),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		   percpu_counter_sum(&m->d_lease_hit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	nr_caps = atomic64_read(&m->total_caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	seq_printf(s, "%-14s%-16d%-16lld%lld\n", "caps", nr_caps,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		   percpu_counter_sum(&m->i_caps_mis),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		   percpu_counter_sum(&m->i_caps_hit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static int caps_show_cb(struct inode *inode, struct ceph_cap *cap, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	struct seq_file *s = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	seq_printf(s, "0x%-17llx%-3d%-17s%-17s\n", ceph_ino(inode),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		   cap->session->s_mds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		   ceph_cap_string(cap->issued),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		   ceph_cap_string(cap->implemented));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static int caps_show(struct seq_file *s, void *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	struct ceph_fs_client *fsc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct ceph_mds_client *mdsc = fsc->mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	int total, avail, used, reserved, min, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	struct cap_wait	*cw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	seq_printf(s, "total\t\t%d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		   "avail\t\t%d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		   "used\t\t%d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		   "reserved\t%d\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		   "min\t\t%d\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		   total, avail, used, reserved, min);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	seq_printf(s, "ino              mds  issued           implemented\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	seq_printf(s, "--------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	mutex_lock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	for (i = 0; i < mdsc->max_sessions; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 		struct ceph_mds_session *session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		session = __ceph_lookup_mds_session(mdsc, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		if (!session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		mutex_unlock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		mutex_lock(&session->s_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		ceph_iterate_session_caps(session, caps_show_cb, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		mutex_unlock(&session->s_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		ceph_put_mds_session(session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		mutex_lock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	mutex_unlock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	seq_printf(s, "\n\nWaiters:\n--------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	seq_printf(s, "tgid         ino                need             want\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	seq_printf(s, "-----------------------------------------------------\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	spin_lock(&mdsc->caps_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	list_for_each_entry(cw, &mdsc->cap_wait_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		seq_printf(s, "%-13d0x%-17llx%-17s%-17s\n", cw->tgid, cw->ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 				ceph_cap_string(cw->need),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 				ceph_cap_string(cw->want));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	spin_unlock(&mdsc->caps_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) static int mds_sessions_show(struct seq_file *s, void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	struct ceph_fs_client *fsc = s->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	struct ceph_mds_client *mdsc = fsc->mdsc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	struct ceph_auth_client *ac = fsc->client->monc.auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	struct ceph_options *opt = fsc->client->options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	int mds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	mutex_lock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	/* The 'num' portion of an 'entity name' */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	seq_printf(s, "global_id %llu\n", ac->global_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	/* The -o name mount argument */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	seq_printf(s, "name \"%s\"\n", opt->name ? opt->name : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	/* The list of MDS session rank+state */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	for (mds = 0; mds < mdsc->max_sessions; mds++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		struct ceph_mds_session *session =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 			__ceph_lookup_mds_session(mdsc, mds);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		if (!session) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		mutex_unlock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		seq_printf(s, "mds.%d %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				session->s_mds,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 				ceph_session_state_name(session->s_state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		ceph_put_mds_session(session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		mutex_lock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	mutex_unlock(&mdsc->mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) DEFINE_SHOW_ATTRIBUTE(mdsmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) DEFINE_SHOW_ATTRIBUTE(mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) DEFINE_SHOW_ATTRIBUTE(caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) DEFINE_SHOW_ATTRIBUTE(mds_sessions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) DEFINE_SHOW_ATTRIBUTE(metric);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * debugfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) static int congestion_kb_set(void *data, u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	struct ceph_fs_client *fsc = (struct ceph_fs_client *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	fsc->mount_options->congestion_kb = (int)val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static int congestion_kb_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	struct ceph_fs_client *fsc = (struct ceph_fs_client *)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	*val = (u64)fsc->mount_options->congestion_kb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 			congestion_kb_set, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	dout("ceph_fs_debugfs_cleanup\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	debugfs_remove(fsc->debugfs_bdi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	debugfs_remove(fsc->debugfs_congestion_kb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	debugfs_remove(fsc->debugfs_mdsmap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	debugfs_remove(fsc->debugfs_mds_sessions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	debugfs_remove(fsc->debugfs_caps);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	debugfs_remove(fsc->debugfs_metric);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	debugfs_remove(fsc->debugfs_mdsc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	char name[100];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	dout("ceph_fs_debugfs_init\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	fsc->debugfs_congestion_kb =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		debugfs_create_file("writeback_congestion_kb",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				    0600,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 				    fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 				    fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 				    &congestion_kb_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	snprintf(name, sizeof(name), "../../bdi/%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		 bdi_dev_name(fsc->sb->s_bdi));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	fsc->debugfs_bdi =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		debugfs_create_symlink("bdi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 				       fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 				       name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	fsc->debugfs_mdsmap = debugfs_create_file("mdsmap",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 					0400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 					fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 					fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 					&mdsmap_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 					0400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 					fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 					fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 					&mds_sessions_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	fsc->debugfs_mdsc = debugfs_create_file("mdsc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 						0400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 						fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 						fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 						&mdsc_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	fsc->debugfs_metric = debugfs_create_file("metrics",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 						  0400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 						  fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 						  fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 						  &metric_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	fsc->debugfs_caps = debugfs_create_file("caps",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 						0400,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 						fsc->client->debugfs_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 						fsc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 						&caps_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) #else  /* CONFIG_DEBUG_FS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) void ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) #endif  /* CONFIG_DEBUG_FS */