linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Brown <neilb@suse.de>
To: Adam Kwolek <adam.kwolek@intel.com>
Cc: linux-raid@vger.kernel.org, dan.j.williams@intel.com,
	ed.ciechanowski@intel.com
Subject: Re: [PATCH 03/27] imsm: Prepare reshape_update in mdadm
Date: Wed, 8 Dec 2010 14:10:16 +1100	[thread overview]
Message-ID: <20101208141016.437dfd2d@notabene.brown> (raw)
In-Reply-To: <20101206132108.21125.54920.stgit@gklab-170-024.igk.intel.com>

On Mon, 06 Dec 2010 14:21:08 +0100 Adam Kwolek <adam.kwolek@intel.com> wrote:

>  
> +int path2devnum(char *pth)
> +{
> +	char *ep;
> +	int fd = -1;
> +	char *dev_pth = NULL;
> +	char *dev_str;
> +	int dev_num = -1;
> +
> +	fd = open(pth, O_RDONLY);
> +	if (fd < 0)
> +		return dev_num;
> +	close(fd);
> +	dev_pth = canonicalize_file_name(pth);
> +	if (dev_pth == NULL)
> +		return dev_num;
> +	dev_str = strrchr(dev_pth, '/');
> +	if (dev_str) {
> +		while (!isdigit(dev_str[0]))
> +			dev_str++;
> +		dev_num = strtoul(dev_str, &ep, 10);
> +		if (*ep != '\0')
> +			dev_num = -1;
> +	}
> +
> +	if (dev_pth)
> +		free(dev_pth);
> +
> +	return dev_num;
> +}


I have repeatedly asked you to explain and document these functions.  They
look way to complex for whatever it that they might be trying to do.

I do not feel at all included to spend time reviewing your patches if you
don't respond to the review comments.

So I'm ignoring the rest of this series until you explain this and we come to
an agreement on what it does and how it should work.

BTW there are two places in this patch where you should be using open_dev,
and several where you have lines longer than 80 characters.

NeilBrown


> +
> +extern void map_read(struct map_ent **map);
> +extern void map_free(struct map_ent *map);
> +int find_array_minor(char *text_version, int external, int container, int *minor)
> +{
> +	int i;
> +	char path[PATH_MAX];
> +	struct stat s;
> +
> +	if (minor == NULL)
> +		return -2;
> +
> +	snprintf(path, PATH_MAX, "/dev/md/%s", text_version);
> +	i = path2devnum(path);
> +	if (i > -1) {
> +		*minor = i;
> +		return 0;
> +	}
> +
> +	i = path2devnum(text_version);
> +	if (i > -1) {
> +		*minor = i;
> +		return 0;
> +	}
> +
> +	if (container > 0) {
> +		struct map_ent *map = NULL;
> +		struct map_ent *m;
> +		char cont[PATH_MAX];
> +
> +		snprintf(cont, PATH_MAX, "/md%i/", container);
> +		map_read(&map);
> +		for (m = map; m; m = m->next) {
> +			int index;
> +			unsigned int len = 0;
> +			char buf[PATH_MAX];
> +
> +			/* array have belongs to proper container
> +			*/
> +			if (strncmp(cont, m->metadata, 6) != 0)
> +				continue;
> +			/* begin of array name in map have to be the same
> +			 * as array name in metadata
> +			 */
> +			if (strncmp(m->path, path, strlen(path)) != 0)
> +				continue;
> +			/* array name has to be followed by '_' char
> +			 */
> +			len = strlen(path);
> +			if (*(m->path + len) != '_')
> +				continue;
> +			/* then we have to have  valid index
> +			 */
> +			len++;
> +			if (strlen(m->path + len) <= 0)
> +			    continue;
> +			/* index has to be las position in array name
> +			 */
> +			index = atoi(m->path + strlen(path) + 1);
> +			snprintf(buf, PATH_MAX, "%i", index);
> +			len += strlen(buf);
> +			if (len != strlen(m->path))
> +				continue;
> +			dprintf("Found %s device based on mdadm maps\n", m->path);
> +			*minor = m->devnum;
> +			map_free(map);
> +			return 0;
> +		}
> +		map_free(map);
> +	}
> +
> +	for (i = 127; i >= 0; i--) {
> +		char buf[PATH_MAX];
> +
> +		snprintf(path, PATH_MAX, "/sys/block/md%d/md/", i);
> +		if (stat(path, &s) != -1) {
> +			strcat(path, "metadata_version");
> +			if (load_sys(path, buf))
> +				continue;
> +			if (external) {
> +				char *version = strchr(buf, ':');
> +				if (version && strcmp(version + 1,
> +						      text_version))
> +					continue;
> +			} else {
> +				if (strcmp(buf, text_version))
> +					continue;
> +			}
> +			*minor = i;
> +			return 0;
> +		}
> +	}
> +
> +	return -1;
> +}
> +
> +/* find_array_minor2 looks for frozen devices also
> + */
> +int find_array_minor2(char *text_version, int external, int container, int *minor)
> +{
> +	int result;
> +	char buf[PATH_MAX];
> +
> +	strcpy(buf, text_version);
> +	result = find_array_minor(text_version, external, container, minor);
> +	if (result < 0) {
> +		/* try to find frozen array also
> +		 */
> +		char buf[PATH_MAX];
> +
> +		strcpy(buf, text_version);
> +
> +		*buf = '-';
> +		result = find_array_minor(buf, external, container, minor);
> +	}
> +	return result;
> +}
> +
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2010-12-08  3:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-06 13:20 [PATCH 00/27] OLCE, migrations and raid10 takeover Adam Kwolek
2010-12-06 13:20 ` [PATCH 01/27] FIX: wait_backup() sometimes hangs Adam Kwolek
2010-12-06 13:21 ` [PATCH 02/27] Add state_of_reshape for external metadata Adam Kwolek
2010-12-06 13:21 ` [PATCH 03/27] imsm: Prepare reshape_update in mdadm Adam Kwolek
2010-12-08  3:10   ` Neil Brown [this message]
2010-12-08 14:18     ` Kwolek, Adam
2010-12-08 22:05       ` Neil Brown
2010-12-09  8:42         ` Suspend_hi mamagment during reshape Kwolek, Adam
2010-12-09 10:28           ` Neil Brown
2010-12-09 15:59             ` Kwolek, Adam
2010-12-09 16:08               ` Kwolek, Adam
2010-12-06 13:21 ` [PATCH 04/27] imsm: Process reshape_update in mdmon Adam Kwolek
2010-12-06 13:21 ` [PATCH 05/27] imsm: Block array state change during reshape Adam Kwolek
2010-12-06 13:21 ` [PATCH 06/27] Process reshape initialization by managemon Adam Kwolek
2010-12-06 13:21 ` [PATCH 07/27] imsm: Verify slots in meta against slot numbers set by md Adam Kwolek
2010-12-06 13:21 ` [PATCH 08/27] imsm: Cancel metadata changes on reshape start failure Adam Kwolek
2010-12-06 13:21 ` [PATCH 09/27] imsm: Do not accept messages sent by mdadm Adam Kwolek
2010-12-06 13:22 ` [PATCH 10/27] imsm: Do not indicate resync during reshape Adam Kwolek
2010-12-06 13:22 ` [PATCH 11/27] imsm: Fill delta_disks field in getinfo_super() Adam Kwolek
2010-12-06 13:22 ` [PATCH 12/27] Control reshape in mdadm Adam Kwolek
2010-12-06 13:22 ` [PATCH 13/27] Finalize reshape after adding disks to array Adam Kwolek
2010-12-06 13:22 ` [PATCH 14/27] Add reshape progress updating Adam Kwolek
2010-12-06 13:22 ` [PATCH 15/27] WORKAROUND: md reports idle state during reshape start Adam Kwolek
2010-12-06 13:22 ` [PATCH 16/27] FIX: core during getting map Adam Kwolek
2010-12-06 13:22 ` [PATCH 17/27] Enable reshape for subarrays Adam Kwolek
2010-12-06 13:23 ` [PATCH 18/27] Change manage_reshape() placement Adam Kwolek
2010-12-06 13:23 ` [PATCH 19/27] Migration: raid5->raid0 Adam Kwolek
2010-12-06 13:23 ` [PATCH 20/27] Detect level change Adam Kwolek
2010-12-06 13:23 ` [PATCH 21/27] Migration raid0->raid5 Adam Kwolek
2010-12-06 13:23 ` [PATCH 22/27] Read chunk size and layout from mdstat Adam Kwolek
2010-12-06 13:23 ` [PATCH 23/27] Migration: Chunk size migration Adam Kwolek
2010-12-06 13:23 ` [PATCH 24/27] Add takeover support for external meta Adam Kwolek
2010-12-06 13:24 ` [PATCH 25/27] Takeover raid10 -> raid0 for external metadata Adam Kwolek
2010-12-06 13:24 ` [PATCH 26/27] Takeover raid0 -> raid10 " Adam Kwolek
2010-12-06 13:24 ` [PATCH 27/27] FIX: Problem with removing array after takeover Adam Kwolek
2010-12-07 10:18 ` [PATCH 00/27] OLCE, migrations and raid10 takeover Neil Brown

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=20101208141016.437dfd2d@notabene.brown \
    --to=neilb@suse.de \
    --cc=adam.kwolek@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ed.ciechanowski@intel.com \
    --cc=linux-raid@vger.kernel.org \
    /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).