aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-01-20 02:11:44 -0500
committerChris Mason <clm@fb.com>2015-01-21 21:06:49 -0500
commitffe2d2034bbb34f49f76c808550fdfbea2ea1659 (patch)
treee77f446b2628d80cff892f604da7ffa292e892ee /fs/btrfs
parent10f11900167a83e0c229c4c27e73e720ebd55b5c (diff)
Btrfs: Introduce BTRFS_BLOCK_GROUP_RAID56_MASK to check raid56 simply
So we can check raid56 with: (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) instead of long: (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ctree.h3
-rw-r--r--fs/btrfs/inode.c3
-rw-r--r--fs/btrfs/scrub.c17
-rw-r--r--fs/btrfs/volumes.c24
4 files changed, 19 insertions, 28 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0b4683f560c8..2ecdac0bd850 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1020,6 +1020,9 @@ enum btrfs_raid_types {
1020 BTRFS_BLOCK_GROUP_RAID6 | \ 1020 BTRFS_BLOCK_GROUP_RAID6 | \
1021 BTRFS_BLOCK_GROUP_DUP | \ 1021 BTRFS_BLOCK_GROUP_DUP | \
1022 BTRFS_BLOCK_GROUP_RAID10) 1022 BTRFS_BLOCK_GROUP_RAID10)
1023#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \
1024 BTRFS_BLOCK_GROUP_RAID6)
1025
1023/* 1026/*
1024 * We need a bit for restriper to be able to tell when chunks of type 1027 * We need a bit for restriper to be able to tell when chunks of type
1025 * SINGLE are available. This "extended" profile format is used in 1028 * SINGLE are available. This "extended" profile format is used in
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 220f0c3f2df6..2d14acbdae47 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7812,8 +7812,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip,
7812 } 7812 }
7813 7813
7814 /* async crcs make it difficult to collect full stripe writes. */ 7814 /* async crcs make it difficult to collect full stripe writes. */
7815 if (btrfs_get_alloc_profile(root, 1) & 7815 if (btrfs_get_alloc_profile(root, 1) & BTRFS_BLOCK_GROUP_RAID56_MASK)
7816 (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6))
7817 async_submit = 0; 7816 async_submit = 0;
7818 else 7817 else
7819 async_submit = 1; 7818 async_submit = 1;
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 19781e924443..1ae527c9f8f4 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1273,7 +1273,7 @@ static inline void scrub_stripe_index_and_offset(u64 logical, u64 map_type,
1273{ 1273{
1274 int i; 1274 int i;
1275 1275
1276 if (map_type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) { 1276 if (map_type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
1277 /* RAID5/6 */ 1277 /* RAID5/6 */
1278 for (i = 0; i < nstripes; i++) { 1278 for (i = 0; i < nstripes; i++) {
1279 if (raid_map[i] == RAID6_Q_STRIPE || 1279 if (raid_map[i] == RAID6_Q_STRIPE ||
@@ -1420,8 +1420,7 @@ static void scrub_bio_wait_endio(struct bio *bio, int error)
1420static inline int scrub_is_page_on_raid56(struct scrub_page *page) 1420static inline int scrub_is_page_on_raid56(struct scrub_page *page)
1421{ 1421{
1422 return page->recover && 1422 return page->recover &&
1423 (page->recover->bbio->map_type & (BTRFS_BLOCK_GROUP_RAID5 | 1423 (page->recover->bbio->map_type & BTRFS_BLOCK_GROUP_RAID56_MASK);
1424 BTRFS_BLOCK_GROUP_RAID6));
1425} 1424}
1426 1425
1427static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info, 1426static int scrub_submit_raid56_bio_wait(struct btrfs_fs_info *fs_info,
@@ -2994,8 +2993,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
2994 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { 2993 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
2995 increment = map->stripe_len; 2994 increment = map->stripe_len;
2996 mirror_num = num % map->num_stripes + 1; 2995 mirror_num = num % map->num_stripes + 1;
2997 } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 2996 } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
2998 BTRFS_BLOCK_GROUP_RAID6)) {
2999 get_raid56_logic_offset(physical, num, map, &offset, NULL); 2997 get_raid56_logic_offset(physical, num, map, &offset, NULL);
3000 increment = map->stripe_len * nr_data_stripes(map); 2998 increment = map->stripe_len * nr_data_stripes(map);
3001 mirror_num = 1; 2999 mirror_num = 1;
@@ -3029,8 +3027,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3029 */ 3027 */
3030 logical = base + offset; 3028 logical = base + offset;
3031 physical_end = physical + nstripes * map->stripe_len; 3029 physical_end = physical + nstripes * map->stripe_len;
3032 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 3030 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
3033 BTRFS_BLOCK_GROUP_RAID6)) {
3034 get_raid56_logic_offset(physical_end, num, 3031 get_raid56_logic_offset(physical_end, num,
3035 map, &logic_end, NULL); 3032 map, &logic_end, NULL);
3036 logic_end += base; 3033 logic_end += base;
@@ -3076,8 +3073,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
3076 ret = 0; 3073 ret = 0;
3077 while (physical < physical_end) { 3074 while (physical < physical_end) {
3078 /* for raid56, we skip parity stripe */ 3075 /* for raid56, we skip parity stripe */
3079 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 3076 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
3080 BTRFS_BLOCK_GROUP_RAID6)) {
3081 ret = get_raid56_logic_offset(physical, num, 3077 ret = get_raid56_logic_offset(physical, num,
3082 map, &logical, &stripe_logical); 3078 map, &logical, &stripe_logical);
3083 logical += base; 3079 logical += base;
@@ -3235,8 +3231,7 @@ again:
3235 scrub_free_csums(sctx); 3231 scrub_free_csums(sctx);
3236 if (extent_logical + extent_len < 3232 if (extent_logical + extent_len <
3237 key.objectid + bytes) { 3233 key.objectid + bytes) {
3238 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 3234 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
3239 BTRFS_BLOCK_GROUP_RAID6)) {
3240 /* 3235 /*
3241 * loop until we find next data stripe 3236 * loop until we find next data stripe
3242 * or we have finished all stripes. 3237 * or we have finished all stripes.
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8933d70c3d53..da7e0e1107d2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4196,7 +4196,7 @@ static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)
4196 4196
4197static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type) 4197static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
4198{ 4198{
4199 if (!(type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6))) 4199 if (!(type & BTRFS_BLOCK_GROUP_RAID56_MASK))
4200 return; 4200 return;
4201 4201
4202 btrfs_set_fs_incompat(info, RAID56); 4202 btrfs_set_fs_incompat(info, RAID56);
@@ -4803,10 +4803,8 @@ unsigned long btrfs_full_stripe_len(struct btrfs_root *root,
4803 4803
4804 BUG_ON(em->start > logical || em->start + em->len < logical); 4804 BUG_ON(em->start > logical || em->start + em->len < logical);
4805 map = (struct map_lookup *)em->bdev; 4805 map = (struct map_lookup *)em->bdev;
4806 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 4806 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
4807 BTRFS_BLOCK_GROUP_RAID6)) {
4808 len = map->stripe_len * nr_data_stripes(map); 4807 len = map->stripe_len * nr_data_stripes(map);
4809 }
4810 free_extent_map(em); 4808 free_extent_map(em);
4811 return len; 4809 return len;
4812} 4810}
@@ -4826,8 +4824,7 @@ int btrfs_is_parity_mirror(struct btrfs_mapping_tree *map_tree,
4826 4824
4827 BUG_ON(em->start > logical || em->start + em->len < logical); 4825 BUG_ON(em->start > logical || em->start + em->len < logical);
4828 map = (struct map_lookup *)em->bdev; 4826 map = (struct map_lookup *)em->bdev;
4829 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 4827 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK)
4830 BTRFS_BLOCK_GROUP_RAID6))
4831 ret = 1; 4828 ret = 1;
4832 free_extent_map(em); 4829 free_extent_map(em);
4833 return ret; 4830 return ret;
@@ -4998,7 +4995,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
4998 stripe_offset = offset - stripe_offset; 4995 stripe_offset = offset - stripe_offset;
4999 4996
5000 /* if we're here for raid56, we need to know the stripe aligned start */ 4997 /* if we're here for raid56, we need to know the stripe aligned start */
5001 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) { 4998 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
5002 unsigned long full_stripe_len = stripe_len * nr_data_stripes(map); 4999 unsigned long full_stripe_len = stripe_len * nr_data_stripes(map);
5003 raid56_full_stripe_start = offset; 5000 raid56_full_stripe_start = offset;
5004 5001
@@ -5011,8 +5008,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5011 5008
5012 if (rw & REQ_DISCARD) { 5009 if (rw & REQ_DISCARD) {
5013 /* we don't discard raid56 yet */ 5010 /* we don't discard raid56 yet */
5014 if (map->type & 5011 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
5015 (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) {
5016 ret = -EOPNOTSUPP; 5012 ret = -EOPNOTSUPP;
5017 goto out; 5013 goto out;
5018 } 5014 }
@@ -5022,7 +5018,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5022 /* For writes to RAID[56], allow a full stripeset across all disks. 5018 /* For writes to RAID[56], allow a full stripeset across all disks.
5023 For other RAID types and for RAID[56] reads, just allow a single 5019 For other RAID types and for RAID[56] reads, just allow a single
5024 stripe (on a single disk). */ 5020 stripe (on a single disk). */
5025 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6) && 5021 if ((map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) &&
5026 (rw & REQ_WRITE)) { 5022 (rw & REQ_WRITE)) {
5027 max_len = stripe_len * nr_data_stripes(map) - 5023 max_len = stripe_len * nr_data_stripes(map) -
5028 (offset - raid56_full_stripe_start); 5024 (offset - raid56_full_stripe_start);
@@ -5188,8 +5184,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5188 mirror_num = stripe_index - old_stripe_index + 1; 5184 mirror_num = stripe_index - old_stripe_index + 1;
5189 } 5185 }
5190 5186
5191 } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 5187 } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
5192 BTRFS_BLOCK_GROUP_RAID6)) {
5193 if (need_raid_map && 5188 if (need_raid_map &&
5194 ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) || 5189 ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) ||
5195 mirror_num > 1)) { 5190 mirror_num > 1)) {
@@ -5253,7 +5248,7 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info, int rw,
5253 bbio->tgtdev_map = (int *)(bbio->stripes + num_alloc_stripes); 5248 bbio->tgtdev_map = (int *)(bbio->stripes + num_alloc_stripes);
5254 5249
5255 /* build raid_map */ 5250 /* build raid_map */
5256 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6) && 5251 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK &&
5257 need_raid_map && ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) || 5252 need_raid_map && ((rw & (REQ_WRITE | REQ_GET_READ_MIRRORS)) ||
5258 mirror_num > 1)) { 5253 mirror_num > 1)) {
5259 u64 tmp; 5254 u64 tmp;
@@ -5534,8 +5529,7 @@ int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
5534 do_div(length, map->num_stripes / map->sub_stripes); 5529 do_div(length, map->num_stripes / map->sub_stripes);
5535 else if (map->type & BTRFS_BLOCK_GROUP_RAID0) 5530 else if (map->type & BTRFS_BLOCK_GROUP_RAID0)
5536 do_div(length, map->num_stripes); 5531 do_div(length, map->num_stripes);
5537 else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | 5532 else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
5538 BTRFS_BLOCK_GROUP_RAID6)) {
5539 do_div(length, nr_data_stripes(map)); 5533 do_div(length, nr_data_stripes(map));
5540 rmap_len = map->stripe_len * nr_data_stripes(map); 5534 rmap_len = map->stripe_len * nr_data_stripes(map);
5541 } 5535 }