Lines Matching refs:fs_info
250 static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
280 static void scrub_remap_extent(struct btrfs_fs_info *fs_info,
287 struct btrfs_fs_info *fs_info,
303 static void __scrub_blocked_if_needed(struct btrfs_fs_info *fs_info);
304 static void scrub_blocked_if_needed(struct btrfs_fs_info *fs_info);
321 static void __scrub_blocked_if_needed(struct btrfs_fs_info *fs_info) in __scrub_blocked_if_needed() argument
323 while (atomic_read(&fs_info->scrub_pause_req)) { in __scrub_blocked_if_needed()
324 mutex_unlock(&fs_info->scrub_lock); in __scrub_blocked_if_needed()
325 wait_event(fs_info->scrub_pause_wait, in __scrub_blocked_if_needed()
326 atomic_read(&fs_info->scrub_pause_req) == 0); in __scrub_blocked_if_needed()
327 mutex_lock(&fs_info->scrub_lock); in __scrub_blocked_if_needed()
331 static void scrub_pause_on(struct btrfs_fs_info *fs_info) in scrub_pause_on() argument
333 atomic_inc(&fs_info->scrubs_paused); in scrub_pause_on()
334 wake_up(&fs_info->scrub_pause_wait); in scrub_pause_on()
337 static void scrub_pause_off(struct btrfs_fs_info *fs_info) in scrub_pause_off() argument
339 mutex_lock(&fs_info->scrub_lock); in scrub_pause_off()
340 __scrub_blocked_if_needed(fs_info); in scrub_pause_off()
341 atomic_dec(&fs_info->scrubs_paused); in scrub_pause_off()
342 mutex_unlock(&fs_info->scrub_lock); in scrub_pause_off()
344 wake_up(&fs_info->scrub_pause_wait); in scrub_pause_off()
347 static void scrub_blocked_if_needed(struct btrfs_fs_info *fs_info) in scrub_blocked_if_needed() argument
349 scrub_pause_on(fs_info); in scrub_blocked_if_needed()
350 scrub_pause_off(fs_info); in scrub_blocked_if_needed()
359 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_pending_trans_workers_inc() local
371 mutex_lock(&fs_info->scrub_lock); in scrub_pending_trans_workers_inc()
372 atomic_inc(&fs_info->scrubs_running); in scrub_pending_trans_workers_inc()
373 atomic_inc(&fs_info->scrubs_paused); in scrub_pending_trans_workers_inc()
374 mutex_unlock(&fs_info->scrub_lock); in scrub_pending_trans_workers_inc()
383 wake_up(&fs_info->scrub_pause_wait); in scrub_pending_trans_workers_inc()
391 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_pending_trans_workers_dec() local
397 mutex_lock(&fs_info->scrub_lock); in scrub_pending_trans_workers_dec()
398 atomic_dec(&fs_info->scrubs_running); in scrub_pending_trans_workers_dec()
399 atomic_dec(&fs_info->scrubs_paused); in scrub_pending_trans_workers_dec()
400 mutex_unlock(&fs_info->scrub_lock); in scrub_pending_trans_workers_dec()
402 wake_up(&fs_info->scrub_pause_wait); in scrub_pending_trans_workers_dec()
461 struct btrfs_fs_info *fs_info = dev->dev_root->fs_info; in scrub_setup_ctx() local
497 sctx->csum_size = btrfs_super_csum_size(fs_info->super_copy); in scrub_setup_ctx()
504 ret = scrub_setup_wr_ctx(sctx, &sctx->wr_ctx, fs_info, in scrub_setup_ctx()
505 fs_info->dev_replace.tgtdev, is_dev_replace); in scrub_setup_ctx()
527 struct btrfs_fs_info *fs_info = swarn->dev->dev_root->fs_info; in scrub_print_warning_inode() local
536 local_root = btrfs_read_fs_root_no_name(fs_info, &root_key); in scrub_print_warning_inode()
578 btrfs_warn_in_rcu(fs_info, "%s at logical %llu on dev " in scrub_print_warning_inode()
590 btrfs_warn_in_rcu(fs_info, "%s at logical %llu on dev " in scrub_print_warning_inode()
603 struct btrfs_fs_info *fs_info; in scrub_print_warning() local
619 fs_info = sblock->sctx->dev_root->fs_info; in scrub_print_warning()
630 ret = extent_from_logical(fs_info, swarn.logical, path, &found_key, in scrub_print_warning()
647 btrfs_warn_in_rcu(fs_info, in scrub_print_warning()
662 iterate_extent_inodes(fs_info, found_key.objectid, in scrub_print_warning()
680 struct btrfs_fs_info *fs_info; in scrub_fixup_readpage() local
689 fs_info = fixup->root->fs_info; in scrub_fixup_readpage()
690 srcu_index = srcu_read_lock(&fs_info->subvol_srcu); in scrub_fixup_readpage()
692 local_root = btrfs_read_fs_root_no_name(fs_info, &key); in scrub_fixup_readpage()
694 srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); in scrub_fixup_readpage()
701 inode = btrfs_iget(fs_info->sb, &key, local_root, NULL); in scrub_fixup_readpage()
702 srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); in scrub_fixup_readpage()
825 ret = iterate_inodes_from_logical(fixup->logical, fixup->root->fs_info, in scrub_fixup_nodatasum()
846 &sctx->dev_root->fs_info->dev_replace. in scrub_fixup_nodatasum()
848 btrfs_err_rl_in_rcu(sctx->dev_root->fs_info, in scrub_fixup_nodatasum()
884 struct btrfs_fs_info *fs_info; in scrub_handle_errored_block() local
900 fs_info = sctx->dev_root->fs_info; in scrub_handle_errored_block()
976 scrub_recheck_block(fs_info, sblock_bad, 1); in scrub_handle_errored_block()
1059 fixup_nodatasum->root = fs_info->extent_root; in scrub_handle_errored_block()
1064 btrfs_queue_work(fs_info->scrub_workers, in scrub_handle_errored_block()
1095 scrub_recheck_block(fs_info, sblock_other, 0); in scrub_handle_errored_block()
1181 fs_info->dev_replace. in scrub_handle_errored_block()
1207 scrub_recheck_block(fs_info, sblock_bad, 1); in scrub_handle_errored_block()
1220 btrfs_err_rl_in_rcu(fs_info, in scrub_handle_errored_block()
1229 btrfs_err_rl_in_rcu(fs_info, in scrub_handle_errored_block()
1305 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_setup_recheck_block() local
1337 ret = btrfs_map_sblock(fs_info, REQ_GET_READ_MIRRORS, logical, in scrub_setup_recheck_block()
1442 static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, in scrub_submit_raid56_bio_wait() argument
1455 ret = raid56_parity_recover(fs_info->fs_root, bio, page->recover->bbio, in scrub_submit_raid56_bio_wait()
1475 static void scrub_recheck_block(struct btrfs_fs_info *fs_info, in scrub_recheck_block() argument
1504 if (scrub_submit_raid56_bio_wait(fs_info, bio, page)) in scrub_recheck_block()
1578 btrfs_warn_rl(sblock_bad->sctx->dev_root->fs_info, in scrub_repair_page_from_good_copy()
1600 &sblock_bad->sctx->dev_root->fs_info-> in scrub_repair_page_from_good_copy()
1628 &sblock->sctx->dev_root->fs_info->dev_replace. in scrub_write_block_to_dev_replace()
1742 struct btrfs_fs_info *fs_info = sbio->dev->dev_root->fs_info; in scrub_wr_bio_end_io() local
1749 btrfs_queue_work(fs_info->scrub_wr_completion_workers, &sbio->work); in scrub_wr_bio_end_io()
1761 &sbio->sctx->dev_root->fs_info->dev_replace; in scrub_wr_bio_end_io_worker()
1862 struct btrfs_fs_info *fs_info = root->fs_info; in scrub_checksum_tree_block() local
1895 if (memcmp(h->chunk_tree_uuid, fs_info->chunk_tree_uuid, in scrub_checksum_tree_block()
2126 struct btrfs_fs_info *fs_info = sblock->sctx->dev_root->fs_info; in scrub_missing_raid56_end_io() local
2131 btrfs_queue_work(fs_info->scrub_workers, &sblock->work); in scrub_missing_raid56_end_io()
2151 btrfs_err_rl_in_rcu(sctx->dev_root->fs_info, in scrub_missing_raid56_worker()
2158 btrfs_err_rl_in_rcu(sctx->dev_root->fs_info, in scrub_missing_raid56_worker()
2180 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_missing_raid56_pages() local
2189 ret = btrfs_map_sblock(fs_info, REQ_GET_READ_MIRRORS, logical, &length, in scrub_missing_raid56_pages()
2332 struct btrfs_fs_info *fs_info = sbio->dev->dev_root->fs_info; in scrub_bio_end_io() local
2337 btrfs_queue_work(fs_info->scrub_workers, &sbio->work); in scrub_bio_end_io()
2757 btrfs_queue_work(sparity->sctx->dev_root->fs_info->scrub_parity_workers, in scrub_parity_bio_endio()
2776 ret = btrfs_map_sblock(sctx->dev_root->fs_info, WRITE, in scrub_parity_check_and_repair()
2842 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_raid56_parity() local
2843 struct btrfs_root *root = fs_info->extent_root; in scrub_raid56_parity()
2844 struct btrfs_root *csum_root = fs_info->csum_root; in scrub_raid56_parity()
2888 if (btrfs_fs_incompat(fs_info, SKINNY_METADATA)) in scrub_raid56_parity()
2959 btrfs_err(fs_info, "scrub: tree block %llu spanning stripes, ignored. logical=%llu", in scrub_raid56_parity()
2984 ret = btrfs_map_block(fs_info, READ, extent_logical, in scrub_raid56_parity()
3064 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in scrub_stripe() local
3065 struct btrfs_root *root = fs_info->extent_root; in scrub_stripe()
3066 struct btrfs_root *csum_root = fs_info->csum_root; in scrub_stripe()
3159 scrub_blocked_if_needed(fs_info); in scrub_stripe()
3198 if (atomic_read(&fs_info->scrub_cancel_req) || in scrub_stripe()
3206 if (atomic_read(&fs_info->scrub_pause_req)) { in scrub_stripe()
3216 scrub_blocked_if_needed(fs_info); in scrub_stripe()
3237 if (btrfs_fs_incompat(fs_info, SKINNY_METADATA)) in scrub_stripe()
3309 btrfs_err(fs_info, in scrub_stripe()
3340 scrub_remap_extent(fs_info, extent_logical, in scrub_stripe()
3441 &sctx->dev_root->fs_info->mapping_tree; in scrub_chunk()
3495 struct btrfs_fs_info *fs_info = root->fs_info; in scrub_enumerate_chunks() local
3505 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in scrub_enumerate_chunks()
3567 cache = btrfs_lookup_block_group(fs_info, chunk_offset); in scrub_enumerate_chunks()
3582 scrub_pause_on(fs_info); in scrub_enumerate_chunks()
3584 scrub_pause_off(fs_info); in scrub_enumerate_chunks()
3598 btrfs_warn(fs_info, "failed setting block group ro, ret=%d\n", in scrub_enumerate_chunks()
3629 scrub_pause_on(fs_info); in scrub_enumerate_chunks()
3640 scrub_pause_off(fs_info); in scrub_enumerate_chunks()
3656 spin_lock(&fs_info->unused_bgs_lock); in scrub_enumerate_chunks()
3660 &fs_info->unused_bgs); in scrub_enumerate_chunks()
3662 spin_unlock(&fs_info->unused_bgs_lock); in scrub_enumerate_chunks()
3701 if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) in scrub_supers()
3705 if (scrub_dev->fs_devices != root->fs_info->fs_devices) in scrub_supers()
3708 gen = root->fs_info->last_trans_committed; in scrub_supers()
3730 static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info, in scrub_workers_get() argument
3734 int max_active = fs_info->thread_pool_size; in scrub_workers_get()
3736 if (fs_info->scrub_workers_refcnt == 0) { in scrub_workers_get()
3738 fs_info->scrub_workers = in scrub_workers_get()
3742 fs_info->scrub_workers = in scrub_workers_get()
3745 if (!fs_info->scrub_workers) in scrub_workers_get()
3748 fs_info->scrub_wr_completion_workers = in scrub_workers_get()
3751 if (!fs_info->scrub_wr_completion_workers) in scrub_workers_get()
3754 fs_info->scrub_nocow_workers = in scrub_workers_get()
3756 if (!fs_info->scrub_nocow_workers) in scrub_workers_get()
3758 fs_info->scrub_parity_workers = in scrub_workers_get()
3761 if (!fs_info->scrub_parity_workers) in scrub_workers_get()
3764 ++fs_info->scrub_workers_refcnt; in scrub_workers_get()
3768 btrfs_destroy_workqueue(fs_info->scrub_nocow_workers); in scrub_workers_get()
3770 btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers); in scrub_workers_get()
3772 btrfs_destroy_workqueue(fs_info->scrub_workers); in scrub_workers_get()
3777 static noinline_for_stack void scrub_workers_put(struct btrfs_fs_info *fs_info) in scrub_workers_put() argument
3779 if (--fs_info->scrub_workers_refcnt == 0) { in scrub_workers_put()
3780 btrfs_destroy_workqueue(fs_info->scrub_workers); in scrub_workers_put()
3781 btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers); in scrub_workers_put()
3782 btrfs_destroy_workqueue(fs_info->scrub_nocow_workers); in scrub_workers_put()
3783 btrfs_destroy_workqueue(fs_info->scrub_parity_workers); in scrub_workers_put()
3785 WARN_ON(fs_info->scrub_workers_refcnt < 0); in scrub_workers_put()
3788 int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start, in btrfs_scrub_dev() argument
3797 if (btrfs_fs_closing(fs_info)) in btrfs_scrub_dev()
3800 if (fs_info->chunk_root->nodesize > BTRFS_STRIPE_LEN) { in btrfs_scrub_dev()
3806 btrfs_err(fs_info, in btrfs_scrub_dev()
3808 fs_info->chunk_root->nodesize, BTRFS_STRIPE_LEN); in btrfs_scrub_dev()
3812 if (fs_info->chunk_root->sectorsize != PAGE_SIZE) { in btrfs_scrub_dev()
3814 btrfs_err(fs_info, in btrfs_scrub_dev()
3817 fs_info->chunk_root->sectorsize, PAGE_SIZE); in btrfs_scrub_dev()
3821 if (fs_info->chunk_root->nodesize > in btrfs_scrub_dev()
3823 fs_info->chunk_root->sectorsize > in btrfs_scrub_dev()
3829 btrfs_err(fs_info, "scrub: size assumption nodesize and sectorsize " in btrfs_scrub_dev()
3831 fs_info->chunk_root->nodesize, in btrfs_scrub_dev()
3833 fs_info->chunk_root->sectorsize, in btrfs_scrub_dev()
3839 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3840 dev = btrfs_find_device(fs_info, devid, NULL, NULL); in btrfs_scrub_dev()
3842 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3847 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3850 btrfs_err(fs_info, "scrub: device %s is not writable", in btrfs_scrub_dev()
3856 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3858 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3859 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3863 btrfs_dev_replace_lock(&fs_info->dev_replace); in btrfs_scrub_dev()
3866 btrfs_dev_replace_is_ongoing(&fs_info->dev_replace))) { in btrfs_scrub_dev()
3867 btrfs_dev_replace_unlock(&fs_info->dev_replace); in btrfs_scrub_dev()
3868 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3869 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3872 btrfs_dev_replace_unlock(&fs_info->dev_replace); in btrfs_scrub_dev()
3874 ret = scrub_workers_get(fs_info, is_dev_replace); in btrfs_scrub_dev()
3876 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3877 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3883 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3884 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3885 scrub_workers_put(fs_info); in btrfs_scrub_dev()
3890 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3896 __scrub_blocked_if_needed(fs_info); in btrfs_scrub_dev()
3897 atomic_inc(&fs_info->scrubs_running); in btrfs_scrub_dev()
3898 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3905 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3907 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_scrub_dev()
3915 atomic_dec(&fs_info->scrubs_running); in btrfs_scrub_dev()
3916 wake_up(&fs_info->scrub_pause_wait); in btrfs_scrub_dev()
3923 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3925 scrub_workers_put(fs_info); in btrfs_scrub_dev()
3926 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_dev()
3935 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_scrub_pause() local
3937 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_pause()
3938 atomic_inc(&fs_info->scrub_pause_req); in btrfs_scrub_pause()
3939 while (atomic_read(&fs_info->scrubs_paused) != in btrfs_scrub_pause()
3940 atomic_read(&fs_info->scrubs_running)) { in btrfs_scrub_pause()
3941 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_pause()
3942 wait_event(fs_info->scrub_pause_wait, in btrfs_scrub_pause()
3943 atomic_read(&fs_info->scrubs_paused) == in btrfs_scrub_pause()
3944 atomic_read(&fs_info->scrubs_running)); in btrfs_scrub_pause()
3945 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_pause()
3947 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_pause()
3952 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_scrub_continue() local
3954 atomic_dec(&fs_info->scrub_pause_req); in btrfs_scrub_continue()
3955 wake_up(&fs_info->scrub_pause_wait); in btrfs_scrub_continue()
3958 int btrfs_scrub_cancel(struct btrfs_fs_info *fs_info) in btrfs_scrub_cancel() argument
3960 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_cancel()
3961 if (!atomic_read(&fs_info->scrubs_running)) { in btrfs_scrub_cancel()
3962 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel()
3966 atomic_inc(&fs_info->scrub_cancel_req); in btrfs_scrub_cancel()
3967 while (atomic_read(&fs_info->scrubs_running)) { in btrfs_scrub_cancel()
3968 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel()
3969 wait_event(fs_info->scrub_pause_wait, in btrfs_scrub_cancel()
3970 atomic_read(&fs_info->scrubs_running) == 0); in btrfs_scrub_cancel()
3971 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_cancel()
3973 atomic_dec(&fs_info->scrub_cancel_req); in btrfs_scrub_cancel()
3974 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel()
3979 int btrfs_scrub_cancel_dev(struct btrfs_fs_info *fs_info, in btrfs_scrub_cancel_dev() argument
3984 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_cancel_dev()
3987 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel_dev()
3992 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel_dev()
3993 wait_event(fs_info->scrub_pause_wait, in btrfs_scrub_cancel_dev()
3995 mutex_lock(&fs_info->scrub_lock); in btrfs_scrub_cancel_dev()
3997 mutex_unlock(&fs_info->scrub_lock); in btrfs_scrub_cancel_dev()
4008 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_scrub_progress()
4009 dev = btrfs_find_device(root->fs_info, devid, NULL, NULL); in btrfs_scrub_progress()
4014 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_scrub_progress()
4019 static void scrub_remap_extent(struct btrfs_fs_info *fs_info, in scrub_remap_extent() argument
4030 ret = btrfs_map_block(fs_info, READ, extent_logical, in scrub_remap_extent()
4046 struct btrfs_fs_info *fs_info, in scrub_setup_wr_ctx() argument
4076 struct btrfs_fs_info *fs_info = sctx->dev_root->fs_info; in copy_nocow_pages() local
4096 btrfs_queue_work(fs_info->scrub_nocow_workers, in copy_nocow_pages()
4130 struct btrfs_fs_info *fs_info; in copy_nocow_pages_worker() local
4135 fs_info = sctx->dev_root->fs_info; in copy_nocow_pages_worker()
4136 root = fs_info->extent_root; in copy_nocow_pages_worker()
4153 ret = iterate_inodes_from_logical(logical, fs_info, path, in copy_nocow_pages_worker()
4156 btrfs_warn(fs_info, "iterate_inodes_from_logical() failed: log %llu, " in copy_nocow_pages_worker()
4194 btrfs_dev_replace_stats_inc(&fs_info->dev_replace. in copy_nocow_pages_worker()
4250 struct btrfs_fs_info *fs_info = nocow_ctx->sctx->dev_root->fs_info; in copy_nocow_pages_for_inode() local
4268 srcu_index = srcu_read_lock(&fs_info->subvol_srcu); in copy_nocow_pages_for_inode()
4270 local_root = btrfs_read_fs_root_no_name(fs_info, &key); in copy_nocow_pages_for_inode()
4272 srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); in copy_nocow_pages_for_inode()
4279 inode = btrfs_iget(fs_info->sb, &key, local_root, NULL); in copy_nocow_pages_for_inode()
4280 srcu_read_unlock(&fs_info->subvol_srcu, srcu_index); in copy_nocow_pages_for_inode()
4303 btrfs_err(fs_info, "find_or_create_page() failed"); in copy_nocow_pages_for_inode()
4380 btrfs_warn_rl(dev->dev_root->fs_info, in write_page_nocow()