From owner-freebsd-hackers@FreeBSD.ORG Fri Jun 25 16:52:30 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A257E106566B for ; Fri, 25 Jun 2010 16:52:30 +0000 (UTC) (envelope-from naylor.b.david@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2DFFE8FC14 for ; Fri, 25 Jun 2010 16:52:29 +0000 (UTC) Received: by wyf22 with SMTP id 22so1536298wyf.13 for ; Fri, 25 Jun 2010 09:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:organization:to:subject :date:user-agent:mime-version:content-type:content-transfer-encoding :message-id; bh=OdIhbkl0eY0F6/iMzmDz6JovcG4wbo0TIHR7S+Vh3Bk=; b=Sr7JXwN/E1+Yt0ejSNk6tEaNxivSaYUC1l3iAx+twlyAr1FiGFSfD7TjuPYnIOcuCP d0sgAuazUMuxYfvKAp8DZouqO5YMoK58UuhiKUuQ82xF9RWqFIE0KAF+WZ3W2DZ8lpOD AwhCE7OZUywFIqi4zCf8e25VdS4tXL1J4atRc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:organization:to:subject:date:user-agent:mime-version :content-type:content-transfer-encoding:message-id; b=c8YgGSrI1sUp/WfLvZEipWytvMFW9tmhmlvOZ4q/BzgGG+u1K9NrSiDghsqbcg4OyR aC0XWJ8iylRaKUoWcWbWdTrLKTMIifFKrKQd6LEaEj0/mOV1zC/CLLwfEsDtJUqjtC6e Blb4cMJWpdRi5kWAjopq+Y7syH176xSfibm1g= Received: by 10.216.153.149 with SMTP id f21mr5345190wek.2.1277484749056; Fri, 25 Jun 2010 09:52:29 -0700 (PDT) Received: from dragon.dg (41-132-24-150.dsl.mweb.co.za [41.132.24.150]) by mx.google.com with ESMTPS id l46sm2523202wed.10.2010.06.25.09.52.24 (version=SSLv3 cipher=RC4-MD5); Fri, 25 Jun 2010 09:52:28 -0700 (PDT) From: David Naylor Organization: Private To: freebsd-hackers@freebsd.org Date: Fri, 25 Jun 2010 18:52:26 +0200 User-Agent: KMail/1.13.3 (FreeBSD/9.0-CURRENT; KDE/4.4.3; amd64; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart42614793.5JcOpxEqdd"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201006251852.30302.naylor.b.david@gmail.com> Subject: [RFC] mtree improvements X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Jun 2010 16:52:30 -0000 --nextPart42614793.5JcOpxEqdd Content-Type: multipart/mixed; boundary="Boundary-01=_K7NJM4EmdaaEL6R" Content-Transfer-Encoding: 7bit --Boundary-01=_K7NJM4EmdaaEL6R Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I've created a patch that increases the performance of mtree. This is of=20 particular use during a port install. In an extreme case I have experience= d a=20 ~20% increase [1]. =20 =46or a full discussion see PR bin/143732. This arose out of [2] where I=20 experienced the increase. =20 =46or your convenience I have attached the patch. =20 Please review this patch and if it is acceptable, commit it. =20 Regards, David 1] http://markmail.org/message/iju3l6hyv7s7emrb 2] http://markmail.org/message/gfztjpszl5dozzii --Boundary-01=_K7NJM4EmdaaEL6R Content-Type: text/x-patch; charset="ISO-8859-1"; name="mtree.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mtree.diff" =2D-- /usr/src/usr.sbin/mtree/verify.c 2010-02-07 15:07:28.000000000 +0200 +++ verify.c 2010-02-07 15:04:10.000000000 +0200 @@ -50,17 +50,23 @@ static NODE *root; static char path[MAXPATHLEN]; =20 =2Dstatic void miss(NODE *, char *); +static int miss(NODE *, char *); +static int check(NODE *, char *); static int vwalk(void); =20 int mtree_verifyspec(FILE *fi) { =2D int rval; + int rval =3D 0; =20 root =3D mtree_readspec(fi); =2D rval =3D vwalk(); =2D miss(root, path); + /* + * No need to walk entire tree if we are only updating the structure + * and extra files are ignored. + */ + if (!(uflag && eflag)) + rval =3D vwalk(); + rval |=3D miss(root, path); return (rval); } =20 @@ -155,15 +161,47 @@ return (rval); } =20 =2Dstatic void +static int +check(NODE *p, char *tail) +{ + FTSENT fts; + struct stat fts_stat; + + strcpy(tail, p->name); + + /* + * It is assumed that compare() only requires fts_accpath and fts_statp + * fields in the FTSENT structure. + */ + fts.fts_accpath =3D path; + fts.fts_statp =3D &fts_stat; + + if (stat(path, fts.fts_statp)) + return (0); + + p->flags |=3D F_VISIT; + if ((p->flags & F_NOCHANGE) =3D=3D 0 && compare(p->name, p, &fts)) + return (MISMATCHEXIT); + else + return (0); + + /* + * tail is not restored to '\0' as the next time tail (or path) is used + * is with a strcpy (thus overriding the '\0'). See +19 lines below. + */ +} + +static int miss(NODE *p, char *tail) { int create; char *tp; const char *type, *what; =2D int serr; + int serr, rval =3D 0; =20 for (; p; p =3D p->next) { + if (uflag && eflag) + rval |=3D check(p, tail); if (p->flags & F_OPT && !(p->flags & F_VISIT)) continue; if (p->type !=3D F_DIR && (dflag || p->flags & F_VISIT)) @@ -256,4 +294,5 @@ (void)printf("%s: file flags not set: %s\n", path, strerror(errno)); } + return (rval); } --Boundary-01=_K7NJM4EmdaaEL6R-- --nextPart42614793.5JcOpxEqdd Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEABECAAYFAkwk3s4ACgkQUaaFgP9pFrLcYQCfaS+oZhomdmcQBGZLHNnR+e12 uVkAoIBLLnexJ0tjEgsxSnvF/ooToQMQ =57B8 -----END PGP SIGNATURE----- --nextPart42614793.5JcOpxEqdd--