Blame view
fs/ceph/debugfs.c
7.66 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
3d14c5d2b ceph: factor out ... |
2 |
#include <linux/ceph/ceph_debug.h> |
76aa844d5 ceph: debugfs |
3 |
|
06edf046d ceph: include lin... |
4 |
#include <linux/device.h> |
5a0e3ad6a include cleanup: ... |
5 |
#include <linux/slab.h> |
76aa844d5 ceph: debugfs |
6 7 8 9 |
#include <linux/module.h> #include <linux/ctype.h> #include <linux/debugfs.h> #include <linux/seq_file.h> |
3d14c5d2b ceph: factor out ... |
10 11 12 13 |
#include <linux/ceph/libceph.h> #include <linux/ceph/mon_client.h> #include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> |
76aa844d5 ceph: debugfs |
14 |
|
6f453ed6c ceph: fix debugfs... |
15 |
#include "super.h" |
039934b89 ceph: build clean... |
16 |
#ifdef CONFIG_DEBUG_FS |
3d14c5d2b ceph: factor out ... |
17 |
#include "mds_client.h" |
76aa844d5 ceph: debugfs |
18 19 20 21 |
static int mdsmap_show(struct seq_file *s, void *p) { int i; |
3d14c5d2b ceph: factor out ... |
22 |
struct ceph_fs_client *fsc = s->private; |
76201b635 ceph: allow conne... |
23 |
struct ceph_mdsmap *mdsmap; |
76aa844d5 ceph: debugfs |
24 |
|
d37b1d994 ceph: adjust 36 c... |
25 |
if (!fsc->mdsc || !fsc->mdsc->mdsmap) |
76aa844d5 ceph: debugfs |
26 |
return 0; |
76201b635 ceph: allow conne... |
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
mdsmap = fsc->mdsc->mdsmap; seq_printf(s, "epoch %d ", mdsmap->m_epoch); seq_printf(s, "root %d ", mdsmap->m_root); seq_printf(s, "max_mds %d ", mdsmap->m_max_mds); seq_printf(s, "session_timeout %d ", mdsmap->m_session_timeout); seq_printf(s, "session_autoclose %d ", mdsmap->m_session_autoclose); for (i = 0; i < mdsmap->m_num_mds; i++) { struct ceph_entity_addr *addr = &mdsmap->m_info[i].addr; int state = mdsmap->m_info[i].state; |
3d14c5d2b ceph: factor out ... |
41 42 43 |
seq_printf(s, "\tmds%d\t%s\t(%s) ", i, ceph_pr_addr(&addr->in_addr), |
76aa844d5 ceph: debugfs |
44 45 46 47 |
ceph_mds_state_name(state)); } return 0; } |
3d14c5d2b ceph: factor out ... |
48 49 50 |
/* * mdsc debugfs */ |
76aa844d5 ceph: debugfs |
51 52 |
static int mdsc_show(struct seq_file *s, void *p) { |
3d14c5d2b ceph: factor out ... |
53 54 |
struct ceph_fs_client *fsc = s->private; struct ceph_mds_client *mdsc = fsc->mdsc; |
44ca18f26 ceph: use rbtree ... |
55 56 |
struct ceph_mds_request *req; struct rb_node *rp; |
76aa844d5 ceph: debugfs |
57 58 59 60 61 |
int pathlen; u64 pathbase; char *path; mutex_lock(&mdsc->mutex); |
44ca18f26 ceph: use rbtree ... |
62 63 |
for (rp = rb_first(&mdsc->request_tree); rp; rp = rb_next(rp)) { req = rb_entry(rp, struct ceph_mds_request, r_node); |
76aa844d5 ceph: debugfs |
64 |
|
4af25fdda ceph: drop redund... |
65 66 67 68 |
if (req->r_request && req->r_session) seq_printf(s, "%lld\tmds%d\t", req->r_tid, req->r_session->s_mds); else if (!req->r_request) |
76aa844d5 ceph: debugfs |
69 |
seq_printf(s, "%lld\t(no request)\t", req->r_tid); |
4af25fdda ceph: drop redund... |
70 71 |
else seq_printf(s, "%lld\t(no session)\t", req->r_tid); |
76aa844d5 ceph: debugfs |
72 73 |
seq_printf(s, "%s", ceph_mds_op_name(req->r_op)); |
bc2de10dc ceph: convert boo... |
74 |
if (test_bit(CEPH_MDS_R_GOT_UNSAFE, &req->r_req_flags)) |
3364d113c fs/ceph/debugfs.c... |
75 |
seq_puts(s, "\t(unsafe)"); |
76aa844d5 ceph: debugfs |
76 |
else |
3364d113c fs/ceph/debugfs.c... |
77 |
seq_puts(s, "\t"); |
76aa844d5 ceph: debugfs |
78 79 80 81 82 83 |
if (req->r_inode) { seq_printf(s, " #%llx", ceph_ino(req->r_inode)); } else if (req->r_dentry) { path = ceph_mdsc_build_path(req->r_dentry, &pathlen, &pathbase, 0); |
f44c3890d ceph: ceph_mdsc_b... |
84 85 |
if (IS_ERR(path)) path = NULL; |
76aa844d5 ceph: debugfs |
86 |
spin_lock(&req->r_dentry->d_lock); |
a455589f1 assorted conversi... |
87 |
seq_printf(s, " #%llx/%pd (%s)", |
2b0143b5c VFS: normal files... |
88 |
ceph_ino(d_inode(req->r_dentry->d_parent)), |
a455589f1 assorted conversi... |
89 |
req->r_dentry, |
76aa844d5 ceph: debugfs |
90 91 92 93 94 95 |
path ? path : ""); spin_unlock(&req->r_dentry->d_lock); kfree(path); } else if (req->r_path1) { seq_printf(s, " #%llx/%s", req->r_ino1.ino, req->r_path1); |
c137a32a4 ceph: print inode... |
96 97 |
} else { seq_printf(s, " #%llx", req->r_ino1.ino); |
76aa844d5 ceph: debugfs |
98 99 100 101 102 |
} if (req->r_old_dentry) { path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen, &pathbase, 0); |
f44c3890d ceph: ceph_mdsc_b... |
103 104 |
if (IS_ERR(path)) path = NULL; |
76aa844d5 ceph: debugfs |
105 |
spin_lock(&req->r_old_dentry->d_lock); |
a455589f1 assorted conversi... |
106 |
seq_printf(s, " #%llx/%pd (%s)", |
844d87c33 ceph: do not assu... |
107 108 |
req->r_old_dentry_dir ? ceph_ino(req->r_old_dentry_dir) : 0, |
a455589f1 assorted conversi... |
109 |
req->r_old_dentry, |
76aa844d5 ceph: debugfs |
110 111 112 |
path ? path : ""); spin_unlock(&req->r_old_dentry->d_lock); kfree(path); |
aeda081c5 ceph: don't show ... |
113 |
} else if (req->r_path2 && req->r_op != CEPH_MDS_OP_SYMLINK) { |
76aa844d5 ceph: debugfs |
114 115 116 117 118 119 |
if (req->r_ino2.ino) seq_printf(s, " #%llx/%s", req->r_ino2.ino, req->r_path2); else seq_printf(s, " %s", req->r_path2); } |
3364d113c fs/ceph/debugfs.c... |
120 121 |
seq_puts(s, " "); |
76aa844d5 ceph: debugfs |
122 123 124 125 126 |
} mutex_unlock(&mdsc->mutex); return 0; } |
76aa844d5 ceph: debugfs |
127 128 |
static int caps_show(struct seq_file *s, void *p) { |
3d14c5d2b ceph: factor out ... |
129 |
struct ceph_fs_client *fsc = s->private; |
85ccce43a ceph: clean up re... |
130 |
int total, avail, used, reserved, min; |
76aa844d5 ceph: debugfs |
131 |
|
3d14c5d2b ceph: factor out ... |
132 |
ceph_reservation_status(fsc, &total, &avail, &used, &reserved, &min); |
76aa844d5 ceph: debugfs |
133 134 |
seq_printf(s, "total\t\t%d " |
85ccce43a ceph: clean up re... |
135 136 137 138 139 140 141 142 143 |
"avail\t\t%d " "used\t\t%d " "reserved\t%d " "min\t%d ", total, avail, used, reserved, min); |
76aa844d5 ceph: debugfs |
144 145 146 147 148 |
return 0; } static int dentry_lru_show(struct seq_file *s, void *ptr) { |
3d14c5d2b ceph: factor out ... |
149 150 |
struct ceph_fs_client *fsc = s->private; struct ceph_mds_client *mdsc = fsc->mdsc; |
76aa844d5 ceph: debugfs |
151 152 153 154 155 |
struct ceph_dentry_info *di; spin_lock(&mdsc->dentry_lru_lock); list_for_each_entry(di, &mdsc->dentry_lru, lru) { struct dentry *dentry = di->dentry; |
a455589f1 assorted conversi... |
156 157 158 |
seq_printf(s, "%p %p\t%pd ", di, dentry, dentry); |
76aa844d5 ceph: debugfs |
159 160 161 162 163 |
} spin_unlock(&mdsc->dentry_lru_lock); return 0; } |
14ed97033 ceph: additional ... |
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
static int mds_sessions_show(struct seq_file *s, void *ptr) { struct ceph_fs_client *fsc = s->private; struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_auth_client *ac = fsc->client->monc.auth; struct ceph_options *opt = fsc->client->options; int mds = -1; mutex_lock(&mdsc->mutex); /* The 'num' portion of an 'entity name' */ seq_printf(s, "global_id %llu ", ac->global_id); /* The -o name mount argument */ seq_printf(s, "name \"%s\" ", opt->name ? opt->name : ""); /* The list of MDS session rank+state */ for (mds = 0; mds < mdsc->max_sessions; mds++) { struct ceph_mds_session *session = __ceph_lookup_mds_session(mdsc, mds); if (!session) { continue; } mutex_unlock(&mdsc->mutex); seq_printf(s, "mds.%d %s ", session->s_mds, ceph_session_state_name(session->s_state)); ceph_put_mds_session(session); mutex_lock(&mdsc->mutex); } mutex_unlock(&mdsc->mutex); return 0; } |
3d14c5d2b ceph: factor out ... |
202 203 204 205 |
CEPH_DEFINE_SHOW_FUNC(mdsmap_show) CEPH_DEFINE_SHOW_FUNC(mdsc_show) CEPH_DEFINE_SHOW_FUNC(caps_show) CEPH_DEFINE_SHOW_FUNC(dentry_lru_show) |
14ed97033 ceph: additional ... |
206 |
CEPH_DEFINE_SHOW_FUNC(mds_sessions_show) |
3d14c5d2b ceph: factor out ... |
207 |
|
76aa844d5 ceph: debugfs |
208 |
|
3d14c5d2b ceph: factor out ... |
209 210 211 |
/* * debugfs */ |
2baba2501 ceph: writeback c... |
212 213 |
static int congestion_kb_set(void *data, u64 val) { |
3d14c5d2b ceph: factor out ... |
214 |
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data; |
2baba2501 ceph: writeback c... |
215 |
|
3d14c5d2b ceph: factor out ... |
216 |
fsc->mount_options->congestion_kb = (int)val; |
2baba2501 ceph: writeback c... |
217 218 219 220 221 |
return 0; } static int congestion_kb_get(void *data, u64 *val) { |
3d14c5d2b ceph: factor out ... |
222 |
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data; |
2baba2501 ceph: writeback c... |
223 |
|
3d14c5d2b ceph: factor out ... |
224 |
*val = (u64)fsc->mount_options->congestion_kb; |
2baba2501 ceph: writeback c... |
225 226 |
return 0; } |
2baba2501 ceph: writeback c... |
227 228 229 |
DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get, congestion_kb_set, "%llu "); |
76aa844d5 ceph: debugfs |
230 |
|
3d14c5d2b ceph: factor out ... |
231 |
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) |
76aa844d5 ceph: debugfs |
232 |
{ |
3d14c5d2b ceph: factor out ... |
233 234 235 236 237 |
dout("ceph_fs_debugfs_cleanup "); debugfs_remove(fsc->debugfs_bdi); debugfs_remove(fsc->debugfs_congestion_kb); debugfs_remove(fsc->debugfs_mdsmap); |
14ed97033 ceph: additional ... |
238 |
debugfs_remove(fsc->debugfs_mds_sessions); |
3d14c5d2b ceph: factor out ... |
239 240 241 |
debugfs_remove(fsc->debugfs_caps); debugfs_remove(fsc->debugfs_mdsc); debugfs_remove(fsc->debugfs_dentry_lru); |
76aa844d5 ceph: debugfs |
242 |
} |
3d14c5d2b ceph: factor out ... |
243 |
int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) |
76aa844d5 ceph: debugfs |
244 |
{ |
3d14c5d2b ceph: factor out ... |
245 246 |
char name[100]; int err = -ENOMEM; |
76aa844d5 ceph: debugfs |
247 |
|
3d14c5d2b ceph: factor out ... |
248 249 |
dout("ceph_fs_debugfs_init "); |
d1c338a50 libceph: delay de... |
250 |
BUG_ON(!fsc->client->debugfs_dir); |
3d14c5d2b ceph: factor out ... |
251 252 253 254 255 256 257 |
fsc->debugfs_congestion_kb = debugfs_create_file("writeback_congestion_kb", 0600, fsc->client->debugfs_dir, fsc, &congestion_kb_fops); if (!fsc->debugfs_congestion_kb) |
76aa844d5 ceph: debugfs |
258 |
goto out; |
3d14c5d2b ceph: factor out ... |
259 |
snprintf(name, sizeof(name), "../../bdi/%s", |
09dc9fc24 ceph: Convert to ... |
260 |
dev_name(fsc->sb->s_bdi->dev)); |
3d14c5d2b ceph: factor out ... |
261 262 263 264 265 |
fsc->debugfs_bdi = debugfs_create_symlink("bdi", fsc->client->debugfs_dir, name); if (!fsc->debugfs_bdi) |
76aa844d5 ceph: debugfs |
266 |
goto out; |
3d14c5d2b ceph: factor out ... |
267 |
fsc->debugfs_mdsmap = debugfs_create_file("mdsmap", |
76aa844d5 ceph: debugfs |
268 |
0600, |
3d14c5d2b ceph: factor out ... |
269 270 |
fsc->client->debugfs_dir, fsc, |
76aa844d5 ceph: debugfs |
271 |
&mdsmap_show_fops); |
3d14c5d2b ceph: factor out ... |
272 |
if (!fsc->debugfs_mdsmap) |
76aa844d5 ceph: debugfs |
273 |
goto out; |
14ed97033 ceph: additional ... |
274 275 276 277 278 279 280 |
fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions", 0600, fsc->client->debugfs_dir, fsc, &mds_sessions_show_fops); if (!fsc->debugfs_mds_sessions) goto out; |
3d14c5d2b ceph: factor out ... |
281 282 283 284 285 286 |
fsc->debugfs_mdsc = debugfs_create_file("mdsc", 0600, fsc->client->debugfs_dir, fsc, &mdsc_show_fops); if (!fsc->debugfs_mdsc) |
76aa844d5 ceph: debugfs |
287 |
goto out; |
3d14c5d2b ceph: factor out ... |
288 |
fsc->debugfs_caps = debugfs_create_file("caps", |
76aa844d5 ceph: debugfs |
289 |
0400, |
3d14c5d2b ceph: factor out ... |
290 291 |
fsc->client->debugfs_dir, fsc, |
76aa844d5 ceph: debugfs |
292 |
&caps_show_fops); |
3d14c5d2b ceph: factor out ... |
293 |
if (!fsc->debugfs_caps) |
76aa844d5 ceph: debugfs |
294 |
goto out; |
3d14c5d2b ceph: factor out ... |
295 296 297 298 299 300 |
fsc->debugfs_dentry_lru = debugfs_create_file("dentry_lru", 0600, fsc->client->debugfs_dir, fsc, &dentry_lru_show_fops); if (!fsc->debugfs_dentry_lru) |
2baba2501 ceph: writeback c... |
301 |
goto out; |
76aa844d5 ceph: debugfs |
302 303 304 |
return 0; out: |
3d14c5d2b ceph: factor out ... |
305 306 |
ceph_fs_debugfs_cleanup(fsc); return err; |
76aa844d5 ceph: debugfs |
307 |
} |
76aa844d5 ceph: debugfs |
308 |
|
213c99ee0 ceph: whitespace ... |
309 |
#else /* CONFIG_DEBUG_FS */ |
039934b89 ceph: build clean... |
310 |
|
3d14c5d2b ceph: factor out ... |
311 |
int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) |
039934b89 ceph: build clean... |
312 313 314 |
{ return 0; } |
3d14c5d2b ceph: factor out ... |
315 |
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) |
039934b89 ceph: build clean... |
316 317 |
{ } |
213c99ee0 ceph: whitespace ... |
318 |
#endif /* CONFIG_DEBUG_FS */ |