From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VlcOI-0005f2-3x for mharc-grub-devel@gnu.org; Wed, 27 Nov 2013 05:30:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlcOA-0005dh-A2 for grub-devel@gnu.org; Wed, 27 Nov 2013 05:30:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlcO4-00045y-G6 for grub-devel@gnu.org; Wed, 27 Nov 2013 05:30:34 -0500 Received: from mail-ea0-x232.google.com ([2a00:1450:4013:c01::232]:40909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlcO4-00045s-4M for grub-devel@gnu.org; Wed, 27 Nov 2013 05:30:28 -0500 Received: by mail-ea0-f178.google.com with SMTP id d10so4527219eaj.37 for ; Wed, 27 Nov 2013 02:30:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=uttN8EzE6nCO/X8VGqJrK/n6PJ9oLkMfrhrRkMeQWEg=; b=DtO9VbviOD02sGuO7/lTFCCI4TzZLQLvRD9PaDAKJZP7U413e5XYNx9CBIhISlRVG4 0DLqJazXjaacE9kxu4Qt4DQe4Nu0ILZi7JEvr11Nkj+4l9XA8LiVvXd557bvx1M/X7PA z6JtGWRcWANQ8qpMUubuBYOeaaQv0Nx9WZUjE5G9ec2qLs0Ag25fSkvUbcYDkXgHQfQW 6ePMC6/TP0wyjwcUVPcdI1uQxiAS9S4bjAbu2kMNE5qqFb9b+RtGeprFv5hrXt3WiFNJ eY8omuPfnExWfLSOg1gBcbDJqdlC4n75pTNOC5oQrv8plPZS0LMnQErAWshYK64FbhPr o3EA== X-Received: by 10.14.119.1 with SMTP id m1mr1458675eeh.39.1385548227171; Wed, 27 Nov 2013 02:30:27 -0800 (PST) Received: from [192.168.1.121] (31-249.1-85.cust.bluewin.ch. [85.1.249.31]) by mx.google.com with ESMTPSA id 8sm18092469eem.15.2013.11.27.02.30.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 27 Nov 2013 02:30:25 -0800 (PST) Message-ID: <5295C9B4.3040205@gmail.com> Date: Wed, 27 Nov 2013 11:30:12 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] Speed up test suite by avoiding fsync References: <20131127101332.GZ16147@riva.ucam.org> In-Reply-To: <20131127101332.GZ16147@riva.ucam.org> X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="----enig2GCHSXCNTFFOCPWVHNKIB" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::232 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Nov 2013 10:30:40 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2GCHSXCNTFFOCPWVHNKIB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 27.11.2013 11:13, Colin Watson wrote: > Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls int= o > no-ops, and use it in programs that copy files but do not need to take > special care to sync writes (grub-mknetdir, grub-rescue, > grub-mkstandalone). >=20 Go ahead. > On my laptop, this reduces partmap_test's runtime from 1236 seconds to > 204 seconds. > --- > ChangeLog | 7 +++++++ > grub-core/osdep/aros/hostdisk.c | 25 ++++++++++++++++++------- > grub-core/osdep/unix/hostdisk.c | 11 ++++++++++- > grub-core/osdep/windows/hostdisk.c | 11 ++++++++++- > include/grub/emu/hostfile.h | 2 ++ > util/grub-install-common.c | 2 +- > util/grub-mknetdir.c | 1 + > util/grub-mkrescue.c | 3 ++- > util/grub-mkstandalone.c | 1 + > 9 files changed, 52 insertions(+), 11 deletions(-) >=20 > diff --git a/ChangeLog b/ChangeLog > index 2e0d96e..4bbec86 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,10 @@ > +2013-11-27 Colin Watson > + > + Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls > + into no-ops, and use it in programs that copy files but do not need > + to take special care to sync writes (grub-mknetdir, grub-rescue, > + grub-mkstandalone). > + > 2013-11-26 Colin Watson > =20 > * tests/util/grub-fs-tester.in: Execute xorriso from $PATH rather > diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hos= tdisk.c > index 9c0a6c8..b153907 100644 > --- a/grub-core/osdep/aros/hostdisk.c > +++ b/grub-core/osdep/aros/hostdisk.c > @@ -455,6 +455,8 @@ grub_util_fd_close (grub_util_fd_t fd) > } > } > =20 > +static int allow_fd_syncs =3D 1; > + > static void > grub_util_fd_sync_volume (grub_util_fd_t fd) > { > @@ -469,18 +471,27 @@ grub_util_fd_sync_volume (grub_util_fd_t fd) > void > grub_util_fd_sync (grub_util_fd_t fd) > { > - switch (fd->type) > + if (allow_fd_syncs) > { > - case GRUB_UTIL_FD_FILE: > - fsync (fd->fd); > - return; > - case GRUB_UTIL_FD_DISK: > - grub_util_fd_sync_volume (fd); > - return; > + switch (fd->type) > + { > + case GRUB_UTIL_FD_FILE: > + fsync (fd->fd); > + return; > + case GRUB_UTIL_FD_DISK: > + grub_util_fd_sync_volume (fd); > + return; > + } > } > } > =20 > void > +grub_util_disable_fd_syncs (void) > +{ > + allow_fd_syncs =3D 0; > +} > + > +void > grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ (= (unused))) > { > } > diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hos= tdisk.c > index 78d4adb..fc88ed4 100644 > --- a/grub-core/osdep/unix/hostdisk.c > +++ b/grub-core/osdep/unix/hostdisk.c > @@ -191,10 +191,19 @@ grub_util_fd_strerror (void) > return strerror (errno); > } > =20 > +static int allow_fd_syncs =3D 1; > + > void > grub_util_fd_sync (grub_util_fd_t fd) > { > - fsync (fd); > + if (allow_fd_syncs) > + fsync (fd); > +} > + > +void > +grub_util_disable_fd_syncs (void) > +{ > + allow_fd_syncs =3D 0; > } > =20 > void > diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windo= ws/hostdisk.c > index 6d7d120..4748a61 100644 > --- a/grub-core/osdep/windows/hostdisk.c > +++ b/grub-core/osdep/windows/hostdisk.c > @@ -240,10 +240,19 @@ grub_util_fd_write (grub_util_fd_t fd, const char= *buf, size_t len) > return real_read; > } > =20 > +static int allow_fd_syncs =3D 1; > + > void > grub_util_fd_sync (grub_util_fd_t fd) > { > - FlushFileBuffers (fd); > + if (allow_fd_syncs) > + FlushFileBuffers (fd); > +} > + > +void > +grub_util_disable_fd_syncs (void) > +{ > + allow_fd_syncs =3D 0; > } > =20 > void > diff --git a/include/grub/emu/hostfile.h b/include/grub/emu/hostfile.h > index ab01fbc..8e37d5a 100644 > --- a/include/grub/emu/hostfile.h > +++ b/include/grub/emu/hostfile.h > @@ -50,6 +50,8 @@ EXPORT_FUNC(grub_util_fd_strerror) (void); > void > grub_util_fd_sync (grub_util_fd_t fd); > void > +grub_util_disable_fd_syncs (void); > +void > EXPORT_FUNC(grub_util_fd_close) (grub_util_fd_t fd); > =20 > grub_uint64_t > diff --git a/util/grub-install-common.c b/util/grub-install-common.c > index 7ecef3e..fcf994d 100644 > --- a/util/grub-install-common.c > +++ b/util/grub-install-common.c > @@ -492,7 +492,7 @@ grub_install_make_image_wrap (const char *dir, cons= t char *prefix, > memdisk_path, config_path, > mkimage_target, note, comp); > fflush (fp); > - fsync (fileno (fp)); > + grub_util_fd_sync (fileno (fp)); > fclose (fp); > } > =20 > diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c > index 3f91705..40ca724 100644 > --- a/util/grub-mknetdir.c > +++ b/util/grub-mknetdir.c > @@ -171,6 +171,7 @@ main (int argc, char *argv[]) > const char *pkglibdir; > =20 > grub_util_host_init (&argc, &argv); > + grub_util_disable_fd_syncs (); > rootdir =3D xstrdup ("/srv/tftp"); > pkglibdir =3D grub_util_get_pkglibdir (); > =20 > diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c > index 7a76bc3..b081b3b 100644 > --- a/util/grub-mkrescue.c > +++ b/util/grub-mkrescue.c > @@ -369,6 +369,7 @@ main (int argc, char *argv[]) > const char *pkgdatadir; > =20 > grub_util_host_init (&argc, &argv); > + grub_util_disable_fd_syncs (); > =20 > pkgdatadir =3D grub_util_get_pkgdatadir (); > =20 > @@ -529,7 +530,7 @@ main (int argc, char *argv[]) > GRUB_COMPRESSION_AUTO); > sz =3D ftello (sa); > fflush (sa); > - fsync (fileno (sa)); > + grub_util_fd_sync (fileno (sa)); > fclose (sa); > =20 > if (sz > 32768) > diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c > index 774af2f..3097f70 100644 > --- a/util/grub-mkstandalone.c > +++ b/util/grub-mkstandalone.c > @@ -305,6 +305,7 @@ main (int argc, char *argv[]) > int i; > =20 > grub_util_host_init (&argc, &argv); > + grub_util_disable_fd_syncs (); > =20 > files =3D xmalloc ((argc + 1) * sizeof (files[0])); > =20 >=20 ------enig2GCHSXCNTFFOCPWVHNKIB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlKVybsACgkQmBXlbbo5nOvv0AEApEdFASULdQhEtSfNkcYatAUK V0Bt13iJ5JFmHpMPLB0A/3OaETt2nP4JOtlq8QHJz52EXyWRGeCaWuf5h8LLBuQW =uhQV -----END PGP SIGNATURE----- ------enig2GCHSXCNTFFOCPWVHNKIB--