Hello community,
here is the log from the commit of package preload for openSUSE:Factory
checked in at Tue Apr 7 14:13:35 CEST 2009.
--------
--- preload/preload.changes 2009-04-02 10:40:48.000000000 +0200
+++ /mounts/work_src_done/STABLE/preload/preload.changes 2009-04-06 15:49:39.000000000 +0200
@@ -1,0 +2,11 @@
+Mon Apr 6 15:47:55 CEST 2009 - coolo@suse.de
+
+- make automatically use of bootcache (*EXPERIMENTAL*):
+ relink files into /appcache/boot, so they are in order of
+ booting. The logic behind it needs to be improved, currently
+ it's done on every boot
+- let the kernel command line say where to save the preload trace.
+ This allows preloadlog=/dev/zero (interesting for booting live cd) or
+ preloadlog=/dev/ttyS0 (interesting for profiling live cd)
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ preload.spec ++++++
--- /var/tmp/diff_new_pack.RO3296/_old 2009-04-07 14:13:09.000000000 +0200
+++ /var/tmp/diff_new_pack.RO3296/_new 2009-04-07 14:13:09.000000000 +0200
@@ -20,7 +20,7 @@
Name: preload
Version: 1.0
-Release: 6
+Release: 7
Summary: Preloads Files into System Cache for Faster Booting
License: GPL v2 or later
Group: System/Boot
@@ -31,7 +31,7 @@
Source6: bootfaster.diff
Source7: waitfornm
BuildRoot: %{_tmppath}/%{name}-%{version}-build
-BuildRequires: e2fsprogs-devel update-desktop-files
+BuildRequires: e2fsprogs-devel gcc-c++ update-desktop-files
PreReq: %fillup_prereq %insserv_prereq
# for the kmp
BuildRequires: kernel-default kernel-default-debuginfo kernel-source kernel-syms module-init-tools systemtap
@@ -109,6 +109,8 @@
install -m 755 init.startpreload $RPM_BUILD_ROOT/etc/init.d/boot.startpreload
install -m 755 init.stoppreload $RPM_BUILD_ROOT/etc/init.d/stoppreload
install -m 755 %{S:7} $RPM_BUILD_ROOT/etc/init.d/
+install -m 755 stop_preload $RPM_BUILD_ROOT/usr/sbin
+install -m 755 waitforidle $RPM_BUILD_ROOT/usr/bin/waitforidle
#install -m 755 cron $RPM_BUILD_ROOT/etc/cron.daily/suse.de-update-preload
# empty dir
mkdir -p $RPM_BUILD_ROOT/var/cache/preload
@@ -139,7 +141,7 @@
%defattr(-, root, root)
%doc bootfaster.diff
/sbin/*
-#/usr/sbin/*
+/usr/sbin/*
/usr/bin/*
#/etc/cron.daily/suse.de-update-preload
/etc/init.d/*
@@ -147,6 +149,14 @@
#/opt/kde3
%changelog
+* Mon Apr 06 2009 coolo@suse.de
+- make automatically use of bootcache (*EXPERIMENTAL*):
+ relink files into /appcache/boot, so they are in order of
+ booting. The logic behind it needs to be improved, currently
+ it's done on every boot
+- let the kernel command line say where to save the preload trace.
+ This allows preloadlog=/dev/zero (interesting for booting live cd) or
+ preloadlog=/dev/ttyS0 (interesting for profiling live cd)
* Thu Apr 02 2009 coolo@suse.de
- ok, I give up. install all kernels
* Thu Apr 02 2009 coolo@suse.de
++++++ bootfaster.diff ++++++
--- /var/tmp/diff_new_pack.RO3296/_old 2009-04-07 14:13:09.000000000 +0200
+++ /var/tmp/diff_new_pack.RO3296/_new 2009-04-07 14:13:09.000000000 +0200
@@ -69,3 +69,21 @@
save_var resumedev
save_var journaldev
save_var dumpdev
+--- boot.localfs.orig 2009-03-26 08:04:50.916224414 +0100
++++ boot.localfs 2009-03-26 08:06:36.857222421 +0100
+@@ -161,12 +161,15 @@
+ else
+ FSCK_OPTS="$FSCK_OPTS -V"
+ fi
++ preload=$(pidof preload)
++ test -n "$preload" && kill -STOP $preload
+ echo "Checking file systems..."
+ fsck $FSCK_OPTS
+ # A return code of 1 indicates that file system errors
+ # were corrected, but that the boot may proceed.
+ # A return code of 2 or larger indicates failure.
+ FSCK_RETURN=$?
++ test -n "$preload" && kill -CONT $preload
+ test $FSCK_RETURN -lt 4
+ rc_status -v1 -r
+ if test $FSCK_RETURN -gt 1 -a $FSCK_RETURN -lt 4 ; then
++++++ preload.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/bootcache new/preload/bootcache
--- old/preload/bootcache 2005-08-23 18:13:37.000000000 +0200
+++ new/preload/bootcache 1970-01-01 01:00:00.000000000 +0100
@@ -1,140 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use File::Copy;
-use File::stat;
-use Getopt::Long;
-use Fcntl ':mode';
-use File::Temp ':mktemp';
-
-my $cachedir = "/appcache/boot";
-my $index = 0;
-my $ret;
-my %inodes = {}; # make sure we do each inode only onc3
-my %hardlinks = {};
-my %stats = {};
-my @order = ();
-my $VERSION = "0.8";
-
-sub print_usage {
- print STDERR "bootcache $VERSION\n";
- print STDERR "usage: bootcache [ -c cache dir ]\n";
- print STDERR "\tfeed files to cache over stdin\n";
- exit 1;
-}
-
-sub link_copy($$) {
- my ($f, $cache) = @_;
- my $tmp;
- my $sum;
- my $tmpsum;
-
- $tmp = mktemp("$cache.XXXXX");
- link($cache, "$tmp") ||
- die "link from $cache to $tmp failed";
-
- if (0) {
- $sum = `md5sum $f`;
- chomp $sum;
- $sum =~ s/ .*$//;
- $tmpsum = `md5sum $tmp`;
- chomp $tmpsum;
- $tmpsum =~ s/ .*$//;
- if ($sum ne $tmpsum) {
- print STDERR "md5sums of $f ($sum) and $tmp ($tmpsum) don't match, stopping\n";
- exit(1);
- }
- }
- rename($tmp, $f) || die "rename $tmp $f failed";
-}
-
-$ret = GetOptions("cachedir=s" => \$cachedir) || print_usage();
-if (scalar(@ARGV)) {
- print_usage();
-}
-
-if (! -d $cachedir) {
- print STDERR "creating $cachedir\n";
- system("mkdir -p $cachedir");
- if ($?) {
- my $ret = $? >> 8;
- die "Unable to create $cachedir error $ret";
- }
-}
-printf "Using $cachedir as the cache directory\n";
-
-my $cachestat = stat($cachedir) || die "Stat failed on $cachedir";
-while(<>) {
- my $ret;
- my $dev;
- my $ino;
-
- chomp;
- my $f = $_;
- if (! -r $f) {
- print STDERR "Skipping $f not readable\n";
- next;
- }
- if (defined ($hardlinks{$f})) {
- print STDERR "Skipping duplicate $f\n";
- next;
- }
- my $st = lstat($f) || die "Stat failed on $f";
-
- $dev = $st->dev;
- $ino = $st->ino;
- if (!S_ISREG($st->mode)) {
- print STDERR "Skipping $f (not regular)\n";
- next;
- }
- if ($dev != $cachestat->dev) {
- print STDERR "$f is on a different device then $cachedir, skipping\n";
- next;
- }
-
- if (defined($inodes{"$dev:$ino"})) {
- my $orig_link = $inodes{"$dev:$ino"};
- print STDERR "linking $f back to $dev:$ino $orig_link\n";
- utime $st->atime, $st->mtime, $f;
- my $ref = $hardlinks{$orig_link};
- push @$ref, $f;
- } else {
- $inodes{"$dev:$ino"} = $f;
- $hardlinks{$f} = [$f];
- $stats{$f} = $st;
- push @order, $f;
- }
-}
-
-foreach my $o (@order) {
- my $ref = $hardlinks{$o};
- foreach my $ol (@$ref) {
- print "$o: $ol\n";
- }
-}
-
-foreach my $f (@order) {
- my $st = $stats{$f};
- while( -e "$cachedir/$index") {
- $index++;
- }
- print STDERR "Processing $f to $cachedir/$index\n";
- copy("$f", "$cachedir/$index") || die "copy failed for $f";
- my $ref = $hardlinks{$f};
- foreach my $ol (@$ref) {
- link_copy($ol, "$cachedir/$index");
- utime $st->atime, $st->mtime, $ol;
- }
-
- # TODO copy acls/xattrs
- $ret = chown $st->uid, $st->gid, "$cachedir/$index";
- if ($ret != 1) {
- die "chown $st->uid, $st->gid, failed for $cachedir/$index ($f)";
- }
- $ret = chmod $st->mode, "$cachedir/$index";
- if ($ret != 1) {
- die "chmod $st->mode failed for $cachedir/$index ($f)";
- }
- $index++;
-}
-
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/init.startpreload new/preload/init.startpreload
--- old/preload/init.startpreload 2009-03-25 15:15:45.000000000 +0100
+++ new/preload/init.startpreload 2009-04-06 12:05:26.000000000 +0200
@@ -16,38 +16,34 @@
. /etc/rc.status
rc_reset
-ROOT_IS_EXT3=
-while read where what type options rest ; do
- case "$where" in
- \#*|"") ;;
- *) if test "$type" = "ext3" -a "$what" = "/"; then
- ROOT_IS_EXT3=$where
- break
- fi ;;
- esac
-done < /etc/fstab
-
case "$1" in
start)
- rm -f /var/run/blktrace.pid
preload=1
- for o in $(cat /proc/cmdline); do
+ preloadlog=/dev/shm/preloadtrace.log
+ for o in $(cat /proc/cmdline); do
case $o in
nopreload)
preload=0
;;
+ preloadlog=*)
+ eval $o
+ ;;
esac
done
if test "$preload" = 1; then
- staprun -o /dev/shm/preloadtrace.log preloadtrace &
- count=0
- while test -z "`pidof stapio`"; do
- usleep 50000
- count=$((count+1))
- test $count -gt 20 && break
- done
- /usr/bin/ionice -c3 /sbin/preload /var/cache/preload/prepared
- /sbin/preload-client startpar &
+ if test "$preloadlog" != "/dev/null"; then
+ staprun -o $preloadlog preloadtrace &
+ count=0
+ while test -z "`pidof stapio`"; do
+ usleep 50000
+ count=$((count+1))
+ test $count -gt 20 && break
+ done
+ fi
+ if test -f /var/cache/preload/prepared; then
+ /usr/bin/ionice -c3 /sbin/preload /var/cache/preload/prepared
+ /sbin/preload-client startpar &
+ fi
fi
rc_status -v -r
;;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/init.stoppreload new/preload/init.stoppreload
--- old/preload/init.stoppreload 2009-03-25 15:15:45.000000000 +0100
+++ new/preload/init.stoppreload 2009-04-06 12:05:26.000000000 +0200
@@ -17,18 +17,7 @@
case "$1" in
start)
- rm -f /var/run/lastblks
- killall stapio
- pid=$(pidof blktrace)
- if test -n "$pid"; then
- echo "Stopping blktrace..."
- kill $pid
- fi
- ( if nice /usr/bin/ionice -c3 /usr/bin/prepare_preload < /dev/shm/preloadtrace.log > /var/cache/preload/prepared.$$; then
- mv /var/cache/preload/prepared.$$ /var/cache/preload/prepared
- gzip -c /dev/shm/preloadtrace.log > /var/cache/preload/trace.gz
- rm /dev/shm/preloadtrace.log
- fi ) &
+ /usr/sbin/stop_preload &
rc_status -v -r
;;
stop)
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/Makefile new/preload/Makefile
--- old/preload/Makefile 2009-03-25 21:47:16.000000000 +0100
+++ new/preload/Makefile 2009-04-06 12:05:26.000000000 +0200
@@ -1,5 +1,5 @@
-all: preload preload-client print-bmap
+all: preload preload-client print-bmap waitforidle
CFLAGS=-g3 -O2 -W -Wall -D_FORTIFY_SOURCE=2 -fstack-protector
@@ -21,6 +21,9 @@
preload-client: preload-client.c
gcc $(CFLAGS) preload-client.c -o preload-client
+waitforidle: waitforidle.cpp
+ g++ $(CFLAGS) waitforidle.cpp -o waitforidle
+
install:
install -m 755 preload /sbin
install -m 755 preload-client /sbin
@@ -28,4 +31,5 @@
install -m 755 init.startpreload /etc/init.d/boot.startpreload
install -m 755 init.stoppreload /etc/init.d/stoppreload
install -m 755 prepare_preload /usr/bin/prepare_preload
+ install -m 755 waitforidle /usr/bin/waitforidle
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/prepare_preload new/preload/prepare_preload
--- old/preload/prepare_preload 2009-03-25 15:15:45.000000000 +0100
+++ new/preload/prepare_preload 2009-03-26 08:08:33.000000000 +0100
@@ -2,9 +2,12 @@
use strict;
use File::stat;
+use File::Copy;
use Fcntl ':mode';
use File::Spec;
use Getopt::Std;
+use Fcntl ':mode';
+use File::Temp ':mktemp';
my %pwds = ();
my %ppids = ();
@@ -32,6 +35,127 @@
my %stated_alldirs;
my %file2size;
my $verbose = 0;
+my @filesintimeorder = ();
+
+sub link_copy($$) {
+ my ($f, $cache) = @_;
+ my $tmp;
+ my $sum;
+ my $tmpsum;
+
+ $tmp = mktemp("$cache.XXXXX");
+ link($cache, "$tmp") ||
+ die "link from $cache to $tmp failed";
+
+ if (0) {
+ $sum = `md5sum $f`;
+ chomp $sum;
+ $sum =~ s/ .*$//;
+ $tmpsum = `md5sum $tmp`;
+ chomp $tmpsum;
+ $tmpsum =~ s/ .*$//;
+ if ($sum ne $tmpsum) {
+ print STDERR "md5sums of $f ($sum) and $tmp ($tmpsum) don't match, stopping\n";
+ exit(1);
+ }
+ }
+ rename($tmp, $f) || die "rename $tmp $f failed";
+}
+
+sub bootcache($) {
+
+ my $cachedir = "/appcache/boot";
+ my $index = 0;
+ my $ret;
+ my %inodes = {}; # make sure we do each inode only onc3
+ my %hardlinks = {};
+ my %stats = {};
+ my @order = ();
+ my ($files) = @_;
+
+ if (! -d $cachedir) {
+ #print STDERR "creating $cachedir\n";
+ system("mkdir -p $cachedir");
+ if ($?) {
+ my $ret = $? >> 8;
+ die "Unable to create $cachedir error $ret";
+ }
+ }
+ #printf "Using $cachedir as the cache directory\n";
+
+ my $cachestat = stat($cachedir) || die "Stat failed on $cachedir";
+ foreach my $f (@$files) {
+ my $ret;
+ my $dev;
+ my $ino;
+
+ if (! -r $f) {
+ #print STDERR "Skipping $f not readable\n";
+ next;
+ }
+ if (defined ($hardlinks{$f})) {
+ #print STDERR "Skipping duplicate $f\n";
+ next;
+ }
+ my $st = lstat($f) || die "Stat failed on $f";
+
+ $dev = $st->dev;
+ $ino = $st->ino;
+ if (!S_ISREG($st->mode)) {
+ #print STDERR "Skipping $f (not regular)\n";
+ next;
+ }
+ if ($dev != $cachestat->dev) {
+ #print STDERR "$f is on a different device then $cachedir, skipping\n";
+ next;
+ }
+
+ if (defined($inodes{"$dev:$ino"})) {
+ my $orig_link = $inodes{"$dev:$ino"};
+ #print STDERR "linking $f back to $dev:$ino $orig_link\n";
+ utime $st->atime, $st->mtime, $f;
+ my $ref = $hardlinks{$orig_link};
+ push @$ref, $f;
+ } else {
+ $inodes{"$dev:$ino"} = $f;
+ $hardlinks{$f} = [$f];
+ $stats{$f} = $st;
+ push @order, $f;
+ }
+ }
+
+ foreach my $o (@order) {
+ my $ref = $hardlinks{$o};
+ #foreach my $ol (@$ref) {
+ # print "$o: $ol\n";
+ #}
+ }
+
+ foreach my $f (@order) {
+ my $st = $stats{$f};
+ while ( -e "$cachedir/$index") {
+ $index++;
+ }
+ #print STDERR "Processing $f to $cachedir/$index\n";
+ copy("$f", "$cachedir/$index") || die "copy failed for $f";
+ my $ref = $hardlinks{$f};
+ foreach my $ol (@$ref) {
+ link_copy($ol, "$cachedir/$index");
+ utime $st->atime, $st->mtime, $ol;
+ }
+
+ # TODO copy acls/xattrs
+ $ret = chown $st->uid, $st->gid, "$cachedir/$index";
+ if ($ret != 1) {
+ die "chown $st->uid, $st->gid, failed for $cachedir/$index ($f)";
+ }
+ $ret = chmod $st->mode, "$cachedir/$index";
+ if ($ret != 1) {
+ die "chmod $st->mode failed for $cachedir/$index ($f)";
+ }
+ $index++;
+ }
+}
# make_abs (PWD, ARG) makes ARG an absolute pathname if it isn't already
# with PWD being the current dir (i.e. the one to which ARG is relative to)
@@ -102,7 +226,7 @@
}
#print "all $filecounter $command $file\n";
$filecounter++;
- #print STDERR "$file\n";
+ push(@filesintimeorder, $file);
}
my $fid = $allfiles{$command . $file};
@@ -504,6 +628,7 @@
}
read_strace;
+bootcache(\@filesintimeorder);
gather_layout;
order_commands;
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/stop_preload new/preload/stop_preload
--- old/preload/stop_preload 1970-01-01 01:00:00.000000000 +0100
+++ new/preload/stop_preload 2009-04-06 12:05:26.000000000 +0200
@@ -0,0 +1,13 @@
+#! /bin/sh
+
+/usr/bin/waitforidle
+killall stapio
+rm -rf /appcache/boot
+if test -f /dev/shm/preloadtrace.log; then
+ if nice /usr/bin/ionice -c3 /usr/bin/prepare_preload < /dev/shm/preloadtrace.log > /var/cache/preload/prepared.$$; then
+ mv /var/cache/preload/prepared.$$ /var/cache/preload/prepared
+ rm -rf /appcache/boot
+ fi
+ gzip -c /dev/shm/preloadtrace.log > /var/cache/preload/trace.gz
+ rm /dev/shm/preloadtrace.log
+fi
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/preload/waitforidle.cpp new/preload/waitforidle.cpp
--- old/preload/waitforidle.cpp 1970-01-01 01:00:00.000000000 +0100
+++ new/preload/waitforidle.cpp 2009-04-06 11:59:30.000000000 +0200
@@ -0,0 +1,110 @@
+#include