aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/async-thread.c1
-rw-r--r--fs/btrfs/async-thread.h2
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/scrub.c26
4 files changed, 27 insertions, 3 deletions
diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
index df9932b00d08..1ce06c849a86 100644
--- a/fs/btrfs/async-thread.c
+++ b/fs/btrfs/async-thread.c
@@ -85,6 +85,7 @@ BTRFS_WORK_HELPER(extent_refs_helper);
85BTRFS_WORK_HELPER(scrub_helper); 85BTRFS_WORK_HELPER(scrub_helper);
86BTRFS_WORK_HELPER(scrubwrc_helper); 86BTRFS_WORK_HELPER(scrubwrc_helper);
87BTRFS_WORK_HELPER(scrubnc_helper); 87BTRFS_WORK_HELPER(scrubnc_helper);
88BTRFS_WORK_HELPER(scrubparity_helper);
88 89
89static struct __btrfs_workqueue * 90static struct __btrfs_workqueue *
90__btrfs_alloc_workqueue(const char *name, unsigned int flags, int max_active, 91__btrfs_alloc_workqueue(const char *name, unsigned int flags, int max_active,
diff --git a/fs/btrfs/async-thread.h b/fs/btrfs/async-thread.h
index ec2ee477f8ba..b0b093b6afec 100644
--- a/fs/btrfs/async-thread.h
+++ b/fs/btrfs/async-thread.h
@@ -64,6 +64,8 @@ BTRFS_WORK_HELPER_PROTO(extent_refs_helper);
64BTRFS_WORK_HELPER_PROTO(scrub_helper); 64BTRFS_WORK_HELPER_PROTO(scrub_helper);
65BTRFS_WORK_HELPER_PROTO(scrubwrc_helper); 65BTRFS_WORK_HELPER_PROTO(scrubwrc_helper);
66BTRFS_WORK_HELPER_PROTO(scrubnc_helper); 66BTRFS_WORK_HELPER_PROTO(scrubnc_helper);
67BTRFS_WORK_HELPER_PROTO(scrubparity_helper);
68
67 69
68struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name, 70struct btrfs_workqueue *btrfs_alloc_workqueue(const char *name,
69 unsigned int flags, 71 unsigned int flags,
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 5e09834ac2ef..881549a35fca 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1698,6 +1698,7 @@ struct btrfs_fs_info {
1698 struct btrfs_workqueue *scrub_workers; 1698 struct btrfs_workqueue *scrub_workers;
1699 struct btrfs_workqueue *scrub_wr_completion_workers; 1699 struct btrfs_workqueue *scrub_wr_completion_workers;
1700 struct btrfs_workqueue *scrub_nocow_workers; 1700 struct btrfs_workqueue *scrub_nocow_workers;
1701 struct btrfs_workqueue *scrub_parity_workers;
1701 1702
1702#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 1703#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY
1703 u32 check_integrity_print_mask; 1704 u32 check_integrity_print_mask;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index ab5811545a98..9f2feabe99f2 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2662,18 +2662,30 @@ static void scrub_free_parity(struct scrub_parity *sparity)
2662 kfree(sparity); 2662 kfree(sparity);
2663} 2663}
2664 2664
2665static void scrub_parity_bio_endio_worker(struct btrfs_work *work)
2666{
2667 struct scrub_parity *sparity = container_of(work, struct scrub_parity,
2668 work);
2669 struct scrub_ctx *sctx = sparity->sctx;
2670
2671 scrub_free_parity(sparity);
2672 scrub_pending_bio_dec(sctx);
2673}
2674
2665static void scrub_parity_bio_endio(struct bio *bio, int error) 2675static void scrub_parity_bio_endio(struct bio *bio, int error)
2666{ 2676{
2667 struct scrub_parity *sparity = (struct scrub_parity *)bio->bi_private; 2677 struct scrub_parity *sparity = (struct scrub_parity *)bio->bi_private;
2668 struct scrub_ctx *sctx = sparity->sctx;
2669 2678
2670 if (error) 2679 if (error)
2671 bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap, 2680 bitmap_or(sparity->ebitmap, sparity->ebitmap, sparity->dbitmap,
2672 sparity->nsectors); 2681 sparity->nsectors);
2673 2682
2674 scrub_free_parity(sparity);
2675 scrub_pending_bio_dec(sctx);
2676 bio_put(bio); 2683 bio_put(bio);
2684
2685 btrfs_init_work(&sparity->work, btrfs_scrubparity_helper,
2686 scrub_parity_bio_endio_worker, NULL, NULL);
2687 btrfs_queue_work(sparity->sctx->dev_root->fs_info->scrub_parity_workers,
2688 &sparity->work);
2677} 2689}
2678 2690
2679static void scrub_parity_check_and_repair(struct scrub_parity *sparity) 2691static void scrub_parity_check_and_repair(struct scrub_parity *sparity)
@@ -3589,6 +3601,13 @@ static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info,
3589 ret = -ENOMEM; 3601 ret = -ENOMEM;
3590 goto out; 3602 goto out;
3591 } 3603 }
3604 fs_info->scrub_parity_workers =
3605 btrfs_alloc_workqueue("btrfs-scrubparity", flags,
3606 max_active, 2);
3607 if (!fs_info->scrub_parity_workers) {
3608 ret = -ENOMEM;
3609 goto out;
3610 }
3592 } 3611 }
3593 ++fs_info->scrub_workers_refcnt; 3612 ++fs_info->scrub_workers_refcnt;
3594out: 3613out:
@@ -3601,6 +3620,7 @@ static noinline_for_stack void scrub_workers_put(struct btrfs_fs_info *fs_info)
3601 btrfs_destroy_workqueue(fs_info->scrub_workers); 3620 btrfs_destroy_workqueue(fs_info->scrub_workers);
3602 btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers); 3621 btrfs_destroy_workqueue(fs_info->scrub_wr_completion_workers);
3603 btrfs_destroy_workqueue(fs_info->scrub_nocow_workers); 3622 btrfs_destroy_workqueue(fs_info->scrub_nocow_workers);
3623 btrfs_destroy_workqueue(fs_info->scrub_parity_workers);
3604 } 3624 }
3605 WARN_ON(fs_info->scrub_workers_refcnt < 0); 3625 WARN_ON(fs_info->scrub_workers_refcnt < 0);
3606} 3626}