Lines Matching full:i

73 		struct bset *i;  in bch2_btree_verify_replica()  local
86 i = &n_ondisk->keys; in bch2_btree_verify_replica()
92 i = &bne->keys; in bch2_btree_verify_replica()
99 bch2_dump_bset(c, b, i, offset); in bch2_btree_verify_replica()
223 struct bset *i; in bch2_btree_node_ondisk_to_text() local
230 i = &n_ondisk->keys; in bch2_btree_node_ondisk_to_text()
232 if (!bch2_checksum_type_valid(c, BSET_CSUM_TYPE(i))) { in bch2_btree_node_ondisk_to_text()
234 offset, BSET_CSUM_TYPE(i)); in bch2_btree_node_ondisk_to_text()
238 nonce = btree_nonce(i, offset << 9); in bch2_btree_node_ondisk_to_text()
239 csum = csum_vstruct(c, BSET_CSUM_TYPE(i), nonce, n_ondisk); in bch2_btree_node_ondisk_to_text()
246 bset_encrypt(c, i, offset << 9); 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()
257 if (!bch2_checksum_type_valid(c, BSET_CSUM_TYPE(i))) { in bch2_btree_node_ondisk_to_text()
259 offset, BSET_CSUM_TYPE(i)); in bch2_btree_node_ondisk_to_text()
263 nonce = btree_nonce(i, offset << 9); in bch2_btree_node_ondisk_to_text()
264 csum = csum_vstruct(c, BSET_CSUM_TYPE(i), nonce, bne); in bch2_btree_node_ondisk_to_text()
271 bset_encrypt(c, i, offset << 9); 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()
284 for (k = i->start; k != vstruct_last(i); k = bkey_p_next(k)) { in bch2_btree_node_ondisk_to_text()
318 static ssize_t flush_buf(struct dump_iter *i) in flush_buf() argument
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()
334 return i->size ? 0 : i->ret; in flush_buf()
340 struct dump_iter *i; in bch2_dump_open() local
342 i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL); in bch2_dump_open()
343 if (!i) 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() local
360 printbuf_exit(&i->buf); in bch2_dump_release()
361 kfree(i); in bch2_dump_release()
368 struct dump_iter *i = file->private_data; in bch2_read_btree() local
370 i->ubuf = buf; in bch2_read_btree()
371 i->size = size; in bch2_read_btree()
372 i->ret = 0; in bch2_read_btree()
374 return flush_buf(i) ?: 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()
383 flush_buf(i); in bch2_read_btree()
385 i->ret; in bch2_read_btree()
398 struct dump_iter *i = file->private_data; in bch2_read_btree_formats() local
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()
408 ret = flush_buf(i); 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()
425 ret = drop_locks_do(trans, flush_buf(i)); in bch2_read_btree_formats()
437 ret = flush_buf(i); in bch2_read_btree_formats()
439 return ret ?: i->ret; in bch2_read_btree_formats()
452 struct dump_iter *i = file->private_data; in bch2_read_bfloat_failed() local
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()
458 return flush_buf(i) ?: 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()
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()
476 flush_buf(i); in bch2_read_bfloat_failed()
478 i->ret; in bch2_read_bfloat_failed()
546 struct dump_iter *i = file->private_data; in bch2_cached_btree_nodes_read() local
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()
560 ret = flush_buf(i); in bch2_cached_btree_nodes_read()
565 i->buf.atomic++; 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()
583 ret = flush_buf(i); in bch2_cached_btree_nodes_read()
585 return ret ?: i->ret; in bch2_cached_btree_nodes_read()
598 struct dump_iter *i = file->private_data; in bch2_btree_transactions_read() local
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()
612 if (!task || task->pid <= i->iter) in bch2_btree_transactions_read()
619 ret = flush_buf(i); 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()
643 if (i->buf.allocation_failure) in bch2_btree_transactions_read()
647 ret = flush_buf(i); in bch2_btree_transactions_read()
649 return ret ?: i->ret; in bch2_btree_transactions_read()
662 struct dump_iter *i = file->private_data; in bch2_journal_pins_read() local
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()
672 err = flush_buf(i); 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()
686 return i->ret; in bch2_journal_pins_read()
699 struct dump_iter *i; in btree_transaction_stats_open() local
701 i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL); in btree_transaction_stats_open()
703 if (!i) 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() local
718 printbuf_exit(&i->buf); in btree_transaction_stats_release()
719 kfree(i); in btree_transaction_stats_release()
727 struct dump_iter *i = file->private_data; in btree_transaction_stats_read() local
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()
738 err = flush_buf(i); 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()
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()
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()
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()
793 return i->ret; in btree_transaction_stats_read()
806 struct dump_iter *i = file->private_data; in bch2_btree_deadlock_read() local
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()
823 if (!task || task->pid <= i->iter) in bch2_btree_deadlock_read()
830 ret = flush_buf(i); 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()
847 if (i->buf.allocation_failure) in bch2_btree_deadlock_read()
851 ret = flush_buf(i); in bch2_btree_deadlock_read()
853 return ret ?: i->ret; in bch2_btree_deadlock_read()