1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
23d14c5d2SYehuda Sadeh #include <linux/ceph/ceph_debug.h>
33d14c5d2SYehuda Sadeh
43d14c5d2SYehuda Sadeh #include <linux/device.h>
53d14c5d2SYehuda Sadeh #include <linux/slab.h>
63d14c5d2SYehuda Sadeh #include <linux/module.h>
73d14c5d2SYehuda Sadeh #include <linux/ctype.h>
83d14c5d2SYehuda Sadeh #include <linux/debugfs.h>
93d14c5d2SYehuda Sadeh #include <linux/seq_file.h>
103d14c5d2SYehuda Sadeh
113d14c5d2SYehuda Sadeh #include <linux/ceph/libceph.h>
123d14c5d2SYehuda Sadeh #include <linux/ceph/mon_client.h>
133d14c5d2SYehuda Sadeh #include <linux/ceph/auth.h>
143d14c5d2SYehuda Sadeh #include <linux/ceph/debugfs.h>
153d14c5d2SYehuda Sadeh
163d14c5d2SYehuda Sadeh #ifdef CONFIG_DEBUG_FS
173d14c5d2SYehuda Sadeh
183d14c5d2SYehuda Sadeh /*
193d14c5d2SYehuda Sadeh * Implement /sys/kernel/debug/ceph fun
203d14c5d2SYehuda Sadeh *
213d14c5d2SYehuda Sadeh * /sys/kernel/debug/ceph/client* - an instance of the ceph client
223d14c5d2SYehuda Sadeh * .../osdmap - current osdmap
233d14c5d2SYehuda Sadeh * .../monmap - current monmap
243d14c5d2SYehuda Sadeh * .../osdc - active osd requests
253d14c5d2SYehuda Sadeh * .../monc - mon client state
265cf7bd30SIlya Dryomov * .../client_options - libceph-only (i.e. not rbd or cephfs) options
273d14c5d2SYehuda Sadeh * .../dentry_lru - dump contents of dentry lru
283d14c5d2SYehuda Sadeh * .../caps - expose cap (reservation) stats
293d14c5d2SYehuda Sadeh * .../bdi - symlink to ../../bdi/something
303d14c5d2SYehuda Sadeh */
313d14c5d2SYehuda Sadeh
323d14c5d2SYehuda Sadeh static struct dentry *ceph_debugfs_dir;
333d14c5d2SYehuda Sadeh
monmap_show(struct seq_file * s,void * p)343d14c5d2SYehuda Sadeh static int monmap_show(struct seq_file *s, void *p)
353d14c5d2SYehuda Sadeh {
363d14c5d2SYehuda Sadeh int i;
373d14c5d2SYehuda Sadeh struct ceph_client *client = s->private;
383d14c5d2SYehuda Sadeh
393d14c5d2SYehuda Sadeh if (client->monc.monmap == NULL)
403d14c5d2SYehuda Sadeh return 0;
413d14c5d2SYehuda Sadeh
423d14c5d2SYehuda Sadeh seq_printf(s, "epoch %d\n", client->monc.monmap->epoch);
433d14c5d2SYehuda Sadeh for (i = 0; i < client->monc.monmap->num_mon; i++) {
443d14c5d2SYehuda Sadeh struct ceph_entity_inst *inst =
453d14c5d2SYehuda Sadeh &client->monc.monmap->mon_inst[i];
463d14c5d2SYehuda Sadeh
473d14c5d2SYehuda Sadeh seq_printf(s, "\t%s%lld\t%s\n",
483d14c5d2SYehuda Sadeh ENTITY_NAME(inst->name),
49b726ec97SJeff Layton ceph_pr_addr(&inst->addr));
503d14c5d2SYehuda Sadeh }
513d14c5d2SYehuda Sadeh return 0;
523d14c5d2SYehuda Sadeh }
533d14c5d2SYehuda Sadeh
osdmap_show(struct seq_file * s,void * p)543d14c5d2SYehuda Sadeh static int osdmap_show(struct seq_file *s, void *p)
553d14c5d2SYehuda Sadeh {
563d14c5d2SYehuda Sadeh int i;
573d14c5d2SYehuda Sadeh struct ceph_client *client = s->private;
58b4f34795SIlya Dryomov struct ceph_osd_client *osdc = &client->osdc;
59b4f34795SIlya Dryomov struct ceph_osdmap *map = osdc->osdmap;
603d14c5d2SYehuda Sadeh struct rb_node *n;
613d14c5d2SYehuda Sadeh
6235fea3a1SIlya Dryomov if (map == NULL)
633d14c5d2SYehuda Sadeh return 0;
6435fea3a1SIlya Dryomov
65b4f34795SIlya Dryomov down_read(&osdc->lock);
6658eb7932SJeff Layton seq_printf(s, "epoch %u barrier %u flags 0x%x\n", map->epoch,
6758eb7932SJeff Layton osdc->epoch_barrier, map->flags);
6835fea3a1SIlya Dryomov
6935fea3a1SIlya Dryomov for (n = rb_first(&map->pg_pools); n; n = rb_next(n)) {
7004812acfSIlya Dryomov struct ceph_pg_pool_info *pi =
713d14c5d2SYehuda Sadeh rb_entry(n, struct ceph_pg_pool_info, node);
7235fea3a1SIlya Dryomov
7304812acfSIlya Dryomov seq_printf(s, "pool %lld '%s' type %d size %d min_size %d pg_num %u pg_num_mask %d flags 0x%llx lfor %u read_tier %lld write_tier %lld\n",
7404812acfSIlya Dryomov pi->id, pi->name, pi->type, pi->size, pi->min_size,
7504812acfSIlya Dryomov pi->pg_num, pi->pg_num_mask, pi->flags,
7604812acfSIlya Dryomov pi->last_force_request_resend, pi->read_tier,
7704812acfSIlya Dryomov pi->write_tier);
783d14c5d2SYehuda Sadeh }
7935fea3a1SIlya Dryomov for (i = 0; i < map->max_osd; i++) {
8035fea3a1SIlya Dryomov struct ceph_entity_addr *addr = &map->osd_addr[i];
810bb05da2SIlya Dryomov u32 state = map->osd_state[i];
823d14c5d2SYehuda Sadeh char sb[64];
833d14c5d2SYehuda Sadeh
84117d96a0SIlya Dryomov seq_printf(s, "osd%d\t%s\t%3d%%\t(%s)\t%3d%%\t%2d\n",
85b726ec97SJeff Layton i, ceph_pr_addr(addr),
8635fea3a1SIlya Dryomov ((map->osd_weight[i]*100) >> 16),
872cfa34f2SIlya Dryomov ceph_osdmap_state_str(sb, sizeof(sb), state),
88117d96a0SIlya Dryomov ((ceph_get_primary_affinity(map, i)*100) >> 16),
89117d96a0SIlya Dryomov ceph_get_crush_locality(map, i,
90117d96a0SIlya Dryomov &client->options->crush_locs));
913d14c5d2SYehuda Sadeh }
921c00240eSIlya Dryomov for (n = rb_first(&map->pg_temp); n; n = rb_next(n)) {
931c00240eSIlya Dryomov struct ceph_pg_mapping *pg =
941c00240eSIlya Dryomov rb_entry(n, struct ceph_pg_mapping, node);
951c00240eSIlya Dryomov
961c00240eSIlya Dryomov seq_printf(s, "pg_temp %llu.%x [", pg->pgid.pool,
971c00240eSIlya Dryomov pg->pgid.seed);
9835a935d7SIlya Dryomov for (i = 0; i < pg->pg_temp.len; i++)
991c00240eSIlya Dryomov seq_printf(s, "%s%d", (i == 0 ? "" : ","),
10035a935d7SIlya Dryomov pg->pg_temp.osds[i]);
1011c00240eSIlya Dryomov seq_printf(s, "]\n");
1021c00240eSIlya Dryomov }
1039686f94cSIlya Dryomov for (n = rb_first(&map->primary_temp); n; n = rb_next(n)) {
1049686f94cSIlya Dryomov struct ceph_pg_mapping *pg =
1059686f94cSIlya Dryomov rb_entry(n, struct ceph_pg_mapping, node);
1069686f94cSIlya Dryomov
1079686f94cSIlya Dryomov seq_printf(s, "primary_temp %llu.%x %d\n", pg->pgid.pool,
1089686f94cSIlya Dryomov pg->pgid.seed, pg->primary_temp.osd);
1099686f94cSIlya Dryomov }
1106f428df4SIlya Dryomov for (n = rb_first(&map->pg_upmap); n; n = rb_next(n)) {
1116f428df4SIlya Dryomov struct ceph_pg_mapping *pg =
1126f428df4SIlya Dryomov rb_entry(n, struct ceph_pg_mapping, node);
1136f428df4SIlya Dryomov
1146f428df4SIlya Dryomov seq_printf(s, "pg_upmap %llu.%x [", pg->pgid.pool,
1156f428df4SIlya Dryomov pg->pgid.seed);
1166f428df4SIlya Dryomov for (i = 0; i < pg->pg_upmap.len; i++)
1176f428df4SIlya Dryomov seq_printf(s, "%s%d", (i == 0 ? "" : ","),
1186f428df4SIlya Dryomov pg->pg_upmap.osds[i]);
1196f428df4SIlya Dryomov seq_printf(s, "]\n");
1206f428df4SIlya Dryomov }
1216f428df4SIlya Dryomov for (n = rb_first(&map->pg_upmap_items); n; n = rb_next(n)) {
1226f428df4SIlya Dryomov struct ceph_pg_mapping *pg =
1236f428df4SIlya Dryomov rb_entry(n, struct ceph_pg_mapping, node);
1246f428df4SIlya Dryomov
1256f428df4SIlya Dryomov seq_printf(s, "pg_upmap_items %llu.%x [", pg->pgid.pool,
1266f428df4SIlya Dryomov pg->pgid.seed);
1276f428df4SIlya Dryomov for (i = 0; i < pg->pg_upmap_items.len; i++)
1286f428df4SIlya Dryomov seq_printf(s, "%s%d->%d", (i == 0 ? "" : ","),
1296f428df4SIlya Dryomov pg->pg_upmap_items.from_to[i][0],
1306f428df4SIlya Dryomov pg->pg_upmap_items.from_to[i][1]);
1316f428df4SIlya Dryomov seq_printf(s, "]\n");
1326f428df4SIlya Dryomov }
13335fea3a1SIlya Dryomov
134b4f34795SIlya Dryomov up_read(&osdc->lock);
1353d14c5d2SYehuda Sadeh return 0;
1363d14c5d2SYehuda Sadeh }
1373d14c5d2SYehuda Sadeh
monc_show(struct seq_file * s,void * p)1383d14c5d2SYehuda Sadeh static int monc_show(struct seq_file *s, void *p)
1393d14c5d2SYehuda Sadeh {
1403d14c5d2SYehuda Sadeh struct ceph_client *client = s->private;
1413d14c5d2SYehuda Sadeh struct ceph_mon_generic_request *req;
1423d14c5d2SYehuda Sadeh struct ceph_mon_client *monc = &client->monc;
1433d14c5d2SYehuda Sadeh struct rb_node *rp;
14482dcabadSIlya Dryomov int i;
1453d14c5d2SYehuda Sadeh
1463d14c5d2SYehuda Sadeh mutex_lock(&monc->mutex);
1473d14c5d2SYehuda Sadeh
14882dcabadSIlya Dryomov for (i = 0; i < ARRAY_SIZE(monc->subs); i++) {
14982dcabadSIlya Dryomov seq_printf(s, "have %s %u", ceph_sub_str[i],
15082dcabadSIlya Dryomov monc->subs[i].have);
15182dcabadSIlya Dryomov if (monc->subs[i].want)
15282dcabadSIlya Dryomov seq_printf(s, " want %llu%s",
15382dcabadSIlya Dryomov le64_to_cpu(monc->subs[i].item.start),
15482dcabadSIlya Dryomov (monc->subs[i].item.flags &
15582dcabadSIlya Dryomov CEPH_SUBSCRIBE_ONETIME ? "" : "+"));
15682dcabadSIlya Dryomov seq_putc(s, '\n');
15782dcabadSIlya Dryomov }
158737cc81eSIlya Dryomov seq_printf(s, "fs_cluster_id %d\n", monc->fs_cluster_id);
1593d14c5d2SYehuda Sadeh
1603d14c5d2SYehuda Sadeh for (rp = rb_first(&monc->generic_request_tree); rp; rp = rb_next(rp)) {
1613d14c5d2SYehuda Sadeh __u16 op;
1623d14c5d2SYehuda Sadeh req = rb_entry(rp, struct ceph_mon_generic_request, node);
1633d14c5d2SYehuda Sadeh op = le16_to_cpu(req->request->hdr.type);
1643d14c5d2SYehuda Sadeh if (op == CEPH_MSG_STATFS)
165002b36baSIlya Dryomov seq_printf(s, "%llu statfs\n", req->tid);
166513a8243SIlya Dryomov else if (op == CEPH_MSG_MON_GET_VERSION)
167513a8243SIlya Dryomov seq_printf(s, "%llu mon_get_version", req->tid);
1683d14c5d2SYehuda Sadeh else
169002b36baSIlya Dryomov seq_printf(s, "%llu unknown\n", req->tid);
1703d14c5d2SYehuda Sadeh }
1713d14c5d2SYehuda Sadeh
1723d14c5d2SYehuda Sadeh mutex_unlock(&monc->mutex);
1733d14c5d2SYehuda Sadeh return 0;
1743d14c5d2SYehuda Sadeh }
1753d14c5d2SYehuda Sadeh
dump_spgid(struct seq_file * s,const struct ceph_spg * spgid)176dc98ff72SIlya Dryomov static void dump_spgid(struct seq_file *s, const struct ceph_spg *spgid)
177dc98ff72SIlya Dryomov {
178dc98ff72SIlya Dryomov seq_printf(s, "%llu.%x", spgid->pgid.pool, spgid->pgid.seed);
179dc98ff72SIlya Dryomov if (spgid->shard != CEPH_SPG_NOSHARD)
180dc98ff72SIlya Dryomov seq_printf(s, "s%d", spgid->shard);
181dc98ff72SIlya Dryomov }
182dc98ff72SIlya Dryomov
dump_target(struct seq_file * s,struct ceph_osd_request_target * t)183bb873b53SIlya Dryomov static void dump_target(struct seq_file *s, struct ceph_osd_request_target *t)
184bb873b53SIlya Dryomov {
185bb873b53SIlya Dryomov int i;
186bb873b53SIlya Dryomov
187dc98ff72SIlya Dryomov seq_printf(s, "osd%d\t%llu.%x\t", t->osd, t->pgid.pool, t->pgid.seed);
188dc98ff72SIlya Dryomov dump_spgid(s, &t->spgid);
189dc98ff72SIlya Dryomov seq_puts(s, "\t[");
190bb873b53SIlya Dryomov for (i = 0; i < t->up.size; i++)
191bb873b53SIlya Dryomov seq_printf(s, "%s%d", (!i ? "" : ","), t->up.osds[i]);
192bb873b53SIlya Dryomov seq_printf(s, "]/%d\t[", t->up.primary);
193bb873b53SIlya Dryomov for (i = 0; i < t->acting.size; i++)
194bb873b53SIlya Dryomov seq_printf(s, "%s%d", (!i ? "" : ","), t->acting.osds[i]);
19504c7d789SIlya Dryomov seq_printf(s, "]/%d\te%u\t", t->acting.primary, t->epoch);
19630c156d9SYan, Zheng if (t->target_oloc.pool_ns) {
19730c156d9SYan, Zheng seq_printf(s, "%*pE/%*pE\t0x%x",
19830c156d9SYan, Zheng (int)t->target_oloc.pool_ns->len,
19930c156d9SYan, Zheng t->target_oloc.pool_ns->str,
200bb873b53SIlya Dryomov t->target_oid.name_len, t->target_oid.name, t->flags);
20130c156d9SYan, Zheng } else {
20230c156d9SYan, Zheng seq_printf(s, "%*pE\t0x%x", t->target_oid.name_len,
20330c156d9SYan, Zheng t->target_oid.name, t->flags);
20430c156d9SYan, Zheng }
205bb873b53SIlya Dryomov if (t->paused)
206bb873b53SIlya Dryomov seq_puts(s, "\tP");
207bb873b53SIlya Dryomov }
208bb873b53SIlya Dryomov
dump_request(struct seq_file * s,struct ceph_osd_request * req)209bb873b53SIlya Dryomov static void dump_request(struct seq_file *s, struct ceph_osd_request *req)
210bb873b53SIlya Dryomov {
211bb873b53SIlya Dryomov int i;
212bb873b53SIlya Dryomov
213bb873b53SIlya Dryomov seq_printf(s, "%llu\t", req->r_tid);
214bb873b53SIlya Dryomov dump_target(s, &req->r_t);
215bb873b53SIlya Dryomov
216aa26d662SJeff Layton seq_printf(s, "\t%d", req->r_attempts);
217bb873b53SIlya Dryomov
218bb873b53SIlya Dryomov for (i = 0; i < req->r_num_ops; i++) {
219bb873b53SIlya Dryomov struct ceph_osd_req_op *op = &req->r_ops[i];
220bb873b53SIlya Dryomov
221bb873b53SIlya Dryomov seq_printf(s, "%s%s", (i == 0 ? "\t" : ","),
222bb873b53SIlya Dryomov ceph_osd_op_name(op->op));
223922dab61SIlya Dryomov if (op->op == CEPH_OSD_OP_WATCH)
224922dab61SIlya Dryomov seq_printf(s, "-%s",
225922dab61SIlya Dryomov ceph_osd_watch_op_name(op->watch.op));
226*6e6f0f01SIlya Dryomov else if (op->op == CEPH_OSD_OP_CALL)
227*6e6f0f01SIlya Dryomov seq_printf(s, "-%s/%s", op->cls.class_name,
228*6e6f0f01SIlya Dryomov op->cls.method_name);
229bb873b53SIlya Dryomov }
230bb873b53SIlya Dryomov
231bb873b53SIlya Dryomov seq_putc(s, '\n');
232bb873b53SIlya Dryomov }
233bb873b53SIlya Dryomov
dump_requests(struct seq_file * s,struct ceph_osd * osd)2345aea3dcdSIlya Dryomov static void dump_requests(struct seq_file *s, struct ceph_osd *osd)
2355aea3dcdSIlya Dryomov {
2365aea3dcdSIlya Dryomov struct rb_node *n;
2375aea3dcdSIlya Dryomov
2385aea3dcdSIlya Dryomov mutex_lock(&osd->lock);
2395aea3dcdSIlya Dryomov for (n = rb_first(&osd->o_requests); n; n = rb_next(n)) {
2405aea3dcdSIlya Dryomov struct ceph_osd_request *req =
2415aea3dcdSIlya Dryomov rb_entry(n, struct ceph_osd_request, r_node);
2425aea3dcdSIlya Dryomov
2435aea3dcdSIlya Dryomov dump_request(s, req);
2445aea3dcdSIlya Dryomov }
2455aea3dcdSIlya Dryomov
2465aea3dcdSIlya Dryomov mutex_unlock(&osd->lock);
2475aea3dcdSIlya Dryomov }
2485aea3dcdSIlya Dryomov
dump_linger_request(struct seq_file * s,struct ceph_osd_linger_request * lreq)249922dab61SIlya Dryomov static void dump_linger_request(struct seq_file *s,
250922dab61SIlya Dryomov struct ceph_osd_linger_request *lreq)
251922dab61SIlya Dryomov {
252922dab61SIlya Dryomov seq_printf(s, "%llu\t", lreq->linger_id);
253922dab61SIlya Dryomov dump_target(s, &lreq->t);
254922dab61SIlya Dryomov
25519079203SIlya Dryomov seq_printf(s, "\t%u\t%s%s/%d\n", lreq->register_gen,
25619079203SIlya Dryomov lreq->is_watch ? "W" : "N", lreq->committed ? "C" : "",
25719079203SIlya Dryomov lreq->last_error);
258922dab61SIlya Dryomov }
259922dab61SIlya Dryomov
dump_linger_requests(struct seq_file * s,struct ceph_osd * osd)260922dab61SIlya Dryomov static void dump_linger_requests(struct seq_file *s, struct ceph_osd *osd)
261922dab61SIlya Dryomov {
262922dab61SIlya Dryomov struct rb_node *n;
263922dab61SIlya Dryomov
264922dab61SIlya Dryomov mutex_lock(&osd->lock);
265922dab61SIlya Dryomov for (n = rb_first(&osd->o_linger_requests); n; n = rb_next(n)) {
266922dab61SIlya Dryomov struct ceph_osd_linger_request *lreq =
267922dab61SIlya Dryomov rb_entry(n, struct ceph_osd_linger_request, node);
268922dab61SIlya Dryomov
269922dab61SIlya Dryomov dump_linger_request(s, lreq);
270922dab61SIlya Dryomov }
271922dab61SIlya Dryomov
272922dab61SIlya Dryomov mutex_unlock(&osd->lock);
273922dab61SIlya Dryomov }
274922dab61SIlya Dryomov
dump_snapid(struct seq_file * s,u64 snapid)275a02a946dSIlya Dryomov static void dump_snapid(struct seq_file *s, u64 snapid)
276a02a946dSIlya Dryomov {
277a02a946dSIlya Dryomov if (snapid == CEPH_NOSNAP)
278a02a946dSIlya Dryomov seq_puts(s, "head");
279a02a946dSIlya Dryomov else if (snapid == CEPH_SNAPDIR)
280a02a946dSIlya Dryomov seq_puts(s, "snapdir");
281a02a946dSIlya Dryomov else
282a02a946dSIlya Dryomov seq_printf(s, "%llx", snapid);
283a02a946dSIlya Dryomov }
284a02a946dSIlya Dryomov
dump_name_escaped(struct seq_file * s,unsigned char * name,size_t len)285a02a946dSIlya Dryomov static void dump_name_escaped(struct seq_file *s, unsigned char *name,
286a02a946dSIlya Dryomov size_t len)
287a02a946dSIlya Dryomov {
288a02a946dSIlya Dryomov size_t i;
289a02a946dSIlya Dryomov
290a02a946dSIlya Dryomov for (i = 0; i < len; i++) {
291a02a946dSIlya Dryomov if (name[i] == '%' || name[i] == ':' || name[i] == '/' ||
292a02a946dSIlya Dryomov name[i] < 32 || name[i] >= 127) {
293a02a946dSIlya Dryomov seq_printf(s, "%%%02x", name[i]);
294a02a946dSIlya Dryomov } else {
295a02a946dSIlya Dryomov seq_putc(s, name[i]);
296a02a946dSIlya Dryomov }
297a02a946dSIlya Dryomov }
298a02a946dSIlya Dryomov }
299a02a946dSIlya Dryomov
dump_hoid(struct seq_file * s,const struct ceph_hobject_id * hoid)300a02a946dSIlya Dryomov static void dump_hoid(struct seq_file *s, const struct ceph_hobject_id *hoid)
301a02a946dSIlya Dryomov {
302a02a946dSIlya Dryomov if (hoid->snapid == 0 && hoid->hash == 0 && !hoid->is_max &&
303a02a946dSIlya Dryomov hoid->pool == S64_MIN) {
304a02a946dSIlya Dryomov seq_puts(s, "MIN");
305a02a946dSIlya Dryomov return;
306a02a946dSIlya Dryomov }
307a02a946dSIlya Dryomov if (hoid->is_max) {
308a02a946dSIlya Dryomov seq_puts(s, "MAX");
309a02a946dSIlya Dryomov return;
310a02a946dSIlya Dryomov }
311a02a946dSIlya Dryomov seq_printf(s, "%lld:%08x:", hoid->pool, hoid->hash_reverse_bits);
312a02a946dSIlya Dryomov dump_name_escaped(s, hoid->nspace, hoid->nspace_len);
313a02a946dSIlya Dryomov seq_putc(s, ':');
314a02a946dSIlya Dryomov dump_name_escaped(s, hoid->key, hoid->key_len);
315a02a946dSIlya Dryomov seq_putc(s, ':');
316a02a946dSIlya Dryomov dump_name_escaped(s, hoid->oid, hoid->oid_len);
317a02a946dSIlya Dryomov seq_putc(s, ':');
318a02a946dSIlya Dryomov dump_snapid(s, hoid->snapid);
319a02a946dSIlya Dryomov }
320a02a946dSIlya Dryomov
dump_backoffs(struct seq_file * s,struct ceph_osd * osd)321a02a946dSIlya Dryomov static void dump_backoffs(struct seq_file *s, struct ceph_osd *osd)
322a02a946dSIlya Dryomov {
323a02a946dSIlya Dryomov struct rb_node *n;
324a02a946dSIlya Dryomov
325a02a946dSIlya Dryomov mutex_lock(&osd->lock);
326a02a946dSIlya Dryomov for (n = rb_first(&osd->o_backoffs_by_id); n; n = rb_next(n)) {
327a02a946dSIlya Dryomov struct ceph_osd_backoff *backoff =
328a02a946dSIlya Dryomov rb_entry(n, struct ceph_osd_backoff, id_node);
329a02a946dSIlya Dryomov
330a02a946dSIlya Dryomov seq_printf(s, "osd%d\t", osd->o_osd);
331a02a946dSIlya Dryomov dump_spgid(s, &backoff->spgid);
332a02a946dSIlya Dryomov seq_printf(s, "\t%llu\t", backoff->id);
333a02a946dSIlya Dryomov dump_hoid(s, backoff->begin);
334a02a946dSIlya Dryomov seq_putc(s, '\t');
335a02a946dSIlya Dryomov dump_hoid(s, backoff->end);
336a02a946dSIlya Dryomov seq_putc(s, '\n');
337a02a946dSIlya Dryomov }
338a02a946dSIlya Dryomov
339a02a946dSIlya Dryomov mutex_unlock(&osd->lock);
340a02a946dSIlya Dryomov }
341a02a946dSIlya Dryomov
osdc_show(struct seq_file * s,void * pp)3423d14c5d2SYehuda Sadeh static int osdc_show(struct seq_file *s, void *pp)
3433d14c5d2SYehuda Sadeh {
3443d14c5d2SYehuda Sadeh struct ceph_client *client = s->private;
3453d14c5d2SYehuda Sadeh struct ceph_osd_client *osdc = &client->osdc;
3465aea3dcdSIlya Dryomov struct rb_node *n;
3473d14c5d2SYehuda Sadeh
3485aea3dcdSIlya Dryomov down_read(&osdc->lock);
3495aea3dcdSIlya Dryomov seq_printf(s, "REQUESTS %d homeless %d\n",
3505aea3dcdSIlya Dryomov atomic_read(&osdc->num_requests),
3515aea3dcdSIlya Dryomov atomic_read(&osdc->num_homeless));
3525aea3dcdSIlya Dryomov for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
3535aea3dcdSIlya Dryomov struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
3543d14c5d2SYehuda Sadeh
3555aea3dcdSIlya Dryomov dump_requests(s, osd);
3563d14c5d2SYehuda Sadeh }
3575aea3dcdSIlya Dryomov dump_requests(s, &osdc->homeless_osd);
3585aea3dcdSIlya Dryomov
359922dab61SIlya Dryomov seq_puts(s, "LINGER REQUESTS\n");
360922dab61SIlya Dryomov for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
361922dab61SIlya Dryomov struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
362922dab61SIlya Dryomov
363922dab61SIlya Dryomov dump_linger_requests(s, osd);
364922dab61SIlya Dryomov }
365922dab61SIlya Dryomov dump_linger_requests(s, &osdc->homeless_osd);
366922dab61SIlya Dryomov
367a02a946dSIlya Dryomov seq_puts(s, "BACKOFFS\n");
368a02a946dSIlya Dryomov for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
369a02a946dSIlya Dryomov struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
370a02a946dSIlya Dryomov
371a02a946dSIlya Dryomov dump_backoffs(s, osd);
372a02a946dSIlya Dryomov }
373a02a946dSIlya Dryomov
3745aea3dcdSIlya Dryomov up_read(&osdc->lock);
3753d14c5d2SYehuda Sadeh return 0;
3763d14c5d2SYehuda Sadeh }
3773d14c5d2SYehuda Sadeh
client_options_show(struct seq_file * s,void * p)3785cf7bd30SIlya Dryomov static int client_options_show(struct seq_file *s, void *p)
3795cf7bd30SIlya Dryomov {
3805cf7bd30SIlya Dryomov struct ceph_client *client = s->private;
3815cf7bd30SIlya Dryomov int ret;
3825cf7bd30SIlya Dryomov
38302b2f549SDongsheng Yang ret = ceph_print_client_options(s, client, true);
3845cf7bd30SIlya Dryomov if (ret)
3855cf7bd30SIlya Dryomov return ret;
3865cf7bd30SIlya Dryomov
3875cf7bd30SIlya Dryomov seq_putc(s, '\n');
3885cf7bd30SIlya Dryomov return 0;
3895cf7bd30SIlya Dryomov }
3905cf7bd30SIlya Dryomov
391072eaf3cSIlya Dryomov DEFINE_SHOW_ATTRIBUTE(monmap);
392072eaf3cSIlya Dryomov DEFINE_SHOW_ATTRIBUTE(osdmap);
393072eaf3cSIlya Dryomov DEFINE_SHOW_ATTRIBUTE(monc);
394072eaf3cSIlya Dryomov DEFINE_SHOW_ATTRIBUTE(osdc);
395072eaf3cSIlya Dryomov DEFINE_SHOW_ATTRIBUTE(client_options);
3963d14c5d2SYehuda Sadeh
ceph_debugfs_init(void)3971a829ff2SGreg Kroah-Hartman void __init ceph_debugfs_init(void)
3983d14c5d2SYehuda Sadeh {
3993d14c5d2SYehuda Sadeh ceph_debugfs_dir = debugfs_create_dir("ceph", NULL);
4003d14c5d2SYehuda Sadeh }
4013d14c5d2SYehuda Sadeh
ceph_debugfs_cleanup(void)4023d14c5d2SYehuda Sadeh void ceph_debugfs_cleanup(void)
4033d14c5d2SYehuda Sadeh {
4043d14c5d2SYehuda Sadeh debugfs_remove(ceph_debugfs_dir);
4053d14c5d2SYehuda Sadeh }
4063d14c5d2SYehuda Sadeh
ceph_debugfs_client_init(struct ceph_client * client)4071a829ff2SGreg Kroah-Hartman void ceph_debugfs_client_init(struct ceph_client *client)
4083d14c5d2SYehuda Sadeh {
4093d14c5d2SYehuda Sadeh char name[80];
4103d14c5d2SYehuda Sadeh
4113d14c5d2SYehuda Sadeh snprintf(name, sizeof(name), "%pU.client%lld", &client->fsid,
4123d14c5d2SYehuda Sadeh client->monc.auth->global_id);
4133d14c5d2SYehuda Sadeh
414d1c338a5SSage Weil dout("ceph_debugfs_client_init %p %s\n", client, name);
415d1c338a5SSage Weil
4163d14c5d2SYehuda Sadeh client->debugfs_dir = debugfs_create_dir(name, ceph_debugfs_dir);
4173d14c5d2SYehuda Sadeh
4183d14c5d2SYehuda Sadeh client->monc.debugfs_file = debugfs_create_file("monc",
41911e1478dSChengguang Xu 0400,
4203d14c5d2SYehuda Sadeh client->debugfs_dir,
4213d14c5d2SYehuda Sadeh client,
422072eaf3cSIlya Dryomov &monc_fops);
4233d14c5d2SYehuda Sadeh
4243d14c5d2SYehuda Sadeh client->osdc.debugfs_file = debugfs_create_file("osdc",
42511e1478dSChengguang Xu 0400,
4263d14c5d2SYehuda Sadeh client->debugfs_dir,
4273d14c5d2SYehuda Sadeh client,
428072eaf3cSIlya Dryomov &osdc_fops);
4293d14c5d2SYehuda Sadeh
4303d14c5d2SYehuda Sadeh client->debugfs_monmap = debugfs_create_file("monmap",
43111e1478dSChengguang Xu 0400,
4323d14c5d2SYehuda Sadeh client->debugfs_dir,
4333d14c5d2SYehuda Sadeh client,
434072eaf3cSIlya Dryomov &monmap_fops);
4353d14c5d2SYehuda Sadeh
4363d14c5d2SYehuda Sadeh client->debugfs_osdmap = debugfs_create_file("osdmap",
43711e1478dSChengguang Xu 0400,
4383d14c5d2SYehuda Sadeh client->debugfs_dir,
4393d14c5d2SYehuda Sadeh client,
440072eaf3cSIlya Dryomov &osdmap_fops);
4413d14c5d2SYehuda Sadeh
4425cf7bd30SIlya Dryomov client->debugfs_options = debugfs_create_file("client_options",
44311e1478dSChengguang Xu 0400,
4445cf7bd30SIlya Dryomov client->debugfs_dir,
4455cf7bd30SIlya Dryomov client,
446072eaf3cSIlya Dryomov &client_options_fops);
4473d14c5d2SYehuda Sadeh }
4483d14c5d2SYehuda Sadeh
ceph_debugfs_client_cleanup(struct ceph_client * client)4493d14c5d2SYehuda Sadeh void ceph_debugfs_client_cleanup(struct ceph_client *client)
4503d14c5d2SYehuda Sadeh {
451d1c338a5SSage Weil dout("ceph_debugfs_client_cleanup %p\n", client);
4525cf7bd30SIlya Dryomov debugfs_remove(client->debugfs_options);
4533d14c5d2SYehuda Sadeh debugfs_remove(client->debugfs_osdmap);
4543d14c5d2SYehuda Sadeh debugfs_remove(client->debugfs_monmap);
4553d14c5d2SYehuda Sadeh debugfs_remove(client->osdc.debugfs_file);
4563d14c5d2SYehuda Sadeh debugfs_remove(client->monc.debugfs_file);
4573d14c5d2SYehuda Sadeh debugfs_remove(client->debugfs_dir);
4583d14c5d2SYehuda Sadeh }
4593d14c5d2SYehuda Sadeh
4603d14c5d2SYehuda Sadeh #else /* CONFIG_DEBUG_FS */
4613d14c5d2SYehuda Sadeh
ceph_debugfs_init(void)4621a829ff2SGreg Kroah-Hartman void __init ceph_debugfs_init(void)
4633d14c5d2SYehuda Sadeh {
4643d14c5d2SYehuda Sadeh }
4653d14c5d2SYehuda Sadeh
ceph_debugfs_cleanup(void)4663d14c5d2SYehuda Sadeh void ceph_debugfs_cleanup(void)
4673d14c5d2SYehuda Sadeh {
4683d14c5d2SYehuda Sadeh }
4693d14c5d2SYehuda Sadeh
ceph_debugfs_client_init(struct ceph_client * client)4701a829ff2SGreg Kroah-Hartman void ceph_debugfs_client_init(struct ceph_client *client)
4713d14c5d2SYehuda Sadeh {
4723d14c5d2SYehuda Sadeh }
4733d14c5d2SYehuda Sadeh
ceph_debugfs_client_cleanup(struct ceph_client * client)4743d14c5d2SYehuda Sadeh void ceph_debugfs_client_cleanup(struct ceph_client *client)
4753d14c5d2SYehuda Sadeh {
4763d14c5d2SYehuda Sadeh }
4773d14c5d2SYehuda Sadeh
4783d14c5d2SYehuda Sadeh #endif /* CONFIG_DEBUG_FS */
479