diff options
| author | Jeff Mahoney <jeffm@suse.com> | 2016-06-22 18:54:23 -0400 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2016-12-06 10:06:59 -0500 |
| commit | 0b246afa62b0cf5b09d078121f543135f28492ad (patch) | |
| tree | 200ad296d09f1b2f5329658c8de81bc625007ace /fs/btrfs/raid56.c | |
| parent | 6202df6921494f29308307e0ae6f567c2ab2ba19 (diff) | |
btrfs: root->fs_info cleanup, add fs_info convenience variables
In routines where someptr->fs_info is referenced multiple times, we
introduce a convenience variable. This makes the code considerably
more readable.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/raid56.c')
| -rw-r--r-- | fs/btrfs/raid56.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index 6e9e21da23e7..9a67346b48f5 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c | |||
| @@ -1478,11 +1478,8 @@ cleanup: | |||
| 1478 | 1478 | ||
| 1479 | static void async_rmw_stripe(struct btrfs_raid_bio *rbio) | 1479 | static void async_rmw_stripe(struct btrfs_raid_bio *rbio) |
| 1480 | { | 1480 | { |
| 1481 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, | 1481 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, rmw_work, NULL, NULL); |
| 1482 | rmw_work, NULL, NULL); | 1482 | btrfs_queue_work(rbio->fs_info->rmw_workers, &rbio->work); |
| 1483 | |||
| 1484 | btrfs_queue_work(rbio->fs_info->rmw_workers, | ||
| 1485 | &rbio->work); | ||
| 1486 | } | 1483 | } |
| 1487 | 1484 | ||
| 1488 | static void async_read_rebuild(struct btrfs_raid_bio *rbio) | 1485 | static void async_read_rebuild(struct btrfs_raid_bio *rbio) |
| @@ -1490,8 +1487,7 @@ static void async_read_rebuild(struct btrfs_raid_bio *rbio) | |||
| 1490 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, | 1487 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, |
| 1491 | read_rebuild_work, NULL, NULL); | 1488 | read_rebuild_work, NULL, NULL); |
| 1492 | 1489 | ||
| 1493 | btrfs_queue_work(rbio->fs_info->rmw_workers, | 1490 | btrfs_queue_work(rbio->fs_info->rmw_workers, &rbio->work); |
| 1494 | &rbio->work); | ||
| 1495 | } | 1491 | } |
| 1496 | 1492 | ||
| 1497 | /* | 1493 | /* |
| @@ -1573,8 +1569,7 @@ static int raid56_rmw_stripe(struct btrfs_raid_bio *rbio) | |||
| 1573 | bio->bi_end_io = raid_rmw_end_io; | 1569 | bio->bi_end_io = raid_rmw_end_io; |
| 1574 | bio_set_op_attrs(bio, REQ_OP_READ, 0); | 1570 | bio_set_op_attrs(bio, REQ_OP_READ, 0); |
| 1575 | 1571 | ||
| 1576 | btrfs_bio_wq_end_io(rbio->fs_info, bio, | 1572 | btrfs_bio_wq_end_io(rbio->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); |
| 1577 | BTRFS_WQ_ENDIO_RAID56); | ||
| 1578 | 1573 | ||
| 1579 | submit_bio(bio); | 1574 | submit_bio(bio); |
| 1580 | } | 1575 | } |
| @@ -1742,6 +1737,7 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule) | |||
| 1742 | int raid56_parity_write(struct btrfs_root *root, struct bio *bio, | 1737 | int raid56_parity_write(struct btrfs_root *root, struct bio *bio, |
| 1743 | struct btrfs_bio *bbio, u64 stripe_len) | 1738 | struct btrfs_bio *bbio, u64 stripe_len) |
| 1744 | { | 1739 | { |
| 1740 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
| 1745 | struct btrfs_raid_bio *rbio; | 1741 | struct btrfs_raid_bio *rbio; |
| 1746 | struct btrfs_plug_cb *plug = NULL; | 1742 | struct btrfs_plug_cb *plug = NULL; |
| 1747 | struct blk_plug_cb *cb; | 1743 | struct blk_plug_cb *cb; |
| @@ -1756,7 +1752,7 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio, | |||
| 1756 | rbio->bio_list_bytes = bio->bi_iter.bi_size; | 1752 | rbio->bio_list_bytes = bio->bi_iter.bi_size; |
| 1757 | rbio->operation = BTRFS_RBIO_WRITE; | 1753 | rbio->operation = BTRFS_RBIO_WRITE; |
| 1758 | 1754 | ||
| 1759 | btrfs_bio_counter_inc_noblocked(root->fs_info); | 1755 | btrfs_bio_counter_inc_noblocked(fs_info); |
| 1760 | rbio->generic_bio_cnt = 1; | 1756 | rbio->generic_bio_cnt = 1; |
| 1761 | 1757 | ||
| 1762 | /* | 1758 | /* |
| @@ -1766,16 +1762,15 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio, | |||
| 1766 | if (rbio_is_full(rbio)) { | 1762 | if (rbio_is_full(rbio)) { |
| 1767 | ret = full_stripe_write(rbio); | 1763 | ret = full_stripe_write(rbio); |
| 1768 | if (ret) | 1764 | if (ret) |
| 1769 | btrfs_bio_counter_dec(root->fs_info); | 1765 | btrfs_bio_counter_dec(fs_info); |
| 1770 | return ret; | 1766 | return ret; |
| 1771 | } | 1767 | } |
| 1772 | 1768 | ||
| 1773 | cb = blk_check_plugged(btrfs_raid_unplug, root->fs_info, | 1769 | cb = blk_check_plugged(btrfs_raid_unplug, fs_info, sizeof(*plug)); |
| 1774 | sizeof(*plug)); | ||
| 1775 | if (cb) { | 1770 | if (cb) { |
| 1776 | plug = container_of(cb, struct btrfs_plug_cb, cb); | 1771 | plug = container_of(cb, struct btrfs_plug_cb, cb); |
| 1777 | if (!plug->info) { | 1772 | if (!plug->info) { |
| 1778 | plug->info = root->fs_info; | 1773 | plug->info = fs_info; |
| 1779 | INIT_LIST_HEAD(&plug->rbio_list); | 1774 | INIT_LIST_HEAD(&plug->rbio_list); |
| 1780 | } | 1775 | } |
| 1781 | list_add_tail(&rbio->plug_list, &plug->rbio_list); | 1776 | list_add_tail(&rbio->plug_list, &plug->rbio_list); |
| @@ -1783,7 +1778,7 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio, | |||
| 1783 | } else { | 1778 | } else { |
| 1784 | ret = __raid56_parity_write(rbio); | 1779 | ret = __raid56_parity_write(rbio); |
| 1785 | if (ret) | 1780 | if (ret) |
| 1786 | btrfs_bio_counter_dec(root->fs_info); | 1781 | btrfs_bio_counter_dec(fs_info); |
| 1787 | } | 1782 | } |
| 1788 | return ret; | 1783 | return ret; |
| 1789 | } | 1784 | } |
| @@ -2098,8 +2093,7 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio) | |||
| 2098 | bio->bi_end_io = raid_recover_end_io; | 2093 | bio->bi_end_io = raid_recover_end_io; |
| 2099 | bio_set_op_attrs(bio, REQ_OP_READ, 0); | 2094 | bio_set_op_attrs(bio, REQ_OP_READ, 0); |
| 2100 | 2095 | ||
| 2101 | btrfs_bio_wq_end_io(rbio->fs_info, bio, | 2096 | btrfs_bio_wq_end_io(rbio->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); |
| 2102 | BTRFS_WQ_ENDIO_RAID56); | ||
| 2103 | 2097 | ||
| 2104 | submit_bio(bio); | 2098 | submit_bio(bio); |
| 2105 | } | 2099 | } |
| @@ -2123,6 +2117,7 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, | |||
| 2123 | struct btrfs_bio *bbio, u64 stripe_len, | 2117 | struct btrfs_bio *bbio, u64 stripe_len, |
| 2124 | int mirror_num, int generic_io) | 2118 | int mirror_num, int generic_io) |
| 2125 | { | 2119 | { |
| 2120 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
| 2126 | struct btrfs_raid_bio *rbio; | 2121 | struct btrfs_raid_bio *rbio; |
| 2127 | int ret; | 2122 | int ret; |
| 2128 | 2123 | ||
| @@ -2139,7 +2134,7 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, | |||
| 2139 | 2134 | ||
| 2140 | rbio->faila = find_logical_bio_stripe(rbio, bio); | 2135 | rbio->faila = find_logical_bio_stripe(rbio, bio); |
| 2141 | if (rbio->faila == -1) { | 2136 | if (rbio->faila == -1) { |
| 2142 | btrfs_warn(root->fs_info, | 2137 | btrfs_warn(fs_info, |
| 2143 | "%s could not find the bad stripe in raid56 so that we cannot recover any more (bio has logical %llu len %llu, bbio has map_type %llu)", | 2138 | "%s could not find the bad stripe in raid56 so that we cannot recover any more (bio has logical %llu len %llu, bbio has map_type %llu)", |
| 2144 | __func__, (u64)bio->bi_iter.bi_sector << 9, | 2139 | __func__, (u64)bio->bi_iter.bi_sector << 9, |
| 2145 | (u64)bio->bi_iter.bi_size, bbio->map_type); | 2140 | (u64)bio->bi_iter.bi_size, bbio->map_type); |
| @@ -2150,7 +2145,7 @@ int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, | |||
| 2150 | } | 2145 | } |
| 2151 | 2146 | ||
| 2152 | if (generic_io) { | 2147 | if (generic_io) { |
| 2153 | btrfs_bio_counter_inc_noblocked(root->fs_info); | 2148 | btrfs_bio_counter_inc_noblocked(fs_info); |
| 2154 | rbio->generic_bio_cnt = 1; | 2149 | rbio->generic_bio_cnt = 1; |
| 2155 | } else { | 2150 | } else { |
| 2156 | btrfs_get_bbio(bbio); | 2151 | btrfs_get_bbio(bbio); |
| @@ -2213,6 +2208,7 @@ raid56_parity_alloc_scrub_rbio(struct btrfs_root *root, struct bio *bio, | |||
| 2213 | struct btrfs_device *scrub_dev, | 2208 | struct btrfs_device *scrub_dev, |
| 2214 | unsigned long *dbitmap, int stripe_nsectors) | 2209 | unsigned long *dbitmap, int stripe_nsectors) |
| 2215 | { | 2210 | { |
| 2211 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
| 2216 | struct btrfs_raid_bio *rbio; | 2212 | struct btrfs_raid_bio *rbio; |
| 2217 | int i; | 2213 | int i; |
| 2218 | 2214 | ||
| @@ -2235,7 +2231,7 @@ raid56_parity_alloc_scrub_rbio(struct btrfs_root *root, struct bio *bio, | |||
| 2235 | } | 2231 | } |
| 2236 | 2232 | ||
| 2237 | /* Now we just support the sectorsize equals to page size */ | 2233 | /* Now we just support the sectorsize equals to page size */ |
| 2238 | ASSERT(root->fs_info->sectorsize == PAGE_SIZE); | 2234 | ASSERT(fs_info->sectorsize == PAGE_SIZE); |
| 2239 | ASSERT(rbio->stripe_npages == stripe_nsectors); | 2235 | ASSERT(rbio->stripe_npages == stripe_nsectors); |
| 2240 | bitmap_copy(rbio->dbitmap, dbitmap, stripe_nsectors); | 2236 | bitmap_copy(rbio->dbitmap, dbitmap, stripe_nsectors); |
| 2241 | 2237 | ||
| @@ -2617,8 +2613,7 @@ static void raid56_parity_scrub_stripe(struct btrfs_raid_bio *rbio) | |||
| 2617 | bio->bi_end_io = raid56_parity_scrub_end_io; | 2613 | bio->bi_end_io = raid56_parity_scrub_end_io; |
| 2618 | bio_set_op_attrs(bio, REQ_OP_READ, 0); | 2614 | bio_set_op_attrs(bio, REQ_OP_READ, 0); |
| 2619 | 2615 | ||
| 2620 | btrfs_bio_wq_end_io(rbio->fs_info, bio, | 2616 | btrfs_bio_wq_end_io(rbio->fs_info, bio, BTRFS_WQ_ENDIO_RAID56); |
| 2621 | BTRFS_WQ_ENDIO_RAID56); | ||
| 2622 | 2617 | ||
| 2623 | submit_bio(bio); | 2618 | submit_bio(bio); |
| 2624 | } | 2619 | } |
| @@ -2646,8 +2641,7 @@ static void async_scrub_parity(struct btrfs_raid_bio *rbio) | |||
| 2646 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, | 2641 | btrfs_init_work(&rbio->work, btrfs_rmw_helper, |
| 2647 | scrub_parity_work, NULL, NULL); | 2642 | scrub_parity_work, NULL, NULL); |
| 2648 | 2643 | ||
| 2649 | btrfs_queue_work(rbio->fs_info->rmw_workers, | 2644 | btrfs_queue_work(rbio->fs_info->rmw_workers, &rbio->work); |
| 2650 | &rbio->work); | ||
| 2651 | } | 2645 | } |
| 2652 | 2646 | ||
| 2653 | void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio) | 2647 | void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio) |
