All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [patch 1/3] wait host devs in base module
Date: Fri, 17 Aug 2012 12:57:09 -0400	[thread overview]
Message-ID: <20120817165709.GA11604@redhat.com> (raw)
In-Reply-To: <20120817123905.089958024-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

On Fri, Aug 17, 2012 at 08:35:20PM +0800, dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org wrote:
> each dev in host_devs[] should be waited in initqueue to make sure they
> are oneline before initqueue finish.
> 
> Add a new wait_host_devs.sh in base module to make this a generic thing.
> Because all the devs in fstab lines are also added to host_devs, so no need
> do same wait in fstab-sys module anymore.
> 
> Chaowang: add slave devices to host_devs as well.

Why should we wait for slave devices? If slave device does not come up,
top level device will not come up anyway. So I don't think we should wait
for slave devices.

Secondly, trying to list slave devices is dangerous as the names you
seem to be stroing are not persistent and device renaming will hang
the system.

So whereever you are waiting for a device to come up, make sure you
are using persistent device name as generated by udev.

Thanks
Vivek

> 
> Signed-off-by: Dave Young <dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  dracut.sh                               |   19 +++++++++++++++++++
>  modules.d/95fstab-sys/module-setup.sh   |    1 -
>  modules.d/95fstab-sys/wait-mount-dev.sh |   22 ----------------------
>  modules.d/99base/module-setup.sh        |    1 +
>  modules.d/99base/wait-host-devs.sh      |   20 ++++++++++++++++++++
>  5 files changed, 40 insertions(+), 23 deletions(-)
> 
> --- dracut.orig/dracut.sh
> +++ dracut/dracut.sh
> @@ -769,6 +769,20 @@ for dev in "${host_devs[@]}"; do
>      done
>  done
>  
> +_get_block_dev() {
> +    echo `readlink -f /dev/block/$1`; return 1;
> +}
> +
> +for dev in "${host_devs[@]}"; do
> +    unset _dev
> +    for _dev in $(check_block_and_slaves _get_block_dev $(get_maj_min $dev)); do
> +       [ -b "$_dev" ] || continue
> +        if ! strstr " ${host_devs[*]} " " $_dev ";then
> +            push host_devs "$_dev"
> +        fi
> +    done
> +done
> +
>  [[ -d $udevdir ]] \
>      || udevdir=$(pkg-config udev --variable=udevdir 2>/dev/null)
>  if ! [[ -d "$udevdir" ]]; then
> @@ -903,6 +917,11 @@ done
>  
>  dinfo "*** Including modules done ***"
>  
> +## save host_devs which we need bring up
> +for _dev in ${host_devs[@]}; do
> +    echo $_dev >> $initdir/etc/host_devs
> +done
> +
>  ## final stuff that has to happen
>  if [[ $no_kernel != yes ]]; then
>  
> --- dracut.orig/modules.d/95fstab-sys/module-setup.sh
> +++ dracut/modules.d/95fstab-sys/module-setup.sh
> @@ -13,5 +13,4 @@ depends() {
>  install() {
>      [ -f /etc/fstab.sys ] && inst_simple /etc/fstab.sys
>      inst_hook pre-pivot 00 "$moddir/mount-sys.sh"
> -    inst_hook cmdline 00 "$moddir/wait-mount-dev.sh"
>  }
> --- dracut.orig/modules.d/95fstab-sys/wait-mount-dev.sh
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -#!/bin/sh
> -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
> -# ex: ts=8 sw=4 sts=4 et filetype=sh
> -
> -type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
> -type det_fs >/dev/null 2>&1 || . /lib/fs-lib.sh
> -
> -fstab_wait_dev() {
> -    local _dev _mp _fs _opts _dump _pass _rest
> -    test -e "$1" || return 1
> -    while read _dev _mp _fs _opts _dump _pass _rest; do
> -        [ -z "${_dev%%#*}" ] && continue # Skip comment lines
> -        case "$_dev" in
> -        /dev/?*)
> -            wait_for_dev $_dev;;
> -        *) ;;
> -        esac
> -    done < $1
> -    return 0
> -}
> -
> -[ -f /etc/fstab ] && fstab_wait_dev /etc/fstab
> --- dracut.orig/modules.d/99base/module-setup.sh
> +++ dracut/modules.d/99base/module-setup.sh
> @@ -41,6 +41,7 @@ install() {
>      dracut_install switch_root || dfatal "Failed to install switch_root"
>  
>      inst_simple "$moddir/dracut-lib.sh" "/lib/dracut-lib.sh"
> +    inst_hook cmdline 00 "$moddir/wait-host-devs.sh"
>      inst_hook cmdline 10 "$moddir/parse-root-opts.sh"
>      mkdir -p "${initdir}/var"
>      [ -x /lib/systemd/systemd-timestamp ] && inst /lib/systemd/systemd-timestamp
> --- /dev/null
> +++ dracut/modules.d/99base/wait-host-devs.sh
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
> +# ex: ts=8 sw=4 sts=4 et filetype=sh
> +
> +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
> +
> +wait_host_devs() {
> +    local _dev
> +
> +    while read _dev; do
> +        case "$_dev" in
> +        /dev/?*)
> +            wait_for_dev $_dev
> +            ;;
> +        *) ;;
> +        esac
> +    done < $1
> +}
> +
> +[ -f /etc/host_devs ] && wait_host_devs /etc/host_devs

  parent reply	other threads:[~2012-08-17 16:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-17 12:35 [patch 0/3] add --device option dyoung-H+wXaHxf7aLQT0dZR+AlfA
2012-08-17 12:35 ` [patch 1/3] wait host devs in base module dyoung-H+wXaHxf7aLQT0dZR+AlfA
     [not found]   ` <20120817123905.089958024-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-17 16:57     ` Vivek Goyal [this message]
     [not found]       ` <20120817165709.GA11604-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-20  5:53         ` Dave Young
     [not found]           ` <5031D0ED.4070901-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-20 14:59             ` Vivek Goyal
     [not found]               ` <20120820145946.GD31044-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-21  7:32                 ` Dave Young
2012-08-17 12:35 ` [patch 2/3] Add for_each_host_dev for device only checking dyoung-H+wXaHxf7aLQT0dZR+AlfA
     [not found]   ` <20120817123905.206266546-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-17 17:02     ` Vivek Goyal
     [not found]       ` <20120817170217.GB11604-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-20  5:56         ` Dave Young
     [not found]           ` <5031D18B.2070208-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-20 14:56             ` Vivek Goyal
2012-08-17 12:35 ` [patch 3/3] Add a dracut option --device to bring up a device in initramfs dyoung-H+wXaHxf7aLQT0dZR+AlfA
     [not found]   ` <20120817123905.353853040-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-08-17 17:04     ` Vivek Goyal

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=20120817165709.GA11604@redhat.com \
    --to=vgoyal-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=chaowang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.