diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-11-06 04:20:58 -0500 |
---|---|---|
committer | Miao Xie <miaox@cn.fujitsu.com> | 2014-12-02 21:18:45 -0500 |
commit | 5a6ac9eacb49143cbad3bbfda72263101cb1f3df (patch) | |
tree | a3da74777b8ffe20edbcd47f2b3e7c8cb17918ac /fs/btrfs/raid56.h | |
parent | 1b94b5567e9c70ad3b24bd5e576a422246875c2a (diff) |
Btrfs, raid56: support parity scrub on raid56
The implementation is:
- Read and check all the data with checksum in the same stripe.
All the data which has checksum is COW data, and we are sure
that it is not changed though we don't lock the stripe. because
the space of that data just can be reclaimed after the current
transction is committed, and then the fs can use it to store the
other data, but when doing scrub, we hold the current transaction,
that is that data can not be recovered, it is safe that read and check
it out of the stripe lock.
- Lock the stripe
- Read out all the data without checksum and parity
The data without checksum and the parity may be changed if we don't
lock the stripe, so we need read it in the stripe lock context.
- Check the parity
- Re-calculate the new parity and write back it if the old parity
is not right
- Unlock the stripe
If we can not read out the data or the data we read is corrupted,
we will try to repair it. If the repair fails. we will mark the
horizontal sub-stripe(pages on the same horizontal) as corrupted
sub-stripe, and we will skip the parity check and repair of that
horizontal sub-stripe.
And in order to skip the horizontal sub-stripe that has no data, we
introduce a bitmap. If there is some data on the horizontal sub-stripe,
we will the relative bit to 1, and when we check and repair the
parity, we will skip those horizontal sub-stripes that the relative
bits is 0.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/raid56.h')
-rw-r--r-- | fs/btrfs/raid56.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h index b310e8c830d1..3d4ddb3d861d 100644 --- a/fs/btrfs/raid56.h +++ b/fs/btrfs/raid56.h | |||
@@ -39,6 +39,9 @@ static inline int nr_data_stripes(struct map_lookup *map) | |||
39 | #define is_parity_stripe(x) (((x) == RAID5_P_STRIPE) || \ | 39 | #define is_parity_stripe(x) (((x) == RAID5_P_STRIPE) || \ |
40 | ((x) == RAID6_Q_STRIPE)) | 40 | ((x) == RAID6_Q_STRIPE)) |
41 | 41 | ||
42 | struct btrfs_raid_bio; | ||
43 | struct btrfs_device; | ||
44 | |||
42 | int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, | 45 | int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, |
43 | struct btrfs_bio *bbio, u64 *raid_map, | 46 | struct btrfs_bio *bbio, u64 *raid_map, |
44 | u64 stripe_len, int mirror_num, int hold_bbio); | 47 | u64 stripe_len, int mirror_num, int hold_bbio); |
@@ -46,6 +49,15 @@ int raid56_parity_write(struct btrfs_root *root, struct bio *bio, | |||
46 | struct btrfs_bio *bbio, u64 *raid_map, | 49 | struct btrfs_bio *bbio, u64 *raid_map, |
47 | u64 stripe_len); | 50 | u64 stripe_len); |
48 | 51 | ||
52 | struct btrfs_raid_bio * | ||
53 | raid56_parity_alloc_scrub_rbio(struct btrfs_root *root, struct bio *bio, | ||
54 | struct btrfs_bio *bbio, u64 *raid_map, | ||
55 | u64 stripe_len, struct btrfs_device *scrub_dev, | ||
56 | unsigned long *dbitmap, int stripe_nsectors); | ||
57 | void raid56_parity_add_scrub_pages(struct btrfs_raid_bio *rbio, | ||
58 | struct page *page, u64 logical); | ||
59 | void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio); | ||
60 | |||
49 | int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info); | 61 | int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info); |
50 | void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info); | 62 | void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info); |
51 | #endif | 63 | #endif |