From: Neil Brown <neilb@suse.de>
To: Dan Williams <dan.j.williams@intel.com>
Cc: linux-raid@vger.kernel.org, Hans de Goede <hdegoede@redhat.com>,
krzysztof.wojcik@intel.com, ed.ciechanowski@intel.com,
maciej.patelczyk@intel.com
Subject: Re: [mdadm PATCH 11/12] mdmon: exec(2) when the switchroot argument is not "/"
Date: Mon, 19 Oct 2009 12:57:59 +1100 [thread overview]
Message-ID: <19163.51111.737753.564465@notabene.brown> (raw)
In-Reply-To: message from Dan Williams on Tuesday October 13
Hi Dan,
thanks for all these. I have pulled them and pushed them out.
However:
On Tuesday October 13, dan.j.williams@intel.com wrote:
> Try to execute mdmon from the target namespace. When used for initramfs
> handovers we need to drop all references to the initramfs filesystem for
> that memory to be freed.
I'm not 100% sure of this one.
Presumably an initramfs is mounted at '/', and the new root is mounted
at e.g. /newroot, and we are running:
mdmon md127 /newroot
and we want to drop all references to '/' that are held by mdmon.
Is that right?
This doesn't do that. The working directory and the root directory
are still '/' and the newly exec'ed mdmon isn't going to drop them.
Don't you want:
chdir(switchroot);
chroot(switchroot);
execl("/sbin/mdmon", "mdmon", devname, NULL);
and not bother with the sprintf??
NeilBrown
>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> mdmon.c | 23 +++++++++++++++++++++++
> 1 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/mdmon.c b/mdmon.c
> index 5f87e78..d3e8be5 100644
> --- a/mdmon.c
> +++ b/mdmon.c
> @@ -369,6 +369,29 @@ int mdmon(char *devname, int devnum, int scan, char *switchroot)
>
> dprintf("starting mdmon for %s in %s\n",
> devname, switchroot ? : "/");
> +
> + /* try to spawn mdmon instances from the target file system */
> + if (switchroot && strcmp(switchroot, "/") != 0) {
> + char path[1024];
> + pid_t pid;
> +
> + sprintf(path, "%s/sbin/mdmon", switchroot);
> + switch (fork()) {
> + case 0:
> + execl(path, "mdmon", devname, NULL);
> + exit(1);
> + case -1:
> + return 1;
> + default:
> + pid = wait(&status);
> + if (pid > -1 && WIFEXITED(status) &&
> + WEXITSTATUS(status) == 0)
> + return 0;
> + else
> + return 1;
> + }
> + }
> +
> mdfd = open_dev(devnum);
> if (mdfd < 0) {
> fprintf(stderr, "mdmon: %s: %s\n", devname,
next prev parent reply other threads:[~2009-10-19 1:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-14 2:10 [mdadm PATCH 00/12] External metadata updates and other fixes for 3.0.3 Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 01/12] imsm: cleanup disk status tests Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 02/12] imsm: kill close() of component device Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 03/12] imsm: disambiguate family_num Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 04/12] imsm: fix spare record writeout race Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 05/12] imsm: fix/support --update Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 06/12] ddf: prevent superblock being zeroed on --update Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 07/12] imsm: add --update=uuid support Dan Williams
2009-10-14 2:10 ` [mdadm PATCH 08/12] imsm: regression test for prodigal array member scenario Dan Williams
2009-10-14 2:11 ` [mdadm PATCH 09/12] Detail: export MD_UUID from mapfile Dan Williams
2009-10-14 2:11 ` [mdadm PATCH 10/12] mdmon: avoid writes in the startup path for mdmon on root arrays Dan Williams
2009-10-14 2:11 ` [mdadm PATCH 11/12] mdmon: exec(2) when the switchroot argument is not "/" Dan Williams
2009-10-19 1:57 ` Neil Brown [this message]
2009-10-14 2:11 ` [mdadm PATCH 12/12] mdmon: preserve socket over chroot Dan Williams
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=19163.51111.737753.564465@notabene.brown \
--to=neilb@suse.de \
--cc=dan.j.williams@intel.com \
--cc=ed.ciechanowski@intel.com \
--cc=hdegoede@redhat.com \
--cc=krzysztof.wojcik@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=maciej.patelczyk@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).