Blame view
fs/ceph/debugfs.c
6.4 KB
3d14c5d2b ceph: factor out ... |
1 |
#include <linux/ceph/ceph_debug.h> |
76aa844d5 ceph: debugfs |
2 |
|
06edf046d ceph: include lin... |
3 |
#include <linux/device.h> |
5a0e3ad6a include cleanup: ... |
4 |
#include <linux/slab.h> |
76aa844d5 ceph: debugfs |
5 6 7 8 |
#include <linux/module.h> #include <linux/ctype.h> #include <linux/debugfs.h> #include <linux/seq_file.h> |
3d14c5d2b ceph: factor out ... |
9 10 11 12 |
#include <linux/ceph/libceph.h> #include <linux/ceph/mon_client.h> #include <linux/ceph/auth.h> #include <linux/ceph/debugfs.h> |
76aa844d5 ceph: debugfs |
13 |
|
6f453ed6c ceph: fix debugfs... |
14 |
#include "super.h" |
039934b89 ceph: build clean... |
15 |
#ifdef CONFIG_DEBUG_FS |
3d14c5d2b ceph: factor out ... |
16 |
#include "mds_client.h" |
76aa844d5 ceph: debugfs |
17 18 19 20 |
static int mdsmap_show(struct seq_file *s, void *p) { int i; |
3d14c5d2b ceph: factor out ... |
21 |
struct ceph_fs_client *fsc = s->private; |
76aa844d5 ceph: debugfs |
22 |
|
3d14c5d2b ceph: factor out ... |
23 |
if (fsc->mdsc == NULL || fsc->mdsc->mdsmap == NULL) |
76aa844d5 ceph: debugfs |
24 |
return 0; |
3d14c5d2b ceph: factor out ... |
25 26 27 28 |
seq_printf(s, "epoch %d ", fsc->mdsc->mdsmap->m_epoch); seq_printf(s, "root %d ", fsc->mdsc->mdsmap->m_root); |
76aa844d5 ceph: debugfs |
29 30 |
seq_printf(s, "session_timeout %d ", |
3d14c5d2b ceph: factor out ... |
31 |
fsc->mdsc->mdsmap->m_session_timeout); |
76aa844d5 ceph: debugfs |
32 33 |
seq_printf(s, "session_autoclose %d ", |
3d14c5d2b ceph: factor out ... |
34 35 |
fsc->mdsc->mdsmap->m_session_autoclose); for (i = 0; i < fsc->mdsc->mdsmap->m_max_mds; i++) { |
76aa844d5 ceph: debugfs |
36 |
struct ceph_entity_addr *addr = |
3d14c5d2b ceph: factor out ... |
37 38 |
&fsc->mdsc->mdsmap->m_info[i].addr; int state = fsc->mdsc->mdsmap->m_info[i].state; |
76aa844d5 ceph: debugfs |
39 |
|
3d14c5d2b ceph: factor out ... |
40 41 42 |
seq_printf(s, "\tmds%d\t%s\t(%s) ", i, ceph_pr_addr(&addr->in_addr), |
76aa844d5 ceph: debugfs |
43 44 45 46 |
ceph_mds_state_name(state)); } return 0; } |
3d14c5d2b ceph: factor out ... |
47 48 49 |
/* * mdsc debugfs */ |
76aa844d5 ceph: debugfs |
50 51 |
static int mdsc_show(struct seq_file *s, void *p) { |
3d14c5d2b ceph: factor out ... |
52 53 |
struct ceph_fs_client *fsc = s->private; struct ceph_mds_client *mdsc = fsc->mdsc; |
44ca18f26 ceph: use rbtree ... |
54 55 |
struct ceph_mds_request *req; struct rb_node *rp; |
76aa844d5 ceph: debugfs |
56 57 58 59 60 |
int pathlen; u64 pathbase; char *path; mutex_lock(&mdsc->mutex); |
44ca18f26 ceph: use rbtree ... |
61 62 |
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 |
63 |
|
4af25fdda ceph: drop redund... |
64 65 66 67 |
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 |
68 |
seq_printf(s, "%lld\t(no request)\t", req->r_tid); |
4af25fdda ceph: drop redund... |
69 70 |
else seq_printf(s, "%lld\t(no session)\t", req->r_tid); |
76aa844d5 ceph: debugfs |
71 72 73 74 75 76 77 78 79 80 81 82 83 |
seq_printf(s, "%s", ceph_mds_op_name(req->r_op)); if (req->r_got_unsafe) seq_printf(s, "\t(unsafe)"); else seq_printf(s, "\t"); 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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
spin_lock(&req->r_dentry->d_lock); seq_printf(s, " #%llx/%.*s (%s)", ceph_ino(req->r_dentry->d_parent->d_inode), req->r_dentry->d_name.len, req->r_dentry->d_name.name, 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); } if (req->r_old_dentry) { path = ceph_mdsc_build_path(req->r_old_dentry, &pathlen, &pathbase, 0); |
f44c3890d ceph: ceph_mdsc_b... |
102 103 |
if (IS_ERR(path)) path = NULL; |
76aa844d5 ceph: debugfs |
104 105 |
spin_lock(&req->r_old_dentry->d_lock); seq_printf(s, " #%llx/%.*s (%s)", |
41b02e1f9 ceph: explicitly ... |
106 |
ceph_ino(req->r_old_dentry_dir), |
76aa844d5 ceph: debugfs |
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
req->r_old_dentry->d_name.len, req->r_old_dentry->d_name.name, path ? path : ""); spin_unlock(&req->r_old_dentry->d_lock); kfree(path); } else if (req->r_path2) { 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); } seq_printf(s, " "); } 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 156 157 158 159 160 161 162 163 |
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; seq_printf(s, "%p %p\t%.*s ", di, dentry, dentry->d_name.len, dentry->d_name.name); } spin_unlock(&mdsc->dentry_lru_lock); return 0; } |
3d14c5d2b ceph: factor out ... |
164 165 166 167 |
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) |
76aa844d5 ceph: debugfs |
168 |
|
3d14c5d2b ceph: factor out ... |
169 170 171 |
/* * debugfs */ |
2baba2501 ceph: writeback c... |
172 173 |
static int congestion_kb_set(void *data, u64 val) { |
3d14c5d2b ceph: factor out ... |
174 |
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data; |
2baba2501 ceph: writeback c... |
175 |
|
3d14c5d2b ceph: factor out ... |
176 |
fsc->mount_options->congestion_kb = (int)val; |
2baba2501 ceph: writeback c... |
177 178 179 180 181 |
return 0; } static int congestion_kb_get(void *data, u64 *val) { |
3d14c5d2b ceph: factor out ... |
182 |
struct ceph_fs_client *fsc = (struct ceph_fs_client *)data; |
2baba2501 ceph: writeback c... |
183 |
|
3d14c5d2b ceph: factor out ... |
184 |
*val = (u64)fsc->mount_options->congestion_kb; |
2baba2501 ceph: writeback c... |
185 186 |
return 0; } |
2baba2501 ceph: writeback c... |
187 188 189 |
DEFINE_SIMPLE_ATTRIBUTE(congestion_kb_fops, congestion_kb_get, congestion_kb_set, "%llu "); |
76aa844d5 ceph: debugfs |
190 |
|
3d14c5d2b ceph: factor out ... |
191 |
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) |
76aa844d5 ceph: debugfs |
192 |
{ |
3d14c5d2b ceph: factor out ... |
193 194 195 196 197 198 199 200 |
dout("ceph_fs_debugfs_cleanup "); debugfs_remove(fsc->debugfs_bdi); debugfs_remove(fsc->debugfs_congestion_kb); debugfs_remove(fsc->debugfs_mdsmap); debugfs_remove(fsc->debugfs_caps); debugfs_remove(fsc->debugfs_mdsc); debugfs_remove(fsc->debugfs_dentry_lru); |
76aa844d5 ceph: debugfs |
201 |
} |
3d14c5d2b ceph: factor out ... |
202 |
int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) |
76aa844d5 ceph: debugfs |
203 |
{ |
3d14c5d2b ceph: factor out ... |
204 205 |
char name[100]; int err = -ENOMEM; |
76aa844d5 ceph: debugfs |
206 |
|
3d14c5d2b ceph: factor out ... |
207 208 209 210 211 212 213 214 215 |
dout("ceph_fs_debugfs_init "); 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 |
216 |
goto out; |
3d14c5d2b ceph: factor out ... |
217 218 219 220 221 222 223 |
snprintf(name, sizeof(name), "../../bdi/%s", dev_name(fsc->backing_dev_info.dev)); fsc->debugfs_bdi = debugfs_create_symlink("bdi", fsc->client->debugfs_dir, name); if (!fsc->debugfs_bdi) |
76aa844d5 ceph: debugfs |
224 |
goto out; |
3d14c5d2b ceph: factor out ... |
225 |
fsc->debugfs_mdsmap = debugfs_create_file("mdsmap", |
76aa844d5 ceph: debugfs |
226 |
0600, |
3d14c5d2b ceph: factor out ... |
227 228 |
fsc->client->debugfs_dir, fsc, |
76aa844d5 ceph: debugfs |
229 |
&mdsmap_show_fops); |
3d14c5d2b ceph: factor out ... |
230 |
if (!fsc->debugfs_mdsmap) |
76aa844d5 ceph: debugfs |
231 |
goto out; |
3d14c5d2b ceph: factor out ... |
232 233 234 235 236 237 |
fsc->debugfs_mdsc = debugfs_create_file("mdsc", 0600, fsc->client->debugfs_dir, fsc, &mdsc_show_fops); if (!fsc->debugfs_mdsc) |
76aa844d5 ceph: debugfs |
238 |
goto out; |
3d14c5d2b ceph: factor out ... |
239 |
fsc->debugfs_caps = debugfs_create_file("caps", |
76aa844d5 ceph: debugfs |
240 |
0400, |
3d14c5d2b ceph: factor out ... |
241 242 |
fsc->client->debugfs_dir, fsc, |
76aa844d5 ceph: debugfs |
243 |
&caps_show_fops); |
3d14c5d2b ceph: factor out ... |
244 |
if (!fsc->debugfs_caps) |
76aa844d5 ceph: debugfs |
245 |
goto out; |
3d14c5d2b ceph: factor out ... |
246 247 248 249 250 251 |
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... |
252 |
goto out; |
76aa844d5 ceph: debugfs |
253 254 255 |
return 0; out: |
3d14c5d2b ceph: factor out ... |
256 257 |
ceph_fs_debugfs_cleanup(fsc); return err; |
76aa844d5 ceph: debugfs |
258 |
} |
76aa844d5 ceph: debugfs |
259 |
|
213c99ee0 ceph: whitespace ... |
260 |
#else /* CONFIG_DEBUG_FS */ |
039934b89 ceph: build clean... |
261 |
|
3d14c5d2b ceph: factor out ... |
262 |
int ceph_fs_debugfs_init(struct ceph_fs_client *fsc) |
039934b89 ceph: build clean... |
263 264 265 |
{ return 0; } |
3d14c5d2b ceph: factor out ... |
266 |
void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc) |
039934b89 ceph: build clean... |
267 268 |
{ } |
213c99ee0 ceph: whitespace ... |
269 |
#endif /* CONFIG_DEBUG_FS */ |