From: NeilBrown <neilb@suse.de>
To: Lukasz Dorau <lukasz.dorau@intel.com>
Cc: linux-raid@vger.kernel.org, dan.j.williams@intel.com,
marcin.labun@intel.com, ed.ciechanowski@intel.com
Subject: Re: [PATCH] fix: do not overwrite existing devices' symlinks
Date: Mon, 30 Jan 2012 12:27:28 +1100 [thread overview]
Message-ID: <20120130122728.3aa8da9a@notabene.brown> (raw)
In-Reply-To: <20120123120652.20165.47998.stgit@gklab-128-085.igk.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2725 bytes --]
On Mon, 23 Jan 2012 13:06:52 +0100 Lukasz Dorau <lukasz.dorau@intel.com>
wrote:
> If the device's name is given in /etc/mdadm.conf, create_mddev()
> does not check if the map contains a device of this name (mdopen.c:140).
> If it does, the symlink of that name will be overwritten.
>
> create_mddev() has been changed. Now it checks if the map contains
> a device of the name given in /etc/mdadm.conf.
> If it does, the appropriate suffix is added to the given name.
>
> Signed-off-by: Lukasz Dorau <lukasz.dorau@intel.com>
Can you please remind me what the big picture problem is here??
It seem like you are suggesting that if
/dev/md/thing
is given in mdadm.conf, but some other array is already assembled with the
name /dev/md/thing, then the array from mdadm.conf should be assembled as
/dev/md/thing0
or something like that - is that correct?
I don't think we want that. If there is a name conflict like this with a
name given in mdadm.conf, then one of the arrays should fail to assemble as
this is really a fairly serious configuration error.
Or did I misunderstand?
Thanks,
NeilBrown
> ---
> mdopen.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/mdopen.c b/mdopen.c
> index eac1c1f..3078de6 100644
> --- a/mdopen.c
> +++ b/mdopen.c
> @@ -147,10 +147,12 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
> char *cname;
> char devname[20];
> char cbuf[400];
> + struct map_ent *map = NULL;
> + int dev_conflict = 0;
> +
> if (chosen == NULL)
> chosen = cbuf;
>
> -
> if (autof == 0)
> autof = ci->autof;
>
> @@ -277,17 +279,21 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
> else
> sprintf(devname, "/dev/md%d", num);
>
> - if (cname[0] == 0 && name) {
> + if ((cname[0] != 0) && map_by_name(&map, cname))
> + dev_conflict = 1;
> +
> + if ((cname[0] == 0 && name) || dev_conflict) {
> /* Need to find a name if we can
> * We don't completely trust 'name'. Truncate to
> * reasonable length and remove '/'
> */
> char *cp;
> - struct map_ent *map = NULL;
> int conflict = 1;
> int unum = 0;
> int cnlen;
> - strncpy(cname, name, 200);
> +
> + if (!dev_conflict)
> + strncpy(cname, name, 200);
> cname[200] = 0;
> while ((cp = strchr(cname, '/')) != NULL)
> *cp = '-';
> @@ -312,7 +318,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
> }
> }
>
> - if (dev && dev[0] == '/')
> + if ((dev && dev[0] == '/') && (!dev_conflict))
> strcpy(chosen, dev);
> else if (cname[0] == 0)
> strcpy(chosen, devname);
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
next prev parent reply other threads:[~2012-01-30 1:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-23 12:06 [PATCH] fix: do not overwrite existing devices' symlinks Lukasz Dorau
2012-01-30 1:27 ` NeilBrown [this message]
2012-01-30 12:13 ` Dorau, Lukasz
2012-01-30 22:13 ` NeilBrown
2012-01-31 8:00 ` Dorau, Lukasz
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=20120130122728.3aa8da9a@notabene.brown \
--to=neilb@suse.de \
--cc=dan.j.williams@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=lukasz.dorau@intel.com \
--cc=marcin.labun@intel.com \
/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).