From: NeilBrown <neilb@suse.de>
To: mwilck@arcor.de
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH 12/27] DDF: layout_md2ddf: new md->DDF layout conversion
Date: Mon, 8 Jul 2013 16:28:00 +1000 [thread overview]
Message-ID: <20130708162800.11ddbc84@notabene.brown> (raw)
In-Reply-To: <1372883287-8859-13-git-send-email-mwilck@arcor.de>
[-- Attachment #1: Type: text/plain, Size: 6910 bytes --]
On Wed, 3 Jul 2013 22:27:52 +0200 mwilck@arcor.de wrote:
> Support for RAID 10 makes it necessary to rewrite the algorithm
> for deriving DDF layout from MD layout. The functions level_to_prl
> and layout_to_rlq are combined in a single function that takes
> md layout parameters and converts them to DDF.
>
> Signed-off-by: Martin Wilck <mwilck@arcor.de>
> ---
> super-ddf.c | 178 ++++++++++++++++++++++++++++++++++++++---------------------
> 1 files changed, 114 insertions(+), 64 deletions(-)
>
> diff --git a/super-ddf.c b/super-ddf.c
> index a43401e..933485d 100644
> --- a/super-ddf.c
> +++ b/super-ddf.c
> @@ -484,6 +484,107 @@ static unsigned int calc_crc(void *buf, int len)
> return __cpu_to_be32(newcrc);
> }
>
> +#define DDF_INVALID_LEVEL 0xff
> +#define DDF_NO_SECONDARY 0xff
> +static int err_bad_md_layout(const mdu_array_info_t *array)
> +{
> + pr_err("RAID%d layout %x with %d disks is unsupported for DDF\n",
> + array->level, array->layout, array->raid_disks);
> + return DDF_INVALID_LEVEL;
> +}
> +
> +static int layout_md2ddf(const mdu_array_info_t *array,
> + struct vd_config *conf)
> +{
> + __u16 prim_elmnt_count = __cpu_to_be16(array->raid_disks);
> + __u8 prl = DDF_INVALID_LEVEL, rlq = 0;
> + __u8 sec_elmnt_count = 1;
> + __u8 srl = DDF_NO_SECONDARY;
> +
> + switch (array->level) {
> + case LEVEL_LINEAR:
> + prl = DDF_CONCAT;
> + break;
> + case 0:
> + rlq = DDF_RAID0_SIMPLE;
> + prl = DDF_RAID0;
> + break;
> + case 1:
> + switch (array->raid_disks) {
> + case 2:
> + rlq = DDF_RAID1_SIMPLE;
> + break;
> + case 3:
> + rlq = DDF_RAID1_MULTI;
> + break;
> + default:
> + return err_bad_md_layout(array);
> + }
> + prl = DDF_RAID1;
> + break;
> + case 4:
> + if (array->layout != 0)
> + return err_bad_md_layout(array);
> + rlq = DDF_RAID4_N;
> + prl = DDF_RAID4;
> + break;
> + case 5:
> + switch (array->layout) {
> + case ALGORITHM_LEFT_ASYMMETRIC:
> + rlq = DDF_RAID5_N_RESTART;
> + break;
> + case ALGORITHM_RIGHT_ASYMMETRIC:
> + rlq = DDF_RAID5_0_RESTART;
> + break;
> + case ALGORITHM_LEFT_SYMMETRIC:
> + rlq = DDF_RAID5_N_CONTINUE;
> + break;
> + case ALGORITHM_RIGHT_SYMMETRIC:
> + /* not mentioned in standard */
> + return err_bad_md_layout(array);
You need a 'default:' case here to throw an error.
> + }
> + prl = DDF_RAID5;
> + break;
> + case 6:
> + switch (array->layout) {
> + case ALGORITHM_ROTATING_N_RESTART:
> + rlq = DDF_RAID5_N_RESTART;
> + break;
> + case ALGORITHM_ROTATING_ZERO_RESTART:
> + rlq = DDF_RAID6_0_RESTART;
> + break;
> + case ALGORITHM_ROTATING_N_CONTINUE:
> + rlq = DDF_RAID5_N_CONTINUE;
> + break;
> + }
Ditto here.
I've made those two changes to the patch.
NeilBrown
> + prl = DDF_RAID6;
> + break;
> + case 10:
> + if (array->raid_disks % 2 == 0 && array->layout == 0x102) {
> + rlq = DDF_RAID1_SIMPLE;
> + prim_elmnt_count = __cpu_to_be16(2);
> + sec_elmnt_count = array->raid_disks / 2;
> + } else if (array->raid_disks % 3 == 0
> + && array->layout == 0x103) {
> + rlq = DDF_RAID1_MULTI;
> + prim_elmnt_count = __cpu_to_be16(3);
> + sec_elmnt_count = array->raid_disks / 3;
> + } else
> + return err_bad_md_layout(array);
> + srl = DDF_2SPANNED;
> + prl = DDF_RAID1;
> + break;
> + default:
> + return err_bad_md_layout(array);
> + }
> + conf->prl = prl;
> + conf->prim_elmnt_count = prim_elmnt_count;
> + conf->rlq = rlq;
> + conf->srl = srl;
> + conf->sec_elmnt_count = sec_elmnt_count;
> + return 0;
> +}
> +
> static int err_bad_ddf_layout(const struct vd_config *conf)
> {
> pr_err("DDF RAID %u qualifier %u with %u disks is unsupported\n",
> @@ -2150,59 +2251,6 @@ static int chunk_to_shift(int chunksize)
> return ffs(chunksize/512)-1;
> }
>
> -static int level_to_prl(int level)
> -{
> - switch (level) {
> - case LEVEL_LINEAR: return DDF_CONCAT;
> - case 0: return DDF_RAID0;
> - case 1: return DDF_RAID1;
> - case 4: return DDF_RAID4;
> - case 5: return DDF_RAID5;
> - case 6: return DDF_RAID6;
> - default: return -1;
> - }
> -}
> -
> -static int layout_to_rlq(int level, int layout, int raiddisks)
> -{
> - switch(level) {
> - case 0:
> - return DDF_RAID0_SIMPLE;
> - case 1:
> - switch(raiddisks) {
> - case 2: return DDF_RAID1_SIMPLE;
> - case 3: return DDF_RAID1_MULTI;
> - default: return -1;
> - }
> - case 4:
> - switch(layout) {
> - case 0: return DDF_RAID4_N;
> - }
> - break;
> - case 5:
> - switch(layout) {
> - case ALGORITHM_LEFT_ASYMMETRIC:
> - return DDF_RAID5_N_RESTART;
> - case ALGORITHM_RIGHT_ASYMMETRIC:
> - return DDF_RAID5_0_RESTART;
> - case ALGORITHM_LEFT_SYMMETRIC:
> - return DDF_RAID5_N_CONTINUE;
> - case ALGORITHM_RIGHT_SYMMETRIC:
> - return -1; /* not mentioned in standard */
> - }
> - case 6:
> - switch(layout) {
> - case ALGORITHM_ROTATING_N_RESTART:
> - return DDF_RAID5_N_RESTART;
> - case ALGORITHM_ROTATING_ZERO_RESTART:
> - return DDF_RAID6_0_RESTART;
> - case ALGORITHM_ROTATING_N_CONTINUE:
> - return DDF_RAID5_N_CONTINUE;
> - }
> - }
> - return -1;
> -}
> -
> #ifndef MDASSEMBLE
> struct extent {
> unsigned long long start, size;
> @@ -2320,13 +2368,15 @@ static int init_super_ddf_bvd(struct supertype *st,
> vc->timestamp = __cpu_to_be32(time(0)-DECADE);
> vc->seqnum = __cpu_to_be32(1);
> memset(vc->pad0, 0xff, 24);
> - vc->prim_elmnt_count = __cpu_to_be16(info->raid_disks);
> vc->chunk_shift = chunk_to_shift(info->chunk_size);
> - vc->prl = level_to_prl(info->level);
> - vc->rlq = layout_to_rlq(info->level, info->layout, info->raid_disks);
> - vc->sec_elmnt_count = 1;
> + if (layout_md2ddf(info, vc) == -1 ||
> + __be16_to_cpu(vc->prim_elmnt_count) > ddf->mppe) {
> + pr_err("%s: unsupported RAID level/layout %d/%d with %d disks\n",
> + __func__, info->level, info->layout, info->raid_disks);
> + free(vcl);
> + return 0;
> + }
> vc->sec_elmnt_seq = 0;
> - vc->srl = 0;
> vc->blocks = __cpu_to_be64(info->size * 2);
> vc->array_blocks = __cpu_to_be64(
> calc_array_size(info->level, info->raid_disks, info->layout,
> @@ -2990,12 +3040,12 @@ static int validate_geometry_ddf(struct supertype *st,
> }
>
> if (!dev) {
> - /* Initial sanity check. Exclude illegal levels. */
> - int i;
> - for (i=0; ddf_level_num[i].num1 != MAXINT; i++)
> - if (ddf_level_num[i].num2 == level)
> - break;
> - if (ddf_level_num[i].num1 == MAXINT) {
> + mdu_array_info_t array = {
> + .level = level, .layout = layout,
> + .raid_disks = raiddisks
> + };
> + struct vd_config conf;
> + if (layout_md2ddf(&array, &conf) == -1) {
> if (verbose)
> pr_err("DDF does not support level %d arrays\n",
> level);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2013-07-08 6:28 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 20:27 DDF/RAID10 patch series mwilck
2013-07-03 20:27 ` [PATCH 01/27] DDF (cleanup): use a common macro for failed searches mwilck
2013-07-03 20:27 ` [PATCH 02/27] DDF: check_secondary: fix treatment of missing BVDs mwilck
2013-07-03 20:27 ` [PATCH 03/27] DDF: load_ddf_headers: use secondary header as fallback mwilck
2013-07-08 5:43 ` NeilBrown
2013-07-08 20:56 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 04/27] DDF: handle "open flag" according to spec mwilck
2013-07-03 20:27 ` [PATCH 05/27] DDF: Implement store_super_ddf mwilck
2013-07-08 5:48 ` NeilBrown
2013-07-10 17:37 ` Martin Wilck
2013-07-15 5:31 ` NeilBrown
2013-07-18 18:48 ` [PATCH 1/3] DDF: increase seq number in ddf_set_updates_pending mwilck
2013-07-18 18:49 ` [PATCH 2/3] DDF: make "null_aligned" a static buffer mwilck
2013-07-18 18:49 ` [PATCH 3/3] DDF: factor out writing super block to single disk mwilck
2013-07-18 18:51 ` [PATCH 05/27] DDF: Implement store_super_ddf Martin Wilck
2013-07-03 20:27 ` [PATCH 06/27] DDF: ddf_open_new: implement minimal consistency check mwilck
2013-07-03 20:27 ` [PATCH 07/27] DDF: find_vdcr: account for secondary RAID level mwilck
2013-07-08 6:16 ` NeilBrown
2013-07-08 21:03 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 08/27] DDF: ddf_set_disk: move status logic to separate function mwilck
2013-07-03 20:27 ` [PATCH 09/27] DDF: get_svd_state: Status logic for secondary RAID level mwilck
2013-07-03 20:27 ` [PATCH 10/27] DDF: allow empty slots in virt disk table mwilck
2013-07-03 20:27 ` [PATCH 11/27] DDF: layout_ddf2md: new DDF->md RAID layout conversion mwilck
2013-07-08 6:48 ` NeilBrown
2013-07-08 21:06 ` Martin Wilck
2013-07-03 20:27 ` [PATCH 12/27] DDF: layout_md2ddf: new md->DDF " mwilck
2013-07-08 6:28 ` NeilBrown [this message]
2013-07-03 20:27 ` [PATCH 13/27] DDF: Simplify allocation of "other BVDs" mwilck
2013-07-03 20:27 ` [PATCH 14/27] DDF: init_super_ddf_bvd: initialize other bvds mwilck
2013-07-03 20:27 ` [PATCH 15/27] DDF: validate_geometry_ddf: support RAID10 mwilck
2013-07-03 20:27 ` [PATCH 16/27] DDF: use LBA_OFFSET macro instead of lba_offset field mwilck
2013-07-03 20:27 ` [PATCH 17/27] DDF: get_extents: support secondary RAID level mwilck
2013-07-03 20:27 ` [PATCH 18/27] DDF: add_to_super_ddf: allow empty slots in phys disk table mwilck
2013-07-03 20:27 ` [PATCH 19/27] DDF: add_to_super_ddf: Use same amount of workspace as other disks mwilck
2013-07-03 20:28 ` [PATCH 20/27] DDF: add_to_super_ddf: RAID10 changes mwilck
2013-07-03 20:28 ` [PATCH 21/27] DDF: add_to_super_ddf_bvd: use get_svd_state() mwilck
2013-07-03 20:28 ` [PATCH 22/27] DDF: getinfo_super_ddf_bvd: lba_offset calculation for RAID10 mwilck
2013-07-03 20:28 ` [PATCH 23/27] DDF: guid_str: convenience function to print GUID for debugging mwilck
2013-07-03 20:28 ` [PATCH 24/27] DDF: ddf_set_array_state: more meaningful output mwilck
2013-07-03 20:28 ` [PATCH 25/27] DDF: ddf_process_update: handle update of conf records for SVD mwilck
2013-07-03 20:28 ` [PATCH 26/27] DDF: ddf_process_update: Fix vlist treatment for SVDs mwilck
2013-07-03 20:28 ` [PATCH 27/27] tests/10ddf-create: add RAID 10 array mwilck
2013-07-04 10:10 ` DDF/RAID10 patch series NeilBrown
2013-07-08 6:53 ` NeilBrown
2013-07-08 21:50 ` Fixes for the DDF " mwilck
2013-07-08 21:50 ` [PATCH 28/39] test/10-ddf-create: fix comments mwilck
2013-07-08 21:50 ` [PATCH 29/39] Monitor: Don't write metadata in inactive array state mwilck
2013-07-08 21:50 ` [PATCH 30/39] DDF: write_init_super_ddf: don't zero superblocks for subarrays mwilck
2013-07-08 21:50 ` [PATCH 31/39] DDF: implement kill_subarray mwilck
2013-07-08 21:50 ` [PATCH 32/39] DDF: getinfo_super_ddf_bvd: identify disk by refnum mwilck
2013-07-08 21:50 ` [PATCH 33/39] DDF: getinfo_super_ddf_bvd: fix raid_disk calculation mwilck
2013-07-08 21:50 ` [PATCH 34/39] DDF: fix endianness of refnum in debug messages mwilck
2013-07-08 21:50 ` [PATCH 35/39] DDF: add debug message in add_super_ddf_bvd mwilck
2013-07-08 21:50 ` [PATCH 36/39] DDF: ddf_process_update: add debug messages fore adding VDs mwilck
2013-07-08 21:50 ` [PATCH 37/39] DDF: guid_str: more readable output mwilck
2013-07-08 21:50 ` [PATCH 38/39] DDF: ddf_process_update: some more debug messages mwilck
2013-07-08 21:50 ` [PATCH 39/39] DDF: ddf_process_update: Fix updates for SVDs mwilck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130708162800.11ddbc84@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=mwilck@arcor.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).