New RAID library supporting up to six parities
Subsystems (5)
v5 cover New RAID library supporting up to six parities
Hi,
A new version of the new RAID library. Finally with *working* btrfs support!
It includes patches for both the kernel and btrfs-progs to add new parity modes "par3", "par4", "par5" and "par6" working similarly at the existing "raid5" and "raid6" ones.
The patches apply cleanly to kernel v3.14-rc3 and btrfs-progs v3.12.
If you are willing to test it, you can do something like that:
mkfs.btrfs -d par3 -m par3 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 mount /dev/sdb1 /mnt/tmp
...copy something to /mnt/tmp...
md5deep -r /mnt/tmp > test_before.hash
umount /mnt/tmp
dd if=/dev/urandom of=/dev/sdc1 count=...
dd if=/dev/urandom of=/dev/sdd1 count=...
dd if=/dev/urandom of=/dev/sde1 count=...
mount -o degraded /dev/sdb1 /mnt/tmp
md5deep -r /mnt/tmp > test_after.hash
umount /mnt/tmp
diff -u test_before.hash test_after.hash && echo OK
I run various test like that, and everything seems to work.
The first patch is the new RAID library for the kernel, supporting up to six parities. It's verified with automated test that reach 99.3% code coverage. It also passes clang and valgrind tests with no error.
It applies cleanly to kernel v3.14-rc3, but it should work with any other version because it's formed only of new files. The only kernel change is the new CONFIG_RAID_CAUCHY option in the "lib" configuration section.
For reviewing I recommend to start from the include/raid/raid.h that describes the new generic raid interface. Then continue in lib/raid/raid.c where the interface is implement. You can start reading the documentation about the RAID mathematics used, taking care that its correctness is proven both mathematically and by brute-force by the test programs.
You can then review raid_gen() and raid_rec(), that are high level forwarders to generic and optimized asm functions that generate parity
and recover data. Their internal structure is very similar at the functions in RAID6. The main difference is to have a generic matrix of parity coefficients. All these functions are verified by the test programs, with full lines and branches coverage, meaning that you can concentrate the review on their structure, than in the computation and asm details.
Finally, you can review the test programs in lib/raid/test, to ensure that everything is really tested, and the coverage test can help you on that.
The second patch contains the kernel btrfs modifications. Besides adding the new parity modes it also removes a lot of code about raid details that are now handled by the new raid library.
It applies cleanly to kernel v3.14-rc3. You can use it also for previous kernels, with an obvious adjustment in fs/btrfs/ctree.h.
For reviewing you can start from the diff, and check chunk after chunk. Likely the two most complex changes are where the new raid_gen() and raid_rec() are called replacing big chunks of code. But the rest is mostly straightforward as I just extended all the checks about RAID5 and RAID6 to six parities. But for sure it needs a more careful review as my knowledge of btrfs internals is very limited.
The third patch contains the btrfs-progs modification. They are just matching the kernel changes, and the same considerations apply.
It applies cleanly to btrfs-progs v3.12.
Please let me know what you think, and if it can be considered for inclusion or something more is required.
If some patch is missing due mailinglist size limit, you can download them at:
http://snapraid.sourceforge.net/linux/v5/
You can see the code coverage analysis made by lcov at:
http://snapraid.sourceforge.net/linux/v5/coverage/
Changes from v4 to v5:
- Adds more comments in the libraid patch.
- Reviews and completes the btrfs patch. The previous patch was not really working due some missing pieces.
- Adds a new patch for btrfs-progs to extend the mkfs.btrfs functionality to create filesystem with up to six parity levels.
- Removes the async_tx patch as not yet ready for inclusion.
Changes from v3 to v4:
- Adds a code coverage test
- Adds a matrix inversion test.
- Everything updated to kernel 3.13.
Changes from v2 to v3:
- Adds a new patch to change async_tx to use the new raid library for synchronous cases and to export a similar interface. Also modified md/raid5.c to use the new interface of async_tx. This is just example code not meant for inclusion!
- Renamed raid_par() to raid_gen() to match better existing naming.
- Removed raid_sort() and replaced with raid_insert() that allows to build a vector already in order instead of sorting it later. This function is declared in the new raid/helper.h.
- Better documentation in the raid.h/c files. Start from raid.h to see the documentation of the new interface.
Changes from v1 to v2:
- Adds a patch to btrfs to extend its support to more than double parity. This is just example code not meant for inclusion!
- Changes the main raid_rec() interface to merge the failed data and parity index vectors. This matches better the kernel usage.
- Uses alloc_pages_exact() instead of __get_free_pages().
- Removes unnecessary register loads from par1_sse().
- Converts the asm_begin/end() macros to inlined functions.
- Fixes some more checkpatch.pl warnings.
- Other minor style/comment changes.
Andrea Mazzoleni (2):
lib: raid: New RAID library supporting up to six parities
fs: btrfs: Adds new par3456 modes to support up to six parities
fs/btrfs/Kconfig | 1 + fs/btrfs/ctree.h | 50 +- fs/btrfs/disk-io.c | 7 +- fs/btrfs/extent-tree.c | 67 +- fs/btrfs/inode.c | 3 +- fs/btrfs/raid56.c | 273 +++----- fs/btrfs/raid56.h | 19 +- fs/btrfs/scrub.c | 3 +- fs/btrfs/volumes.c | 144 ++-- include/linux/raid/helper.h | 32 + include/linux/raid/raid.h | 87 +++ include/trace/events/btrfs.h | 16 +- include/uapi/linux/btrfs.h | 19 +- lib/Kconfig | 17 + lib/Makefile | 1 + lib/raid/.gitignore | 3 + lib/raid/Makefile | 14 + lib/raid/cpu.h | 44 ++ lib/raid/gf.h | 109 +++ lib/raid/helper.c | 38 + lib/raid/int.c | 567 +++++++++++++++ lib/raid/internal.h | 148 ++++ lib/raid/mktables.c | 383 +++++++++++ lib/raid/module.c | 458 ++++++++++++ lib/raid/raid.c | 492 +++++++++++++ lib/raid/test/Makefile | 72 ++ lib/raid/test/combo.h | 155 +++++ lib/raid/test/fulltest.c | 79 +++ lib/raid/test/invtest.c | 172 +++++ lib/raid/test/memory.c | 79 +++ lib/raid/test/memory.h | 78 +++ lib/raid/test/selftest.c | 44 ++ lib/raid/test/speedtest.c | 578 ++++++++++++++++ lib/raid/test/test.c | 314 +++++++++ lib/raid/test/test.h | 59 ++ lib/raid/test/usermode.h | 95 +++ lib/raid/test/xor.c | 41 ++ lib/raid/x86.c | 1565 ++++++++++++++++++++++++++++++++++++++++++ 38 files changed, 6037 insertions(+), 289 deletions(-) create mode 100644 include/linux/raid/helper.h create mode 100644 include/linux/raid/raid.h create mode 100644 lib/raid/.gitignore create mode 100644 lib/raid/Makefile create mode 100644 lib/raid/cpu.h create mode 100644 lib/raid/gf.h create mode 100644 lib/raid/helper.c create mode 100644 lib/raid/int.c create mode 100644 lib/raid/internal.h create mode 100644 lib/raid/mktables.c create mode 100644 lib/raid/module.c create mode 100644 lib/raid/raid.c create mode 100644 lib/raid/test/Makefile create mode 100644 lib/raid/test/combo.h create mode 100644 lib/raid/test/fulltest.c create mode 100644 lib/raid/test/invtest.c create mode 100644 lib/raid/test/memory.c create mode 100644 lib/raid/test/memory.h create mode 100644 lib/raid/test/selftest.c create mode 100644 lib/raid/test/speedtest.c create mode 100644 lib/raid/test/test.c create mode 100644 lib/raid/test/test.h create mode 100644 lib/raid/test/usermode.h create mode 100644 lib/raid/test/xor.c create mode 100644 lib/raid/x86.c
Signature · 1 line
1.7.12.1
PATCH v5 1/3 lib: raid: New RAID library supporting up to six parities
This patch adds a new lib/raid directory, containing a new RAID support based on a Cauchy matrix working for up to six parities, and backward compatible with the existing RAID6 support.
The interface is defined in include/linux/raid/raid.h and provides two new functions raid_gen() and raid_rec() that handle parity generation and data recovering for up to six level of redundancy, and replaces the previous RAID6 interface.
The library provides fast implementations using SSE2 and SSSE3 for x86/x64 and a portable C implementation working everywhere.
If the RAID6 library is enabled in the kernel, its functionality is also used to maintain the existing level of performance for the first two parities in architectures different than x86.
At startup the module runs a very fast self test (about 1ms) to ensure that the used functions are correct.
You can also enable a speed test similar at the one used by raid6, using the "speedtest=1" argument when loading the module.
In the lib/raid/test directory are present also some user mode test programs:
selftest - Runs the same selftest and speedtest executed at the module startup. fulltest - Runs a more extensive test that checks all the built-in functions. speetest - Runs a more complete speed test.
invtest - Runs an extensive matrix inversion test of all the 377.342.351.231
possible square submatrices of the Cauchy matrix used.
covtest - Runs a coverage test using lcov.
As a reference, in my icore7 2.7GHz the speedtest program reports:
...
Speed test using 16 data buffers of 4096 bytes, for a total of 64 KiB. Memory blocks have a displacement of 64 bytes to improve cache performance. The reported value is the aggregate bandwidth of all data blocks in MiB/s, not counting parity blocks.
Memory write speed using the C memset() function:
memset 33518
RAID functions used for computing the parity:
int8 int32 int64 sse2 sse2e ssse3 ssse3e
gen1 11762 21450 44621 gen2 3520 6176 18100 20338
gen3 848 8009 9210
gen4 659 6518 7303
gen5 531 4931 5363
gen6 430 4069 4471
RAID functions used for recovering:
int8 ssse3
rec1 591 1126
rec2 272 456
rec3 80 305
rec4 49 216
rec5 34 151...
Legend:
genX functions to generate X parities
recX functions to recover X data blocks
int8 implementation based on 8 bits arithmetics int32 implementation based on 32 bits arithmetics int64 implementation based on 64 bits arithmetics sse2 implementation based on SSE2
sse2e implementation based on SSE2 with 16 registers (x64) ssse3 implementation based on SSSE3
ssse3e implementation based on SSSE3 with 16 registers (x64)
--- include/linux/raid/helper.h | 32 + include/linux/raid/raid.h | 87 +++ lib/Kconfig | 17 + lib/Makefile | 1 + lib/raid/.gitignore | 3 + lib/raid/Makefile | 14 + lib/raid/cpu.h | 44 ++ lib/raid/gf.h | 109 +++ lib/raid/helper.c | 38 ++ lib/raid/int.c | 567 ++++++++++++++++ lib/raid/internal.h | 148 ++++ lib/raid/mktables.c | 383 +++++++++++ lib/raid/module.c | 458 +++++++++++++ lib/raid/raid.c | 492 ++++++++++++++ lib/raid/test/Makefile | 72 ++ lib/raid/test/combo.h | 155 +++++ lib/raid/test/fulltest.c | 79 +++ lib/raid/test/invtest.c | 172 +++++ lib/raid/test/memory.c | 79 +++ lib/raid/test/memory.h | 78 +++ lib/raid/test/selftest.c | 44 ++ lib/raid/test/speedtest.c | 578 ++++++++++++++++ lib/raid/test/test.c | 314 +++++++++ lib/raid/test/test.h | 59 ++ lib/raid/test/usermode.h | 95 +++ lib/raid/test/xor.c | 41 ++ lib/raid/x86.c | 1565 +++++++++++++++++++++++++++++++++++++++++++ 27 files changed, 5724 insertions(+) create mode 100644 include/linux/raid/helper.h create mode 100644 include/linux/raid/raid.h create mode 100644 lib/raid/.gitignore create mode 100644 lib/raid/Makefile create mode 100644 lib/raid/cpu.h create mode 100644 lib/raid/gf.h create mode 100644 lib/raid/helper.c create mode 100644 lib/raid/int.c create mode 100644 lib/raid/internal.h create mode 100644 lib/raid/mktables.c create mode 100644 lib/raid/module.c create mode 100644 lib/raid/raid.c create mode 100644 lib/raid/test/Makefile create mode 100644 lib/raid/test/combo.h create mode 100644 lib/raid/test/fulltest.c create mode 100644 lib/raid/test/invtest.c create mode 100644 lib/raid/test/memory.c create mode 100644 lib/raid/test/memory.h create mode 100644 lib/raid/test/selftest.c create mode 100644 lib/raid/test/speedtest.c create mode 100644 lib/raid/test/test.c create mode 100644 lib/raid/test/test.h create mode 100644 lib/raid/test/usermode.h create mode 100644 lib/raid/test/xor.c create mode 100644 lib/raid/x86.c
include/linux/raid/helper.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2013 Andrea Mazzoleni +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __RAID_HELPER_H +#define __RAID_HELPER_H + +/** +* Inserts an integer in a sorted vector. +* +* This function can be used to insert indexes in order, ready to be used for +* calling raid_rec(). +* +* @n Number of integers currently in the vector. +* @v Vector of integers already sorted. +* It must have extra space for the new elemet at the end. +* @i Value to insert. +*/ +void raid_insert (int n,int *v,int i); + +#endif +
include/linux/raid/raid.h new file +87 -0
87 lines not on this page · raw message
lib/Kconfig +17 -0
@@ -10,6 +10,23 @@ menu "Library routines" config RAID6_PQ tristate +config RAID_CAUCHY + tristate "RAID Cauchy functions" + help + This option enables the RAID parity library based on a Cauchy matrix + that supports up to six parities, and it's compatible with the + existing RAID6 support. + + This library provides optimized functions for triple parity and + beyond for architectures with SSSE3 support. + + The new interface is defined in the linux/raid/raid.h file. + If the RAID6 module is enabled, it's used to maintain the same + performance level for RAID5 and RAID6 in all the architectures + when using the new interface. + + Module will be called raid_cauchy. + config BITREVERSE tristate
lib/Makefile +1 -0
@@ -82,6 +82,7 @@ obj-$(CONFIG_LZ4HC_COMPRESS) += lz4/ obj-$(CONFIG_LZ4_DECOMPRESS) += lz4/ obj-$(CONFIG_XZ_DEC) += xz/ obj-$(CONFIG_RAID6_PQ) += raid6/ +obj-$(CONFIG_RAID_CAUCHY) += raid/ lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
lib/raid/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +mktables +tables.c +
lib/raid/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +obj-$(CONFIG_RAID_CAUCHY) += raid_cauchy.o + +raid_cauchy-y += module.o raid.o tables.o int.o helper.o + +raid_cauchy-$(CONFIG_X86) += x86.o + +hostprogs-y += mktables + +quiet_cmd_mktable = TABLE $@ + cmd_mktable = $(obj)/mktables > $@ || ( rm -f $@ && exit 1 ) + +targets += tables.c +$(obj)/tables.c: $(obj)/mktables FORCE + $(call if_changed,mktable)
lib/raid/cpu.h new file +44 -0
44 lines not on this page · raw message
lib/raid/gf.h new file +109 -0
109 lines not on this page · raw message
lib/raid/helper.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (C) 2013 Andrea Mazzoleni +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include "internal.h" + +void raid_insert (int n,int *v,int i) +{ +/* we don't use binary search because this is intended */ +/* for very small vectors and we want to optimize the case */ +/* of elements inserted already in order */ + +/* insert at the end */ + v[n] = i; + +/* swap until in the correct position */ +while (n >0 && v[n-1 ] > v[n]) { +/* swap */ +int t = v[n-1 ]; + v[n-1 ] = v[n]; + v[n] = t; + +/* previous position */ + --n; + } +} +EXPORT_SYMBOL_GPL (raid_insert); +
lib/raid/int.c new file +567 -0
567 lines not on this page · raw message
lib/raid/internal.h new file +148 -0
148 lines not on this page · raw message
lib/raid/mktables.c new file +383 -0
383 lines not on this page · raw message
lib/raid/module.c new file +458 -0
458 lines not on this page · raw message
lib/raid/raid.c new file +492 -0
492 lines not on this page · raw message
lib/raid/test/Makefile new file +72 -0
72 lines not on this page · raw message
lib/raid/test/combo.h new file +155 -0
155 lines not on this page · raw message
lib/raid/test/fulltest.c new file +79 -0
79 lines not on this page · raw message
lib/raid/test/invtest.c new file +172 -0
172 lines not on this page · raw message
lib/raid/test/memory.c new file +79 -0
79 lines not on this page · raw message
lib/raid/test/memory.h new file +78 -0
38 lines not on this page · raw message
lib/raid/test/selftest.c new file +44 -0
44 lines not on this page · raw message
lib/raid/test/speedtest.c new file +578 -0
578 lines not on this page · raw message
lib/raid/test/test.c new file +314 -0
314 lines not on this page · raw message
lib/raid/test/test.h new file +59 -0
59 lines not on this page · raw message
lib/raid/test/usermode.h new file +95 -0
95 lines not on this page · raw message
lib/raid/test/xor.c new file +41 -0
41 lines not on this page · raw message
lib/raid/x86.c new file +1565 -0
1,565 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.12.1
Part of the diff is not shown here. View the raw message.
PATCH v5 2/3 fs: btrfs: Adds new par3456 modes to support up to six parities
In reply to Andrea MazzoleniRemoves the RAID logic now handled in the new raid_gen() and raid_rec() calls that hide all the details.
Replaces the faila/failb failure indexes with a fail[] vector that keeps track of up to six failures.
Replaces the existing BLOCK_GROUP_RAID5/6 with new PAR1/2/3/4/5/6 ones that handle up to six parities, and updates all the code to use them.
--- fs/btrfs/Kconfig | 1 + fs/btrfs/ctree.h | 50 ++++++-- fs/btrfs/disk-io.c | 7 +- fs/btrfs/extent-tree.c | 67 +++++++---- fs/btrfs/inode.c | 3 +- fs/btrfs/raid56.c | 273 ++++++++++++++----------------------------- fs/btrfs/raid56.h | 19 ++- fs/btrfs/scrub.c | 3 +- fs/btrfs/volumes.c | 144 +++++++++++++++-------- include/trace/events/btrfs.h | 16 ++- include/uapi/linux/btrfs.h | 19 ++- 11 files changed, 313 insertions(+), 289 deletions(-)
fs/btrfs/Kconfig +1 -0
@@ -6,6 +6,7 @@ config BTRFS_FS select ZLIB_DEFLATE select LZO_COMPRESS select LZO_DECOMPRESS + select RAID_CAUCHY select RAID6_PQ select XOR_BLOCKS
fs/btrfs/ctree.h +43 -7
80 lines not on this page · raw message
fs/btrfs/disk-io.c +3 -4
@@ -3337,12 +3337,11 @@ int btrfs_calc_num_tolerated_disk_barrier_failures( num_tolerated_disk_barrier_failures =0 ; else if (num_tolerated_disk_barrier_failures > 1) {if (flags & (BTRFS_BLOCK_GROUP_RAID1 | -BTRFS_BLOCK_GROUP_RAID5 |BTRFS_BLOCK_GROUP_RAID10 )) { num_tolerated_disk_barrier_failures =1 ; - }else if (flags & -BTRFS_BLOCK_GROUP_RAID6 ) { - num_tolerated_disk_barrier_failures =2 ; + }else if (flags &BTRFS_BLOCK_GROUP_PARX ) { + num_tolerated_disk_barrier_failures + =btrfs_flags_par (flags); } } }
fs/btrfs/extent-tree.c +45 -22
115 lines not on this page · raw message
fs/btrfs/inode.c +1 -2
@@ -7184,8 +7184,7 @@ static int btrfs_submit_direct_hook(int rw, struct btrfs_dio_private *dip, }/* async crcs make it difficult to collect full stripe writes. */ -if (btrfs_get_alloc_profile (root,1 ) & - (BTRFS_BLOCK_GROUP_RAID5 |BTRFS_BLOCK_GROUP_RAID6 )) +if (btrfs_get_alloc_profile (root,1 ) &BTRFS_BLOCK_GROUP_PARX ) async_submit =0 ;else async_submit =1 ;
fs/btrfs/raid56.c +86 -187
450 lines not on this page · raw message
fs/btrfs/raid56.h +9 -10
@@ -21,23 +21,22 @@#define __BTRFS_RAID56__static inline int nr_parity_stripes (struct map_lookup *map) { -if (map->type &BTRFS_BLOCK_GROUP_RAID5 ) -return 1 ; -else if (map->type &BTRFS_BLOCK_GROUP_RAID6 ) -return 2 ; -else -return 0 ; +return btrfs_flags_par (map->type); }static inline int nr_data_stripes (struct map_lookup *map) {return map->num_stripes -nr_parity_stripes (map); } -#define RAID5_P_STRIPE ((u64)-2) -#define RAID6_Q_STRIPE ((u64)-1) -#define is_parity_stripe (x) (((x) == RAID5_P_STRIPE) || \ - ((x) == RAID6_Q_STRIPE)) +#define BTRFS_RAID_PAR1_STRIPE ((u64)-6) +#define BTRFS_RAID_PAR2_STRIPE ((u64)-5) +#define BTRFS_RAID_PAR3_STRIPE ((u64)-4) +#define BTRFS_RAID_PAR4_STRIPE ((u64)-3) +#define BTRFS_RAID_PAR5_STRIPE ((u64)-2) +#define BTRFS_RAID_PAR6_STRIPE ((u64)-1) + +#define is_parity_stripe (x) (((u64)(x) >= BTRFS_RAID_PAR1_STRIPE)) int raid56_parity_recover(struct btrfs_root *root, struct bio *bio, struct btrfs_bio *bbio, u64 *raid_map,
fs/btrfs/scrub.c +1 -2
@@ -2259,8 +2259,7 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,int extent_mirror_num;int stop_loop; -if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 )) { +if (map->type &BTRFS_BLOCK_GROUP_PARX ) {if (num >=nr_data_stripes (map)) {return 0 ; }
fs/btrfs/volumes.c +96 -48
283 lines not on this page · raw message
include/trace/events/btrfs.h +12 -4
@@ -58,8 +58,12 @@ struct extent_buffer; { BTRFS_BLOCK_GROUP_RAID1, "RAID1"}, \ { BTRFS_BLOCK_GROUP_DUP, "DUP"}, \ { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ - { BTRFS_BLOCK_GROUP_RAID5, "RAID5"}, \ - { BTRFS_BLOCK_GROUP_RAID6, "RAID6"} + { BTRFS_BLOCK_GROUP_PAR1, "RAID5"}, \ + { BTRFS_BLOCK_GROUP_PAR2, "RAID6"}, \ + { BTRFS_BLOCK_GROUP_PAR3, "PAR3"}, \ + { BTRFS_BLOCK_GROUP_PAR4, "PAR4"}, \ + { BTRFS_BLOCK_GROUP_PAR5, "PAR5"}, \ + { BTRFS_BLOCK_GROUP_PAR6, "PAR6"} #define BTRFS_UUID_SIZE 16
@@ -623,8 +627,12 @@ DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head, { BTRFS_BLOCK_GROUP_RAID1, "RAID1" }, \ { BTRFS_BLOCK_GROUP_DUP, "DUP" }, \ { BTRFS_BLOCK_GROUP_RAID10, "RAID10"}, \ - { BTRFS_BLOCK_GROUP_RAID5, "RAID5" }, \ - { BTRFS_BLOCK_GROUP_RAID6, "RAID6" }) + { BTRFS_BLOCK_GROUP_PAR1, "RAID5" }, \ + { BTRFS_BLOCK_GROUP_PAR2, "RAID6" }, \ + { BTRFS_BLOCK_GROUP_PAR3, "PAR3" }, \ + { BTRFS_BLOCK_GROUP_PAR4, "PAR4" }, \ + { BTRFS_BLOCK_GROUP_PAR5, "PAR5" }, \ + { BTRFS_BLOCK_GROUP_PAR6, "PAR6" }) DECLARE_EVENT_CLASS(btrfs__chunk,
include/uapi/linux/btrfs.h +16 -3
@@ -488,8 +488,13 @@ enum btrfs_err_code {BTRFS_ERROR_DEV_TGT_REPLACE ,BTRFS_ERROR_DEV_MISSING_NOT_FOUND ,BTRFS_ERROR_DEV_ONLY_WRITABLE , - BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS +BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS , +BTRFS_ERROR_DEV_PAR3_MIN_NOT_MET , +BTRFS_ERROR_DEV_PAR4_MIN_NOT_MET , +BTRFS_ERROR_DEV_PAR5_MIN_NOT_MET , + BTRFS_ERROR_DEV_PAR6_MIN_NOT_MET }; +/* An error code to error string mapping for the kernel * error codes */
@@ -501,9 +506,9 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET :return "unable to go below four devices on raid10" ;case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET : -return "unable to go below two devices on raid5" ; +return "unable to go below two devices on raid5/par1" ;case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET : -return "unable to go below three devices on raid6" ; +return "unable to go below three devices on raid6/par2" ;case BTRFS_ERROR_DEV_TGT_REPLACE :return "unable to remove the dev_replace target dev" ;case BTRFS_ERROR_DEV_MISSING_NOT_FOUND :
@@ -513,6 +518,14 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS :return "add/delete/balance/replace/resize operation " \"in progress" ; +case BTRFS_ERROR_DEV_PAR3_MIN_NOT_MET : +return "unable to go below four devices on par3" ; +case BTRFS_ERROR_DEV_PAR4_MIN_NOT_MET : +return "unable to go below five devices on par4" ; +case BTRFS_ERROR_DEV_PAR5_MIN_NOT_MET : +return "unable to go below six devices on par5" ; +case BTRFS_ERROR_DEV_PAR6_MIN_NOT_MET : +return "unable to go below seven devices on par5" ;default :return NULL ; }
Signature · 1 line
1.7.12.1
PATCH v5 3/3 btrfs-progs: Adds new par3456 modes to support up to six parities
In reply to Andrea MazzoleniExtends mkfs.btrfs to support the new par1/2/3/4/5/6 modes to create filesystem with up to six parities.
Replaces the raid6 code with a new references function able to compute up to six parities.
Replaces the existing BLOCK_GROUP_RAID5/6 with new PAR1/2/3/4/5/6 ones that handle up to six parities, and updates all the code to use them.
--- Makefile | 14 ++- chunk-recover.c | 18 +--- cmds-balance.c | 20 +++- cmds-check.c | 7 +- cmds-chunk.c | 18 +--- cmds-filesystem.c | 12 ++- ctree.h | 42 ++++++++- disk-io.h | 2 - extent-tree.c | 3 +- ioctl.h | 18 +++- man/mkfs.btrfs.8.in | 4 +- mkfs.c | 28 +++++- mktables.c | 256 ++++++++++++++++++++++++++++++++++++++++++++++++++++ raid.c | 44 +++++++++ raid.h | 34 +++++++ raid6.c | 101 --------------------- utils.c | 12 ++- volumes.c | 112 ++++++++++------------- volumes.h | 12 ++- 19 files changed, 530 insertions(+), 227 deletions(-) create mode 100644 mktables.c create mode 100644 raid.c create mode 100644 raid.h delete mode 100644 raid6.c
Makefile +11 -3
@@ -9,7 +9,7 @@ CFLAGS = -g -O1 -fno-strict-aliasing 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 \ extent-cache.o extent_io.o volumes.o utils.o repair.o \ - qgroup.o raid6.o free-space-cache.o list_sort.o + qgroup.o raid.o tables.o free-space-cache.o list_sort.o cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \ cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
@@ -140,6 +140,10 @@ version.h: @echo " [SH] $@" $(Q)bash version.sh +tables.c: mktables + @echo " [MK] $@" + $(Q)./mktables > tables.c + $(libs_shared): $(libbtrfs_objects) $(lib_links) send.h @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(lib_LIBS) \
@@ -193,6 +197,10 @@ mkfs.btrfs: $(objects) $(libs) mkfs.o @echo " [LD] $@" $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS) +mktables: $(libs) mktables.o + @echo " [LD] $@" + $(Q)$(CC) $(CFLAGS) -o mktables mktables.o $(LDFLAGS) $(LIBS) + mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects) @echo " [LD] $@" $(Q)$(CC) $(STATIC_CFLAGS) -o mkfs.btrfs.static mkfs.static.o $(static_objects) \
@@ -225,8 +233,8 @@ clean: $(CLEANDIRS) @echo "Cleaning" $(Q)rm -f $(progs) cscope.out *.o *.o.d btrfs-convert btrfs-image btrfs-select-super \ btrfs-zero-log btrfstune dir-test ioctl-test quick-test send-test btrfsck \ - btrfs.static mkfs.btrfs.static btrfs-calc-size \ - version.h $(check_defs) \ + btrfs.static mkfs.btrfs.static btrfs-calc-size mktables \ + version.h tables.c $(check_defs) \ $(libs) $(lib_links) $(CLEANDIRS):
chunk-recover.c +5 -13
@@ -1327,8 +1327,7 @@ static int calc_num_stripes(u64 type) {if (type & (BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID10 | -BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 )) +BTRFS_BLOCK_GROUP_PARX ))return 0 ;else if (type & (BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_DUP ))
@@ -1404,13 +1403,8 @@ static int btrfs_calc_stripe_index(struct chunk_record *chunk, u64 logical) }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID10 ) { index = stripe_nr % (chunk->num_stripes / chunk->sub_stripes); index *= chunk->sub_stripes; - }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID5 ) { - nr_data_stripes = chunk->num_stripes -1 ; - index = stripe_nr % nr_data_stripes; - stripe_nr /= nr_data_stripes; - index = (index + stripe_nr) % chunk->num_stripes; - }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID6 ) { - nr_data_stripes = chunk->num_stripes -2 ; + }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_PARX ) { + nr_data_stripes = chunk->num_stripes -btrfs_flags_par (chunk->type_flags); index = stripe_nr % nr_data_stripes; stripe_nr /= nr_data_stripes; index = (index + stripe_nr) % chunk->num_stripes;
@@ -1503,8 +1497,7 @@ no_extent_record:if (list_empty (&devexts))return 0 ; -if (chunk->type_flags & (BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 )) { +if (chunk->type_flags &BTRFS_BLOCK_GROUP_PARX ) {/* Fixme: try to recover the order by the parity block. */ list_splice_tail (&devexts, &chunk->dextents);return -EINVAL ;
@@ -1540,8 +1533,7 @@ no_extent_record:#define BTRFS_ORDERED_RAID (BTRFS_BLOCK_GROUP_RAID0 | \ BTRFS_BLOCK_GROUP_RAID10 | \ - BTRFS_BLOCK_GROUP_RAID5 | \ - BTRFS_BLOCK_GROUP_RAID6) + BTRFS_BLOCK_GROUP_PARX)static int btrfs_rebuild_chunk_stripes (struct recover_control *rc,struct chunk_record *chunk)
cmds-balance.c +16 -4
@@ -48,10 +48,22 @@ static int parse_one_profile(const char *profile, u64 *flags) *flags |=BTRFS_BLOCK_GROUP_RAID1 ; }else if (!strcmp (profile,"raid10" )) { *flags |=BTRFS_BLOCK_GROUP_RAID10 ; - }else if (!strcmp (profile,"raid5" )) { - *flags |=BTRFS_BLOCK_GROUP_RAID5 ; - }else if (!strcmp (profile,"raid6" )) { - *flags |=BTRFS_BLOCK_GROUP_RAID6 ; + }else if (!strcmp (profile,"raid5" )) {/* synonymous of "par1" */ + *flags |=BTRFS_BLOCK_GROUP_PAR1 ; + }else if (!strcmp (profile,"raid6" )) {/* synonymous of "par2" */ + *flags |=BTRFS_BLOCK_GROUP_PAR2 ; + }else if (!strcmp (profile,"par1" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR1 ; + }else if (!strcmp (profile,"par2" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR2 ; + }else if (!strcmp (profile,"par3" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR3 ; + }else if (!strcmp (profile,"par4" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR4 ; + }else if (!strcmp (profile,"par5" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR5 ; + }else if (!strcmp (profile,"par6" )) { + *flags |=BTRFS_BLOCK_GROUP_PAR6 ; }else if (!strcmp (profile,"dup" )) { *flags |=BTRFS_BLOCK_GROUP_DUP ; }else if (!strcmp (profile,"single" )) {
cmds-check.c +2 -5
@@ -5189,12 +5189,9 @@ u64 calc_stripe_length(u64 type, u64 length, int num_stripes) }else if (type &BTRFS_BLOCK_GROUP_RAID10 ) { stripe_size = length *2 ; stripe_size /= num_stripes; - }else if (type &BTRFS_BLOCK_GROUP_RAID5 ) { + }else if (type &BTRFS_BLOCK_GROUP_PARX ) { stripe_size = length; - stripe_size /= (num_stripes -1 ); - }else if (type &BTRFS_BLOCK_GROUP_RAID6 ) { - stripe_size = length; - stripe_size /= (num_stripes -2 ); + stripe_size /= num_stripes -btrfs_flags_par (type); }else { stripe_size = length; }
cmds-chunk.c +5 -13
@@ -1347,8 +1347,7 @@ static int calc_num_stripes(u64 type) {if (type & (BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID10 | -BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 )) +BTRFS_BLOCK_GROUP_PARX ))return 0 ;else if (type & (BTRFS_BLOCK_GROUP_RAID1 |BTRFS_BLOCK_GROUP_DUP ))
@@ -1424,13 +1423,8 @@ static int btrfs_calc_stripe_index(struct chunk_record *chunk, u64 logical) }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID10 ) { index = stripe_nr % (chunk->num_stripes / chunk->sub_stripes); index *= chunk->sub_stripes; - }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID5 ) { - nr_data_stripes = chunk->num_stripes -1 ; - index = stripe_nr % nr_data_stripes; - stripe_nr /= nr_data_stripes; - index = (index + stripe_nr) % chunk->num_stripes; - }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_RAID6 ) { - nr_data_stripes = chunk->num_stripes -2 ; + }else if (chunk->type_flags &BTRFS_BLOCK_GROUP_PARX ) { + nr_data_stripes = chunk->num_stripes -btrfs_flags_par (chunk->type_flags); index = stripe_nr % nr_data_stripes; stripe_nr /= nr_data_stripes; index = (index + stripe_nr) % chunk->num_stripes;
@@ -1523,8 +1517,7 @@ no_extent_record:if (list_empty (&devexts))return 0 ; -if (chunk->type_flags & (BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 )) { +if (chunk->type_flags &BTRFS_BLOCK_GROUP_PARX ) {/* Fixme: try to recover the order by the parity block. */ list_splice_tail (&devexts, &chunk->dextents);return -EINVAL ;
@@ -1560,8 +1553,7 @@ no_extent_record:#define BTRFS_ORDERED_RAID (BTRFS_BLOCK_GROUP_RAID0 | \ BTRFS_BLOCK_GROUP_RAID10 | \ - BTRFS_BLOCK_GROUP_RAID5 | \ - BTRFS_BLOCK_GROUP_RAID6) + BTRFS_BLOCK_GROUP_PARX)static int btrfs_rebuild_chunk_stripes (struct recover_control *rc,struct chunk_record *chunk)
cmds-filesystem.c +10 -2
@@ -142,10 +142,18 @@ static char *group_profile_str(u64 flag)return "RAID0" ;case BTRFS_BLOCK_GROUP_RAID1 :return "RAID1" ; -case BTRFS_BLOCK_GROUP_RAID5 : +case BTRFS_BLOCK_GROUP_PAR1 :return "RAID5" ; -case BTRFS_BLOCK_GROUP_RAID6 : +case BTRFS_BLOCK_GROUP_PAR2 :return "RAID6" ; +case BTRFS_BLOCK_GROUP_PAR3 : +return "PAR3" ; +case BTRFS_BLOCK_GROUP_PAR4 : +return "PAR4" ; +case BTRFS_BLOCK_GROUP_PAR5 : +return "PAR5" ; +case BTRFS_BLOCK_GROUP_PAR6 : +return "PAR6" ;case BTRFS_BLOCK_GROUP_DUP :return "DUP" ;case BTRFS_BLOCK_GROUP_RAID10 :
ctree.h +37 -5
66 lines not on this page · raw message
disk-io.h +0 -2
@@ -110,5 +110,3 @@ int write_and_map_eb(struct btrfs_trans_handle *trans, struct btrfs_root *root, struct extent_buffer *eb);#endif -/* raid6.c */ -void raid6_gen_syndrome (int disks,size_t bytes,void **ptrs);
extent-tree.c +1 -2
@@ -1862,8 +1862,7 @@ 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_RAID10 | -BTRFS_BLOCK_GROUP_RAID5 | -BTRFS_BLOCK_GROUP_RAID6 | +BTRFS_BLOCK_GROUP_PARX |BTRFS_BLOCK_GROUP_DUP );if (extra_flags) {if (flags &BTRFS_BLOCK_GROUP_DATA )
ioctl.h +15 -3
@@ -466,7 +466,11 @@ enum btrfs_err_code {BTRFS_ERROR_DEV_TGT_REPLACE ,BTRFS_ERROR_DEV_MISSING_NOT_FOUND ,BTRFS_ERROR_DEV_ONLY_WRITABLE , - BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS +BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS , +BTRFS_ERROR_DEV_PAR3_MIN_NOT_MET , +BTRFS_ERROR_DEV_PAR4_MIN_NOT_MET , +BTRFS_ERROR_DEV_PAR5_MIN_NOT_MET , + BTRFS_ERROR_DEV_PAR6_MIN_NOT_MET };/* An error code to error string mapping for the kernel
@@ -480,9 +484,9 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET :return "unable to go below four devices on raid10" ;case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET : -return "unable to go below three devices on raid5" ; +return "unable to go below two devices on raid5/par1" ;case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET : -return "unable to go below four devices on raid6" ; +return "unable to go below three devices on raid6/par2" ;case BTRFS_ERROR_DEV_TGT_REPLACE :return "unable to remove the dev_replace target dev" ;case BTRFS_ERROR_DEV_MISSING_NOT_FOUND :
@@ -492,6 +496,14 @@ static inline char *btrfs_err_str(enum btrfs_err_code err_code)case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS :return "add/delete/balance/replace/resize operation " "in progress" ; +case BTRFS_ERROR_DEV_PAR3_MIN_NOT_MET : +return "unable to go below four devices on par3" ; +case BTRFS_ERROR_DEV_PAR4_MIN_NOT_MET : +return "unable to go below five devices on par4" ; +case BTRFS_ERROR_DEV_PAR5_MIN_NOT_MET : +return "unable to go below six devices on par5" ; +case BTRFS_ERROR_DEV_PAR6_MIN_NOT_MET : +return "unable to go below seven devices on par5" ;default :return NULL ; }
man/mkfs.btrfs.8.in +3 -1
@@ -38,7 +38,9 @@ mkfs.btrfs uses all the available storage for the filesystem. .TP \fB\-d\fR, \fB\-\-data \fItype\fR Specify how the data must be spanned across the devices specified. Valid -values are raid0, raid1, raid5, raid6, raid10 or single. +values are raid0, raid1, raid5, raid6, raid10, par1, par2, par3, par4, par5, +par6 or single. The parX values enable RAID for up to six parity levels. +Note that raid5 and raid6 are synonymous of par1 and par2. .TP \fB\-f\fR, \fB\-\-force\fR Force overwrite when an existing filesystem is detected on the device.
mkfs.c +24 -4
@@ -276,7 +276,7 @@ static void print_usage(void)fprintf (stderr,"options:\n" );fprintf (stderr,"\t -A --alloc-start the offset to start the FS\n" );fprintf (stderr,"\t -b --byte-count total number of bytes in the FS\n" ); -fprintf (stderr,"\t -d --data data profile, raid0, raid1, raid5, raid6, raid10, dup or single\n" ); +fprintf (stderr,"\t -d --data data profile, raid0, raid1, raid5, raid6, par[1,2,3,4,5,6], raid10, dup or single\n" );fprintf (stderr,"\t -f --force force overwrite of existing filesystem\n" );fprintf (stderr,"\t -l --leafsize size of btree leaves\n" );fprintf (stderr,"\t -L --label set a label\n" );
@@ -306,9 +306,21 @@ static u64 parse_profile(char *s) }else if (strcmp (s,"raid1" ) ==0 ) {return BTRFS_BLOCK_GROUP_RAID1 ; }else if (strcmp (s,"raid5" ) ==0 ) { -return BTRFS_BLOCK_GROUP_RAID5 ; +return BTRFS_BLOCK_GROUP_PAR1 ; }else if (strcmp (s,"raid6" ) ==0 ) { -return BTRFS_BLOCK_GROUP_RAID6 ; +return BTRFS_BLOCK_GROUP_PAR2 ; + }else if (strcmp (s,"par1" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR1 ; + }else if (strcmp (s,"par2" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR2 ; + }else if (strcmp (s,"par3" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR3 ; + }else if (strcmp (s,"par4" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR4 ; + }else if (strcmp (s,"par5" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR5 ; + }else if (strcmp (s,"par6" ) ==0 ) { +return BTRFS_BLOCK_GROUP_PAR6 ; }else if (strcmp (s,"raid10" ) ==0 ) {return BTRFS_BLOCK_GROUP_RAID10 ; }else if (strcmp (s,"dup" ) ==0 ) {
@@ -1147,6 +1159,8 @@ static const struct btrfs_fs_feature { "raid56 extended format" }, {"skinny-metadata" ,BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA , "reduced-size metadata extent refs" }, + { "par3456", BTRFS_FEATURE_INCOMPAT_PAR3456, + "raid support with up to six parities" },/* Keep this one last */ { "list-all", BTRFS_FEATURE_LIST_ALL, NULL } };
@@ -1491,10 +1505,16 @@ int main(int ac, char **av) features |=BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS ;if ((data_profile | metadata_profile) & - (BTRFS_BLOCK_GROUP_RAID5 |BTRFS_BLOCK_GROUP_RAID6 )) { + (BTRFS_BLOCK_GROUP_PAR1 |BTRFS_BLOCK_GROUP_PAR2 )) { features |=BTRFS_FEATURE_INCOMPAT_RAID56 ; } +if ((data_profile | metadata_profile) & + (BTRFS_BLOCK_GROUP_PAR3 |BTRFS_BLOCK_GROUP_PAR4 + |BTRFS_BLOCK_GROUP_PAR5 |BTRFS_BLOCK_GROUP_PAR6 )) { + features |=BTRFS_FEATURE_INCOMPAT_PAR3456 ; + } +process_fs_features (features); ret = make_btrfs(fd, file, label, blocks, dev_block_count,
mktables.c new file +256 -0
256 lines not on this page · raw message
raid.c new file +44 -0
44 lines not on this page · raw message
raid.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Copyright (C) 2013 Andrea Mazzoleni +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef __RAID_H +#define __RAID_H + +#include "kerncompat.h" + +/* +* Max number of parities supported. +*/ +#define RAID_PARITY_MAX 6 + +/* +* Generate the RAID Cauchy parity. +* +* Note that this is the slow reference implementation. +* For a faster one and documentation see lib/raid/raid.c in the Linux Kernel. +*/ +void raid_gen (int nd,int np,size_t size,void **vv); + +#endif +
raid6.c deleted +0 -101
101 lines not on this page · raw message
utils.c +9 -3
@@ -1856,13 +1856,19 @@ int test_num_disk_vs_raid(u64 metadata_profile, u64 data_profile,switch (dev_cnt) {default : +case 7 : + allowed |=BTRFS_BLOCK_GROUP_PAR6 ; +case 6 : + allowed |=BTRFS_BLOCK_GROUP_PAR5 ; +case 5 : + allowed |=BTRFS_BLOCK_GROUP_PAR4 ;case 4 : - allowed |=BTRFS_BLOCK_GROUP_RAID10 ; + allowed |=BTRFS_BLOCK_GROUP_RAID10 |BTRFS_BLOCK_GROUP_PAR3 ;case 3 : - allowed |=BTRFS_BLOCK_GROUP_RAID6 ; + allowed |=BTRFS_BLOCK_GROUP_PAR2 ;case 2 : allowed |=BTRFS_BLOCK_GROUP_RAID0 |BTRFS_BLOCK_GROUP_RAID1 | -BTRFS_BLOCK_GROUP_RAID5 ; +BTRFS_BLOCK_GROUP_PAR1 ;break ;case 1 : allowed |=BTRFS_BLOCK_GROUP_DUP ;
volumes.c +49 -63
242 lines not on this page · raw message
volumes.h +9 -3
@@ -137,9 +137,15 @@ struct map_lookup {#define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)#define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9) -#define BTRFS_RAID5_P_STRIPE ((u64)-2) -#define BTRFS_RAID6_Q_STRIPE ((u64)-1) - +/* +* Parity stripe indexes. +*/ +#define BTRFS_RAID_PAR1_STRIPE ((u64)-6) +#define BTRFS_RAID_PAR2_STRIPE ((u64)-5) +#define BTRFS_RAID_PAR3_STRIPE ((u64)-4) +#define BTRFS_RAID_PAR4_STRIPE ((u64)-3) +#define BTRFS_RAID_PAR5_STRIPE ((u64)-2) +#define BTRFS_RAID_PAR6_STRIPE ((u64)-1) int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, u64 logical, u64 *length, u64 *type,
Signature · 1 line
1.7.12.1