Lines Matching +full:read +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0
35 struct btree *v = c->verify_data; in bch2_btree_verify_replica()
36 struct btree_node *n_ondisk = c->verify_ondisk; in bch2_btree_verify_replica()
37 struct btree_node *n_sorted = c->verify_data->data; in bch2_btree_verify_replica()
38 struct bset *sorted, *inmemory = &b->data->keys; in bch2_btree_verify_replica()
43 if (!bch2_dev_get_ioref(ca, READ)) in bch2_btree_verify_replica()
46 bio = bio_alloc_bioset(ca->disk_sb.bdev, in bch2_btree_verify_replica()
50 &c->btree_bio); in bch2_btree_verify_replica()
51 bio->bi_iter.bi_sector = pick.ptr.offset; in bch2_btree_verify_replica()
57 percpu_ref_put(&ca->io_ref); in bch2_btree_verify_replica()
61 v->written = 0; in bch2_btree_verify_replica()
65 n_sorted = c->verify_data->data; in bch2_btree_verify_replica()
66 sorted = &n_sorted->keys; in bch2_btree_verify_replica()
68 if (inmemory->u64s != sorted->u64s || in bch2_btree_verify_replica()
69 memcmp(inmemory->start, in bch2_btree_verify_replica()
70 sorted->start, in bch2_btree_verify_replica()
71 vstruct_end(inmemory) - (void *) inmemory->start)) { in bch2_btree_verify_replica()
81 printk(KERN_ERR "*** read back in:\n"); in bch2_btree_verify_replica()
84 while (offset < v->written) { in bch2_btree_verify_replica()
86 i = &n_ondisk->keys; in bch2_btree_verify_replica()
87 sectors = vstruct_blocks(n_ondisk, c->block_bits) << in bch2_btree_verify_replica()
88 c->block_bits; in bch2_btree_verify_replica()
92 i = &bne->keys; in bch2_btree_verify_replica()
94 sectors = vstruct_blocks(bne, c->block_bits) << in bch2_btree_verify_replica()
95 c->block_bits; in bch2_btree_verify_replica()
104 for (j = 0; j < le16_to_cpu(inmemory->u64s); j++) in bch2_btree_verify_replica()
105 if (inmemory->_data[j] != sorted->_data[j]) in bch2_btree_verify_replica()
114 if (v->written != b->written) { in bch2_btree_verify_replica()
116 b->written, v->written); in bch2_btree_verify_replica()
129 struct bset *inmemory = &b->data->keys; in __bch2_btree_verify()
133 if (c->opts.nochanges) in __bch2_btree_verify()
137 mutex_lock(&c->verify_lock); in __bch2_btree_verify()
139 if (!c->verify_ondisk) { in __bch2_btree_verify()
140 c->verify_ondisk = kvpmalloc(btree_buf_bytes(b), GFP_KERNEL); in __bch2_btree_verify()
141 if (!c->verify_ondisk) in __bch2_btree_verify()
142 goto out; in __bch2_btree_verify()
145 if (!c->verify_data) { in __bch2_btree_verify()
146 c->verify_data = __bch2_btree_node_mem_alloc(c); in __bch2_btree_verify()
147 if (!c->verify_data) in __bch2_btree_verify()
148 goto out; in __bch2_btree_verify()
150 list_del_init(&c->verify_data->list); in __bch2_btree_verify()
153 BUG_ON(b->nsets != 1); in __bch2_btree_verify()
155 for (k = inmemory->start; k != vstruct_last(inmemory); k = bkey_p_next(k)) in __bch2_btree_verify()
156 if (k->type == KEY_TYPE_btree_ptr_v2) in __bch2_btree_verify()
157 ((struct bch_btree_ptr_v2 *) bkeyp_val(&b->format, k))->mem_ptr = 0; in __bch2_btree_verify()
159 v = c->verify_data; in __bch2_btree_verify()
160 bkey_copy(&v->key, &b->key); in __bch2_btree_verify()
161 v->c.level = b->c.level; in __bch2_btree_verify()
162 v->c.btree_id = b->c.btree_id; in __bch2_btree_verify()
165 ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(&b->key)); in __bch2_btree_verify()
166 bkey_for_each_ptr_decode(&b->key.k, ptrs, p, entry) in __bch2_btree_verify()
172 bch2_bkey_val_to_text(&buf, c, bkey_i_to_s_c(&b->key)); in __bch2_btree_verify()
176 out: in __bch2_btree_verify()
177 mutex_unlock(&c->verify_lock); in __bch2_btree_verify()
181 void bch2_btree_node_ondisk_to_text(struct printbuf *out, struct bch_fs *c, in bch2_btree_node_ondisk_to_text() argument
191 if (bch2_bkey_pick_read_device(c, bkey_i_to_s_c(&b->key), NULL, &pick) <= 0) { in bch2_btree_node_ondisk_to_text()
192 prt_printf(out, "error getting device to read from: invalid device\n"); in bch2_btree_node_ondisk_to_text()
197 if (!bch2_dev_get_ioref(ca, READ)) { in bch2_btree_node_ondisk_to_text()
198 prt_printf(out, "error getting device to read from: not online\n"); in bch2_btree_node_ondisk_to_text()
204 prt_printf(out, "memory allocation failure\n"); in bch2_btree_node_ondisk_to_text()
205 goto out; in bch2_btree_node_ondisk_to_text()
208 bio = bio_alloc_bioset(ca->disk_sb.bdev, in bch2_btree_node_ondisk_to_text()
212 &c->btree_bio); in bch2_btree_node_ondisk_to_text()
213 bio->bi_iter.bi_sector = pick.ptr.offset; in bch2_btree_node_ondisk_to_text()
218 prt_printf(out, "IO error reading btree node: %s\n", bch2_err_str(ret)); in bch2_btree_node_ondisk_to_text()
219 goto out; in bch2_btree_node_ondisk_to_text()
230 i = &n_ondisk->keys; in bch2_btree_node_ondisk_to_text()
233 prt_printf(out, "unknown checksum type at offset %u: %llu\n", in bch2_btree_node_ondisk_to_text()
235 goto out; in bch2_btree_node_ondisk_to_text()
241 if (bch2_crc_cmp(csum, n_ondisk->csum)) { in bch2_btree_node_ondisk_to_text()
242 prt_printf(out, "invalid checksum\n"); in bch2_btree_node_ondisk_to_text()
243 goto out; in bch2_btree_node_ondisk_to_text()
248 sectors = vstruct_sectors(n_ondisk, c->block_bits); in bch2_btree_node_ondisk_to_text()
252 i = &bne->keys; in bch2_btree_node_ondisk_to_text()
254 if (i->seq != n_ondisk->keys.seq) in bch2_btree_node_ondisk_to_text()
258 prt_printf(out, "unknown checksum type at offset %u: %llu\n", in bch2_btree_node_ondisk_to_text()
260 goto out; in bch2_btree_node_ondisk_to_text()
266 if (bch2_crc_cmp(csum, bne->csum)) { in bch2_btree_node_ondisk_to_text()
267 prt_printf(out, "invalid checksum"); in bch2_btree_node_ondisk_to_text()
268 goto out; in bch2_btree_node_ondisk_to_text()
273 sectors = vstruct_sectors(bne, c->block_bits); in bch2_btree_node_ondisk_to_text()
276 prt_printf(out, " offset %u version %u, journal seq %llu\n", in bch2_btree_node_ondisk_to_text()
278 le16_to_cpu(i->version), in bch2_btree_node_ondisk_to_text()
279 le64_to_cpu(i->journal_seq)); in bch2_btree_node_ondisk_to_text()
282 printbuf_indent_add(out, 4); in bch2_btree_node_ondisk_to_text()
284 for (k = i->start; k != vstruct_last(i); k = bkey_p_next(k)) { in bch2_btree_node_ondisk_to_text()
287 bch2_bkey_val_to_text(out, c, bkey_disassemble(b, k, &u)); in bch2_btree_node_ondisk_to_text()
288 prt_newline(out); in bch2_btree_node_ondisk_to_text()
291 printbuf_indent_sub(out, 4); in bch2_btree_node_ondisk_to_text()
293 out: in bch2_btree_node_ondisk_to_text()
297 percpu_ref_put(&ca->io_ref); in bch2_btree_node_ondisk_to_text()
314 size_t size; /* size of requested read */
315 ssize_t ret; /* bytes read so far */
320 if (i->buf.pos) { in flush_buf()
321 size_t bytes = min_t(size_t, i->buf.pos, i->size); in flush_buf()
322 int copied = bytes - copy_to_user(i->ubuf, i->buf.buf, bytes); in flush_buf()
324 i->ret += copied; in flush_buf()
325 i->ubuf += copied; in flush_buf()
326 i->size -= copied; in flush_buf()
327 i->buf.pos -= copied; in flush_buf()
328 memmove(i->buf.buf, i->buf.buf + copied, i->buf.pos); in flush_buf()
331 return -EFAULT; in flush_buf()
334 return i->size ? 0 : i->ret; in flush_buf()
339 struct btree_debug *bd = inode->i_private; in bch2_dump_open()
344 return -ENOMEM; in bch2_dump_open()
346 file->private_data = i; in bch2_dump_open()
347 i->from = POS_MIN; in bch2_dump_open()
348 i->iter = 0; in bch2_dump_open()
349 i->c = container_of(bd, struct bch_fs, btree_debug[bd->id]); in bch2_dump_open()
350 i->id = bd->id; in bch2_dump_open()
351 i->buf = PRINTBUF; in bch2_dump_open()
358 struct dump_iter *i = file->private_data; in bch2_dump_release()
360 printbuf_exit(&i->buf); in bch2_dump_release()
368 struct dump_iter *i = file->private_data; in bch2_read_btree()
370 i->ubuf = buf; in bch2_read_btree()
371 i->size = size; in bch2_read_btree()
372 i->ret = 0; in bch2_read_btree()
375 bch2_trans_run(i->c, in bch2_read_btree()
376 for_each_btree_key(trans, iter, i->id, i->from, in bch2_read_btree()
379 bch2_bkey_val_to_text(&i->buf, i->c, k); in bch2_read_btree()
380 prt_newline(&i->buf); in bch2_read_btree()
382 i->from = bpos_successor(iter.pos); in bch2_read_btree()
385 i->ret; in bch2_read_btree()
392 .read = bch2_read_btree,
398 struct dump_iter *i = file->private_data; in bch2_read_btree_formats()
404 i->ubuf = buf; in bch2_read_btree_formats()
405 i->size = size; in bch2_read_btree_formats()
406 i->ret = 0; in bch2_read_btree_formats()
412 if (bpos_eq(SPOS_MAX, i->from)) in bch2_read_btree_formats()
413 return i->ret; in bch2_read_btree_formats()
415 trans = bch2_trans_get(i->c); in bch2_read_btree_formats()
419 for_each_btree_node(trans, iter, i->id, i->from, 0, b, ret) { in bch2_read_btree_formats()
420 bch2_btree_node_to_text(&i->buf, i->c, b); in bch2_read_btree_formats()
421 i->from = !bpos_eq(SPOS_MAX, b->key.k.p) in bch2_read_btree_formats()
422 ? bpos_successor(b->key.k.p) in bch2_read_btree_formats()
423 : b->key.k.p; in bch2_read_btree_formats()
439 return ret ?: i->ret; in bch2_read_btree_formats()
446 .read = bch2_read_btree_formats,
452 struct dump_iter *i = file->private_data; in bch2_read_bfloat_failed()
454 i->ubuf = buf; in bch2_read_bfloat_failed()
455 i->size = size; in bch2_read_bfloat_failed()
456 i->ret = 0; in bch2_read_bfloat_failed()
459 bch2_trans_run(i->c, in bch2_read_bfloat_failed()
460 for_each_btree_key(trans, iter, i->id, i->from, in bch2_read_bfloat_failed()
464 &btree_iter_path(trans, &iter)->l[0]; in bch2_read_bfloat_failed()
466 bch2_btree_node_iter_peek(&l->iter, l->b); in bch2_read_bfloat_failed()
468 if (bpos_gt(l->b->key.k.p, i->prev_node)) { in bch2_read_bfloat_failed()
469 bch2_btree_node_to_text(&i->buf, i->c, l->b); in bch2_read_bfloat_failed()
470 i->prev_node = l->b->key.k.p; in bch2_read_bfloat_failed()
473 bch2_bfloat_to_text(&i->buf, l->b, _k); in bch2_read_bfloat_failed()
475 i->from = bpos_successor(iter.pos); in bch2_read_bfloat_failed()
478 i->ret; in bch2_read_bfloat_failed()
485 .read = bch2_read_bfloat_failed,
488 static void bch2_cached_btree_node_to_text(struct printbuf *out, struct bch_fs *c, in bch2_cached_btree_node_to_text() argument
491 if (!out->nr_tabstops) in bch2_cached_btree_node_to_text()
492 printbuf_tabstop_push(out, 32); in bch2_cached_btree_node_to_text()
494 prt_printf(out, "%px btree=%s l=%u ", in bch2_cached_btree_node_to_text()
496 bch2_btree_id_str(b->c.btree_id), in bch2_cached_btree_node_to_text()
497 b->c.level); in bch2_cached_btree_node_to_text()
498 prt_newline(out); in bch2_cached_btree_node_to_text()
500 printbuf_indent_add(out, 2); in bch2_cached_btree_node_to_text()
502 bch2_bkey_val_to_text(out, c, bkey_i_to_s_c(&b->key)); in bch2_cached_btree_node_to_text()
503 prt_newline(out); in bch2_cached_btree_node_to_text()
505 prt_printf(out, "flags: "); in bch2_cached_btree_node_to_text()
506 prt_tab(out); in bch2_cached_btree_node_to_text()
507 prt_bitflags(out, bch2_btree_node_flags, b->flags); in bch2_cached_btree_node_to_text()
508 prt_newline(out); in bch2_cached_btree_node_to_text()
510 prt_printf(out, "pcpu read locks: "); in bch2_cached_btree_node_to_text()
511 prt_tab(out); in bch2_cached_btree_node_to_text()
512 prt_printf(out, "%u", b->c.lock.readers != NULL); in bch2_cached_btree_node_to_text()
513 prt_newline(out); in bch2_cached_btree_node_to_text()
515 prt_printf(out, "written:"); in bch2_cached_btree_node_to_text()
516 prt_tab(out); in bch2_cached_btree_node_to_text()
517 prt_printf(out, "%u", b->written); in bch2_cached_btree_node_to_text()
518 prt_newline(out); in bch2_cached_btree_node_to_text()
520 prt_printf(out, "writes blocked:"); in bch2_cached_btree_node_to_text()
521 prt_tab(out); in bch2_cached_btree_node_to_text()
522 prt_printf(out, "%u", !list_empty_careful(&b->write_blocked)); in bch2_cached_btree_node_to_text()
523 prt_newline(out); in bch2_cached_btree_node_to_text()
525 prt_printf(out, "will make reachable:"); in bch2_cached_btree_node_to_text()
526 prt_tab(out); in bch2_cached_btree_node_to_text()
527 prt_printf(out, "%lx", b->will_make_reachable); in bch2_cached_btree_node_to_text()
528 prt_newline(out); in bch2_cached_btree_node_to_text()
530 prt_printf(out, "journal pin %px:", &b->writes[0].journal); in bch2_cached_btree_node_to_text()
531 prt_tab(out); in bch2_cached_btree_node_to_text()
532 prt_printf(out, "%llu", b->writes[0].journal.seq); in bch2_cached_btree_node_to_text()
533 prt_newline(out); in bch2_cached_btree_node_to_text()
535 prt_printf(out, "journal pin %px:", &b->writes[1].journal); in bch2_cached_btree_node_to_text()
536 prt_tab(out); in bch2_cached_btree_node_to_text()
537 prt_printf(out, "%llu", b->writes[1].journal.seq); in bch2_cached_btree_node_to_text()
538 prt_newline(out); in bch2_cached_btree_node_to_text()
540 printbuf_indent_sub(out, 2); in bch2_cached_btree_node_to_text()
546 struct dump_iter *i = file->private_data; in bch2_cached_btree_nodes_read()
547 struct bch_fs *c = i->c; in bch2_cached_btree_nodes_read()
551 i->ubuf = buf; in bch2_cached_btree_nodes_read()
552 i->size = size; in bch2_cached_btree_nodes_read()
553 i->ret = 0; in bch2_cached_btree_nodes_read()
565 i->buf.atomic++; in bch2_cached_btree_nodes_read()
566 tbl = rht_dereference_rcu(c->btree_cache.table.tbl, in bch2_cached_btree_nodes_read()
567 &c->btree_cache.table); in bch2_cached_btree_nodes_read()
568 if (i->iter < tbl->size) { in bch2_cached_btree_nodes_read()
569 rht_for_each_entry_rcu(b, pos, tbl, i->iter, hash) in bch2_cached_btree_nodes_read()
570 bch2_cached_btree_node_to_text(&i->buf, c, b); in bch2_cached_btree_nodes_read()
571 i->iter++; in bch2_cached_btree_nodes_read()
575 --i->buf.atomic; in bch2_cached_btree_nodes_read()
579 if (i->buf.allocation_failure) in bch2_cached_btree_nodes_read()
580 ret = -ENOMEM; in bch2_cached_btree_nodes_read()
585 return ret ?: i->ret; in bch2_cached_btree_nodes_read()
592 .read = bch2_cached_btree_nodes_read,
598 struct dump_iter *i = file->private_data; in bch2_btree_transactions_read()
599 struct bch_fs *c = i->c; in bch2_btree_transactions_read()
604 i->ubuf = buf; in bch2_btree_transactions_read()
605 i->size = size; in bch2_btree_transactions_read()
606 i->ret = 0; in bch2_btree_transactions_read()
608 seqmutex_lock(&c->btree_trans_lock); in bch2_btree_transactions_read()
609 list_for_each_entry(trans, &c->btree_trans_list, list) { in bch2_btree_transactions_read()
610 struct task_struct *task = READ_ONCE(trans->locking_wait.task); in bch2_btree_transactions_read()
612 if (!task || task->pid <= i->iter) in bch2_btree_transactions_read()
615 closure_get(&trans->ref); in bch2_btree_transactions_read()
616 seq = seqmutex_seq(&c->btree_trans_lock); in bch2_btree_transactions_read()
617 seqmutex_unlock(&c->btree_trans_lock); in bch2_btree_transactions_read()
621 closure_put(&trans->ref); in bch2_btree_transactions_read()
625 bch2_btree_trans_to_text(&i->buf, trans); in bch2_btree_transactions_read()
627 prt_printf(&i->buf, "backtrace:"); in bch2_btree_transactions_read()
628 prt_newline(&i->buf); in bch2_btree_transactions_read()
629 printbuf_indent_add(&i->buf, 2); in bch2_btree_transactions_read()
630 bch2_prt_task_backtrace(&i->buf, task, 0, GFP_KERNEL); in bch2_btree_transactions_read()
631 printbuf_indent_sub(&i->buf, 2); in bch2_btree_transactions_read()
632 prt_newline(&i->buf); in bch2_btree_transactions_read()
634 i->iter = task->pid; in bch2_btree_transactions_read()
636 closure_put(&trans->ref); in bch2_btree_transactions_read()
638 if (!seqmutex_relock(&c->btree_trans_lock, seq)) in bch2_btree_transactions_read()
641 seqmutex_unlock(&c->btree_trans_lock); in bch2_btree_transactions_read()
643 if (i->buf.allocation_failure) in bch2_btree_transactions_read()
644 ret = -ENOMEM; in bch2_btree_transactions_read()
649 return ret ?: i->ret; in bch2_btree_transactions_read()
656 .read = bch2_btree_transactions_read,
662 struct dump_iter *i = file->private_data; in bch2_journal_pins_read()
663 struct bch_fs *c = i->c; in bch2_journal_pins_read()
667 i->ubuf = buf; in bch2_journal_pins_read()
668 i->size = size; in bch2_journal_pins_read()
669 i->ret = 0; in bch2_journal_pins_read()
676 if (!i->size) in bch2_journal_pins_read()
679 done = bch2_journal_seq_pins_to_text(&i->buf, &c->journal, &i->iter); in bch2_journal_pins_read()
680 i->iter++; in bch2_journal_pins_read()
683 if (i->buf.allocation_failure) in bch2_journal_pins_read()
684 return -ENOMEM; in bch2_journal_pins_read()
686 return i->ret; in bch2_journal_pins_read()
693 .read = bch2_journal_pins_read,
698 struct bch_fs *c = inode->i_private; in btree_transaction_stats_open()
704 return -ENOMEM; in btree_transaction_stats_open()
706 i->iter = 1; in btree_transaction_stats_open()
707 i->c = c; in btree_transaction_stats_open()
708 i->buf = PRINTBUF; in btree_transaction_stats_open()
709 file->private_data = i; in btree_transaction_stats_open()
716 struct dump_iter *i = file->private_data; in btree_transaction_stats_release()
718 printbuf_exit(&i->buf); in btree_transaction_stats_release()
727 struct dump_iter *i = file->private_data; in btree_transaction_stats_read()
728 struct bch_fs *c = i->c; in btree_transaction_stats_read()
731 i->ubuf = buf; in btree_transaction_stats_read()
732 i->size = size; in btree_transaction_stats_read()
733 i->ret = 0; in btree_transaction_stats_read()
736 struct btree_transaction_stats *s = &c->btree_transaction_stats[i->iter]; in btree_transaction_stats_read()
742 if (!i->size) in btree_transaction_stats_read()
745 if (i->iter == ARRAY_SIZE(bch2_btree_transaction_fns) || in btree_transaction_stats_read()
746 !bch2_btree_transaction_fns[i->iter]) in btree_transaction_stats_read()
749 prt_printf(&i->buf, "%s: ", bch2_btree_transaction_fns[i->iter]); in btree_transaction_stats_read()
750 prt_newline(&i->buf); in btree_transaction_stats_read()
751 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
753 mutex_lock(&s->lock); in btree_transaction_stats_read()
755 prt_printf(&i->buf, "Max mem used: %u", s->max_mem); in btree_transaction_stats_read()
756 prt_newline(&i->buf); in btree_transaction_stats_read()
758 prt_printf(&i->buf, "Transaction duration:"); in btree_transaction_stats_read()
759 prt_newline(&i->buf); in btree_transaction_stats_read()
761 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
762 bch2_time_stats_to_text(&i->buf, &s->duration); in btree_transaction_stats_read()
763 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
766 prt_printf(&i->buf, "Lock hold times:"); in btree_transaction_stats_read()
767 prt_newline(&i->buf); in btree_transaction_stats_read()
769 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
770 bch2_time_stats_to_text(&i->buf, &s->lock_hold_times); in btree_transaction_stats_read()
771 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
774 if (s->max_paths_text) { in btree_transaction_stats_read()
775 prt_printf(&i->buf, "Maximum allocated btree paths (%u):", s->nr_max_paths); in btree_transaction_stats_read()
776 prt_newline(&i->buf); in btree_transaction_stats_read()
778 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
779 prt_str_indented(&i->buf, s->max_paths_text); in btree_transaction_stats_read()
780 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
783 mutex_unlock(&s->lock); in btree_transaction_stats_read()
785 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
786 prt_newline(&i->buf); in btree_transaction_stats_read()
787 i->iter++; in btree_transaction_stats_read()
790 if (i->buf.allocation_failure) in btree_transaction_stats_read()
791 return -ENOMEM; in btree_transaction_stats_read()
793 return i->ret; in btree_transaction_stats_read()
800 .read = btree_transaction_stats_read,
806 struct dump_iter *i = file->private_data; in bch2_btree_deadlock_read()
807 struct bch_fs *c = i->c; in bch2_btree_deadlock_read()
812 i->ubuf = buf; in bch2_btree_deadlock_read()
813 i->size = size; in bch2_btree_deadlock_read()
814 i->ret = 0; in bch2_btree_deadlock_read()
816 if (i->iter) in bch2_btree_deadlock_read()
817 goto out; in bch2_btree_deadlock_read()
819 seqmutex_lock(&c->btree_trans_lock); in bch2_btree_deadlock_read()
820 list_for_each_entry(trans, &c->btree_trans_list, list) { in bch2_btree_deadlock_read()
821 struct task_struct *task = READ_ONCE(trans->locking_wait.task); in bch2_btree_deadlock_read()
823 if (!task || task->pid <= i->iter) in bch2_btree_deadlock_read()
826 closure_get(&trans->ref); in bch2_btree_deadlock_read()
827 seq = seqmutex_seq(&c->btree_trans_lock); in bch2_btree_deadlock_read()
828 seqmutex_unlock(&c->btree_trans_lock); in bch2_btree_deadlock_read()
832 closure_put(&trans->ref); in bch2_btree_deadlock_read()
833 goto out; in bch2_btree_deadlock_read()
836 bch2_check_for_deadlock(trans, &i->buf); in bch2_btree_deadlock_read()
838 i->iter = task->pid; in bch2_btree_deadlock_read()
840 closure_put(&trans->ref); in bch2_btree_deadlock_read()
842 if (!seqmutex_relock(&c->btree_trans_lock, seq)) in bch2_btree_deadlock_read()
845 seqmutex_unlock(&c->btree_trans_lock); in bch2_btree_deadlock_read()
846 out: in bch2_btree_deadlock_read()
847 if (i->buf.allocation_failure) in bch2_btree_deadlock_read()
848 ret = -ENOMEM; in bch2_btree_deadlock_read()
853 return ret ?: i->ret; in bch2_btree_deadlock_read()
860 .read = bch2_btree_deadlock_read,
865 if (!IS_ERR_OR_NULL(c->fs_debug_dir)) in bch2_fs_debug_exit()
866 debugfs_remove_recursive(c->fs_debug_dir); in bch2_fs_debug_exit()
877 snprintf(name, sizeof(name), "%pU", c->sb.user_uuid.b); in bch2_fs_debug_init()
878 c->fs_debug_dir = debugfs_create_dir(name, bch_debug); in bch2_fs_debug_init()
879 if (IS_ERR_OR_NULL(c->fs_debug_dir)) in bch2_fs_debug_init()
882 debugfs_create_file("cached_btree_nodes", 0400, c->fs_debug_dir, in bch2_fs_debug_init()
883 c->btree_debug, &cached_btree_nodes_ops); in bch2_fs_debug_init()
885 debugfs_create_file("btree_transactions", 0400, c->fs_debug_dir, in bch2_fs_debug_init()
886 c->btree_debug, &btree_transactions_ops); in bch2_fs_debug_init()
888 debugfs_create_file("journal_pins", 0400, c->fs_debug_dir, in bch2_fs_debug_init()
889 c->btree_debug, &journal_pins_ops); in bch2_fs_debug_init()
891 debugfs_create_file("btree_transaction_stats", 0400, c->fs_debug_dir, in bch2_fs_debug_init()
894 debugfs_create_file("btree_deadlock", 0400, c->fs_debug_dir, in bch2_fs_debug_init()
895 c->btree_debug, &btree_deadlock_ops); in bch2_fs_debug_init()
897 c->btree_debug_dir = debugfs_create_dir("btrees", c->fs_debug_dir); in bch2_fs_debug_init()
898 if (IS_ERR_OR_NULL(c->btree_debug_dir)) in bch2_fs_debug_init()
901 for (bd = c->btree_debug; in bch2_fs_debug_init()
902 bd < c->btree_debug + ARRAY_SIZE(c->btree_debug); in bch2_fs_debug_init()
904 bd->id = bd - c->btree_debug; in bch2_fs_debug_init()
905 debugfs_create_file(bch2_btree_id_str(bd->id), in bch2_fs_debug_init()
906 0400, c->btree_debug_dir, bd, in bch2_fs_debug_init()
909 snprintf(name, sizeof(name), "%s-formats", in bch2_fs_debug_init()
910 bch2_btree_id_str(bd->id)); in bch2_fs_debug_init()
912 debugfs_create_file(name, 0400, c->btree_debug_dir, bd, in bch2_fs_debug_init()
915 snprintf(name, sizeof(name), "%s-bfloat-failed", in bch2_fs_debug_init()
916 bch2_btree_id_str(bd->id)); in bch2_fs_debug_init()
918 debugfs_create_file(name, 0400, c->btree_debug_dir, bd, in bch2_fs_debug_init()