Pino Toscano
2015-May-04 12:26 UTC
[Libguestfs] [PATCH] build: remove unreadable files after filtering
Move the removal of the files which don't exist or cannot be read, doing it after the filtering with excludefiles and hostfiles files. This avoid stat'ing files which will be excluded later anyway, hence reducing the I/O during a supermin build phase. --- src/build.ml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/build.ml b/src/build.ml index b9b44ac..d7d0781 100644 --- a/src/build.ml +++ b/src/build.ml @@ -125,22 +125,6 @@ let rec build debug if debug >= 1 then printf "supermin: build: %d files\n%!" (List.length files); - (* Remove files from the list which don't exist on the host or are - * unreadable to us. - *) - let files - List.filter ( - fun file -> - try ignore (lstat file.ft_source_path); true - with Unix_error _ -> - try ignore (lstat file.ft_path); true - with Unix_error _ -> false - ) files in - - if debug >= 1 then - printf "supermin: build: %d files, after removing unreadable files\n%!" - (List.length files); - (* Remove excludefiles from the list. Notes: (1) The current * implementation does not apply excludefiles to the base image. (2) * The current implementation does not apply excludefiles to the @@ -185,6 +169,22 @@ let rec build debug printf "supermin: build: %d files, after adding hostfiles\n%!" (List.length files); + (* Remove files from the list which don't exist on the host or are + * unreadable to us. + *) + let files + List.filter ( + fun file -> + try ignore (lstat file.ft_source_path); true + with Unix_error _ -> + try ignore (lstat file.ft_path); true + with Unix_error _ -> false + ) files in + + if debug >= 1 then + printf "supermin: build: %d files, after removing unreadable files\n%!" + (List.length files); + (* Difficult to explain what this does. See comment below. *) let files = munge files in -- 2.1.0
Richard W.M. Jones
2015-May-06 15:47 UTC
Re: [Libguestfs] [PATCH] build: remove unreadable files after filtering
On Mon, May 04, 2015 at 02:26:11PM +0200, Pino Toscano wrote:> Move the removal of the files which don't exist or cannot be read, doing > it after the filtering with excludefiles and hostfiles files. > This avoid stat'ing files which will be excluded later anyway, hence > reducing the I/O during a supermin build phase. > --- > src/build.ml | 32 ++++++++++++++++---------------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/src/build.ml b/src/build.ml > index b9b44ac..d7d0781 100644 > --- a/src/build.ml > +++ b/src/build.ml > @@ -125,22 +125,6 @@ let rec build debug > if debug >= 1 then > printf "supermin: build: %d files\n%!" (List.length files); > > - (* Remove files from the list which don't exist on the host or are > - * unreadable to us. > - *) > - let files > - List.filter ( > - fun file -> > - try ignore (lstat file.ft_source_path); true > - with Unix_error _ -> > - try ignore (lstat file.ft_path); true > - with Unix_error _ -> false > - ) files in > - > - if debug >= 1 then > - printf "supermin: build: %d files, after removing unreadable files\n%!" > - (List.length files); > - > (* Remove excludefiles from the list. Notes: (1) The current > * implementation does not apply excludefiles to the base image. (2) > * The current implementation does not apply excludefiles to the > @@ -185,6 +169,22 @@ let rec build debug > printf "supermin: build: %d files, after adding hostfiles\n%!" > (List.length files); > > + (* Remove files from the list which don't exist on the host or are > + * unreadable to us. > + *) > + let files > + List.filter ( > + fun file -> > + try ignore (lstat file.ft_source_path); true > + with Unix_error _ -> > + try ignore (lstat file.ft_path); true > + with Unix_error _ -> false > + ) files in > + > + if debug >= 1 then > + printf "supermin: build: %d files, after removing unreadable files\n%!" > + (List.length files); > + > (* Difficult to explain what this does. See comment below. *) > let files = munge files inACK. I have pushed this, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Seemingly Similar Threads
- [supermin 3/3] Use the file tuple up to the point where files are copied into the filesystem / chroot
- [supermin 2/3] Add file.source_path, no functional changes
- supermin and dpkg-divert
- [supermin 1/3] Recognize dpkg-divert
- [supermin 1/2] chroot: Fix corner case introduced with dpkg-divert support