Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Patches and discussions about the oe-core layer
	<openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 1/2] udev: improve udev-cache robustness
Date: Wed, 01 Feb 2012 16:35:51 +0000	[thread overview]
Message-ID: <1328114151.13744.95.camel@ted> (raw)
In-Reply-To: <ddaf0e6f05439011bf5f04950922d0a6d5cd60b6.1327975625.git.otavio@ossystems.com.br>

On Tue, 2012-01-31 at 02:10 +0000, Otavio Salvador wrote:
> * allow udev-cache to be disabled at runtime (using
>    /etc/default/udev-cache);
> 
>  * make cache invalidated if kernel, bootparams or device list
>    changes;
> 
> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> ---
>  meta/recipes-core/udev/udev.inc                |    8 +++++++-
>  meta/recipes-core/udev/udev/init               |   15 ++++++++++++---
>  meta/recipes-core/udev/udev/udev-cache         |   14 +++++++++++---
>  meta/recipes-core/udev/udev/udev-cache.default |    4 ++++
>  4 files changed, 34 insertions(+), 7 deletions(-)
>  create mode 100644 meta/recipes-core/udev/udev/udev-cache.default
> 
> diff --git a/meta/recipes-core/udev/udev.inc b/meta/recipes-core/udev/udev.inc
> index 0e571d6..e5fbe40 100644
> --- a/meta/recipes-core/udev/udev.inc
> +++ b/meta/recipes-core/udev/udev.inc
> @@ -25,6 +25,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/kernel/hotplug/udev-${PV}.tar.gz \
>             file://network.sh \
>             file://local.rules \
>             file://udev-cache \
> +           file://udev-cache.default \
>             file://init"
>  
>  inherit autotools pkgconfig update-rc.d
> @@ -58,7 +59,7 @@ FILES_libgudev = "${base_libdir}/libgudev*.so.* ${libdir}/libgudev*.so.*"
>  FILES_libgudev-dbg = "${base_libdir}/.debug/libgudev*.so.* ${libdir}/.debug/libgudev*.so.*"
>  FILES_libgudev-dev = "${includedir}/gudev* ${libdir}/libgudev*.so ${libdir}/libgudev*.la \
>                       ${libdir}/libgudev*.a ${libdir}/pkgconfig/gudev*.pc"
> -FILES_udev-cache = "${sysconfdir}/init.d/udev-cache"
> +FILES_udev-cache = "${sysconfdir}/init.d/udev-cache ${sysconfdir}/default/udev-cache"
>  
>  FILES_udev-acl = "${base_libdir}/udev/udev-acl ${base_libdir}/udev/rules.d/70-acl.rules"
>  
> @@ -72,6 +73,11 @@ do_install_append () {
>  	install -m 0755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/udev
>  	install -m 0755 ${WORKDIR}/udev-cache ${D}${sysconfdir}/init.d/udev-cache
>  
> +	install -d ${D}${sysconfdir}/default
> +	install -m 0755 ${WORKDIR}/udev-cache.default ${D}${sysconfdir}/default/udev-cache
> +
> +	touch ${D}${sysconfdir}/udev/cache.data
> +
>  	install -d ${D}${sysconfdir}/udev/rules.d/
>  
>  	install -m 0644 ${WORKDIR}/local.rules         ${D}${sysconfdir}/udev/rules.d/local.rules
> diff --git a/meta/recipes-core/udev/udev/init b/meta/recipes-core/udev/udev/init
> index 6a4464c..f2c7f87 100644
> --- a/meta/recipes-core/udev/udev/init
> +++ b/meta/recipes-core/udev/udev/init
> @@ -14,6 +14,7 @@ export TZ=/etc/localtime
>  [ -d /sys/class ] || exit 1
>  [ -r /proc/mounts ] || exit 1
>  [ -x /sbin/udevd ] || exit 1
> +[ -f /etc/default/udev-cache ] && . /etc/default/udev-cache
>  [ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
>  
>  kill_udevd() {
> @@ -35,9 +36,17 @@ LANG=C awk '$2 == "/dev" && ($3 == "tmpfs" || $3 == "devtmpfs") { exit 1 }' /pro
>  [ -e /dev/shm ] || mkdir -m 1777 /dev/shm
>  
> 
> -if [ -e /etc/dev.tar ]; then
> -	(cd /; tar xf /etc/dev.tar 2>&1 | grep -v 'time stamp' || true)
> -	not_first_boot=1
> +if [ "$DEVCACHE" != "" ]; then
> +	# Ensure we are consistent to use the cache
> +	echo -n > /dev/shm/cache.data
> +	[ -x /bin/uname ] && /bin/uname -mrspv >> /dev/shm/cache.data
> +	[ -r /proc/cmdline ] && cat /proc/cmdline >> /dev/shm/cache.data
> +	[ -r /proc/devices ] && cat /proc/devices >> /dev/shm/cache.data
> +	[ -r /proc/atags ] && cat /proc/atags >> /dev/shm/cache.data
> +	if [ -e $DEVCACHE ] && cmp -s /dev/shm/cache.data /etc/udev/cache.data; then
> +		(cd /; tar xf $DEVCACHE > /dev/null 2>&1)
> +		not_first_boot=1
> +	fi
>  fi

This still forks much more than I'd like or than is necessary. In the
interests of getting this resolved, you could do something like my
example below which doesn't fork. It does mangle newlines in the data
but in this case I don't think that matters.

Could we get away with /proc/version instead of uname -mrpsv ?

Cheers,

Richard

#!/bin/sh
readfile () {
    filename=$1
    READDATA=""
    if [ -r $filename ]; then
        while read line; do    
            READDATA="$READDATA$line"
        done < $filename
    fi
}

readfile /proc/cmdline
CMDLINE="$READDATA"
readfile /proc/devices
DEVICES="$READDATA"
readfile /proc/atags
ATAGS="$READDATA"

if [ "$DEVCACHE" != "" ]; then
    if [ -e $DEVCACHE ]; then
        readfile /etc/udev/cache.data
        if [ "$READDATA" = "$CMDLINE $DEVICES $ATAGS" ]; then
            (cd /; tar xf $DEVCACHE > /dev/null 2>&1)
            not_first_boot=1
        fi
    fi
fi






  reply	other threads:[~2012-02-01 16:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-31  2:10 [PATCH 0/2] Ready to merge patches from O.S. Systems tree Otavio Salvador
2012-01-31  2:10 ` [PATCH 1/2] udev: improve udev-cache robustness Otavio Salvador
2012-02-01 16:35   ` Richard Purdie [this message]
2012-02-01 18:11     ` Otavio Salvador
2012-01-31  2:10 ` [PATCH 2/2] classes/gitpkgv.bbclass: import from Meta-OE Otavio Salvador
2012-02-01 13:19   ` Richard Purdie
2012-02-01 18:00     ` Otavio Salvador

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=1328114151.13744.95.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=openembedded-core@lists.openembedded.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