Lines Matching refs:failrec

495 			  struct io_failure_record *failrec)  in insert_failrec()  argument
500 exist = rb_simple_insert(&inode->io_failure_tree, failrec->bytenr, in insert_failrec()
501 &failrec->rb_node); in insert_failrec()
510 struct io_failure_record *failrec = ERR_PTR(-ENOENT); in get_failrec() local
515 failrec = rb_entry(node, struct io_failure_record, rb_node); in get_failrec()
517 return failrec; in get_failrec()
653 static int next_mirror(const struct io_failure_record *failrec, int cur_mirror) in next_mirror() argument
655 if (cur_mirror == failrec->num_copies) in next_mirror()
656 return cur_mirror + 1 - failrec->num_copies; in next_mirror()
660 static int prev_mirror(const struct io_failure_record *failrec, int cur_mirror) in prev_mirror() argument
663 return failrec->num_copies; in prev_mirror()
678 struct io_failure_record *failrec; in btrfs_clean_io_failure() local
682 failrec = get_failrec(inode, start); in btrfs_clean_io_failure()
683 if (IS_ERR(failrec)) in btrfs_clean_io_failure()
686 BUG_ON(!failrec->this_mirror); in btrfs_clean_io_failure()
691 ret = find_first_extent_bit(io_tree, failrec->bytenr, &locked_start, in btrfs_clean_io_failure()
693 if (ret || locked_start > failrec->bytenr || in btrfs_clean_io_failure()
694 locked_end < failrec->bytenr + failrec->len - 1) in btrfs_clean_io_failure()
697 mirror = failrec->this_mirror; in btrfs_clean_io_failure()
699 mirror = prev_mirror(failrec, mirror); in btrfs_clean_io_failure()
700 repair_io_failure(fs_info, ino, start, failrec->len, in btrfs_clean_io_failure()
701 failrec->logical, page, pg_offset, mirror); in btrfs_clean_io_failure()
702 } while (mirror != failrec->failed_mirror); in btrfs_clean_io_failure()
705 free_io_failure(inode, failrec); in btrfs_clean_io_failure()
717 struct io_failure_record *failrec; in btrfs_free_io_failure_record() local
726 failrec = rb_entry(node, struct io_failure_record, rb_node); in btrfs_free_io_failure_record()
727 if (failrec->bytenr > end) in btrfs_free_io_failure_record()
731 rb_erase(&failrec->rb_node, &inode->io_failure_tree); in btrfs_free_io_failure_record()
732 kfree(failrec); in btrfs_free_io_failure_record()
745 struct io_failure_record *failrec; in btrfs_get_io_failure_record() local
749 failrec = get_failrec(BTRFS_I(inode), start); in btrfs_get_io_failure_record()
750 if (!IS_ERR(failrec)) { in btrfs_get_io_failure_record()
753 failrec->logical, failrec->bytenr, failrec->len); in btrfs_get_io_failure_record()
759 ASSERT(failrec->this_mirror == bbio->mirror_num); in btrfs_get_io_failure_record()
760 ASSERT(failrec->len == fs_info->sectorsize); in btrfs_get_io_failure_record()
761 return failrec; in btrfs_get_io_failure_record()
764 failrec = kzalloc(sizeof(*failrec), GFP_NOFS); in btrfs_get_io_failure_record()
765 if (!failrec) in btrfs_get_io_failure_record()
768 RB_CLEAR_NODE(&failrec->rb_node); in btrfs_get_io_failure_record()
769 failrec->bytenr = start; in btrfs_get_io_failure_record()
770 failrec->len = sectorsize; in btrfs_get_io_failure_record()
771 failrec->failed_mirror = bbio->mirror_num; in btrfs_get_io_failure_record()
772 failrec->this_mirror = bbio->mirror_num; in btrfs_get_io_failure_record()
773 failrec->logical = (bbio->iter.bi_sector << SECTOR_SHIFT) + bio_offset; in btrfs_get_io_failure_record()
777 failrec->logical, start); in btrfs_get_io_failure_record()
779 failrec->num_copies = btrfs_num_copies(fs_info, failrec->logical, sectorsize); in btrfs_get_io_failure_record()
780 if (failrec->num_copies == 1) { in btrfs_get_io_failure_record()
788 failrec->logical, failrec->num_copies); in btrfs_get_io_failure_record()
789 kfree(failrec); in btrfs_get_io_failure_record()
794 ret = insert_failrec(BTRFS_I(inode), failrec); in btrfs_get_io_failure_record()
796 kfree(failrec); in btrfs_get_io_failure_record()
800 return failrec; in btrfs_get_io_failure_record()
808 struct io_failure_record *failrec; in btrfs_repair_one_sector() local
820 failrec = btrfs_get_io_failure_record(inode, failed_bbio, bio_offset); in btrfs_repair_one_sector()
821 if (IS_ERR(failrec)) in btrfs_repair_one_sector()
822 return PTR_ERR(failrec); in btrfs_repair_one_sector()
833 failrec->this_mirror = next_mirror(failrec, failrec->this_mirror); in btrfs_repair_one_sector()
834 if (failrec->this_mirror == failrec->failed_mirror) { in btrfs_repair_one_sector()
837 failrec->num_copies, failrec->this_mirror, failrec->failed_mirror); in btrfs_repair_one_sector()
838 free_io_failure(BTRFS_I(inode), failrec); in btrfs_repair_one_sector()
846 repair_bio->bi_iter.bi_sector = failrec->logical >> 9; in btrfs_repair_one_sector()
856 bio_add_page(repair_bio, page, failrec->len, pgoff); in btrfs_repair_one_sector()
861 failrec->this_mirror); in btrfs_repair_one_sector()
868 submit_bio_hook(inode, repair_bio, failrec->this_mirror, 0); in btrfs_repair_one_sector()