Blame view
fs/dlm/debug_fs.c
18.1 KB
2522fe45a treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
e7fd41792 [DLM] The core of... |
2 3 4 |
/****************************************************************************** ******************************************************************************* ** |
892c4467e dlm: fix seq_file... |
5 |
** Copyright (C) 2005-2009 Red Hat, Inc. All rights reserved. |
e7fd41792 [DLM] The core of... |
6 |
** |
e7fd41792 [DLM] The core of... |
7 8 9 10 11 12 |
** ******************************************************************************* ******************************************************************************/ #include <linux/pagemap.h> #include <linux/seq_file.h> |
7963b8a59 dlm: audit and re... |
13 |
#include <linux/init.h> |
e7fd41792 [DLM] The core of... |
14 15 |
#include <linux/ctype.h> #include <linux/debugfs.h> |
5a0e3ad6a include cleanup: ... |
16 |
#include <linux/slab.h> |
e7fd41792 [DLM] The core of... |
17 18 |
#include "dlm_internal.h" |
916297aad [DLM] keep dlm fr... |
19 |
#include "lock.h" |
e7fd41792 [DLM] The core of... |
20 |
|
5de6319b1 [DLM] more info t... |
21 22 23 |
#define DLM_DEBUG_BUF_LEN 4096 static char debug_buf[DLM_DEBUG_BUF_LEN]; static struct mutex debug_buf_lock; |
e7fd41792 [DLM] The core of... |
24 25 |
static struct dentry *dlm_root; |
e7fd41792 [DLM] The core of... |
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
static char *print_lockmode(int mode) { switch (mode) { case DLM_LOCK_IV: return "--"; case DLM_LOCK_NL: return "NL"; case DLM_LOCK_CR: return "CR"; case DLM_LOCK_CW: return "CW"; case DLM_LOCK_PR: return "PR"; case DLM_LOCK_PW: return "PW"; case DLM_LOCK_EX: return "EX"; default: return "??"; } } |
d6d906b23 dlm: Remove seq_p... |
47 48 |
static void print_format1_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *res) |
e7fd41792 [DLM] The core of... |
49 50 |
{ seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_grmode)); |
892c4467e dlm: fix seq_file... |
51 52 |
if (lkb->lkb_status == DLM_LKSTS_CONVERT || lkb->lkb_status == DLM_LKSTS_WAITING) |
e7fd41792 [DLM] The core of... |
53 |
seq_printf(s, " (%s)", print_lockmode(lkb->lkb_rqmode)); |
e7fd41792 [DLM] The core of... |
54 55 56 57 58 59 60 61 62 63 |
if (lkb->lkb_nodeid) { if (lkb->lkb_nodeid != res->res_nodeid) seq_printf(s, " Remote: %3d %08x", lkb->lkb_nodeid, lkb->lkb_remid); else seq_printf(s, " Master: %08x", lkb->lkb_remid); } if (lkb->lkb_wait_type) seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
653996ca8 dlm: Replace six ... |
64 65 |
seq_putc(s, ' '); |
e7fd41792 [DLM] The core of... |
66 |
} |
d6d906b23 dlm: Remove seq_p... |
67 |
static void print_format1(struct dlm_rsb *res, struct seq_file *s) |
e7fd41792 [DLM] The core of... |
68 69 |
{ struct dlm_lkb *lkb; |
5de6319b1 [DLM] more info t... |
70 |
int i, lvblen = res->res_ls->ls_lvblen, recover_list, root_list; |
e7fd41792 [DLM] The core of... |
71 |
|
9dd592d70 [DLM] dumping mas... |
72 |
lock_rsb(res); |
d6d906b23 dlm: Remove seq_p... |
73 74 |
seq_printf(s, " Resource %p Name (len=%d) \"", res, res->res_length); |
892c4467e dlm: fix seq_file... |
75 |
|
e7fd41792 [DLM] The core of... |
76 77 78 79 80 81 |
for (i = 0; i < res->res_length; i++) { if (isprint(res->res_name[i])) seq_printf(s, "%c", res->res_name[i]); else seq_printf(s, "%c", '.'); } |
892c4467e dlm: fix seq_file... |
82 |
|
e7fd41792 [DLM] The core of... |
83 |
if (res->res_nodeid > 0) |
d6d906b23 dlm: Remove seq_p... |
84 85 86 87 |
seq_printf(s, "\" Local Copy, Master is node %d ", res->res_nodeid); |
e7fd41792 [DLM] The core of... |
88 |
else if (res->res_nodeid == 0) |
d6d906b23 dlm: Remove seq_p... |
89 90 91 |
seq_puts(s, "\" Master Copy "); |
e7fd41792 [DLM] The core of... |
92 |
else if (res->res_nodeid == -1) |
d6d906b23 dlm: Remove seq_p... |
93 94 95 96 |
seq_printf(s, "\" Looking up master (lkid %x) ", res->res_first_lkid); |
e7fd41792 [DLM] The core of... |
97 |
else |
d6d906b23 dlm: Remove seq_p... |
98 99 100 101 |
seq_printf(s, "\" Invalid master %d ", res->res_nodeid); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
102 |
goto out; |
e7fd41792 [DLM] The core of... |
103 104 105 |
/* Print the LVB: */ if (res->res_lvbptr) { |
c1d4518c4 fs/dlm/debug_fs.c... |
106 |
seq_puts(s, "LVB: "); |
e7fd41792 [DLM] The core of... |
107 108 |
for (i = 0; i < lvblen; i++) { if (i == lvblen / 2) |
c1d4518c4 fs/dlm/debug_fs.c... |
109 110 |
seq_puts(s, " "); |
e7fd41792 [DLM] The core of... |
111 112 113 114 |
seq_printf(s, "%02x ", (unsigned char) res->res_lvbptr[i]); } if (rsb_flag(res, RSB_VALNOTVALID)) |
c1d4518c4 fs/dlm/debug_fs.c... |
115 |
seq_puts(s, " (INVALID)"); |
653996ca8 dlm: Replace six ... |
116 117 |
seq_putc(s, ' '); |
d6d906b23 dlm: Remove seq_p... |
118 |
if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
119 |
goto out; |
e7fd41792 [DLM] The core of... |
120 |
} |
5de6319b1 [DLM] more info t... |
121 122 123 124 |
root_list = !list_empty(&res->res_root_list); recover_list = !list_empty(&res->res_recover_list); if (root_list || recover_list) { |
d6d906b23 dlm: Remove seq_p... |
125 126 127 128 |
seq_printf(s, "Recovery: root %d recover %d flags %lx count %d ", root_list, recover_list, res->res_flags, res->res_recover_locks_count); |
5de6319b1 [DLM] more info t... |
129 |
} |
e7fd41792 [DLM] The core of... |
130 |
/* Print the locks attached to this resource */ |
c1d4518c4 fs/dlm/debug_fs.c... |
131 132 |
seq_puts(s, "Granted Queue "); |
892c4467e dlm: fix seq_file... |
133 |
list_for_each_entry(lkb, &res->res_grantqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
134 135 |
print_format1_lock(s, lkb, res); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
136 137 |
goto out; } |
e7fd41792 [DLM] The core of... |
138 |
|
c1d4518c4 fs/dlm/debug_fs.c... |
139 140 |
seq_puts(s, "Conversion Queue "); |
892c4467e dlm: fix seq_file... |
141 |
list_for_each_entry(lkb, &res->res_convertqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
142 143 |
print_format1_lock(s, lkb, res); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
144 145 |
goto out; } |
e7fd41792 [DLM] The core of... |
146 |
|
c1d4518c4 fs/dlm/debug_fs.c... |
147 148 |
seq_puts(s, "Waiting Queue "); |
892c4467e dlm: fix seq_file... |
149 |
list_for_each_entry(lkb, &res->res_waitqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
150 151 |
print_format1_lock(s, lkb, res); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
152 153 |
goto out; } |
e7fd41792 [DLM] The core of... |
154 |
|
5de6319b1 [DLM] more info t... |
155 156 |
if (list_empty(&res->res_lookup)) goto out; |
c1d4518c4 fs/dlm/debug_fs.c... |
157 158 |
seq_puts(s, "Lookup Queue "); |
5de6319b1 [DLM] more info t... |
159 |
list_for_each_entry(lkb, &res->res_lookup, lkb_rsb_lookup) { |
d6d906b23 dlm: Remove seq_p... |
160 161 |
seq_printf(s, "%08x %s", lkb->lkb_id, print_lockmode(lkb->lkb_rqmode)); |
5de6319b1 [DLM] more info t... |
162 163 |
if (lkb->lkb_wait_type) seq_printf(s, " wait_type: %d", lkb->lkb_wait_type); |
653996ca8 dlm: Replace six ... |
164 165 |
seq_putc(s, ' '); |
d6d906b23 dlm: Remove seq_p... |
166 167 |
if (seq_has_overflowed(s)) goto out; |
5de6319b1 [DLM] more info t... |
168 169 |
} out: |
9dd592d70 [DLM] dumping mas... |
170 |
unlock_rsb(res); |
9dd592d70 [DLM] dumping mas... |
171 |
} |
d6d906b23 dlm: Remove seq_p... |
172 173 |
static void print_format2_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r) |
9dd592d70 [DLM] dumping mas... |
174 |
{ |
eeda418d8 dlm: change lock ... |
175 176 |
u64 xid = 0; u64 us; |
9dd592d70 [DLM] dumping mas... |
177 178 |
if (lkb->lkb_flags & DLM_IFL_USER) { |
d292c0cc4 dlm: eliminate as... |
179 180 |
if (lkb->lkb_ua) xid = lkb->lkb_ua->xid; |
9dd592d70 [DLM] dumping mas... |
181 |
} |
eeda418d8 dlm: change lock ... |
182 183 |
/* microseconds since lkb was added to current queue */ us = ktime_to_us(ktime_sub(ktime_get(), lkb->lkb_timestamp)); |
9dd592d70 [DLM] dumping mas... |
184 |
|
eeda418d8 dlm: change lock ... |
185 |
/* id nodeid remid pid xid exflags flags sts grmode rqmode time_us |
ac90a2552 [DLM] dump more l... |
186 |
r_nodeid r_len r_name */ |
9dd592d70 [DLM] dumping mas... |
187 |
|
d6d906b23 dlm: Remove seq_p... |
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
seq_printf(s, "%x %d %x %u %llu %x %x %d %d %d %llu %u %d \"%s\" ", lkb->lkb_id, lkb->lkb_nodeid, lkb->lkb_remid, lkb->lkb_ownpid, (unsigned long long)xid, lkb->lkb_exflags, lkb->lkb_flags, lkb->lkb_status, lkb->lkb_grmode, lkb->lkb_rqmode, (unsigned long long)us, r->res_nodeid, r->res_length, r->res_name); |
9dd592d70 [DLM] dumping mas... |
204 |
} |
d6d906b23 dlm: Remove seq_p... |
205 |
static void print_format2(struct dlm_rsb *r, struct seq_file *s) |
9dd592d70 [DLM] dumping mas... |
206 207 208 209 |
{ struct dlm_lkb *lkb; lock_rsb(r); |
892c4467e dlm: fix seq_file... |
210 |
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
211 212 |
print_format2_lock(s, lkb, r); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
213 214 |
goto out; } |
9dd592d70 [DLM] dumping mas... |
215 |
|
892c4467e dlm: fix seq_file... |
216 |
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
217 218 |
print_format2_lock(s, lkb, r); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
219 220 |
goto out; } |
d022509d1 dlm: add new debu... |
221 |
|
892c4467e dlm: fix seq_file... |
222 |
list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
223 224 |
print_format2_lock(s, lkb, r); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
225 226 227 |
goto out; } out: |
d022509d1 dlm: add new debu... |
228 |
unlock_rsb(r); |
d022509d1 dlm: add new debu... |
229 |
} |
d6d906b23 dlm: Remove seq_p... |
230 |
static void print_format3_lock(struct seq_file *s, struct dlm_lkb *lkb, |
892c4467e dlm: fix seq_file... |
231 |
int rsb_lookup) |
d022509d1 dlm: add new debu... |
232 233 234 235 236 237 238 |
{ u64 xid = 0; if (lkb->lkb_flags & DLM_IFL_USER) { if (lkb->lkb_ua) xid = lkb->lkb_ua->xid; } |
d6d906b23 dlm: Remove seq_p... |
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
seq_printf(s, "lkb %x %d %x %u %llu %x %x %d %d %d %d %d %d %u %llu %llu ", lkb->lkb_id, lkb->lkb_nodeid, lkb->lkb_remid, lkb->lkb_ownpid, (unsigned long long)xid, lkb->lkb_exflags, lkb->lkb_flags, lkb->lkb_status, lkb->lkb_grmode, lkb->lkb_rqmode, lkb->lkb_last_bast.mode, rsb_lookup, lkb->lkb_wait_type, lkb->lkb_lvbseq, (unsigned long long)ktime_to_ns(lkb->lkb_timestamp), (unsigned long long)ktime_to_ns(lkb->lkb_last_bast_time)); |
d022509d1 dlm: add new debu... |
257 |
} |
d6d906b23 dlm: Remove seq_p... |
258 |
static void print_format3(struct dlm_rsb *r, struct seq_file *s) |
d022509d1 dlm: add new debu... |
259 260 261 262 263 264 |
{ struct dlm_lkb *lkb; int i, lvblen = r->res_ls->ls_lvblen; int print_name = 1; lock_rsb(r); |
d6d906b23 dlm: Remove seq_p... |
265 266 267 268 269 270 271 272 273 274 |
seq_printf(s, "rsb %p %d %x %lx %d %d %u %d ", r, r->res_nodeid, r->res_first_lkid, r->res_flags, !list_empty(&r->res_root_list), !list_empty(&r->res_recover_list), r->res_recover_locks_count, r->res_length); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
275 |
goto out; |
d022509d1 dlm: add new debu... |
276 277 278 279 280 |
for (i = 0; i < r->res_length; i++) { if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) print_name = 0; } |
f365ef9b7 dlm: Use seq_puts... |
281 |
seq_puts(s, print_name ? "str " : "hex"); |
d022509d1 dlm: add new debu... |
282 283 284 285 286 287 288 |
for (i = 0; i < r->res_length; i++) { if (print_name) seq_printf(s, "%c", r->res_name[i]); else seq_printf(s, " %02x", (unsigned char)r->res_name[i]); } |
653996ca8 dlm: Replace six ... |
289 290 |
seq_putc(s, ' '); |
d6d906b23 dlm: Remove seq_p... |
291 |
if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
292 |
goto out; |
d022509d1 dlm: add new debu... |
293 294 295 296 297 298 299 300 |
if (!r->res_lvbptr) goto do_locks; seq_printf(s, "lvb %u %d", r->res_lvbseq, lvblen); for (i = 0; i < lvblen; i++) seq_printf(s, " %02x", (unsigned char)r->res_lvbptr[i]); |
653996ca8 dlm: Replace six ... |
301 302 |
seq_putc(s, ' '); |
d6d906b23 dlm: Remove seq_p... |
303 |
if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
304 |
goto out; |
d022509d1 dlm: add new debu... |
305 306 |
do_locks: |
892c4467e dlm: fix seq_file... |
307 |
list_for_each_entry(lkb, &r->res_grantqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
308 309 |
print_format3_lock(s, lkb, 0); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
310 |
goto out; |
e7fd41792 [DLM] The core of... |
311 |
} |
e7fd41792 [DLM] The core of... |
312 |
|
892c4467e dlm: fix seq_file... |
313 |
list_for_each_entry(lkb, &r->res_convertqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
314 315 |
print_format3_lock(s, lkb, 0); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
316 |
goto out; |
e7fd41792 [DLM] The core of... |
317 |
} |
892c4467e dlm: fix seq_file... |
318 |
list_for_each_entry(lkb, &r->res_waitqueue, lkb_statequeue) { |
d6d906b23 dlm: Remove seq_p... |
319 320 |
print_format3_lock(s, lkb, 0); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
321 |
goto out; |
e7fd41792 [DLM] The core of... |
322 |
} |
892c4467e dlm: fix seq_file... |
323 |
list_for_each_entry(lkb, &r->res_lookup, lkb_rsb_lookup) { |
d6d906b23 dlm: Remove seq_p... |
324 325 |
print_format3_lock(s, lkb, 1); if (seq_has_overflowed(s)) |
892c4467e dlm: fix seq_file... |
326 |
goto out; |
e7fd41792 [DLM] The core of... |
327 |
} |
892c4467e dlm: fix seq_file... |
328 329 |
out: unlock_rsb(r); |
e7fd41792 [DLM] The core of... |
330 |
} |
d6d906b23 dlm: Remove seq_p... |
331 |
static void print_format4(struct dlm_rsb *r, struct seq_file *s) |
c04fecb4d dlm: use rsbtbl a... |
332 333 334 |
{ int our_nodeid = dlm_our_nodeid(); int print_name = 1; |
d6d906b23 dlm: Remove seq_p... |
335 |
int i; |
c04fecb4d dlm: use rsbtbl a... |
336 337 |
lock_rsb(r); |
d6d906b23 dlm: Remove seq_p... |
338 339 340 341 342 343 344 345 346 |
seq_printf(s, "rsb %p %d %d %d %d %lu %lx %d ", r, r->res_nodeid, r->res_master_nodeid, r->res_dir_nodeid, our_nodeid, r->res_toss_time, r->res_flags, r->res_length); |
c04fecb4d dlm: use rsbtbl a... |
347 348 349 350 351 |
for (i = 0; i < r->res_length; i++) { if (!isascii(r->res_name[i]) || !isprint(r->res_name[i])) print_name = 0; } |
f365ef9b7 dlm: Use seq_puts... |
352 |
seq_puts(s, print_name ? "str " : "hex"); |
c04fecb4d dlm: use rsbtbl a... |
353 354 355 356 357 358 359 |
for (i = 0; i < r->res_length; i++) { if (print_name) seq_printf(s, "%c", r->res_name[i]); else seq_printf(s, " %02x", (unsigned char)r->res_name[i]); } |
653996ca8 dlm: Replace six ... |
360 361 |
seq_putc(s, ' '); |
c04fecb4d dlm: use rsbtbl a... |
362 |
unlock_rsb(r); |
c04fecb4d dlm: use rsbtbl a... |
363 |
} |
892c4467e dlm: fix seq_file... |
364 365 366 367 368 369 |
struct rsbtbl_iter { struct dlm_rsb *rsb; unsigned bucket; int format; int header; }; |
e7fd41792 [DLM] The core of... |
370 |
|
d6d906b23 dlm: Remove seq_p... |
371 372 373 374 375 376 |
/* * If the buffer is full, seq_printf can be called again, but it * does nothing. So, the these printing routines periodically check * seq_has_overflowed to avoid wasting too much time trying to print to * a full buffer. */ |
892c4467e dlm: fix seq_file... |
377 378 |
static int table_seq_show(struct seq_file *seq, void *iter_ptr) |
e7fd41792 [DLM] The core of... |
379 |
{ |
892c4467e dlm: fix seq_file... |
380 |
struct rsbtbl_iter *ri = iter_ptr; |
e7fd41792 [DLM] The core of... |
381 |
|
d022509d1 dlm: add new debu... |
382 383 |
switch (ri->format) { case 1: |
d6d906b23 dlm: Remove seq_p... |
384 |
print_format1(ri->rsb, seq); |
d022509d1 dlm: add new debu... |
385 386 |
break; case 2: |
9dd592d70 [DLM] dumping mas... |
387 |
if (ri->header) { |
f365ef9b7 dlm: Use seq_puts... |
388 389 |
seq_puts(seq, "id nodeid remid pid xid exflags flags sts grmode rqmode time_ms r_nodeid r_len r_name "); |
9dd592d70 [DLM] dumping mas... |
390 391 |
ri->header = 0; } |
d6d906b23 dlm: Remove seq_p... |
392 |
print_format2(ri->rsb, seq); |
d022509d1 dlm: add new debu... |
393 394 395 |
break; case 3: if (ri->header) { |
f365ef9b7 dlm: Use seq_puts... |
396 397 |
seq_puts(seq, "version rsb 1.1 lvb 1.1 lkb 1.1 "); |
d022509d1 dlm: add new debu... |
398 399 |
ri->header = 0; } |
d6d906b23 dlm: Remove seq_p... |
400 |
print_format3(ri->rsb, seq); |
d022509d1 dlm: add new debu... |
401 |
break; |
c04fecb4d dlm: use rsbtbl a... |
402 403 |
case 4: if (ri->header) { |
f365ef9b7 dlm: Use seq_puts... |
404 405 |
seq_puts(seq, "version 4 rsb 2 "); |
c04fecb4d dlm: use rsbtbl a... |
406 407 |
ri->header = 0; } |
d6d906b23 dlm: Remove seq_p... |
408 |
print_format4(ri->rsb, seq); |
c04fecb4d dlm: use rsbtbl a... |
409 |
break; |
9dd592d70 [DLM] dumping mas... |
410 |
} |
e7fd41792 [DLM] The core of... |
411 |
|
d6d906b23 dlm: Remove seq_p... |
412 |
return 0; |
e7fd41792 [DLM] The core of... |
413 |
} |
88e9d34c7 seq_file: constif... |
414 415 416 |
static const struct seq_operations format1_seq_ops; static const struct seq_operations format2_seq_ops; static const struct seq_operations format3_seq_ops; |
c04fecb4d dlm: use rsbtbl a... |
417 |
static const struct seq_operations format4_seq_ops; |
e7fd41792 [DLM] The core of... |
418 |
|
892c4467e dlm: fix seq_file... |
419 |
static void *table_seq_start(struct seq_file *seq, loff_t *pos) |
e7fd41792 [DLM] The core of... |
420 |
{ |
c04fecb4d dlm: use rsbtbl a... |
421 |
struct rb_root *tree; |
9beb3bf5a dlm: convert rsb ... |
422 |
struct rb_node *node; |
892c4467e dlm: fix seq_file... |
423 424 425 426 427 |
struct dlm_ls *ls = seq->private; struct rsbtbl_iter *ri; struct dlm_rsb *r; loff_t n = *pos; unsigned bucket, entry; |
c04fecb4d dlm: use rsbtbl a... |
428 |
int toss = (seq->op == &format4_seq_ops); |
e7fd41792 [DLM] The core of... |
429 |
|
892c4467e dlm: fix seq_file... |
430 431 |
bucket = n >> 32; entry = n & ((1LL << 32) - 1); |
9dd592d70 [DLM] dumping mas... |
432 |
|
892c4467e dlm: fix seq_file... |
433 434 |
if (bucket >= ls->ls_rsbtbl_size) return NULL; |
9dd592d70 [DLM] dumping mas... |
435 |
|
2c257e96d dlm: Improve a si... |
436 |
ri = kzalloc(sizeof(*ri), GFP_NOFS); |
9dd592d70 [DLM] dumping mas... |
437 438 |
if (!ri) return NULL; |
892c4467e dlm: fix seq_file... |
439 |
if (n == 0) |
9dd592d70 [DLM] dumping mas... |
440 |
ri->header = 1; |
892c4467e dlm: fix seq_file... |
441 442 443 444 445 446 |
if (seq->op == &format1_seq_ops) ri->format = 1; if (seq->op == &format2_seq_ops) ri->format = 2; if (seq->op == &format3_seq_ops) ri->format = 3; |
c04fecb4d dlm: use rsbtbl a... |
447 448 449 450 |
if (seq->op == &format4_seq_ops) ri->format = 4; tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep; |
892c4467e dlm: fix seq_file... |
451 |
|
c7be761a8 dlm: change rsbtb... |
452 |
spin_lock(&ls->ls_rsbtbl[bucket].lock); |
c04fecb4d dlm: use rsbtbl a... |
453 454 |
if (!RB_EMPTY_ROOT(tree)) { for (node = rb_first(tree); node; node = rb_next(node)) { |
9beb3bf5a dlm: convert rsb ... |
455 |
r = rb_entry(node, struct dlm_rsb, res_hashnode); |
892c4467e dlm: fix seq_file... |
456 457 458 459 |
if (!entry--) { dlm_hold_rsb(r); ri->rsb = r; ri->bucket = bucket; |
c7be761a8 dlm: change rsbtb... |
460 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
461 462 463 |
return ri; } } |
9dd592d70 [DLM] dumping mas... |
464 |
} |
c7be761a8 dlm: change rsbtb... |
465 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
9dd592d70 [DLM] dumping mas... |
466 |
|
892c4467e dlm: fix seq_file... |
467 468 469 |
/* * move to the first rsb in the next non-empty bucket */ |
9dd592d70 [DLM] dumping mas... |
470 |
|
892c4467e dlm: fix seq_file... |
471 472 |
/* zero the entry */ n &= ~((1LL << 32) - 1); |
9dd592d70 [DLM] dumping mas... |
473 |
|
892c4467e dlm: fix seq_file... |
474 475 476 |
while (1) { bucket++; n += 1LL << 32; |
9dd592d70 [DLM] dumping mas... |
477 |
|
892c4467e dlm: fix seq_file... |
478 479 |
if (bucket >= ls->ls_rsbtbl_size) { kfree(ri); |
9dd592d70 [DLM] dumping mas... |
480 481 |
return NULL; } |
c04fecb4d dlm: use rsbtbl a... |
482 |
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep; |
9dd592d70 [DLM] dumping mas... |
483 |
|
c7be761a8 dlm: change rsbtb... |
484 |
spin_lock(&ls->ls_rsbtbl[bucket].lock); |
c04fecb4d dlm: use rsbtbl a... |
485 486 |
if (!RB_EMPTY_ROOT(tree)) { node = rb_first(tree); |
9beb3bf5a dlm: convert rsb ... |
487 |
r = rb_entry(node, struct dlm_rsb, res_hashnode); |
892c4467e dlm: fix seq_file... |
488 489 490 |
dlm_hold_rsb(r); ri->rsb = r; ri->bucket = bucket; |
c7be761a8 dlm: change rsbtb... |
491 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
492 493 494 |
*pos = n; return ri; } |
c7be761a8 dlm: change rsbtb... |
495 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
496 |
} |
9dd592d70 [DLM] dumping mas... |
497 |
} |
892c4467e dlm: fix seq_file... |
498 |
static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos) |
9dd592d70 [DLM] dumping mas... |
499 |
{ |
892c4467e dlm: fix seq_file... |
500 501 |
struct dlm_ls *ls = seq->private; struct rsbtbl_iter *ri = iter_ptr; |
c04fecb4d dlm: use rsbtbl a... |
502 |
struct rb_root *tree; |
9beb3bf5a dlm: convert rsb ... |
503 |
struct rb_node *next; |
892c4467e dlm: fix seq_file... |
504 505 506 |
struct dlm_rsb *r, *rp; loff_t n = *pos; unsigned bucket; |
c04fecb4d dlm: use rsbtbl a... |
507 |
int toss = (seq->op == &format4_seq_ops); |
892c4467e dlm: fix seq_file... |
508 509 510 511 512 513 |
bucket = n >> 32; /* * move to the next rsb in the same bucket */ |
c7be761a8 dlm: change rsbtb... |
514 |
spin_lock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
515 |
rp = ri->rsb; |
9beb3bf5a dlm: convert rsb ... |
516 |
next = rb_next(&rp->res_hashnode); |
892c4467e dlm: fix seq_file... |
517 |
|
9beb3bf5a dlm: convert rsb ... |
518 519 |
if (next) { r = rb_entry(next, struct dlm_rsb, res_hashnode); |
892c4467e dlm: fix seq_file... |
520 521 |
dlm_hold_rsb(r); ri->rsb = r; |
c7be761a8 dlm: change rsbtb... |
522 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
523 524 525 526 |
dlm_put_rsb(rp); ++*pos; return ri; } |
c7be761a8 dlm: change rsbtb... |
527 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
528 |
dlm_put_rsb(rp); |
d022509d1 dlm: add new debu... |
529 |
|
892c4467e dlm: fix seq_file... |
530 531 532 |
/* * move to the first rsb in the next non-empty bucket */ |
d022509d1 dlm: add new debu... |
533 |
|
892c4467e dlm: fix seq_file... |
534 535 |
/* zero the entry */ n &= ~((1LL << 32) - 1); |
d022509d1 dlm: add new debu... |
536 |
|
892c4467e dlm: fix seq_file... |
537 538 539 |
while (1) { bucket++; n += 1LL << 32; |
d022509d1 dlm: add new debu... |
540 |
|
892c4467e dlm: fix seq_file... |
541 542 543 544 |
if (bucket >= ls->ls_rsbtbl_size) { kfree(ri); return NULL; } |
c04fecb4d dlm: use rsbtbl a... |
545 |
tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep; |
d022509d1 dlm: add new debu... |
546 |
|
c7be761a8 dlm: change rsbtb... |
547 |
spin_lock(&ls->ls_rsbtbl[bucket].lock); |
c04fecb4d dlm: use rsbtbl a... |
548 549 |
if (!RB_EMPTY_ROOT(tree)) { next = rb_first(tree); |
9beb3bf5a dlm: convert rsb ... |
550 |
r = rb_entry(next, struct dlm_rsb, res_hashnode); |
892c4467e dlm: fix seq_file... |
551 552 553 |
dlm_hold_rsb(r); ri->rsb = r; ri->bucket = bucket; |
c7be761a8 dlm: change rsbtb... |
554 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
892c4467e dlm: fix seq_file... |
555 556 557 |
*pos = n; return ri; } |
c7be761a8 dlm: change rsbtb... |
558 |
spin_unlock(&ls->ls_rsbtbl[bucket].lock); |
d022509d1 dlm: add new debu... |
559 |
} |
d022509d1 dlm: add new debu... |
560 |
} |
892c4467e dlm: fix seq_file... |
561 |
static void table_seq_stop(struct seq_file *seq, void *iter_ptr) |
d022509d1 dlm: add new debu... |
562 |
{ |
892c4467e dlm: fix seq_file... |
563 |
struct rsbtbl_iter *ri = iter_ptr; |
d022509d1 dlm: add new debu... |
564 |
|
892c4467e dlm: fix seq_file... |
565 566 567 |
if (ri) { dlm_put_rsb(ri->rsb); kfree(ri); |
d022509d1 dlm: add new debu... |
568 |
} |
d022509d1 dlm: add new debu... |
569 |
} |
88e9d34c7 seq_file: constif... |
570 |
static const struct seq_operations format1_seq_ops = { |
892c4467e dlm: fix seq_file... |
571 572 573 574 |
.start = table_seq_start, .next = table_seq_next, .stop = table_seq_stop, .show = table_seq_show, |
d022509d1 dlm: add new debu... |
575 |
}; |
88e9d34c7 seq_file: constif... |
576 |
static const struct seq_operations format2_seq_ops = { |
892c4467e dlm: fix seq_file... |
577 578 579 580 581 |
.start = table_seq_start, .next = table_seq_next, .stop = table_seq_stop, .show = table_seq_show, }; |
88e9d34c7 seq_file: constif... |
582 |
static const struct seq_operations format3_seq_ops = { |
892c4467e dlm: fix seq_file... |
583 584 585 586 587 |
.start = table_seq_start, .next = table_seq_next, .stop = table_seq_stop, .show = table_seq_show, }; |
c04fecb4d dlm: use rsbtbl a... |
588 589 590 591 592 593 |
static const struct seq_operations format4_seq_ops = { .start = table_seq_start, .next = table_seq_next, .stop = table_seq_stop, .show = table_seq_show, }; |
892c4467e dlm: fix seq_file... |
594 595 596 |
static const struct file_operations format1_fops; static const struct file_operations format2_fops; static const struct file_operations format3_fops; |
c04fecb4d dlm: use rsbtbl a... |
597 |
static const struct file_operations format4_fops; |
892c4467e dlm: fix seq_file... |
598 |
|
079d37df3 dlm: fix malfunct... |
599 |
static int table_open1(struct inode *inode, struct file *file) |
d022509d1 dlm: add new debu... |
600 601 |
{ struct seq_file *seq; |
079d37df3 dlm: fix malfunct... |
602 |
int ret; |
892c4467e dlm: fix seq_file... |
603 |
|
079d37df3 dlm: fix malfunct... |
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
ret = seq_open(file, &format1_seq_ops); if (ret) return ret; seq = file->private_data; seq->private = inode->i_private; /* the dlm_ls */ return 0; } static int table_open2(struct inode *inode, struct file *file) { struct seq_file *seq; int ret; ret = seq_open(file, &format2_seq_ops); if (ret) return ret; seq = file->private_data; seq->private = inode->i_private; /* the dlm_ls */ return 0; } static int table_open3(struct inode *inode, struct file *file) { struct seq_file *seq; int ret; ret = seq_open(file, &format3_seq_ops); if (ret) return ret; seq = file->private_data; seq->private = inode->i_private; /* the dlm_ls */ return 0; } static int table_open4(struct inode *inode, struct file *file) { struct seq_file *seq; int ret; |
d022509d1 dlm: add new debu... |
645 |
|
079d37df3 dlm: fix malfunct... |
646 |
ret = seq_open(file, &format4_seq_ops); |
d022509d1 dlm: add new debu... |
647 648 649 650 |
if (ret) return ret; seq = file->private_data; |
892c4467e dlm: fix seq_file... |
651 |
seq->private = inode->i_private; /* the dlm_ls */ |
d022509d1 dlm: add new debu... |
652 653 |
return 0; } |
892c4467e dlm: fix seq_file... |
654 655 |
static const struct file_operations format1_fops = { .owner = THIS_MODULE, |
079d37df3 dlm: fix malfunct... |
656 |
.open = table_open1, |
892c4467e dlm: fix seq_file... |
657 658 659 660 661 662 663 |
.read = seq_read, .llseek = seq_lseek, .release = seq_release }; static const struct file_operations format2_fops = { .owner = THIS_MODULE, |
079d37df3 dlm: fix malfunct... |
664 |
.open = table_open2, |
892c4467e dlm: fix seq_file... |
665 666 667 668 669 670 |
.read = seq_read, .llseek = seq_lseek, .release = seq_release }; static const struct file_operations format3_fops = { |
d022509d1 dlm: add new debu... |
671 |
.owner = THIS_MODULE, |
079d37df3 dlm: fix malfunct... |
672 |
.open = table_open3, |
d022509d1 dlm: add new debu... |
673 674 675 676 |
.read = seq_read, .llseek = seq_lseek, .release = seq_release }; |
c04fecb4d dlm: use rsbtbl a... |
677 678 |
static const struct file_operations format4_fops = { .owner = THIS_MODULE, |
079d37df3 dlm: fix malfunct... |
679 |
.open = table_open4, |
c04fecb4d dlm: use rsbtbl a... |
680 681 682 683 |
.read = seq_read, .llseek = seq_lseek, .release = seq_release }; |
d022509d1 dlm: add new debu... |
684 |
/* |
5de6319b1 [DLM] more info t... |
685 686 |
* dump lkb's on the ls_waiters list */ |
5de6319b1 [DLM] more info t... |
687 688 689 690 691 |
static ssize_t waiters_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { struct dlm_ls *ls = file->private_data; struct dlm_lkb *lkb; |
06442440b [DLM] break from ... |
692 |
size_t len = DLM_DEBUG_BUF_LEN, pos = 0, ret, rv; |
5de6319b1 [DLM] more info t... |
693 694 695 696 697 698 |
mutex_lock(&debug_buf_lock); mutex_lock(&ls->ls_waiters_mutex); memset(debug_buf, 0, sizeof(debug_buf)); list_for_each_entry(lkb, &ls->ls_waiters, lkb_wait_reply) { |
06442440b [DLM] break from ... |
699 700 701 702 703 704 705 |
ret = snprintf(debug_buf + pos, len - pos, "%x %d %d %s ", lkb->lkb_id, lkb->lkb_wait_type, lkb->lkb_nodeid, lkb->lkb_resource->res_name); if (ret >= len - pos) break; pos += ret; |
5de6319b1 [DLM] more info t... |
706 707 708 709 710 711 712 |
} mutex_unlock(&ls->ls_waiters_mutex); rv = simple_read_from_buffer(userbuf, count, ppos, debug_buf, pos); mutex_unlock(&debug_buf_lock); return rv; } |
00977a59b [PATCH] mark stru... |
713 |
static const struct file_operations waiters_fops = { |
5de6319b1 [DLM] more info t... |
714 |
.owner = THIS_MODULE, |
234e34058 simple_open: auto... |
715 |
.open = simple_open, |
6038f373a llseek: automatic... |
716 717 |
.read = waiters_read, .llseek = default_llseek, |
5de6319b1 [DLM] more info t... |
718 |
}; |
d022509d1 dlm: add new debu... |
719 720 |
void dlm_delete_debug_file(struct dlm_ls *ls) { |
e0d9bf4cc fs/dlm/debug_fs.c... |
721 722 723 724 725 |
debugfs_remove(ls->ls_debug_rsb_dentry); debugfs_remove(ls->ls_debug_waiters_dentry); debugfs_remove(ls->ls_debug_locks_dentry); debugfs_remove(ls->ls_debug_all_dentry); debugfs_remove(ls->ls_debug_toss_dentry); |
d022509d1 dlm: add new debu... |
726 |
} |
a48f9721e dlm: no need to c... |
727 |
void dlm_create_debug_file(struct dlm_ls *ls) |
e7fd41792 [DLM] The core of... |
728 |
{ |
41922ce83 dlm: Add spaces f... |
729 |
char name[DLM_LOCKSPACE_LEN + 8]; |
5de6319b1 [DLM] more info t... |
730 |
|
d022509d1 dlm: add new debu... |
731 |
/* format 1 */ |
5de6319b1 [DLM] more info t... |
732 733 734 735 |
ls->ls_debug_rsb_dentry = debugfs_create_file(ls->ls_name, S_IFREG | S_IRUGO, dlm_root, ls, |
892c4467e dlm: fix seq_file... |
736 |
&format1_fops); |
5de6319b1 [DLM] more info t... |
737 |
|
d022509d1 dlm: add new debu... |
738 |
/* format 2 */ |
5de6319b1 [DLM] more info t... |
739 |
|
9dd592d70 [DLM] dumping mas... |
740 |
memset(name, 0, sizeof(name)); |
41922ce83 dlm: Add spaces f... |
741 |
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_locks", ls->ls_name); |
ac90a2552 [DLM] dump more l... |
742 743 744 745 746 |
ls->ls_debug_locks_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, dlm_root, ls, |
892c4467e dlm: fix seq_file... |
747 |
&format2_fops); |
d022509d1 dlm: add new debu... |
748 749 750 751 |
/* format 3 */ memset(name, 0, sizeof(name)); |
41922ce83 dlm: Add spaces f... |
752 |
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_all", ls->ls_name); |
d022509d1 dlm: add new debu... |
753 754 755 756 757 |
ls->ls_debug_all_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, dlm_root, ls, |
892c4467e dlm: fix seq_file... |
758 |
&format3_fops); |
d022509d1 dlm: add new debu... |
759 |
|
c04fecb4d dlm: use rsbtbl a... |
760 761 762 |
/* format 4 */ memset(name, 0, sizeof(name)); |
41922ce83 dlm: Add spaces f... |
763 |
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_toss", ls->ls_name); |
c04fecb4d dlm: use rsbtbl a... |
764 765 766 767 768 769 |
ls->ls_debug_toss_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, dlm_root, ls, &format4_fops); |
c04fecb4d dlm: use rsbtbl a... |
770 |
|
d022509d1 dlm: add new debu... |
771 |
memset(name, 0, sizeof(name)); |
41922ce83 dlm: Add spaces f... |
772 |
snprintf(name, DLM_LOCKSPACE_LEN + 8, "%s_waiters", ls->ls_name); |
d022509d1 dlm: add new debu... |
773 774 775 776 777 778 |
ls->ls_debug_waiters_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, dlm_root, ls, &waiters_fops); |
e7fd41792 [DLM] The core of... |
779 |
} |
a48f9721e dlm: no need to c... |
780 |
void __init dlm_register_debugfs(void) |
e7fd41792 [DLM] The core of... |
781 |
{ |
5de6319b1 [DLM] more info t... |
782 |
mutex_init(&debug_buf_lock); |
e7fd41792 [DLM] The core of... |
783 |
dlm_root = debugfs_create_dir("dlm", NULL); |
e7fd41792 [DLM] The core of... |
784 785 786 787 788 789 |
} void dlm_unregister_debugfs(void) { debugfs_remove(dlm_root); } |