A start at RAID[56] support.
Subsystems (2)
This is a preliminary attempt to add RAID5 and RAID6 support.
So far it doesn't attempt to write or read the parity blocks -- it just lays the data blocks out as we want them, so it's effectively just a complex and wasteful kind of RAID0.
The next step is to make btrfs_map_bio() do the right thing:
- Satisfy read requests for mirrors #2 and #3 by recreating data from RAID5 parity or RAID6 error correction stripe respectively.
- Write out parity and RAID6 blocks appropriately when data writes happen.
The former is relatively easy; the latter is slightly more interesting.
Chris suggests that we can avoid read/modify/write cycles for the parity blocks by ensuring that the file system always writes a full set of stripes. So for a RAID5 of 4 disks with 64KiB stripe_len, that would be a 192KiB minimum write size, for example.
I'm not entirely sure of the best way to do that -- can we set a minimum allocation size for a chunk, and then maybe have it fall back to RAID1 (or a RAID5 chunk with smaller stripe_len) for smaller allocations if they'd be too wasteful on the larger RAID5 chunks?
And how would we handle nodatacow?
I think I'm going to do a crappy r/m/w thing for now (in the knowledge that the error correction stripes won't be powerfail-safe), and then we can set about trying to render it unnecessary.
(Yes, I know I need to fix up btrfs_discard_extent() for RAID5 too -- it doesn't discard the parity stripes, and I may want to make it avoid discarding partial stripes for now, until we fix the above.)
fs/btrfs/ctree.h +2 -0
@@ -653,6 +653,8 @@ struct btrfs_csum_item {#define BTRFS_BLOCK_GROUP_RAID1 (1 << 4)#define BTRFS_BLOCK_GROUP_DUP (1 << 5)#define BTRFS_BLOCK_GROUP_RAID10 (1 << 6) +#define BTRFS_BLOCK_GROUP_RAID5 (1 << 7) +#define BTRFS_BLOCK_GROUP_RAID6 (1 << 8)struct btrfs_block_group_item {__le64 used;
fs/btrfs/extent-tree.c +24 -16
@@ -2496,6 +2496,8 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) {u64 extra_flags = flags & (BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 | +BTRFS_BLOCK_GROUP_RAID5 | +BTRFS_BLOCK_GROUP_RAID6 |BTRFS_BLOCK_GROUP_RAID10 |BTRFS_BLOCK_GROUP_DUP );if (extra_flags) {
@@ -2524,29 +2526,34 @@ static void set_block_group_readonly(struct btrfs_block_group_cache *cache)u64 btrfs_reduce_alloc_profile (struct btrfs_root *root,u64 flags) {u64 num_devices = root->fs_info->fs_devices->rw_devices; +u64 tmp; +/* First, mask out the RAID levels which aren't possible */ if (num_devices ==1 ) - flags &= ~(BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_RAID0 ); + flags &= ~(BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_RAID0 | +BTRFS_BLOCK_GROUP_RAID5 ); +if (num_devices <3 ) + flags &= ~BTRFS_BLOCK_GROUP_RAID6 ;if (num_devices <4 ) flags &= ~BTRFS_BLOCK_GROUP_RAID10 ; -if ((flags &BTRFS_BLOCK_GROUP_DUP ) && - (flags & (BTRFS_BLOCK_GROUP_RAID1 | -BTRFS_BLOCK_GROUP_RAID10 ))) { - flags &= ~BTRFS_BLOCK_GROUP_DUP ; - } + tmp = flags & (BTRFS_BLOCK_GROUP_DUP |BTRFS_BLOCK_GROUP_RAID0 | +BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_RAID5 | +BTRFS_BLOCK_GROUP_RAID6 |BTRFS_BLOCK_GROUP_RAID10 ); + flags &= ~tmp; -if ((flags &BTRFS_BLOCK_GROUP_RAID1 ) && - (flags &BTRFS_BLOCK_GROUP_RAID10 )) { - flags &= ~BTRFS_BLOCK_GROUP_RAID1 ; - } +if (tmp &BTRFS_BLOCK_GROUP_RAID6 ) + tmp =BTRFS_BLOCK_GROUP_RAID6 ; +else if (tmp &BTRFS_BLOCK_GROUP_RAID5 ) + tmp =BTRFS_BLOCK_GROUP_RAID5 ; +else if (tmp &BTRFS_BLOCK_GROUP_RAID10 ) + tmp =BTRFS_BLOCK_GROUP_RAID10 ; +else if (tmp &BTRFS_BLOCK_GROUP_RAID1 ) + tmp =BTRFS_BLOCK_GROUP_RAID1 ; +else if (tmp &BTRFS_BLOCK_GROUP_RAID0 ) + tmp =BTRFS_BLOCK_GROUP_RAID0 ; -if ((flags &BTRFS_BLOCK_GROUP_RAID0 ) && - ((flags &BTRFS_BLOCK_GROUP_RAID1 ) | - (flags &BTRFS_BLOCK_GROUP_RAID10 ) | - (flags &BTRFS_BLOCK_GROUP_DUP ))) - flags &= ~BTRFS_BLOCK_GROUP_RAID0 ; -return flags; +return flags | tmp; }static u64 btrfs_get_alloc_profile (struct btrfs_root *root,u64 data)
@@ -6548,6 +6555,7 @@ static u64 update_block_group_flags(struct btrfs_root *root, u64 flags) {u64 num_devices;u64 stripped =BTRFS_BLOCK_GROUP_RAID0 | +BTRFS_BLOCK_GROUP_RAID5 |BTRFS_BLOCK_GROUP_RAID6 |BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_RAID10 ; num_devices = root->fs_info->fs_devices->rw_devices;
fs/btrfs/volumes.c +84 -3
157 lines not on this page · raw message
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Quoted 1 line · David Woodhouse
This is a preliminary attempt to add RAID5 and RAID6 support.
Matching btrfs-progs patch...
ctree.h +2 -0
@@ -640,6 +640,8 @@ struct btrfs_csum_item {#define BTRFS_BLOCK_GROUP_RAID1 (1 << 4)#define BTRFS_BLOCK_GROUP_DUP (1 << 5)#define BTRFS_BLOCK_GROUP_RAID10 (1 << 6) +#define BTRFS_BLOCK_GROUP_RAID5 (1 << 7) +#define BTRFS_BLOCK_GROUP_RAID6 (1 << 8)struct btrfs_block_group_item {__le64 used;
extent-tree.c +2 -0
@@ -1775,6 +1775,8 @@ static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) {u64 extra_flags = flags & (BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 | +BTRFS_BLOCK_GROUP_RAID5 | +BTRFS_BLOCK_GROUP_RAID6 |BTRFS_BLOCK_GROUP_DUP );if (extra_flags) {if (flags &BTRFS_BLOCK_GROUP_DATA )
mkfs.c +18 -8
@@ -203,16 +203,22 @@ static int create_raid_groups(struct btrfs_trans_handle *trans, u64 metadata_profile) {u64 num_devices =btrfs_super_num_devices (&root->fs_info->super_copy); -u64 allowed; +u64 allowed =0 ;int ret; -if (num_devices ==1 ) - allowed =BTRFS_BLOCK_GROUP_DUP ; -else if (num_devices >=4 ) { - allowed =BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 | -BTRFS_BLOCK_GROUP_RAID10 ; - }else - allowed =BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 ; +switch (num_devices) { +default : +case 4 : + allowed |=BTRFS_BLOCK_GROUP_RAID10 ; +case 3 : + allowed |=BTRFS_BLOCK_GROUP_RAID6 ; +case 2 : + allowed |=BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 | +BTRFS_BLOCK_GROUP_RAID5 ; +break ; +case 1 : + allowed |=BTRFS_BLOCK_GROUP_DUP ; + }if (allowed & metadata_profile) { ret = create_one_raid_group(trans, root,
@@ -292,6 +298,10 @@ static u64 parse_profile(char *s)return BTRFS_BLOCK_GROUP_RAID0 ; }else if (strcmp (s,"raid1" ) ==0 ) {return BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_DUP ; + }else if (strcmp (s,"raid5" ) ==0 ) { +return BTRFS_BLOCK_GROUP_RAID5 ; + }else if (strcmp (s,"raid6" ) ==0 ) { +return BTRFS_BLOCK_GROUP_RAID6 ; }else if (strcmp (s,"raid10" ) ==0 ) {return BTRFS_BLOCK_GROUP_RAID10 |BTRFS_BLOCK_GROUP_DUP ; }else if (strcmp (s,"single" ) ==0 ) {
volumes.c +67 -3
140 lines not on this page · raw message
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Quoted 4 lines · David Woodhouse
Quoted 1 line · David Woodhouse
This is a preliminary attempt to add RAID5 and RAID6 support.
Matching btrfs-progs patch...
And this makes it actually write the P and Q stripes...
These patches at git://,
http://git.infradead.org/users/dwmw2/btrfs-progs-raid56.git
I can now make a 4-disk RAID6 file system, copy some stuff to it, then kick out two of the disks and use it in degraded mode, and everything seems to work fine.
Makefile +1 -1
@@ -4,7 +4,7 @@ CFLAGS = -g -Werror -Os objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \ root-tree.o dir-item.o file-item.o inode-item.o \ inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \ - volumes.o utils.o + volumes.o utils.o raid6.o # CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \
disk-io.c +89 -4
124 lines not on this page · raw message
disk-io.h +3 -0
@@ -76,3 +76,6 @@ int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, int verify);int btrfs_read_buffer (struct extent_buffer *buf,u64 parent_transid);#endif + +/* raid6.c */ +void raid6_gen_syndrome (int disks,size_t bytes,void **ptrs);
raid6.c new file +105 -0
105 lines not on this page · raw message
volumes.c +59 -13
111 lines not on this page · raw message
volumes.h +2 -1
@@ -98,7 +98,8 @@ int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, u64 num_bytes, u64 *start);int btrfs_map_block (struct btrfs_mapping_tree *map_tree,int rw,u64 logical,u64 *length, -struct btrfs_multi_bio **multi_ret,int mirror_num); +struct btrfs_multi_bio **multi_ret,int mirror_num, +u64 **raid_map);int btrfs_rmap_block (struct btrfs_mapping_tree *map_tree,u64 chunk_start,u64 physical,u64 devid,u64 **logical,int *naddrs,int *stripe_len);
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Quoted 7 lines · David Woodhouse
This is a preliminary attempt to add RAID5 and RAID6 support.
So far it doesn't attempt to write or read the parity blocks -- it just
lays the data blocks out as we want them, so it's effectively just a complex and wasteful kind of RAID0.
Quoted 5 lines
The next step is to make
btrfs_map_bio()do the right thing:
- Satisfy read requests for mirrors #2 and #3 by recreating data from RAID5 parity or RAID6 error correction stripe respectively.
- Write out parity and RAID6 blocks appropriately when data writes happen.
Actually, the next step is to tweak __btrfs_map_block() a bit more to let it return information about the whole stripe-set, so that btrfs_map_bio() _can_ do what we say above...
So rather than just mapping the requested address as if it's RAID0, we (where appropriate) return information about the _entire_ disk set in the btrfs_multi_bio, with an auxiliary array giving the _logical_ offset corresponding to each physical stripe in the referenced set (with special values for the P and Q stripes).
We do this for all writes, and for reads where mirror_num > 1 (i.e. when we're being asked to rebuild it from parity, rather than reading the original data blocks).
git://, http://git.infradead.org/users/dwmw2/btrfs-raid56.git
commit ed90c58ba7c60555af4b8c00a104c7d71f6db6d2
Author: David Woodhouse <[email protected]> Date: Sun Jul 12 11:15:22 2009 +0100
Btrfs: Let btrfs_map_block() return full stripe information for RAID[56]
... in the cases where it's necessary -- which is for a write, or for a parity recovery attempt. We'll let btrfs_map_bio() do the rest.
fs/btrfs/volumes.c +67 -18
@@ -62,6 +62,11 @@ static int init_first_rw_device(struct btrfs_trans_handle *trans, struct btrfs_device *device);static int btrfs_relocate_sys_chunks (struct btrfs_root *root); +#define RAID5_P_STRIPE ((u64)-1) +#define RAID6_Q_STRIPE ((u64)-2) + +#define is_parity_stripe (x) ( ((x) == RAID5_P_STRIPE) || ((x) == RAID6_Q_STRIPE) ) +#define map_lookup_size (n) (sizeof(struct map_lookup) + \ (sizeof(struct btrfs_bio_stripe) * (n)))
@@ -2614,7 +2619,8 @@ static int find_live_mirror(struct map_lookup *map, int first, int num,static int __btrfs_map_block (struct btrfs_mapping_tree *map_tree,int rw,u64 logical,u64 *length,struct btrfs_multi_bio **multi_ret, -int mirror_num,struct page *unplug_page) +int mirror_num,struct page *unplug_page, +u64 **raid_map_ret) {struct extent_map *em;struct map_lookup *map;
@@ -2622,6 +2628,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw,u64 offset;u64 stripe_offset;u64 stripe_nr; +u64 *raid_map =NULL ;int stripes_allocated =8 ;int stripes_required =1 ;int stripe_index;
@@ -2674,9 +2681,24 @@ again: max_errors =1 ; } } -if (multi_ret && (rw & (1 <<BIO_RW )) && - stripes_allocated < stripes_required) { - stripes_allocated = map->num_stripes; +if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |BTRFS_BLOCK_GROUP_RAID6 ) + && multi_ret && (rw & (1 <<BIO_RW ) || mirror_num >1 ) && raid_map_ret) { +/* RAID[56] write or recovery. Return all stripes */ + stripes_required = map->num_stripes; + max_errors =nr_parity_stripes (map); + +/* Only allocate the map if we've already got a large enough multi_ret */ +if (stripes_allocated >= stripes_required) { + raid_map =kmalloc (sizeof (u64) * map->num_stripes,GFP_NOFS ); +if (!raid_map) { +free_extent_map (em); +kfree (multi); +return -ENOMEM ; + } + } + } +if (multi_ret && stripes_allocated < stripes_required) { + stripes_allocated = stripes_required;free_extent_map (em);kfree (multi); goto again;
@@ -2749,18 +2771,43 @@ again: stripe_index =do_div (stripe_nr,nr_data_stripes (map)); -/* -* Mirror #0 or #1 means the original data block. -* Mirror #2 is RAID5 parity block. -* Mirror #3 is RAID6 Q block. -*/ -if (mirror_num >1 ) - stripe_index =nr_data_stripes (map) + mirror_num -2 ; - -/* We distribute the parity blocks across stripes */ - tmp = stripe_nr + stripe_index; - stripe_index =do_div (tmp, map->num_stripes); - +if (unplug_page) { + stripe_index =0 ; + num_stripes = map->num_stripes; + }else if (raid_map) { +int i, rot; + +/* Work out the disk rotation on this stripe-set */ + tmp = stripe_nr; + rot =do_div (tmp, map->num_stripes); + +/* Fill in the logical address of each stripe */ + tmp = stripe_nr *nr_data_stripes (map); +for (i =0 ; i <nr_data_stripes (map); i++) + raid_map[(i+rot) % map->num_stripes] = + em->start + (tmp + i) * map->stripe_len; + + raid_map[(i+rot) % map->num_stripes] =RAID5_P_STRIPE ; +if (map->type &BTRFS_BLOCK_GROUP_RAID6 ) + raid_map[(i+rot+1 ) % map->num_stripes] =RAID6_Q_STRIPE ; + + *length = map->stripe_len; + stripe_index =0 ; + stripe_offset =0 ; + num_stripes = map->num_stripes; + }else { +/* +* Mirror #0 or #1 means the original data block. +* Mirror #2 is RAID5 parity block. +* Mirror #3 is RAID6 Q block. +*/ +if (mirror_num >1 ) + stripe_index =nr_data_stripes (map) + mirror_num -2 ; + +/* We distribute the parity blocks across stripes */ + tmp = stripe_nr + stripe_index; + stripe_index =do_div (tmp, map->num_stripes); + } }else {/* * after this do_div call, stripe_nr is the number of stripes
@@ -2795,6 +2842,8 @@ again: multi->num_stripes = num_stripes; multi->max_errors = max_errors; } +if (raid_map_ret) + *raid_map_ret = raid_map; out:free_extent_map (em);return 0 ;
@@ -2805,7 +2854,7 @@ int btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, struct btrfs_multi_bio **multi_ret, int mirror_num) { return __btrfs_map_block(map_tree, rw, logical, length, multi_ret, -mirror_num ,NULL ); +mirror_num ,NULL ,NULL ); } int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree,
@@ -2889,7 +2938,7 @@ int btrfs_unplug_page(struct btrfs_mapping_tree *map_tree, {u64 length =PAGE_CACHE_SIZE ;return __btrfs_map_block (map_tree,READ , logical, &length, -NULL ,0 , page); +NULL ,0 , page,NULL ); }static void end_bio_multi_stripe (struct bio *bio,int err)
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
First attempt at writing RAID[56] parity stripes
This is a fairly crap hack. Even if the file system _does_ want to write a full stripe-set at a time, the merge_bio_hook logic will prevent it from doing so, and ensure that we always have to read the other stripes to recreate the parity -- with all the concurrency issues that involves.
The raid_hack_mutex is a brute-force approach which isn't even really sufficient to fix the RAID5 'write hole' problem, but does protect us against simultaneous writes to different data stripes in the same set.
This hack serves two purposes:
- It does actually write parity (and RAID6 syndrome) blocks so that I can implement and test the recovery.
- It will hopefully offend someone more clueful about the higher layers of the filesystem, provoking them to help me with the task of ensuring that we only ever write full stripe-sets (or at least that we can waste the remaining free space in the stripe-set, if we can't manage that).
So hopefully most of this code can go away in the end -- although some of it may be cannibalised to handle rebuilding after a disk replacement.
--- fs/btrfs/Kconfig | 1 + fs/btrfs/volumes.c | 321 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 316 insertions(+), 6 deletions(-)
fs/btrfs/Kconfig +1 -0
@@ -4,6 +4,7 @@ config BTRFS_FS select LIBCRC32C select ZLIB_INFLATE select ZLIB_DEFLATE + select MD_RAID6_PQ help Btrfs is a new filesystem with extents, writable snapshotting, support for multiple devices and many more features.
fs/btrfs/volumes.c +315 -6
356 lines not on this page · raw message
Signature · 6 lines
1.6.2.2 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
RAID[56] recovery...
Quoted 4 lines · David Woodhouse
This hack serves two purposes:
- It does actually write parity (and RAID6 syndrome) blocks so that I can implement and test the recovery.
fs/btrfs/volumes.c +183 -4
@@ -3792,14 +3792,193 @@ static int raid56_parity_write(struct btrfs_root *root, struct bio *bio,return 0 ; } +static void raid_recover_end_io (struct bio *bio,int err) +{ +struct btrfs_raid_multi_bio *rmult = bio->bi_private; +int nr_pages = rmult->multi->orig_bio->bi_size >>PAGE_SHIFT ; +int i, j, k; +void **pointers; +void *q_ptr =NULL , *p_ptr; +int faila =-1 , failb =-1 ; + +if (err) +atomic_inc (&rmult->multi->error); + +if (!atomic_dec_and_test (&rmult->multi->stripes_pending)) +return ; + +/* OK, we have read all the stripes we need to. */ +if (atomic_read (&rmult->multi->error) > rmult->multi->max_errors -1 ) { +bio_endio (rmult->multi->orig_bio, -EIO ); + goto cleanup; + } + + pointers =kmalloc (rmult->multi->num_stripes *sizeof (void *),GFP_ATOMIC ); +if (!pointers) { +bio_endio (rmult->multi->orig_bio, -EIO ); + goto cleanup; + } + +for (i =0 ; i < nr_pages; i++) { + p_ptr = q_ptr =NULL ; + k =0 ; +for (j =0 ; j < rmult->multi->num_stripes; j++) { +struct bio *bio = rmult->bio[j]; +if (!bio) { +if (rmult->raid_map[j] ==RAID6_Q_STRIPE ) +continue ; + bio = rmult->multi->orig_bio; + faila = j; + }else if (!test_bit (BIO_UPTODATE , &bio->bi_flags)) { +/* We counted the errors. There can be only one */ +BUG_ON (failb !=-1 ); +if (rmult->raid_map[j] ==RAID6_Q_STRIPE ) { +/* Eep. Can't recover from this. Theoretically if the only +failure is the Q stripe and the original data we're trying +to read, then parity should have recovered it. But we'd +only get here if that was broken _too_ */ +bio_endio (rmult->multi->orig_bio, -EIO ); +kfree (pointers); + goto cleanup; + }else if (rmult->raid_map[j] ==RAID5_P_STRIPE ) { + failb =-2 ; + }else { + failb = j; + } + } + +/* Is this always a valid assumption? */ +BUG_ON (bio->bi_io_vec[i].bv_len !=PAGE_SIZE ); +BUG_ON (bio->bi_io_vec[i].bv_offset); + +/* FIXME: Would be nice to kmap here so that we can allow highmem +pages, but since we're in end_io context it would need to be +kmap_atomic, and there are an arbitrary number of pages... */ +if (rmult->raid_map[j] ==RAID5_P_STRIPE ) + p_ptr =phys_to_virt (page_to_phys (bio->bi_io_vec[i].bv_page)); +else if (rmult->raid_map[j] ==RAID6_Q_STRIPE ) + q_ptr =phys_to_virt (page_to_phys (bio->bi_io_vec[i].bv_page)); +else + pointers[k++] =phys_to_virt (page_to_phys (bio->bi_io_vec[i].bv_page)); + } + pointers[k++] = p_ptr; + +if (q_ptr) { + pointers[k++] = q_ptr; +BUG_ON (k != j); + +if (failb ==-1 ) { +/* +* Eep. We don't _have_ a second failure, so parity really +* _should_ have worked. One of the stripes must be _corrupted_ +* rather than unreadable, which is a problem for us -- we have +* no way of knowing which one. Theoretically, we could increase +* the value of btrfs_num_copies() to let the upper layers try +* _all_ possible combinations until it finds one that looks OK? +*/ + failb =-2 ; + } +if (failb ==-2 ) { +raid6_datap_recov (rmult->multi->num_stripes,PAGE_SIZE , faila, pointers); + }else { +if (faila > failb) { +int tmp = failb; + failb = faila; + faila = tmp; + } +raid6_2data_recov (rmult->multi->num_stripes,PAGE_SIZE , faila, failb, pointers); + } + }else { +memcpy (pointers[faila], p_ptr,PAGE_SIZE ); +for (k =0 ; pointers[k] != p_ptr; k++) { +if (k == faila) +continue ; +for (j =0 ; j <PAGE_SIZE ; j +=sizeof (unsigned long )) { + *(unsigned long *)(pointers[faila] + j) ^= + *(unsigned long *)(pointers[k] + j); + } + } + } +/* kunmap pages here */ + } +kfree (pointers); + + rmult->multi->orig_bio->bi_size =0 ; +bio_endio (rmult->multi->orig_bio,0 ); +return ; + + cleanup: +for (i =0 ; i < rmult->multi->num_stripes; i++) { +if (!rmult->bio[i]) +continue ; +for (j =0 ; j < nr_pages; j++) { +__free_page (rmult->bio[i]->bi_io_vec[j].bv_page); + } +bio_put (rmult->bio[i]); + } +kfree (rmult->raid_map); +kfree (rmult->multi); +kfree (rmult); +} +static int raid56_parity_recover (struct btrfs_root *root,struct bio *bio,int async,struct btrfs_multi_bio *multi,u64 *raid_map,u64 stripe_len,int mirror_num) { -WARN_ON (1 ); -kfree (multi); -kfree (raid_map); -bio_endio (bio, -EIO ); +int i; +int start_ofs, end_ofs; +int stripes_to_read =0 ; +u64 logical = (u64 )bio->bi_sector <<9 ; +struct btrfs_raid_multi_bio *rmult; + + rmult =kzalloc (sizeof (*rmult) + multi->num_stripes *sizeof (void *), +GFP_NOFS ); +if (!rmult) { +kfree (raid_map); +kfree (multi); +return -ENOMEM ; + } + rmult->multi = multi; + rmult->raid_map = raid_map; + rmult->root = root; + +/* What subrange of the stripe are we reading? */ + start_ofs =do_div (logical, stripe_len); + end_ofs = start_ofs + bio->bi_size; +BUG_ON (end_ofs > stripe_len); + +/* Allocate bios for reading all the other stripes */ + logical = (u64 )bio->bi_sector <<9 ; +for (i =0 ; i < multi->num_stripes; i++) { +if (start_ofs) { +if (!is_parity_stripe (raid_map[i])) + raid_map[i] += start_ofs; + multi->stripes[i].physical += start_ofs; + } +/* Don't read the original data block, of course. And +don't read the Q stripe if we're asked for mirror #2 +(which means recreate from parity) */ +if (raid_map[i] != logical && + (raid_map[i] !=RAID6_Q_STRIPE || mirror_num ==3 )) { + rmult->bio[i] =alloc_raid_stripe_bio (&multi->stripes[i], + bio->bi_size); +BUG_ON (!rmult->bio[i]);/* FIXME */ + rmult->bio[i]->bi_private = rmult; + rmult->bio[i]->bi_end_io = raid_recover_end_io; + stripes_to_read++; + } + } + +atomic_set (&multi->stripes_pending, stripes_to_read); +for (i =0 ; i < multi->num_stripes; i++) { + +if (rmult->bio[i]) { +if (async) +schedule_bio (root, multi->stripes[i].dev,READ , rmult->bio[i]); +else +submit_bio (READ , rmult->bio[i]); + } + }return 0 ; }
Signature · 6 lines
1.6.2.5 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Hello list,
for an internal demonstration system due in Q1/2011, I am very much interested in setting up a btrfs fs with RAID5; RAID1 just won't cut it.
As can be read in the btrfs wiki [1], the 'magic' number for RAID5 support in btrfs is 2.6.37 which is just around the corner.
So my question is: Is this still the roadmap for the introduction of RAID5 and RAID6, or has it been delayed somewhat? If so, what is the current target kernel release for btrfs RAID5 support?
Thanks for the information!
Best regards
Martin
[1] https://btrfs.wiki.kernel.org/index.php/FAQ#Can_I_use_RAID.5B56.5D_on_my_Btrfs_filesystem.3F