Lines Matching full:i

75 		struct bset *i;  in bch2_btree_verify_replica()  local
88 i = &n_ondisk->keys; in bch2_btree_verify_replica()
94 i = &bne->keys; in bch2_btree_verify_replica()
101 bch2_dump_bset(c, b, i, offset); in bch2_btree_verify_replica()
225 struct bset *i; in bch2_btree_node_ondisk_to_text() local
232 i = &n_ondisk->keys; in bch2_btree_node_ondisk_to_text()
234 if (!bch2_checksum_type_valid(c, BSET_CSUM_TYPE(i))) { in bch2_btree_node_ondisk_to_text()
236 offset, BSET_CSUM_TYPE(i)); in bch2_btree_node_ondisk_to_text()
240 nonce = btree_nonce(i, offset << 9); in bch2_btree_node_ondisk_to_text()
241 csum = csum_vstruct(c, BSET_CSUM_TYPE(i), nonce, n_ondisk); in bch2_btree_node_ondisk_to_text()
248 bset_encrypt(c, i, offset << 9); in bch2_btree_node_ondisk_to_text()
254 i = &bne->keys; in bch2_btree_node_ondisk_to_text()
256 if (i->seq != n_ondisk->keys.seq) in bch2_btree_node_ondisk_to_text()
259 if (!bch2_checksum_type_valid(c, BSET_CSUM_TYPE(i))) { in bch2_btree_node_ondisk_to_text()
261 offset, BSET_CSUM_TYPE(i)); in bch2_btree_node_ondisk_to_text()
265 nonce = btree_nonce(i, offset << 9); in bch2_btree_node_ondisk_to_text()
266 csum = csum_vstruct(c, BSET_CSUM_TYPE(i), nonce, bne); in bch2_btree_node_ondisk_to_text()
273 bset_encrypt(c, i, offset << 9); in bch2_btree_node_ondisk_to_text()
280 le16_to_cpu(i->version), in bch2_btree_node_ondisk_to_text()
281 le64_to_cpu(i->journal_seq)); in bch2_btree_node_ondisk_to_text()
286 for (k = i->start; k != vstruct_last(i); k = bkey_p_next(k)) { in bch2_btree_node_ondisk_to_text()
320 static ssize_t flush_buf(struct dump_iter *i) in flush_buf() argument
322 if (i->buf.pos) { in flush_buf()
323 size_t bytes = min_t(size_t, i->buf.pos, i->size); in flush_buf()
324 int copied = bytes - copy_to_user(i->ubuf, i->buf.buf, bytes); in flush_buf()
326 i->ret += copied; in flush_buf()
327 i->ubuf += copied; in flush_buf()
328 i->size -= copied; in flush_buf()
329 i->buf.pos -= copied; in flush_buf()
330 memmove(i->buf.buf, i->buf.buf + copied, i->buf.pos); in flush_buf()
336 return i->size ? 0 : i->ret; in flush_buf()
342 struct dump_iter *i; in bch2_dump_open() local
344 i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL); in bch2_dump_open()
345 if (!i) in bch2_dump_open()
348 file->private_data = i; in bch2_dump_open()
349 i->from = POS_MIN; in bch2_dump_open()
350 i->iter = 0; in bch2_dump_open()
351 i->c = container_of(bd, struct bch_fs, btree_debug[bd->id]); in bch2_dump_open()
352 i->id = bd->id; in bch2_dump_open()
353 i->buf = PRINTBUF; in bch2_dump_open()
360 struct dump_iter *i = file->private_data; in bch2_dump_release() local
362 printbuf_exit(&i->buf); in bch2_dump_release()
363 kfree(i); in bch2_dump_release()
370 struct dump_iter *i = file->private_data; in bch2_read_btree() local
372 i->ubuf = buf; in bch2_read_btree()
373 i->size = size; in bch2_read_btree()
374 i->ret = 0; in bch2_read_btree()
376 return flush_buf(i) ?: in bch2_read_btree()
377 bch2_trans_run(i->c, in bch2_read_btree()
378 for_each_btree_key(trans, iter, i->id, i->from, in bch2_read_btree()
381 bch2_bkey_val_to_text(&i->buf, i->c, k); in bch2_read_btree()
382 prt_newline(&i->buf); in bch2_read_btree()
384 i->from = bpos_successor(iter.pos); in bch2_read_btree()
385 flush_buf(i); in bch2_read_btree()
387 i->ret; in bch2_read_btree()
400 struct dump_iter *i = file->private_data; in bch2_read_btree_formats() local
402 i->ubuf = buf; in bch2_read_btree_formats()
403 i->size = size; in bch2_read_btree_formats()
404 i->ret = 0; in bch2_read_btree_formats()
406 ssize_t ret = flush_buf(i); in bch2_read_btree_formats()
410 if (bpos_eq(SPOS_MAX, i->from)) in bch2_read_btree_formats()
411 return i->ret; in bch2_read_btree_formats()
413 return bch2_trans_run(i->c, in bch2_read_btree_formats()
414 for_each_btree_node(trans, iter, i->id, i->from, 0, b, ({ in bch2_read_btree_formats()
415 bch2_btree_node_to_text(&i->buf, i->c, b); in bch2_read_btree_formats()
416 i->from = !bpos_eq(SPOS_MAX, b->key.k.p) in bch2_read_btree_formats()
420 drop_locks_do(trans, flush_buf(i)); in bch2_read_btree_formats()
421 }))) ?: i->ret; in bch2_read_btree_formats()
434 struct dump_iter *i = file->private_data; in bch2_read_bfloat_failed() local
436 i->ubuf = buf; in bch2_read_bfloat_failed()
437 i->size = size; in bch2_read_bfloat_failed()
438 i->ret = 0; in bch2_read_bfloat_failed()
440 return flush_buf(i) ?: in bch2_read_bfloat_failed()
441 bch2_trans_run(i->c, in bch2_read_bfloat_failed()
442 for_each_btree_key(trans, iter, i->id, i->from, in bch2_read_bfloat_failed()
450 if (bpos_gt(l->b->key.k.p, i->prev_node)) { in bch2_read_bfloat_failed()
451 bch2_btree_node_to_text(&i->buf, i->c, l->b); in bch2_read_bfloat_failed()
452 i->prev_node = l->b->key.k.p; in bch2_read_bfloat_failed()
455 bch2_bfloat_to_text(&i->buf, l->b, _k); in bch2_read_bfloat_failed()
457 i->from = bpos_successor(iter.pos); in bch2_read_bfloat_failed()
458 flush_buf(i); in bch2_read_bfloat_failed()
460 i->ret; in bch2_read_bfloat_failed()
505 struct dump_iter *i = file->private_data; in bch2_cached_btree_nodes_read() local
506 struct bch_fs *c = i->c; in bch2_cached_btree_nodes_read()
510 i->ubuf = buf; in bch2_cached_btree_nodes_read()
511 i->size = size; in bch2_cached_btree_nodes_read()
512 i->ret = 0; in bch2_cached_btree_nodes_read()
519 ret = flush_buf(i); in bch2_cached_btree_nodes_read()
524 i->buf.atomic++; in bch2_cached_btree_nodes_read()
527 if (i->iter < tbl->size) { in bch2_cached_btree_nodes_read()
528 rht_for_each_entry_rcu(b, pos, tbl, i->iter, hash) in bch2_cached_btree_nodes_read()
529 bch2_cached_btree_node_to_text(&i->buf, c, b); in bch2_cached_btree_nodes_read()
530 i->iter++; in bch2_cached_btree_nodes_read()
534 --i->buf.atomic; in bch2_cached_btree_nodes_read()
538 if (i->buf.allocation_failure) in bch2_cached_btree_nodes_read()
542 ret = flush_buf(i); in bch2_cached_btree_nodes_read()
544 return ret ?: i->ret; in bch2_cached_btree_nodes_read()
583 struct dump_iter *i = file->private_data; in bch2_btree_transactions_read() local
584 struct bch_fs *c = i->c; in bch2_btree_transactions_read()
588 i->ubuf = buf; in bch2_btree_transactions_read()
589 i->size = size; in bch2_btree_transactions_read()
590 i->ret = 0; in bch2_btree_transactions_read()
596 if ((ulong) trans <= i->iter) in bch2_btree_transactions_read()
599 i->iter = (ulong) trans; in bch2_btree_transactions_read()
606 bch2_btree_trans_to_text(&i->buf, trans); in bch2_btree_transactions_read()
608 prt_printf(&i->buf, "backtrace:\n"); in bch2_btree_transactions_read()
609 printbuf_indent_add(&i->buf, 2); in bch2_btree_transactions_read()
610 bch2_prt_task_backtrace(&i->buf, trans->locking_wait.task, 0, GFP_KERNEL); in bch2_btree_transactions_read()
611 printbuf_indent_sub(&i->buf, 2); in bch2_btree_transactions_read()
612 prt_newline(&i->buf); in bch2_btree_transactions_read()
616 ret = flush_buf(i); in bch2_btree_transactions_read()
625 if (i->buf.allocation_failure) in bch2_btree_transactions_read()
629 ret = flush_buf(i); in bch2_btree_transactions_read()
631 return ret ?: i->ret; in bch2_btree_transactions_read()
644 struct dump_iter *i = file->private_data; in bch2_journal_pins_read() local
645 struct bch_fs *c = i->c; in bch2_journal_pins_read()
649 i->ubuf = buf; in bch2_journal_pins_read()
650 i->size = size; in bch2_journal_pins_read()
651 i->ret = 0; in bch2_journal_pins_read()
654 err = flush_buf(i); in bch2_journal_pins_read()
658 if (!i->size) in bch2_journal_pins_read()
664 done = bch2_journal_seq_pins_to_text(&i->buf, &c->journal, &i->iter); in bch2_journal_pins_read()
665 i->iter++; in bch2_journal_pins_read()
668 if (i->buf.allocation_failure) in bch2_journal_pins_read()
671 return i->ret; in bch2_journal_pins_read()
684 struct dump_iter *i = file->private_data; in bch2_btree_updates_read() local
685 struct bch_fs *c = i->c; in bch2_btree_updates_read()
688 i->ubuf = buf; in bch2_btree_updates_read()
689 i->size = size; in bch2_btree_updates_read()
690 i->ret = 0; in bch2_btree_updates_read()
692 if (!i->iter) { in bch2_btree_updates_read()
693 bch2_btree_updates_to_text(&i->buf, c); in bch2_btree_updates_read()
694 i->iter++; in bch2_btree_updates_read()
697 err = flush_buf(i); in bch2_btree_updates_read()
701 if (i->buf.allocation_failure) in bch2_btree_updates_read()
704 return i->ret; in bch2_btree_updates_read()
717 struct dump_iter *i; in btree_transaction_stats_open() local
719 i = kzalloc(sizeof(struct dump_iter), GFP_KERNEL); in btree_transaction_stats_open()
720 if (!i) in btree_transaction_stats_open()
723 i->iter = 1; in btree_transaction_stats_open()
724 i->c = c; in btree_transaction_stats_open()
725 i->buf = PRINTBUF; in btree_transaction_stats_open()
726 file->private_data = i; in btree_transaction_stats_open()
733 struct dump_iter *i = file->private_data; in btree_transaction_stats_release() local
735 printbuf_exit(&i->buf); in btree_transaction_stats_release()
736 kfree(i); in btree_transaction_stats_release()
744 struct dump_iter *i = file->private_data; in btree_transaction_stats_read() local
745 struct bch_fs *c = i->c; in btree_transaction_stats_read()
748 i->ubuf = buf; in btree_transaction_stats_read()
749 i->size = size; in btree_transaction_stats_read()
750 i->ret = 0; in btree_transaction_stats_read()
753 struct btree_transaction_stats *s = &c->btree_transaction_stats[i->iter]; in btree_transaction_stats_read()
755 err = flush_buf(i); in btree_transaction_stats_read()
759 if (!i->size) in btree_transaction_stats_read()
762 if (i->iter == ARRAY_SIZE(bch2_btree_transaction_fns) || in btree_transaction_stats_read()
763 !bch2_btree_transaction_fns[i->iter]) in btree_transaction_stats_read()
766 prt_printf(&i->buf, "%s:\n", bch2_btree_transaction_fns[i->iter]); in btree_transaction_stats_read()
767 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
771 prt_printf(&i->buf, "Max mem used: %u\n", s->max_mem); in btree_transaction_stats_read()
772 prt_printf(&i->buf, "Transaction duration:\n"); in btree_transaction_stats_read()
774 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
775 bch2_time_stats_to_text(&i->buf, &s->duration); in btree_transaction_stats_read()
776 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
779 prt_printf(&i->buf, "Lock hold times:\n"); in btree_transaction_stats_read()
781 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
782 bch2_time_stats_to_text(&i->buf, &s->lock_hold_times); in btree_transaction_stats_read()
783 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
787 prt_printf(&i->buf, "Maximum allocated btree paths (%u):\n", s->nr_max_paths); in btree_transaction_stats_read()
789 printbuf_indent_add(&i->buf, 2); in btree_transaction_stats_read()
790 prt_str_indented(&i->buf, s->max_paths_text); in btree_transaction_stats_read()
791 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
796 printbuf_indent_sub(&i->buf, 2); in btree_transaction_stats_read()
797 prt_newline(&i->buf); in btree_transaction_stats_read()
798 i->iter++; in btree_transaction_stats_read()
801 if (i->buf.allocation_failure) in btree_transaction_stats_read()
804 return i->ret; in btree_transaction_stats_read()
850 struct dump_iter *i = file->private_data; in bch2_btree_deadlock_read() local
851 struct bch_fs *c = i->c; in bch2_btree_deadlock_read()
854 i->ubuf = buf; in bch2_btree_deadlock_read()
855 i->size = size; in bch2_btree_deadlock_read()
856 i->ret = 0; in bch2_btree_deadlock_read()
858 if (!i->iter) { in bch2_btree_deadlock_read()
859 btree_deadlock_to_text(&i->buf, c); in bch2_btree_deadlock_read()
860 i->iter++; in bch2_btree_deadlock_read()
863 if (i->buf.allocation_failure) in bch2_btree_deadlock_read()
867 ret = flush_buf(i); in bch2_btree_deadlock_read()
869 return ret ?: i->ret; in bch2_btree_deadlock_read()