linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: mwilck@arcor.de
Cc: linux-raid@vger.kernel.org
Subject: Re: [PATCH 11/27] DDF: layout_ddf2md: new DDF->md RAID layout conversion
Date: Mon, 8 Jul 2013 16:48:20 +1000	[thread overview]
Message-ID: <20130708164820.3a344e28@notabene.brown> (raw)
In-Reply-To: <1372883287-8859-12-git-send-email-mwilck@arcor.de>

[-- Attachment #1: Type: text/plain, Size: 7867 bytes --]

On Wed,  3 Jul 2013 22:27:51 +0200 mwilck@arcor.de wrote:

> layout_ddf2md() is a new RAID layout conversion routine.
> It obsoletes the previous separate routines for obtaining
> md level and layout (map_num1, rlq_to_layout).
> 
> Signed-off-by: Martin Wilck <mwilck@arcor.de>
> ---
>  super-ddf.c |  197 ++++++++++++++++++++++++++++++-----------------------------
>  1 files changed, 100 insertions(+), 97 deletions(-)
> 
> diff --git a/super-ddf.c b/super-ddf.c
> index 0f955be..a43401e 100644
> --- a/super-ddf.c
> +++ b/super-ddf.c
> @@ -484,6 +484,102 @@ static unsigned int calc_crc(void *buf, int len)
>  	return __cpu_to_be32(newcrc);
>  }
>  
> +static int err_bad_ddf_layout(const struct vd_config *conf)
> +{
> +	pr_err("DDF RAID %u qualifier %u with %u disks is unsupported\n",
> +	       conf->prl, conf->rlq, __be16_to_cpu(conf->prim_elmnt_count));
> +	return -1;
> +}
> +
> +static int layout_ddf2md(const struct vd_config *conf,
> +			 mdu_array_info_t *array)
> +{
> +	int level = LEVEL_UNSUPPORTED;
> +	int layout = 0;
> +	int raiddisks = __be16_to_cpu(conf->prim_elmnt_count);
> +
> +	if (conf->sec_elmnt_count > 1) {
> +		/* see also check_secondary() */
> +		if (conf->prl != DDF_RAID1 ||
> +		    (conf->srl != DDF_2STRIPED && conf->srl != DDF_2SPANNED)) {
> +			pr_err("Unsupported secondary RAID level %u/%u\n",
> +			       conf->prl, conf->srl);
> +			return -1;
> +		}
> +		if (raiddisks == 2 && conf->rlq == DDF_RAID1_SIMPLE)
> +			layout = 0x102;
> +		else if  (raiddisks == 3 && conf->rlq == DDF_RAID1_MULTI)
> +			layout = 0x103;
> +		else
> +			return err_bad_ddf_layout(conf);
> +		raiddisks *= conf->sec_elmnt_count;
> +		level = 10;
> +		goto good;
> +	}
> +
> +	switch (conf->prl) {
> +	case DDF_CONCAT:
> +		level = LEVEL_LINEAR;
> +		break;
> +	case DDF_RAID0:
> +		if (conf->rlq != DDF_RAID0_SIMPLE)
> +			return err_bad_ddf_layout(conf);
> +		level = 0;
> +		break;
> +	case DDF_RAID1:
> +		if (!((conf->rlq == DDF_RAID1_SIMPLE && raiddisks == 2) ||
> +		      (conf->rlq == DDF_RAID1_MULTI && raiddisks == 3)))
> +			return err_bad_ddf_layout(conf);
> +		level = 1;
> +		break;
> +	case DDF_RAID4:
> +		if (conf->rlq != DDF_RAID4_N)
> +			return err_bad_ddf_layout(conf);
> +		level = 4;
> +		break;
> +	case DDF_RAID5:
> +		switch (conf->rlq) {
> +		case DDF_RAID5_N_RESTART:
> +			layout = ALGORITHM_LEFT_ASYMMETRIC;
> +			break;
> +		case DDF_RAID5_0_RESTART:
> +			layout = ALGORITHM_RIGHT_ASYMMETRIC;
> +			break;
> +		case DDF_RAID5_N_CONTINUE:
> +			layout = ALGORITHM_LEFT_SYMMETRIC;
> +			break;
> +		default:
> +			return err_bad_ddf_layout(conf);
> +		}
> +		level = 5;
> +		break;
> +	case DDF_RAID6:
> +		switch (conf->rlq) {
> +		case DDF_RAID5_N_RESTART:
> +			layout = ALGORITHM_ROTATING_N_RESTART;
> +			break;
> +		case DDF_RAID6_0_RESTART:
> +			layout = ALGORITHM_ROTATING_ZERO_RESTART;
> +			break;
> +		case DDF_RAID5_N_CONTINUE:
> +			layout = ALGORITHM_ROTATING_N_CONTINUE;
> +			break;
> +		default:
> +			return err_bad_ddf_layout(conf);
> +		}
> +		level = 6;
> +		break;
> +	default:
> +		return err_bad_ddf_layout(conf);
> +	};
> +
> +good:
> +	array->level = level;
> +	array->layout = layout;
> +	array->raid_disks = raiddisks;
> +	return 0;
> +}
> +
>  static int load_ddf_header(int fd, unsigned long long lba,
>  			   unsigned long long size,
>  			   int type,
> @@ -1032,33 +1128,6 @@ static mapping_t ddf_sec_level[] = {
>  };
>  #endif
>  
> -struct num_mapping {
> -	int num1, num2;
> -};
> -static struct num_mapping ddf_level_num[] = {
> -	{ DDF_RAID0, 0 },
> -	{ DDF_RAID1, 1 },
> -	{ DDF_RAID3, LEVEL_UNSUPPORTED },
> -	{ DDF_RAID4, 4 },
> -	{ DDF_RAID5, 5 },
> -	{ DDF_RAID1E, LEVEL_UNSUPPORTED },
> -	{ DDF_JBOD, LEVEL_UNSUPPORTED },
> -	{ DDF_CONCAT, LEVEL_LINEAR },
> -	{ DDF_RAID5E, LEVEL_UNSUPPORTED },
> -	{ DDF_RAID5EE, LEVEL_UNSUPPORTED },
> -	{ DDF_RAID6, 6},
> -	{ MAXINT, MAXINT }
> -};

Ooops.  You removed that while there was still a user.
Code must compile after each patch!
I've delayed the removal of this structure to the next patch, which removes
the last user.

NeilBrown


> -
> -static int map_num1(struct num_mapping *map, int num)
> -{
> -	int i;
> -	for (i=0 ; map[i].num1 != MAXINT; i++)
> -		if (map[i].num1 == num)
> -			break;
> -	return map[i].num2;
> -}
> -
>  static int all_ff(const char *guid)
>  {
>  	int i;
> @@ -1638,8 +1707,6 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
>  	}
>  }
>  
> -static int rlq_to_layout(int rlq, int prl, int raiddisks);
> -
>  static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, char *map)
>  {
>  	struct ddf_super *ddf = st->sb;
> @@ -1651,12 +1718,8 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
>  	__u32 *cptr;
>  
>  	memset(info, 0, sizeof(*info));
> -	/* FIXME this returns BVD info - what if we want SVD ?? */
> -
> -	info->array.raid_disks    = __be16_to_cpu(vc->conf.prim_elmnt_count);
> -	info->array.level	  = map_num1(ddf_level_num, vc->conf.prl);
> -	info->array.layout	  = rlq_to_layout(vc->conf.rlq, vc->conf.prl,
> -						  info->array.raid_disks);
> +	if (layout_ddf2md(&vc->conf, &info->array) == -1)
> +		return;
>  	info->array.md_minor	  = -1;
>  	cptr = (__u32 *)(vc->conf.guid + 16);
>  	info->array.ctime	  = DECADE + __be32_to_cpu(*cptr);
> @@ -2140,48 +2203,6 @@ static int layout_to_rlq(int level, int layout, int raiddisks)
>  	return -1;
>  }
>  
> -static int rlq_to_layout(int rlq, int prl, int raiddisks)
> -{
> -	switch(prl) {
> -	case DDF_RAID0:
> -		return 0; /* hopefully rlq == DDF_RAID0_SIMPLE */
> -	case DDF_RAID1:
> -		return 0; /* hopefully rlq == SIMPLE or MULTI depending
> -			     on raiddisks*/
> -	case DDF_RAID4:
> -		switch(rlq) {
> -		case DDF_RAID4_N:
> -			return 0;
> -		default:
> -			/* not supported */
> -			return -1; /* FIXME this isn't checked */
> -		}
> -	case DDF_RAID5:
> -		switch(rlq) {
> -		case DDF_RAID5_N_RESTART:
> -			return ALGORITHM_LEFT_ASYMMETRIC;
> -		case DDF_RAID5_0_RESTART:
> -			return ALGORITHM_RIGHT_ASYMMETRIC;
> -		case DDF_RAID5_N_CONTINUE:
> -			return ALGORITHM_LEFT_SYMMETRIC;
> -		default:
> -			return -1;
> -		}
> -	case DDF_RAID6:
> -		switch(rlq) {
> -		case DDF_RAID5_N_RESTART:
> -			return ALGORITHM_ROTATING_N_RESTART;
> -		case DDF_RAID6_0_RESTART:
> -			return ALGORITHM_ROTATING_ZERO_RESTART;
> -		case DDF_RAID5_N_CONTINUE:
> -			return ALGORITHM_ROTATING_N_CONTINUE;
> -		default:
> -			return -1;
> -		}
> -	}
> -	return -1;
> -}
> -
>  #ifndef MDASSEMBLE
>  struct extent {
>  	unsigned long long start, size;
> @@ -3433,26 +3454,8 @@ static struct mdinfo *container_content_ddf(struct supertype *st, char *subarray
>  		this->next = rest;
>  		rest = this;
>  
> -		if (vc->conf.sec_elmnt_count == 1) {
> -			this->array.level = map_num1(ddf_level_num,
> -						     vc->conf.prl);
> -			this->array.raid_disks =
> -				__be16_to_cpu(vc->conf.prim_elmnt_count);
> -			this->array.layout =
> -				rlq_to_layout(vc->conf.rlq, vc->conf.prl,
> -					      this->array.raid_disks);
> -		} else {
> -			/* The only supported layout is RAID 10.
> -			 * Compatibility has been checked in check_secondary()
> -			 * above.
> -			 */
> -			this->array.level = 10;
> -			this->array.raid_disks =
> -				__be16_to_cpu(vc->conf.prim_elmnt_count)
> -				* vc->conf.sec_elmnt_count;
> -			this->array.layout = 0x100 |
> -				__be16_to_cpu(vc->conf.prim_elmnt_count);
> -		}
> +		if (layout_ddf2md(&vc->conf, &this->array))
> +			continue;
>  		this->array.md_minor      = -1;
>  		this->array.major_version = -1;
>  		this->array.minor_version = -2;


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

  reply	other threads:[~2013-07-08  6:48 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 [this message]
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
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=20130708164820.3a344e28@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).