svn commit: r345727 - in head: sbin/devd sys/geom
Author: pjd Date: Sat Mar 30 07:24:34 2019 New Revision: 345727 URL: https://svnweb.freebsd.org/changeset/base/345727 Log: Introduce new event SIZECHANGE within GEOM system to inform about GEOM providers mediasize changes. While here, use GEOM nomenclature to describe providers instead of calling them device nodes. Obtained from:Fudo Security Tested in:AWS Modified: head/sbin/devd/devd.conf.5 head/sys/geom/geom_dev.c Modified: head/sbin/devd/devd.conf.5 == --- head/sbin/devd/devd.conf.5 Sat Mar 30 07:20:28 2019(r345726) +++ head/sbin/devd/devd.conf.5 Sat Mar 30 07:24:34 2019(r345727) @@ -41,7 +41,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd July 20, 2018 +.Dd March 29, 2019 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -432,15 +432,19 @@ only includes disk-like devices. .It Li CREATE A .Xr geom 4 -device node is created. +provider is created. .It Li DESTROY A .Xr geom 4 -device node is destroyed. +provider is destroyed. .It Li GEOM::physpath The physical path of a device has changed. .It Li MEDIACHANGE Physical media has changed. +.It Li SIZECHANGE +A +.Xr geom 4 +provider size has changed. .El .El .Pp Modified: head/sys/geom/geom_dev.c == --- head/sys/geom/geom_dev.cSat Mar 30 07:20:28 2019(r345726) +++ head/sys/geom/geom_dev.cSat Mar 30 07:24:34 2019(r345727) @@ -92,6 +92,7 @@ static g_fini_t g_dev_fini; static g_taste_t g_dev_taste; static g_orphan_t g_dev_orphan; static g_attrchanged_t g_dev_attrchanged; +static g_resize_t g_dev_resize; static struct g_class g_dev_class = { .name = "DEV", @@ -100,7 +101,8 @@ static struct g_class g_dev_class = { .fini = g_dev_fini, .taste = g_dev_taste, .orphan = g_dev_orphan, - .attrchanged = g_dev_attrchanged + .attrchanged = g_dev_attrchanged, + .resize = g_dev_resize }; /* @@ -300,6 +302,15 @@ g_dev_attrchanged(struct g_consumer *cp, const char *a g_dev_set_physpath(cp); return; } +} + +static void +g_dev_resize(struct g_consumer *cp) +{ + char buf[SPECNAMELEN + 6]; + + snprintf(buf, sizeof(buf), "cdev=%s", cp->provider->name); + devctl_notify_f("GEOM", "DEV", "SIZECHANGE", buf, M_WAITOK); } struct g_provider * ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345728 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Sat Mar 30 07:29:20 2019 New Revision: 345728 URL: https://svnweb.freebsd.org/changeset/base/345728 Log: If the autoexpand pool property is turned on and vdev is healthy try to expand the pool automatically when we detect underlying GEOM provider size change. Obtained from:Fudo Security Tested in:AWS Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Mar 30 07:24:34 2019(r345727) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Mar 30 07:29:20 2019(r345728) @@ -158,6 +158,29 @@ vdev_geom_attrchanged(struct g_consumer *cp, const cha } static void +vdev_geom_resize(struct g_consumer *cp) +{ + struct consumer_priv_t *priv; + struct consumer_vdev_elem *elem; + spa_t *spa; + vdev_t *vd; + + priv = (struct consumer_priv_t *)&cp->private; + if (SLIST_EMPTY(priv)) + return; + + SLIST_FOREACH(elem, priv, elems) { + vd = elem->vd; + if (vd->vdev_state != VDEV_STATE_HEALTHY) + continue; + spa = vd->vdev_spa; + if (!spa->spa_autoexpand) + continue; + vdev_online(spa, vd->vdev_guid, ZFS_ONLINE_EXPAND, NULL); + } +} + +static void vdev_geom_orphan(struct g_consumer *cp) { struct consumer_priv_t *priv; @@ -229,6 +252,7 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd, bo gp = g_new_geomf(&zfs_vdev_class, "zfs::vdev"); gp->orphan = vdev_geom_orphan; gp->attrchanged = vdev_geom_attrchanged; + gp->resize = vdev_geom_resize; cp = g_new_consumer(gp); error = g_attach(cp, pp); if (error != 0) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345726 - head/sys/dev/xen/blkfront
Author: pjd Date: Sat Mar 30 07:20:28 2019 New Revision: 345726 URL: https://svnweb.freebsd.org/changeset/base/345726 Log: Implement support for online disk capacity changes. Obtained from:Fudo Security Tested in:AWS Modified: head/sys/dev/xen/blkfront/blkfront.c Modified: head/sys/dev/xen/blkfront/blkfront.c == --- head/sys/dev/xen/blkfront/blkfront.cSat Mar 30 01:56:53 2019 (r345725) +++ head/sys/dev/xen/blkfront/blkfront.cSat Mar 30 07:20:28 2019 (r345726) @@ -1227,11 +1227,40 @@ xbd_connect(struct xbd_softc *sc) int err, feature_barrier, feature_flush; int i, j; - if (sc->xbd_state == XBD_STATE_CONNECTED || - sc->xbd_state == XBD_STATE_SUSPENDED) + DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev)); + + if (sc->xbd_state == XBD_STATE_SUSPENDED) { return; + } - DPRINTK("blkfront.c:connect:%s.\n", xenbus_get_otherend_path(dev)); + if (sc->xbd_state == XBD_STATE_CONNECTED) { + struct disk *disk; + + disk = sc->xbd_disk; + if (disk == NULL) { + return; + } + err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), + "sectors", "%lu", §ors, NULL); + if (err != 0) { + xenbus_dev_error(dev, err, + "reading sectors at %s", + xenbus_get_otherend_path(dev)); + return; + } + disk->d_mediasize = disk->d_sectorsize * sectors; + err = disk_resize(disk, M_NOWAIT); + if (err) { + xenbus_dev_error(dev, err, + "unable to resize disk %s%u", + disk->d_name, disk->d_unit); + return; + } + device_printf(sc->xbd_dev, + "changed capacity to %jd\n", + (intmax_t)disk->d_mediasize); + return; + } err = xs_gather(XST_NIL, xenbus_get_otherend_path(dev), "sectors", "%lu", §ors, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345862 - in head: lib/geom/eli sys/geom/eli
Author: pjd Date: Wed Apr 3 23:57:37 2019 New Revision: 345862 URL: https://svnweb.freebsd.org/changeset/base/345862 Log: Implement automatic online expansion of GELI providers - if the underlying provider grows, GELI will expand automatically and will move the metadata to the new location of the last sector. This functionality is turned on by default. It can be turned off with the -R flag, but it is not recommended - if the underlying provider grows and automatic expansion is turned off, it won't be possible to attach this provider again, as the metadata is no longer located in the last sector. If the automatic expansion is turned off and the underlying provider grows, GELI will only log a message with the previous size of the provider, so recovery can be easier. Obtained from:Fudo Security Modified: head/lib/geom/eli/geli.8 head/lib/geom/eli/geom_eli.c head/sys/geom/eli/g_eli.c head/sys/geom/eli/g_eli.h head/sys/geom/eli/g_eli_ctl.c head/sys/geom/eli/g_eli_key_cache.c Modified: head/lib/geom/eli/geli.8 == --- head/lib/geom/eli/geli.8Wed Apr 3 23:50:52 2019(r345861) +++ head/lib/geom/eli/geli.8Wed Apr 3 23:57:37 2019(r345862) @@ -1,4 +1,4 @@ -.\" Copyright (c) 2005-2011 Pawel Jakub Dawidek +.\" Copyright (c) 2005-2019 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 24, 2018 +.Dd April 3, 2019 .Dt GELI 8 .Os .Sh NAME @@ -51,7 +51,7 @@ utility: .Pp .Nm .Cm init -.Op Fl bdgPTv +.Op Fl bdgPRTv .Op Fl a Ar aalgo .Op Fl B Ar backupfile .Op Fl e Ar ealgo @@ -81,7 +81,7 @@ utility: .Cm detach .Nm .Cm onetime -.Op Fl dT +.Op Fl dRT .Op Fl a Ar aalgo .Op Fl e Ar ealgo .Op Fl l Ar keylen @@ -89,7 +89,7 @@ utility: .Ar prov .Nm .Cm configure -.Op Fl bBdDgGtT +.Op Fl bBdDgGrRtT .Ar prov ... .Nm .Cm setkey @@ -375,6 +375,18 @@ Change decrypted provider's sector size. Increasing the sector size allows increased performance, because encryption/decryption which requires an initialization vector is done per sector; fewer sectors means less computational work. +.It Fl R +Turn off automatic expansion. +By default, if the underlying provider grows, the encrypted provider will +grow automatically too. +The metadata will be moved to the new location. +If automatic expansion if turned off and the underlying provider changes +size, attaching encrypted provider will no longer be possible as the metadata +will no longer be located in the last sector. +In this case +.Nm GELI +will only log the previous size of the underlying provider, so metadata can +be found easier, if resize was done by mistake. .It Fl T Don't pass through .Dv BIO_DELETE @@ -506,6 +518,11 @@ Change decrypted provider's sector size. For more information, see the description of the .Cm init subcommand. +.It Fl R +Turn off automatic expansion. +For more information, see the description of the +.Cm init +subcommand. .It Fl T Disable TRIM/UNMAP passthru. For more information, see the description of the @@ -540,6 +557,13 @@ The boot loader prompts for the passphrase and loads from the encrypted partition. .It Fl G Deactivate booting from this encrypted root partition. +.It Fl r +Turn on automatic expansion. +For more information, see the description of the +.Cm init +subcommand. +.It Fl R +Turn off automatic expansion. .It Fl t Enable TRIM/UNMAP passthru. For more information, see the description of the Modified: head/lib/geom/eli/geom_eli.c == --- head/lib/geom/eli/geom_eli.cWed Apr 3 23:50:52 2019 (r345861) +++ head/lib/geom/eli/geom_eli.cWed Apr 3 23:57:37 2019 (r345862) @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * - * Copyright (c) 2004-2010 Pawel Jakub Dawidek + * Copyright (c) 2004-2019 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,13 +91,13 @@ static int eli_backup_create(struct gctl_req *req, con /* * Available commands: * - * init [-bdgPTv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov ... + * init [-bdgPRTv] [-a aalgo] [-B backupfile] [-e ealgo] [-i iterations] [-l keylen] [-J newpassfile] [-K newkeyfile] [-s sectorsize] [-V version] prov ... * label - alias for 'init' * attach [-Cdprv] [-n keyno] [-j passfile] [-k keyfile] prov ... * detach [-fl] prov ... * stop - alias for 'detach' - * onetime [-dT] [-a aalgo] [-e ealgo] [-l keylen] prov - * configure [-bBgGtT] prov ... + * onetime [-dRT] [-a aalgo] [-e ealgo] [-l keylen] prov +
svn commit: r345861 - head/lib/geom/eli
Author: pjd Date: Wed Apr 3 23:50:52 2019 New Revision: 345861 URL: https://svnweb.freebsd.org/changeset/base/345861 Log: - Add missing -T (notrim) option to the label subcommand. - Add missing -T option in the onetime subcommand comment. Obtained from:Fudo Security Modified: head/lib/geom/eli/geom_eli.c Modified: head/lib/geom/eli/geom_eli.c == --- head/lib/geom/eli/geom_eli.cWed Apr 3 22:30:20 2019 (r345860) +++ head/lib/geom/eli/geom_eli.cWed Apr 3 23:50:52 2019 (r345861) @@ -96,7 +96,7 @@ static int eli_backup_create(struct gctl_req *req, con * attach [-Cdprv] [-n keyno] [-j passfile] [-k keyfile] prov ... * detach [-fl] prov ... * stop - alias for 'detach' - * onetime [-d] [-a aalgo] [-e ealgo] [-l keylen] prov + * onetime [-dT] [-a aalgo] [-e ealgo] [-l keylen] prov * configure [-bBgGtT] prov ... * setkey [-pPv] [-n keyno] [-j passfile] [-J newpassfile] [-k keyfile] [-K newkeyfile] prov * delkey [-afv] [-n keyno] prov @@ -145,6 +145,7 @@ struct g_command class_commands[] = { { 'l', "keylen", "0", G_TYPE_NUMBER }, { 'P', "nonewpassphrase", NULL, G_TYPE_BOOL }, { 's', "sectorsize", "0", G_TYPE_NUMBER }, + { 'T', "notrim", NULL, G_TYPE_BOOL }, { 'V', "mdversion", "-1", G_TYPE_NUMBER }, G_OPT_SENTINEL }, ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345863 - head/tests/sys/geom/class/eli
Author: pjd Date: Wed Apr 3 23:58:58 2019 New Revision: 345863 URL: https://svnweb.freebsd.org/changeset/base/345863 Log: Update configure tests after addition of the online expansion. Obtained from:Fudo Security Modified: head/tests/sys/geom/class/eli/configure_test.sh Modified: head/tests/sys/geom/class/eli/configure_test.sh == --- head/tests/sys/geom/class/eli/configure_test.sh Wed Apr 3 23:57:37 2019(r345862) +++ head/tests/sys/geom/class/eli/configure_test.sh Wed Apr 3 23:58:58 2019(r345863) @@ -17,19 +17,19 @@ configure_b_B_body() atf_check geli init -B none -P -K /dev/null ${md} - atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli init -B none -b -P -K /dev/null ${md} - atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli configure -B ${md} - atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli configure -b ${md} - atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli attach -p -k /dev/null ${md} @@ -39,13 +39,13 @@ configure_b_B_body() atf_check -o not-match:'^Flags: .*BOOT' geli list ${md}.eli - atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x200$' geli dump ${md} atf_check geli configure -b ${md} atf_check -s exit:0 -o match:'^Flags: .*BOOT' geli list ${md}.eli - atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + atf_check -s exit:0 -o match:'flags: 0x202$' geli dump ${md} atf_check geli detach ${md} } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r345864 - head/tests/sys/geom/class/eli
Author: pjd Date: Thu Apr 4 00:05:36 2019 New Revision: 345864 URL: https://svnweb.freebsd.org/changeset/base/345864 Log: Implement tests for online expansion: - init, init -R - onetime, onetime -R - 512 and 4k sectors - encryption only - encryption and authentication - configure -r/-R for detached providers - configure -r/-R for attached providers - all keys allocated (10, 20 and 30MB provider sizes) - keys allocated on demand (10, 20 and 30PB provider sizes) - reading and writing to provider after expansion (10-30MB only) - checking if metadata in old location is cleared. Obtained from:Fudo Security Added: head/tests/sys/geom/class/eli/online_resize_test.sh (contents, props changed) Modified: head/tests/sys/geom/class/eli/Makefile Modified: head/tests/sys/geom/class/eli/Makefile == --- head/tests/sys/geom/class/eli/Makefile Wed Apr 3 23:58:58 2019 (r345863) +++ head/tests/sys/geom/class/eli/Makefile Thu Apr 4 00:05:36 2019 (r345864) @@ -16,6 +16,7 @@ ATF_TESTS_SH+=integrity_test ATF_TESTS_SH+= kill_test ATF_TESTS_SH+= misc_test ATF_TESTS_SH+= onetime_test +ATF_TESTS_SH+= online_resize_test ATF_TESTS_SH+= resize_test ATF_TESTS_SH+= setkey_test Added: head/tests/sys/geom/class/eli/online_resize_test.sh == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/geom/class/eli/online_resize_test.sh Thu Apr 4 00:05:36 2019(r345864) @@ -0,0 +1,196 @@ +#!/bin/sh +# $FreeBSD$ + +. $(atf_get_srcdir)/conf.sh + +atf_test_case online_resize cleanup +online_resize_head() +{ + atf_set "descr" "online resize of geli providers" + atf_set "require.user" "root" +} +online_resize_body() +{ + geli_test_setup + + ( + echo "m 512 none 10485248 1 1 20971008 1 1 31456768 1 1" + echo "m 4096 none 10481664 1 1 20967424 1 1 31453184 1 1" + echo "m 512 HMAC/SHA256 5242368 1 1 10485248 1 1 15728128 1 1" + echo "m 4096 HMAC/SHA256 9318400 1 1 18640896 1 1 27959296 1 1" + echo "p 512 none 11258999068425728 [0-9] 20971520 22517998136851968 [0-9] 41943040 33776997205278208 [0-9] 62914560" + echo "p 4096 none 11258999068422144 [0-9] 2621440 22517998136848384 [0-9] 5242880 33776997205274624 [0-9] 7864320" + echo "p 512 HMAC/SHA256 5629499534212608 [0-9] 20971520 11258999068425728 [0-9] 41943040 16888498602638848 [0-9] 62914560" + echo "p 4096 HMAC/SHA256 10007999171932160 [0-9] 20971520 20015998343868416 [0-9] 41943040 30023997515800576 [0-9] 62914560" + ) | while read prefix sector auth esize10 ka10 kt10 esize20 ka20 kt20 esize30 ka30 kt30; do + if [ "${auth}" = "none" ]; then + aalgo="" + eflags="0x200" + dflags="0x0" + else + aalgo="-a ${auth}" + eflags="0x210" + dflags="0x10" + fi + + if [ "${prefix}" = "m" ]; then + psize10="10485760" + psize20="20971520" + psize30="31457280" + else + psize10="11258999068426240" + psize20="22517998136852480" + psize30="33776997205278720" + fi + + md=$(attach_md -t malloc -s40${prefix}) + + # Initialise + atf_check -s exit:0 -o ignore gpart create -s GPT ${md} + atf_check -s exit:0 -o ignore gpart add -t freebsd-ufs -s 10${prefix} ${md} + + echo secret >tmp.key + + atf_check geli init ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 + # Autoresize is set by default. + atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 + + atf_check geli configure -R ${md}p1 + atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 + atf_check geli configure -r ${md}p1 + atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 + + atf_check geli init -R ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 + atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 + + atf_check geli configure -r ${md}p1 + atf_check -s exit:0 -o match:"flags: ${eflags}$" geli dump ${md}p1 + atf_check geli configure -R ${md}p1 + atf_check -s exit:0 -o match:"flags: ${dflags}$" geli dump ${md}p1 + + atf_check geli init ${aalgo} -s ${sector} -Bnone -PKtmp.key ${md}p1 + atf_check geli attach -pk tmp.key ${md}p1 + atf_check -s exit:0 -o m
svn commit: r357138 - head/bin/pwait
Author: pjd Date: Sun Jan 26 10:49:24 2020 New Revision: 357138 URL: https://svnweb.freebsd.org/changeset/base/357138 Log: - Be consistent with using sysexits(3) codes. - Turn fprintf()+exit() into errx(). Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 07:24:49 2020(r357137) +++ head/bin/pwait/pwait.c Sun Jan 26 10:49:24 2020(r357138) @@ -53,8 +53,7 @@ static void usage(void) { - fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); - exit(EX_USAGE); + errx(EX_USAGE, "usage: pwait [-t timeout] [-v] pid ..."); } /* @@ -120,11 +119,11 @@ main(int argc, char *argv[]) kq = kqueue(); if (kq == -1) - err(1, "kqueue"); + err(EX_OSERR, "kqueue"); e = malloc((argc + tflag) * sizeof(struct kevent)); if (e == NULL) - err(1, "malloc"); + err(EX_OSERR, "malloc"); nleft = 0; for (n = 0; n < argc; n++) { s = argv[n]; @@ -166,12 +165,12 @@ main(int argc, char *argv[]) while (nleft > 0) { n = kevent(kq, NULL, 0, e, nleft + tflag, NULL); if (n == -1) - err(1, "kevent"); + err(EX_OSERR, "kevent"); for (i = 0; i < n; i++) { if (e[i].filter == EVFILT_SIGNAL) { if (verbose) printf("timeout\n"); - return (124); + exit(124); } if (verbose) { status = e[i].data; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357139 - head/bin/pwait
Author: pjd Date: Sun Jan 26 10:51:57 2020 New Revision: 357139 URL: https://svnweb.freebsd.org/changeset/base/357139 Log: Check for duplicated PID without using additional variable. Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 10:49:24 2020(r357138) +++ head/bin/pwait/pwait.c Sun Jan 26 10:51:57 2020(r357139) @@ -66,7 +66,7 @@ main(int argc, char *argv[]) int kq; struct kevent *e; int tflag, verbose; - int opt, nleft, n, i, duplicate, status; + int opt, nleft, n, i, status; long pid; char *s, *end; double timeout; @@ -135,18 +135,19 @@ main(int argc, char *argv[]) warnx("%s: bad process id", s); continue; } - duplicate = 0; - for (i = 0; i < nleft; i++) + for (i = 0; i < nleft; i++) { if (e[i].ident == (uintptr_t)pid) - duplicate = 1; - if (!duplicate) { - EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, - 0, NULL); - if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) - warn("%ld", pid); - else - nleft++; + break; } + if (i < nleft) { + /* Duplicate. */ + continue; + } + EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) + warn("%ld", pid); + else + nleft++; } if (tflag) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357140 - head/bin/pwait
Author: pjd Date: Sun Jan 26 10:54:16 2020 New Revision: 357140 URL: https://svnweb.freebsd.org/changeset/base/357140 Log: Don't setup a timeout if we are exiting. Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 10:51:57 2020(r357139) +++ head/bin/pwait/pwait.c Sun Jan 26 10:54:16 2020(r357140) @@ -150,7 +150,7 @@ main(int argc, char *argv[]) nleft++; } - if (tflag) { + if (nleft > 0 && tflag) { /* * Explicitly detect SIGALRM so that an exit status of 124 * can be returned rather than 142. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357141 - head/bin/pwait
Author: pjd Date: Sun Jan 26 11:02:51 2020 New Revision: 357141 URL: https://svnweb.freebsd.org/changeset/base/357141 Log: Implement -o flag which tells pwait(1) to exit if any of the given processes has terminated. Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.1 head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.1 == --- head/bin/pwait/pwait.1 Sun Jan 26 10:54:16 2020(r357140) +++ head/bin/pwait/pwait.1 Sun Jan 26 11:02:51 2020(r357141) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 7, 2017 +.Dd January 26, 2020 .Dt PWAIT 1 .Os .Sh NAME @@ -41,7 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl t Ar duration -.Op Fl v +.Op Fl ov .Ar pid \&... .Sh DESCRIPTION @@ -51,6 +51,8 @@ utility will wait until each of the given processes ha .Pp The following option is available: .Bl -tag -width indent +.It Fl o +Exit when any of the given processes has terminated. .It Fl t Ar duration If any process is still running after .Ar duration , Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 10:54:16 2020(r357140) +++ head/bin/pwait/pwait.c Sun Jan 26 11:02:51 2020(r357141) @@ -53,7 +53,7 @@ static void usage(void) { - errx(EX_USAGE, "usage: pwait [-t timeout] [-v] pid ..."); + errx(EX_USAGE, "usage: pwait [-t timeout] [-ov] pid ..."); } /* @@ -65,16 +65,22 @@ main(int argc, char *argv[]) struct itimerval itv; int kq; struct kevent *e; - int tflag, verbose; + int oflag, tflag, verbose; int opt, nleft, n, i, status; long pid; char *s, *end; double timeout; - tflag = verbose = 0; + oflag = 0; + tflag = 0; + verbose = 0; memset(&itv, 0, sizeof(itv)); - while ((opt = getopt(argc, argv, "t:v")) != -1) { + + while ((opt = getopt(argc, argv, "t:ov")) != -1) { switch (opt) { + case 'o': + oflag = 1; + break; case 't': tflag = 1; errno = 0; @@ -144,10 +150,13 @@ main(int argc, char *argv[]) continue; } EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); - if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { warn("%ld", pid); - else + if (oflag) + exit(EX_OK); + } else { nleft++; + } } if (nleft > 0 && tflag) { @@ -187,6 +196,8 @@ main(int argc, char *argv[]) printf("%ld: terminated.\n", (long)e[i].ident); } + if (oflag) + exit(EX_OK); --nleft; } } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357142 - head/bin/pwait/tests
Author: pjd Date: Sun Jan 26 11:03:45 2020 New Revision: 357142 URL: https://svnweb.freebsd.org/changeset/base/357142 Log: Implement tests for the newly added -o flag. Sponsored by: Fudo Security Modified: head/bin/pwait/tests/pwait_test.sh Modified: head/bin/pwait/tests/pwait_test.sh == --- head/bin/pwait/tests/pwait_test.sh Sun Jan 26 11:02:51 2020 (r357141) +++ head/bin/pwait/tests/pwait_test.sh Sun Jan 26 11:03:45 2020 (r357142) @@ -232,6 +232,85 @@ timeout_many_cleanup() wait $p1 $p5 $p10 >/dev/null 2>&1 } +atf_test_case or_flag +or_flag_head() +{ + atf_set "descr" "Test OR flag" +} + +or_flag_body() +{ + sleep 2 & + p2=$! + + sleep 4 & + p4=$! + + sleep 6 & + p6=$! + + atf_check \ + -o inline:"$p2: exited with status 0.\n" \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o -v $p2 $p4 $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p2: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p2 $p4 $p6 + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p4 $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p4: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p4 $p6 + + atf_check \ + -o inline:"$p6: exited with status 0.\n" \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o -v $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p6: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p6 + + atf_check \ + -o empty \ + -e inline:"kill: $p2: No such process\n" \ + -s exit:1 \ + kill -0 $p2 + + atf_check \ + -o empty \ + -e inline:"kill: $p4: No such process\n" \ + -s exit:1 \ + kill -0 $p4 + + atf_check \ + -o empty \ + -e inline:"kill: $p6: No such process\n" \ + -s exit:1 \ + kill -0 $p6 + +} + +or_flag_cleanup() +{ + kill $p2 $p4 $p6 >/dev/null 2>&1 + wait $p2 $p4 $p6 >/dev/null 2>&1 +} + atf_init_test_cases() { atf_add_test_case basic @@ -239,4 +318,5 @@ atf_init_test_cases() atf_add_test_case timeout_trigger_timeout atf_add_test_case timeout_no_timeout atf_add_test_case timeout_many + atf_add_test_case or_flag } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357143 - head/bin/pwait
Author: pjd Date: Sun Jan 26 11:13:34 2020 New Revision: 357143 URL: https://svnweb.freebsd.org/changeset/base/357143 Log: Style changes, mostly usage of braces around single line statements - it is safer and allowed for some time now by style(9). Sponsored by: Fudo Security Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sun Jan 26 11:03:45 2020(r357142) +++ head/bin/pwait/pwait.c Sun Jan 26 11:13:34 2020(r357143) @@ -63,12 +63,11 @@ int main(int argc, char *argv[]) { struct itimerval itv; - int kq; struct kevent *e; int oflag, tflag, verbose; - int opt, nleft, n, i, status; + int i, kq, n, nleft, opt, status; long pid; - char *s, *end; + char *end, *s; double timeout; oflag = 0; @@ -76,7 +75,7 @@ main(int argc, char *argv[]) verbose = 0; memset(&itv, 0, sizeof(itv)); - while ((opt = getopt(argc, argv, "t:ov")) != -1) { + while ((opt = getopt(argc, argv, "ot:v")) != -1) { switch (opt) { case 'o': oflag = 1; @@ -85,9 +84,9 @@ main(int argc, char *argv[]) tflag = 1; errno = 0; timeout = strtod(optarg, &end); - if (end == optarg || errno == ERANGE || - timeout < 0) + if (end == optarg || errno == ERANGE || timeout < 0) { errx(EX_DATAERR, "timeout value"); + } switch(*end) { case 0: case 's': @@ -101,8 +100,9 @@ main(int argc, char *argv[]) default: errx(EX_DATAERR, "timeout unit"); } - if (timeout > 1L) + if (timeout > 1L) { errx(EX_DATAERR, "timeout value"); + } itv.it_value.tv_sec = (time_t)timeout; timeout -= (time_t)timeout; itv.it_value.tv_usec = @@ -120,21 +120,26 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc == 0) + if (argc == 0) { usage(); + } kq = kqueue(); - if (kq == -1) + if (kq == -1) { err(EX_OSERR, "kqueue"); + } e = malloc((argc + tflag) * sizeof(struct kevent)); - if (e == NULL) + if (e == NULL) { err(EX_OSERR, "malloc"); + } nleft = 0; for (n = 0; n < argc; n++) { s = argv[n]; - if (!strncmp(s, "/proc/", 6)) /* Undocumented Solaris compat */ + /* Undocumented Solaris compat */ + if (!strncmp(s, "/proc/", 6)) { s += 6; + } errno = 0; pid = strtol(s, &end, 10); if (pid < 0 || *end != '\0' || errno != 0) { @@ -142,8 +147,9 @@ main(int argc, char *argv[]) continue; } for (i = 0; i < nleft; i++) { - if (e[i].ident == (uintptr_t)pid) + if (e[i].ident == (uintptr_t)pid) { break; + } } if (i < nleft) { /* Duplicate. */ @@ -152,8 +158,9 @@ main(int argc, char *argv[]) EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { warn("%ld", pid); - if (oflag) + if (oflag) { exit(EX_OK); + } } else { nleft++; } @@ -165,39 +172,45 @@ main(int argc, char *argv[]) * can be returned rather than 142. */ EV_SET(e + nleft, SIGALRM, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); - if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { err(EX_OSERR, "kevent"); + } /* Ignore SIGALRM to not interrupt kevent(2). */ signal(SIGALRM, SIG_IGN); - if (setitimer(ITIMER_REAL, &itv, NULL) == -1) + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { err(EX_OSERR, "setitimer"); + } } while (nleft > 0) { n = kevent(kq, NULL, 0, e, nleft + tflag, NULL); - if (n == -1) + if (n == -
svn commit: r357362 - head/bin/pwait
Author: pjd Date: Sat Feb 1 09:13:11 2020 New Revision: 357362 URL: https://svnweb.freebsd.org/changeset/base/357362 Log: Restore previous usage presentation (without "pwait: " prefix). Pointed out by: jilles Modified: head/bin/pwait/pwait.c Modified: head/bin/pwait/pwait.c == --- head/bin/pwait/pwait.c Sat Feb 1 06:46:55 2020(r357361) +++ head/bin/pwait/pwait.c Sat Feb 1 09:13:11 2020(r357362) @@ -53,7 +53,8 @@ static void usage(void) { - errx(EX_USAGE, "usage: pwait [-t timeout] [-ov] pid ..."); + fprintf(stderr, "usage: pwait [-t timeout] [-ov] pid ...\n"); + exit(EX_USAGE); } /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r357138 - head/bin/pwait
On 1/30/20 14:47, Jilles Tjoelker wrote: > On 26-01-2020 11:49, Pawel Jakub Dawidek wrote: >> Author: pjd >> Date: Sun Jan 26 10:49:24 2020 >> New Revision: 357138 >> URL: https://svnweb.freebsd.org/changeset/base/357138 >> >> Log: >> - Be consistent with using sysexits(3) codes. >> - Turn fprintf()+exit() into errx(). >> Sponsored by: Fudo Security >> >> Modified: >> head/bin/pwait/pwait.c >> >> Modified: head/bin/pwait/pwait.c >> == >> >> --- head/bin/pwait/pwait.c Sun Jan 26 07:24:49 2020 (r357137) >> +++ head/bin/pwait/pwait.c Sun Jan 26 10:49:24 2020 (r357138) >> @@ -53,8 +53,7 @@ static void >> usage(void) >> { >> - fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); >> - exit(EX_USAGE); >> + errx(EX_USAGE, "usage: pwait [-t timeout] [-v] pid ..."); > > This adds a "pwait: " before the line, which most other programs do not do. > Reverted in r357362. Thanks. -- Pawel Jakub Dawidek ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r357363 - head/sys/geom
Author: pjd Date: Sat Feb 1 10:15:23 2020 New Revision: 357363 URL: https://svnweb.freebsd.org/changeset/base/357363 Log: The error variable is not really needed. Remove it. Modified: head/sys/geom/geom_disk.c Modified: head/sys/geom/geom_disk.c == --- head/sys/geom/geom_disk.c Sat Feb 1 09:13:11 2020(r357362) +++ head/sys/geom/geom_disk.c Sat Feb 1 10:15:23 2020(r357363) @@ -268,7 +268,6 @@ g_disk_ioctl(struct g_provider *pp, u_long cmd, void * { struct disk *dp; struct g_disk_softc *sc; - int error; sc = pp->private; dp = sc->dp; @@ -277,8 +276,7 @@ g_disk_ioctl(struct g_provider *pp, u_long cmd, void * if (dp->d_ioctl == NULL) return (ENOIOCTL); - error = dp->d_ioctl(dp, cmd, data, fflag, td); - return (error); + return (dp->d_ioctl(dp, cmd, data, fflag, td)); } static off_t ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360323 - head/sys/geom
Author: pjd Date: Sat Apr 25 21:41:09 2020 New Revision: 360323 URL: https://svnweb.freebsd.org/changeset/base/360323 Log: Add g_topology_locked() macro that returns true if we already hold the GEOM topology lock. Modified: head/sys/geom/geom.h Modified: head/sys/geom/geom.h == --- head/sys/geom/geom.hSat Apr 25 20:24:41 2020(r360322) +++ head/sys/geom/geom.hSat Apr 25 21:41:09 2020(r360323) @@ -395,6 +395,8 @@ g_free(void *ptr) sx_xunlock(&topology_lock); \ } while (0) +#define g_topology_locked()sx_xlocked(&topology_lock) + #define g_topology_assert()\ do {\ sx_assert(&topology_lock, SX_XLOCKED); \ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r360325 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Sat Apr 25 21:45:31 2020 New Revision: 360325 URL: https://svnweb.freebsd.org/changeset/base/360325 Log: Avoid the GEOM topology lock recursion when we automatically expand a pool. The steps to reproduce the problem: mdconfig -a -t swap -s 3g -u 0 gpart create -s GPT md0 gpart add -t freebsd-zfs -s 1g md0 zpool create -o autoexpand=on foo md0p1 gpart resize -i 1 -s 2g md0 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Apr 25 21:41:38 2020(r360324) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Sat Apr 25 21:45:31 2020(r360325) @@ -973,18 +973,22 @@ static void vdev_geom_close(vdev_t *vd) { struct g_consumer *cp; + int locked; cp = vd->vdev_tsd; DROP_GIANT(); - g_topology_lock(); + locked = g_topology_locked(); + if (!locked) + g_topology_lock(); if (!vd->vdev_reopening || (cp != NULL && ((cp->flags & G_CF_ORPHAN) != 0 || (cp->provider != NULL && cp->provider->error != 0 vdev_geom_close_locked(vd); - g_topology_unlock(); + if (!locked) + g_topology_unlock(); PICKUP_GIANT(); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219082 - head/etc/rc.d
Author: pjd Date: Sun Feb 27 11:40:20 2011 New Revision: 219082 URL: http://svn.freebsd.org/changeset/base/219082 Log: Recognize 'reload' command, as hastd can be reloaded with the SIGHUP signal. MFC after:1 week Modified: head/etc/rc.d/hastd Modified: head/etc/rc.d/hastd == --- head/etc/rc.d/hastd Sun Feb 27 10:13:16 2011(r219081) +++ head/etc/rc.d/hastd Sun Feb 27 11:40:20 2011(r219082) @@ -18,6 +18,7 @@ hastctl="/sbin/hastctl" required_files="/etc/hast.conf" stop_precmd="hastd_stop_precmd" required_modules="geom_gate:g_gate" +extra_commands="reload" hastd_stop_precmd() { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219083 - head/sys/boot/common
Author: pjd Date: Sun Feb 27 12:25:47 2011 New Revision: 219083 URL: http://svn.freebsd.org/changeset/base/219083 Log: Rename bcpy() macro to bcopy(). Modified: head/sys/boot/common/gpt.c head/sys/boot/common/util.h Modified: head/sys/boot/common/gpt.c == --- head/sys/boot/common/gpt.c Sun Feb 27 11:40:20 2011(r219082) +++ head/sys/boot/common/gpt.c Sun Feb 27 12:25:47 2011(r219083) @@ -71,7 +71,7 @@ gptupdate(const char *which, struct dsk entries_per_sec = DEV_BSIZE / hdr->hdr_entsz; slba = curent / entries_per_sec; firstent = slba * entries_per_sec; - bcpy(&table[firstent], secbuf, DEV_BSIZE); + bcopy(&table[firstent], secbuf, DEV_BSIZE); slba += hdr->hdr_lba_table; if (drvwrite(dskp, secbuf, slba, 1)) { printf("%s: unable to update %s GPT partition table\n", @@ -82,7 +82,7 @@ gptupdate(const char *which, struct dsk hdr->hdr_crc_self = 0; hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size); bzero(secbuf, DEV_BSIZE); - bcpy(hdr, secbuf, hdr->hdr_size); + bcopy(hdr, secbuf, hdr->hdr_size); if (drvwrite(dskp, secbuf, hdr->hdr_lba_self, 1)) { printf("%s: unable to update %s GPT header\n", BOOTPROG, which); return; @@ -191,7 +191,7 @@ gptread_hdr(const char *which, struct ds printf("%s: unable to read %s GPT header\n", BOOTPROG, which); return (-1); } - bcpy(secbuf, hdr, sizeof(*hdr)); + bcopy(secbuf, hdr, sizeof(*hdr)); if (bcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0 || hdr->hdr_lba_self != hdrlba || hdr->hdr_revision < 0x0001 || hdr->hdr_entsz < sizeof(struct gpt_ent) || @@ -259,7 +259,7 @@ gptbootconv(const char *which, struct ds } if (!sector_updated) continue; - bcpy(&table[nent], secbuf, DEV_BSIZE); + bcopy(&table[nent], secbuf, DEV_BSIZE); if (drvwrite(dskp, secbuf, slba, 1)) { printf("%s: unable to update %s GPT partition table\n", BOOTPROG, which); @@ -271,7 +271,7 @@ gptbootconv(const char *which, struct ds hdr->hdr_crc_self = 0; hdr->hdr_crc_self = crc32(hdr, hdr->hdr_size); bzero(secbuf, DEV_BSIZE); - bcpy(hdr, secbuf, hdr->hdr_size); + bcopy(hdr, secbuf, hdr->hdr_size); if (drvwrite(dskp, secbuf, hdr->hdr_lba_self, 1)) printf("%s: unable to update %s GPT header\n", BOOTPROG, which); } @@ -299,7 +299,7 @@ gptread_table(const char *which, const u } ent = (struct gpt_ent *)secbuf; for (part = 0; part < entries_per_sec; part++, ent++) { - bcpy(ent, &table[nent], sizeof(table[nent])); + bcopy(ent, &table[nent], sizeof(table[nent])); if (++nent >= hdr->hdr_entries) break; } Modified: head/sys/boot/common/util.h == --- head/sys/boot/common/util.h Sun Feb 27 11:40:20 2011(r219082) +++ head/sys/boot/common/util.h Sun Feb 27 12:25:47 2011(r219083) @@ -37,7 +37,7 @@ void memcpy(void *dst, const void *src, void memset(void *b, int c, size_t len); int memcmp(const void *b1, const void *b2, size_t len); -#definebcpy(src, dst, len) memcpy((dst), (src), (len)) +#definebcopy(src, dst, len)memcpy((dst), (src), (len)) #definebzero(buf, size)memset((buf), 0, (size)) #definebcmp(b1, b2, len) (memcmp((b1), (b2), (len)) != 0) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219085 - head/sys/dev/sdhci
Author: pjd Date: Sun Feb 27 13:58:20 2011 New Revision: 219085 URL: http://svn.freebsd.org/changeset/base/219085 Log: Force DMA for controller found in Lenovo T510 (probably in others too). This makes reads 10 times faster. Discussed with: mav Modified: head/sys/dev/sdhci/sdhci.c Modified: head/sys/dev/sdhci/sdhci.c == --- head/sys/dev/sdhci/sdhci.c Sun Feb 27 12:28:06 2011(r219084) +++ head/sys/dev/sdhci/sdhci.c Sun Feb 27 13:58:20 2011(r219085) @@ -83,6 +83,8 @@ static const struct sdhci_device { } sdhci_devices[] = { { 0x08221180, 0x, "RICOH R5C822 SD", SDHCI_QUIRK_FORCE_DMA }, + { 0xe8221180, 0x, "RICOH SD", + SDHCI_QUIRK_FORCE_DMA }, { 0x8034104c, 0x, "TI XX21/XX11 SD", SDHCI_QUIRK_FORCE_DMA }, { 0x05501524, 0x, "ENE CB712 SD", ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219089 - in head: cddl/compat/opensolaris/include cddl/compat/opensolaris/misc cddl/contrib/opensolaris/cmd/stat cddl/contrib/opensolaris/cmd/stat/common cddl/contrib/opensolaris/cmd/z...
/eventdefs.h head/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h head/sys/cddl/contrib/opensolaris/uts/common/sys/taskq.h head/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h head/sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h head/sys/modules/opensolaris/Makefile head/sys/modules/zfs/Makefile head/usr.bin/fstat/zfs.c Modified: head/cddl/compat/opensolaris/include/fcntl.h == --- head/cddl/compat/opensolaris/include/fcntl.hSun Feb 27 18:23:28 2011(r219088) +++ head/cddl/compat/opensolaris/include/fcntl.hSun Feb 27 19:41:40 2011(r219089) @@ -32,6 +32,7 @@ #include_next -#define open64 open +#define open64(...)open(__VA_ARGS__) +#define openat64(...) openat(__VA_ARGS__) #endif Modified: head/cddl/compat/opensolaris/include/mnttab.h == --- head/cddl/compat/opensolaris/include/mnttab.h Sun Feb 27 18:23:28 2011(r219088) +++ head/cddl/compat/opensolaris/include/mnttab.h Sun Feb 27 19:41:40 2011(r219089) @@ -12,6 +12,10 @@ #defineMNTTAB _PATH_DEVZERO #defineMNT_LINE_MAX1024 +#defineMS_OVERLAY 0x0 +#defineMS_NOMNTTAB 0x0 +#defineMS_RDONLY 0x1 + #defineumount2(p, f) unmount(p, f) struct mnttab { Modified: head/cddl/compat/opensolaris/include/priv.h == --- head/cddl/compat/opensolaris/include/priv.h Sun Feb 27 18:23:28 2011 (r219088) +++ head/cddl/compat/opensolaris/include/priv.h Sun Feb 27 19:41:40 2011 (r219089) @@ -10,7 +10,7 @@ #definePRIV_SYS_CONFIG 0 static __inline int -priv_ineffect(priv) +priv_ineffect(int priv) { assert(priv == PRIV_SYS_CONFIG); Added: head/cddl/compat/opensolaris/include/sha2.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/compat/opensolaris/include/sha2.h Sun Feb 27 19:41:40 2011 (r219089) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2010 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _OPENSOLARIS_SHA2_H_ +#define _OPENSOLARIS_SHA2_H_ + +#include_next + +#defineSHA256Init(c) SHA256_Init(c) +#defineSHA256Update(c, d, s) SHA256_Update((c), (d), (s)) +#defineSHA256Final(b, c) SHA256_Final((unsigned char *)(b), (c)) + +#endif /* !_OPENSOLARIS_SHA2_H_ */ Modified: head/cddl/compat/opensolaris/include/solaris.h == --- head/cddl/compat/opensolaris/include/solaris.h Sun Feb 27 18:23:28 2011(r219088) +++ head/cddl/compat/opensolaris/include/solaris.h Sun Feb 27 19:41:40 2011(r219089) @@ -5,6 +5,10 @@ #include -#definedirent64dirent +#include + +#defineNOTE(s) + +int mkdirp(const char *, mode_t); #endif /* !_SOLARIS_H_ */ Added: head/cddl/compat/opensolaris/include/thread_pool.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/cddl/compat/opensolaris/include/thread_pool.h Sun Feb 27 19:41:40 2011(r219089) @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2010 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitte
svn commit: r219090 - in head: . etc/rc.d
Author: pjd Date: Sun Feb 27 19:44:10 2011 New Revision: 219090 URL: http://svn.freebsd.org/changeset/base/219090 Log: Commit two more files missed in r219089. MFC after:1 month Modified: head/Makefile.inc1 head/etc/rc.d/zvol Modified: head/Makefile.inc1 == --- head/Makefile.inc1 Sun Feb 27 19:41:40 2011(r219089) +++ head/Makefile.inc1 Sun Feb 27 19:44:10 2011(r219090) @@ -1153,6 +1153,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1 lib/ncurses/ncurses lib/ncurses/ncursesw \ lib/libopie lib/libpam ${_lib_libthr} \ lib/libradius lib/libsbuf lib/libtacplus \ + ${_cddl_lib_libumem} \ lib/libutil ${_lib_libypclnt} lib/libz lib/msun \ ${_secure_lib_libcrypto} ${_secure_lib_libssh} \ ${_secure_lib_libssl} @@ -1166,6 +1167,7 @@ _generic_libs=${_cddl_lib} gnu/lib ${_k lib/libopie__L lib/libtacplus__L: lib/libmd__L .if ${MK_CDDL} != "no" +_cddl_lib_libumem= cddl/lib/libumem _cddl_lib= cddl/lib .endif Modified: head/etc/rc.d/zvol == --- head/etc/rc.d/zvol Sun Feb 27 19:41:40 2011(r219089) +++ head/etc/rc.d/zvol Sun Feb 27 19:44:10 2011(r219090) @@ -17,7 +17,6 @@ required_modules="zfs" zvol_start() { - zfs volinit # Enable swap on ZVOLs with property org.freebsd:swap=on. zfs list -H -o org.freebsd:swap,name -t volume | \ while read state name; do @@ -40,7 +39,6 @@ zvol_stop() ;; esac done - zfs volfini } load_rc_config $name ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219092 - head/sys/cddl/compat/opensolaris/kern
Author: pjd Date: Mon Feb 28 05:45:31 2011 New Revision: 219092 URL: http://svn.freebsd.org/changeset/base/219092 Log: Use proper lock in assertion. MFC after:1 month Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Modified: head/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c == --- head/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Sun Feb 27 21:32:25 2011(r219091) +++ head/sys/cddl/compat/opensolaris/kern/opensolaris_sunddi.c Mon Feb 28 05:45:31 2011(r219092) @@ -94,7 +94,7 @@ ddi_get_soft_state_locked(struct ddi_sof { struct ddi_soft_state_item *itemp; - ASSERT(MUTEX_HELD(&zfsdev_state_lock)); + ASSERT(MUTEX_HELD(&ss->ss_lock)); LIST_FOREACH(itemp, &ss->ss_list, ssi_next) { if (itemp->ssi_item == item) @@ -142,7 +142,7 @@ ddi_soft_state_free_locked(struct ddi_so { struct ddi_soft_state_item *itemp; - ASSERT(MUTEX_HELD(&zfsdev_state_lock)); + ASSERT(MUTEX_HELD(&ss->ss_lock)); LIST_FOREACH(itemp, &ss->ss_list, ssi_next) { if (itemp->ssi_item == item) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r219089 - in head: cddl/compat/opensolaris/include cddl/compat/opensolaris/misc cddl/contrib/opensolaris/cmd/stat cddl/contrib/opensolaris/cmd/stat/common cddl/contrib/opensolaris/cmd/
On Sun, Feb 27, 2011 at 02:52:42PM -0800, Doug Barton wrote: > On 02/27/2011 11:41, Pawel Jakub Dawidek wrote: > >Author: pjd > >Date: Sun Feb 27 19:41:40 2011 > >New Revision: 219089 > >URL: http://svn.freebsd.org/changeset/base/219089 > > > >Log: > > Finally... Import the latest open-source ZFS version - (SPA) 28. > > Has this been successfully built with clang? [...] I haven't tried clang. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpePqsXaqHBn.pgp Description: PGP signature
svn commit: r219316 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Sat Mar 5 22:24:31 2011 New Revision: 219316 URL: http://svn.freebsd.org/changeset/base/219316 Log: Simplify zvol_remove_minors() a bit. MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Mar 5 21:20:18 2011(r219315) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Sat Mar 5 22:24:31 2011(r219316) @@ -753,14 +753,13 @@ zvol_update_volsize(objset_t *os, uint64 void zvol_remove_minors(const char *name) { - struct g_provider *pp, *pptmp; struct g_geom *gp, *gptmp; + struct g_provider *pp; zvol_state_t *zv; - char *namebuf; + size_t namelen; + + namelen = strlen(name); - namebuf = kmem_zalloc(strlen(name) + 2, KM_SLEEP); - (void) strncpy(namebuf, name, strlen(name)); - (void) strcat(namebuf, "/"); DROP_GIANT(); mutex_enter(&zfsdev_state_lock); g_topology_lock(); @@ -772,10 +771,12 @@ zvol_remove_minors(const char *name) zv = pp->private; if (zv == NULL) continue; - if (strncmp(namebuf, zv->zv_name, strlen(namebuf)) == 0) + if (strcmp(zv->zv_name, name) == 0 || + (strncmp(zv->zv_name, name, namelen) == 0 && +zv->zv_name[namelen] == '/')) { (void) zvol_remove_zv(zv); + } } - kmem_free(namebuf, strlen(name) + 2); g_topology_unlock(); mutex_exit(&zfsdev_state_lock); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219317 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Author: pjd Date: Sat Mar 5 22:31:03 2011 New Revision: 219317 URL: http://svn.freebsd.org/changeset/base/219317 Log: Make renaming of a ZVOL, ZVOL's parent directory and ZVOL snapshot work. Reported by: avg MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Sat Mar 5 22:24:31 2011(r219316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Sat Mar 5 22:31:03 2011(r219317) @@ -2312,6 +2312,7 @@ dsl_dataset_snapshot_rename_check(void * static void dsl_dataset_snapshot_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx) { + char oldname[MAXPATHLEN], newname[MAXPATHLEN]; dsl_dataset_t *ds = arg1; const char *newsnapname = arg2; dsl_dir_t *dd = ds->ds_dir; @@ -2327,12 +2328,15 @@ dsl_dataset_snapshot_rename_sync(void *a VERIFY(0 == dsl_dataset_get_snapname(ds)); err = dsl_dataset_snap_remove(hds, ds->ds_snapname, tx); ASSERT3U(err, ==, 0); + dsl_dataset_name(ds, oldname); mutex_enter(&ds->ds_lock); (void) strcpy(ds->ds_snapname, newsnapname); mutex_exit(&ds->ds_lock); err = zap_add(mos, hds->ds_phys->ds_snapnames_zapobj, ds->ds_snapname, 8, 1, &ds->ds_object, tx); ASSERT3U(err, ==, 0); + dsl_dataset_name(ds, newname); + zvol_rename_minors(oldname, newname); spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, "dataset = %llu", ds->ds_object); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c Sat Mar 5 22:24:31 2011(r219316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c Sat Mar 5 22:31:03 2011(r219317) @@ -36,6 +36,7 @@ #include #include #include +#include #include "zfs_namecheck.h" static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd); @@ -1294,6 +1295,7 @@ dsl_dir_rename_check(void *arg1, void *a static void dsl_dir_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx) { + char oldname[MAXPATHLEN], newname[MAXPATHLEN]; dsl_dir_t *dd = arg1; struct renamearg *ra = arg2; dsl_pool_t *dp = dd->dd_pool; @@ -1326,6 +1328,7 @@ dsl_dir_rename_sync(void *arg1, void *ar dmu_buf_will_dirty(dd->dd_dbuf, tx); /* remove from old parent zapobj */ + dsl_dir_name(dd, oldname); err = zap_remove(mos, dd->dd_parent->dd_phys->dd_child_dir_zapobj, dd->dd_myname, tx); ASSERT3U(err, ==, 0); @@ -1340,6 +1343,8 @@ dsl_dir_rename_sync(void *arg1, void *ar err = zap_add(mos, ra->newparent->dd_phys->dd_child_dir_zapobj, dd->dd_myname, 8, 1, &dd->dd_object, tx); ASSERT3U(err, ==, 0); + dsl_dir_name(dd, newname); + zvol_rename_minors(oldname, newname); spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, "dataset = %llu", dd->dd_phys->dd_head_dataset_obj); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h Sat Mar 5 22:24:31 2011(r219316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h Sat Mar 5 22:31:03 2011(r219317) @@ -73,6 +73,7 @@ extern void zvol_log_write_minor(void *m #ifdef __FreeBSD__ extern int zvol_create_minors(const char *name); +extern void zvol_rename_minors(const char *oldname, const char *newname); #endif #endif Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Mar 5 22:24:31 2011(r219316) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Sat Mar 5 22:31:03 2011(r219317) @@ -3271,8 +3271,6 @@ zfs_ioc_rename(zfs_cmd_t *zc) if (err) return (err); } - if (zc->zc_objset_type == DMU_OST_ZVOL) - (void) zvol_remove_minor(zc->zc_name); return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive)); } Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c =
svn commit: r219320 - in head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys
Author: pjd Date: Sun Mar 6 01:22:14 2011 New Revision: 219320 URL: http://svn.freebsd.org/changeset/base/219320 Log: Fix libzpool build. MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Sun Mar 6 00:57:08 2011(r219319) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Sun Mar 6 01:22:14 2011(r219320) @@ -2336,7 +2336,9 @@ dsl_dataset_snapshot_rename_sync(void *a ds->ds_snapname, 8, 1, &ds->ds_object, tx); ASSERT3U(err, ==, 0); dsl_dataset_name(ds, newname); +#ifdef _KERNEL zvol_rename_minors(oldname, newname); +#endif spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, "dataset = %llu", ds->ds_object); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c Sun Mar 6 00:57:08 2011(r219319) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c Sun Mar 6 01:22:14 2011(r219320) @@ -1344,7 +1344,9 @@ dsl_dir_rename_sync(void *arg1, void *ar dd->dd_myname, 8, 1, &dd->dd_object, tx); ASSERT3U(err, ==, 0); dsl_dir_name(dd, newname); +#ifdef _KERNEL zvol_rename_minors(oldname, newname); +#endif spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx, "dataset = %llu", dd->dd_phys->dd_head_dataset_obj); Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h Sun Mar 6 00:57:08 2011(r219319) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h Sun Mar 6 01:22:14 2011(r219320) @@ -76,7 +76,7 @@ extern int zvol_create_minors(const char extern void zvol_rename_minors(const char *oldname, const char *newname); #endif -#endif +#endif /* _KERNEL */ #ifdef __cplusplus } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219342 - head/lib/libc/stdio
Author: pjd Date: Sun Mar 6 17:43:32 2011 New Revision: 219342 URL: http://svn.freebsd.org/changeset/base/219342 Log: Fix various issues in how %#T is handled: - If precision is 0, don't print period followed by no digits. - If precision is 0 stop printing units as soon as possible (eg. if we have three years and five days and precision is 0 print only 3y5d). - If precision is not 0, print all units (eg. 3y0d0h0m0s.00). MFC after:2 weeks Modified: head/lib/libc/stdio/xprintf_time.c Modified: head/lib/libc/stdio/xprintf_time.c == --- head/lib/libc/stdio/xprintf_time.c Sun Mar 6 16:10:39 2011 (r219341) +++ head/lib/libc/stdio/xprintf_time.c Sun Mar 6 17:43:32 2011 (r219342) @@ -80,6 +80,12 @@ __printf_render_time(struct __printf_io nsec = 0; prec = 0; } + if (pi->is_long || pi->is_long_double) { + if (pi->prec >= 0) + prec = pi->prec; + if (prec == 0) + nsec = 0; + } p = buf; if (pi->alt) { @@ -88,26 +94,24 @@ __printf_render_time(struct __printf_io p += sprintf(p, "%jdy", t / YEAR); t %= YEAR; } - if (t >= DAY && t != 0) { + if (tx >= DAY && (t != 0 || prec != 0)) { p += sprintf(p, "%jdd", t / DAY); t %= DAY; } - if (t >= HOUR && t != 0) { + if (tx >= HOUR && (t != 0 || prec != 0)) { p += sprintf(p, "%jdh", t / HOUR); t %= HOUR; } - if (t >= MINUTE && t != 0) { + if (tx >= MINUTE && (t != 0 || prec != 0)) { p += sprintf(p, "%jdm", t / MINUTE); t %= MINUTE; } - if (t != 0 || tx == 0) + if (t != 0 || tx == 0 || prec != 0) p += sprintf(p, "%jds", t); } else { p += sprintf(p, "%jd", (intmax_t)t); } - if (pi->is_long || pi->is_long_double) { - if (pi->prec >= 0) - prec = pi->prec; + if (prec != 0) { for (i = prec; i < 9; i++) nsec /= 10; p += sprintf(p, ".%.*d", prec, nsec); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219343 - head/include
Author: pjd Date: Sun Mar 6 17:45:37 2011 New Revision: 219343 URL: http://svn.freebsd.org/changeset/base/219343 Log: Include stdio.h, so we can include printf.h in any order, as it needs FILE. MFC after:2 weeks Modified: head/include/printf.h Modified: head/include/printf.h == --- head/include/printf.h Sun Mar 6 17:43:32 2011(r219342) +++ head/include/printf.h Sun Mar 6 17:45:37 2011(r219343) @@ -29,6 +29,7 @@ #ifndef _PRINTF_H_ #define _PRINTF_H_ +#include #include /* ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219344 - head/lib/libutil
Author: pjd Date: Sun Mar 6 17:46:06 2011 New Revision: 219344 URL: http://svn.freebsd.org/changeset/base/219344 Log: expand_number() needs uint64_t, declare it here if not already declared. MFC after:3 days Modified: head/lib/libutil/libutil.h Modified: head/lib/libutil/libutil.h == --- head/lib/libutil/libutil.h Sun Mar 6 17:45:37 2011(r219343) +++ head/lib/libutil/libutil.h Sun Mar 6 17:46:06 2011(r219344) @@ -52,6 +52,11 @@ typedef __int64_t int64_t; #define_INT64_T_DECLARED #endif +#ifndef _UINT64_T_DECLARED +typedef__uint64_t uint64_t; +#define_UINT64_T_DECLARED +#endif + #ifndef _PID_T_DECLARED typedef__pid_t pid_t; #define_PID_T_DECLARED ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219346 - head/lib/libc/stdio
Author: pjd Date: Sun Mar 6 19:47:46 2011 New Revision: 219346 URL: http://svn.freebsd.org/changeset/base/219346 Log: Because we call __printf_out() with a on-stack buffer, also call __printf_flush() so we are sure it won't be referenced after we return. MFC after:2 weeks Modified: head/lib/libc/stdio/xprintf_time.c Modified: head/lib/libc/stdio/xprintf_time.c == --- head/lib/libc/stdio/xprintf_time.c Sun Mar 6 18:43:59 2011 (r219345) +++ head/lib/libc/stdio/xprintf_time.c Sun Mar 6 19:47:46 2011 (r219346) @@ -62,7 +62,7 @@ __printf_render_time(struct __printf_io struct timespec *ts; time_t *tp; intmax_t t, tx; - int i, prec, nsec; + int i, prec, nsec, ret; if (pi->is_long) { tv = *((struct timeval **)arg[0]); @@ -116,5 +116,7 @@ __printf_render_time(struct __printf_io nsec /= 10; p += sprintf(p, ".%.*d", prec, nsec); } - return(__printf_out(io, pi, buf, p - buf)); + ret = __printf_out(io, pi, buf, p - buf); + __printf_flush(io); + return (ret); } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219351 - in head/sbin: hastctl hastd
); +} + +#endif /* !_CRC32_H_ */ Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Sun Mar 6 21:20:53 2011(r219350) +++ head/sbin/hastd/hast.conf.5 Sun Mar 6 22:56:14 2011(r219351) @@ -1,5 +1,5 @@ .\" Copyright (c) 2010 The FreeBSD Foundation -.\" Copyright (c) 2010 Pawel Jakub Dawidek +.\" Copyright (c) 2010-2011 Pawel Jakub Dawidek .\" All rights reserved. .\" .\" This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -59,6 +59,7 @@ file is following: control listen replication +checksum timeout exec @@ -77,6 +78,7 @@ on { resource { # Resource section replication + checksum name local timeout @@ -201,6 +203,18 @@ The .Ic async replication mode is currently not implemented. .El +.It Ic checksum Aq algorithm +.Pp +Checksum algorithm should be one of the following: +.Bl -tag -width ".Ic sha256" +.It Ic none +No checksum will be calculated for the data being send over the network. +This is the default setting. +.It Ic crc32 +CRC32 checksum will be calculated. +.It Ic sha256 +SHA256 checksum will be calculated. +.El .It Ic timeout Aq seconds .Pp Connection timeout in seconds. Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Sun Mar 6 21:20:53 2011(r219350) +++ head/sbin/hastd/hast.h Sun Mar 6 22:56:14 2011(r219351) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -116,6 +117,10 @@ struct hastd_config { #defineHAST_REPLICATION_MEMSYNC1 #defineHAST_REPLICATION_ASYNC 2 +#defineHAST_CHECKSUM_NONE 0 +#defineHAST_CHECKSUM_CRC32 1 +#defineHAST_CHECKSUM_SHA2562 + /* * Structure that describes single resource. */ @@ -132,6 +137,8 @@ struct hast_resource { int hr_keepdirty; /* Path to a program to execute on various events. */ charhr_exec[PATH_MAX]; + /* Checksum algorithm. */ + int hr_checksum; /* Path to local component. */ charhr_localpath[PATH_MAX]; Added: head/sbin/hastd/hast_checksum.c ========== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/hastd/hast_checksum.c Sun Mar 6 22:56:14 2011 (r219351) @@ -0,0 +1,169 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +#ifdef HAVE_CRYPTO +#include +#endif + +#include +#include +#include +#include + +#include "hast_checksum.h" + +#ifdef HAVE_CRYPTO +#defineMAX_HASH_SIZE SHA256_DIGEST_LENGTH +#else +#defineMAX_HASH_SIZE 4 +#endif + +static int +hast_crc32_checksum(const unsigned char *data, size_t size, +unsigned char *hash, size_t *hsizep) +{ + uint32_t crc; + + crc = crc32(data, size); + /* XXXPJD: Do we have to use htole32() on crc first? */ + bcopy(&crc, hash, sizeof(crc)); + *hsizep = sizeof(crc); + + return (0); +} + +#ifdef HAVE_CRYPTO +static int +hast_sha256_checksum(const unsigned char *data, size_t size, +unsigned char *hash, size_t *hsizep) +{ + SH
svn commit: r219354 - in head/sbin: hastctl hastd
fineHAST_COMPRESSION_LZF2 + #defineHAST_CHECKSUM_NONE 0 #defineHAST_CHECKSUM_CRC32 1 #defineHAST_CHECKSUM_SHA2562 @@ -137,6 +141,8 @@ struct hast_resource { int hr_keepdirty; /* Path to a program to execute on various events. */ charhr_exec[PATH_MAX]; + /* Compression algorithm. */ + int hr_compression; /* Checksum algorithm. */ int hr_checksum; Added: head/sbin/hastd/hast_compression.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sbin/hastd/hast_compression.c Sun Mar 6 23:09:33 2011 (r219354) @@ -0,0 +1,283 @@ +/*- + * Copyright (c) 2011 Pawel Jakub Dawidek + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include "hast_compression.h" + +static bool +allzeros(const void *data, size_t size) +{ + const uint64_t *p = data; + unsigned int i; + uint64_t v; + + PJDLOG_ASSERT((size % sizeof(*p)) == 0); + + /* +* This is the fastest method I found for checking if the given +* buffer contain all zeros. +* Because inside the loop we don't check at every step, we would +* get an answer only after walking through entire buffer. +* To return early if the buffer doesn't contain all zeros, we probe +* 8 bytes at the begining, in the middle and at the end of the buffer +* first. +*/ + + size >>= 3; /* divide by 8 */ + if ((p[0] | p[size >> 1] | p[size - 1]) != 0) + return (false); + v = 0; + for (i = 0; i < size; i++) + v |= *p++; + return (v == 0); +} + +static void * +hast_hole_compress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (!allzeros(data, *sizep)) + return (NULL); + + newbuf = malloc(sizeof(size)); + if (newbuf == NULL) { + pjdlog_warning("Unable to compress (no memory: %zu).", + (size_t)*sizep); + return (NULL); + } + size = htole32((uint32_t)*sizep); + bcopy(&size, newbuf, sizeof(size)); + *sizep = sizeof(size); + + return (newbuf); +} + +static void * +hast_hole_decompress(const unsigned char *data, size_t *sizep) +{ + uint32_t size; + void *newbuf; + + if (*sizep != sizeof(size)) { + pjdlog_error("Unable to decompress (invalid size: %zu).", + *sizep); + return (NULL); + } + + bcopy(data, &size, sizeof(size)); + size = le32toh(size); + + newbuf = malloc(size); + if (newbuf == NULL) { + pjdlog_error("Unable to decompress (no memory: %zu).", + (size_t)size); + return (NULL); + } + bzero(newbuf, size); + *sizep = size; + + return (newbuf); +} + +/* Minimum block size to try to compress. */ +#defineHAST_LZF_COMPRESS_MIN 1024 + +static void * +hast_lzf_compress(const unsigned char *data, size_t *sizep) +{ + unsigned char *newbuf; + uint32_t origsize; + size_t newsize; + + origsize = *sizep; + + if (origsize <= HAST_LZF_COMPRESS_MIN) + return (NULL); + + newsize = sizeof(origsize) + origsize - HAST_LZF_COMPRESS_MIN; + newbuf = malloc(newsize); + if (n
svn commit: r219368 - head/share/mk
Author: pjd Date: Mon Mar 7 09:28:21 2011 New Revision: 219368 URL: http://svn.freebsd.org/changeset/base/219368 Log: To be able to use printf extensions we need to turn off gcc format checking. Following the convention of NO_WERROR and NO_WCAST_ALIGN add NO_WFORMAT, which, when defined in Makefile, turns off compile-time format checking (by adding -Wno-format), but still allows to use high WARNS level. MFC after:2 weeks Modified: head/share/mk/bsd.sys.mk Modified: head/share/mk/bsd.sys.mk == --- head/share/mk/bsd.sys.mkMon Mar 7 09:04:06 2011(r219367) +++ head/share/mk/bsd.sys.mkMon Mar 7 09:28:21 2011(r219368) @@ -73,6 +73,9 @@ CWARNFLAGS+= -Werror . endif . endif . endif +. if defined(NO_WFORMAT) +CWARNFLAGS += -Wno-format +. endif .endif .if defined(IGNORE_PRAGMA) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219369 - head/sbin/hastd
Author: pjd Date: Mon Mar 7 10:33:52 2011 New Revision: 219369 URL: http://svn.freebsd.org/changeset/base/219369 Log: Provides three states for pjdlog_initialized, so we can also tell that this is fist initialization ever. MFC after:2 weeks Modified: head/sbin/hastd/pjdlog.c Modified: head/sbin/hastd/pjdlog.c == --- head/sbin/hastd/pjdlog.cMon Mar 7 09:28:21 2011(r219368) +++ head/sbin/hastd/pjdlog.cMon Mar 7 10:33:52 2011(r219369) @@ -34,7 +34,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -42,7 +41,11 @@ __FBSDID("$FreeBSD$"); #include "pjdlog.h" -static bool pjdlog_initialized = false; +#definePJDLOG_NEVER_INITIALIZED0 +#definePJDLOG_NOT_INITIALIZED 1 +#definePJDLOG_INITIALIZED 2 + +static int pjdlog_initialized = PJDLOG_NEVER_INITIALIZED; static int pjdlog_mode, pjdlog_debug_level; static char pjdlog_prefix[128]; @@ -50,7 +53,8 @@ void pjdlog_init(int mode) { - assert(!pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_NEVER_INITIALIZED || + pjdlog_initialized == PJDLOG_NOT_INITIALIZED); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); if (mode == PJDLOG_MODE_SYSLOG) @@ -59,19 +63,19 @@ pjdlog_init(int mode) pjdlog_debug_level = 0; bzero(pjdlog_prefix, sizeof(pjdlog_prefix)); - pjdlog_initialized = true; + pjdlog_initialized = PJDLOG_INITIALIZED; } void pjdlog_fini(void) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); if (pjdlog_mode == PJDLOG_MODE_SYSLOG) closelog(); - pjdlog_initialized = false; + pjdlog_initialized = PJDLOG_NOT_INITIALIZED; } /* @@ -84,7 +88,7 @@ void pjdlog_mode_set(int mode) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); if (pjdlog_mode == mode) @@ -105,7 +109,7 @@ int pjdlog_mode_get(void) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); return (pjdlog_mode); } @@ -118,7 +122,7 @@ void pjdlog_debug_set(int level) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(level >= 0); pjdlog_debug_level = level; @@ -131,7 +135,7 @@ int pjdlog_debug_get(void) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); return (pjdlog_debug_level); } @@ -145,7 +149,7 @@ pjdlog_prefix_set(const char *fmt, ...) { va_list ap; - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); va_start(ap, fmt); pjdlogv_prefix_set(fmt, ap); @@ -160,7 +164,7 @@ void pjdlogv_prefix_set(const char *fmt, va_list ap) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(fmt != NULL); vsnprintf(pjdlog_prefix, sizeof(pjdlog_prefix), fmt, ap); @@ -203,7 +207,7 @@ pjdlog_common(int loglevel, int debuglev { va_list ap; - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); va_start(ap, fmt); pjdlogv_common(loglevel, debuglevel, error, fmt, ap); @@ -219,7 +223,7 @@ pjdlogv_common(int loglevel, int debugle va_list ap) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || loglevel == LOG_CRIT || loglevel == LOG_ERR || loglevel == LOG_WARNING || loglevel == LOG_NOTICE || @@ -296,7 +300,7 @@ void pjdlogv(int loglevel, const char *fmt, va_list ap) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); /* LOG_DEBUG is invalid here, pjdlogv?_debug() should be used. */ assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || @@ -315,7 +319,7 @@ pjdlog(int loglevel, const char *fmt, .. { va_list ap; - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); va_start(ap, fmt); pjdlogv(loglevel, fmt, ap); @@ -329,7 +333,7 @@ void pjdlogv_debug(int debuglevel, const char *fmt, va_list ap) { - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); pjdlogv_common(LOG_DEBUG, debuglevel, -1, fmt, ap); } @@ -342,7 +346,7 @@ pjdlog_debug(int debuglevel, const char { va_list ap; - assert(pjdlog_initialized); + assert(pjdlog_initialized == PJDLOG_INITIALIZED); va_start(ap, fmt); pjdlogv_debug(debuglevel, fmt, ap); @@ -356,7 +360,7 @@ v
svn commit: r219370 - in head/sbin: hastctl hastd
Author: pjd Date: Mon Mar 7 10:38:18 2011 New Revision: 219370 URL: http://svn.freebsd.org/changeset/base/219370 Log: - Turn on printf extentions. - Load support for %T for pritning time. - Add support for %N for printing number in human readable form. - Add support for %S for printing sockaddr structure (currently only AF_INET family is supported, as this is all we need in HAST). - Disable gcc compile-time format checking as this will no longer work. MFC after:2 weeks Modified: head/sbin/hastctl/Makefile head/sbin/hastd/Makefile head/sbin/hastd/pjdlog.c Modified: head/sbin/hastctl/Makefile == --- head/sbin/hastctl/Makefile Mon Mar 7 10:33:52 2011(r219369) +++ head/sbin/hastctl/Makefile Mon Mar 7 10:38:18 2011(r219370) @@ -19,6 +19,7 @@ SRCS+=subr.c SRCS+= y.tab.h MAN= hastctl.8 +NO_WFORMAT= CFLAGS+=-I${.CURDIR}/../hastd CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" @@ -28,8 +29,8 @@ CFLAGS+=-DINET6 CFLAGS+=-DYY_NO_UNPUT CFLAGS+=-DYY_NO_INPUT -DPADD= ${LIBL} -LDADD= -ll +DPADD= ${LIBL} ${LIBUTIL} +LDADD= -ll -lutil .if ${MK_OPENSSL} != "no" DPADD+=${LIBCRYPTO} LDADD+=-lcrypto Modified: head/sbin/hastd/Makefile == --- head/sbin/hastd/MakefileMon Mar 7 10:33:52 2011(r219369) +++ head/sbin/hastd/MakefileMon Mar 7 10:38:18 2011(r219370) @@ -19,6 +19,7 @@ SRCS+=token.l SRCS+= y.tab.h MAN= hastd.8 hast.conf.5 +NO_WFORMAT= CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: head/sbin/hastd/pjdlog.c == --- head/sbin/hastd/pjdlog.cMon Mar 7 10:33:52 2011(r219369) +++ head/sbin/hastd/pjdlog.cMon Mar 7 10:38:18 2011(r219370) @@ -31,9 +31,15 @@ #include __FBSDID("$FreeBSD$"); +#include +#include + #include #include +#include +#include #include +#include #include #include #include @@ -49,6 +55,77 @@ static int pjdlog_initialized = PJDLOG_N static int pjdlog_mode, pjdlog_debug_level; static char pjdlog_prefix[128]; +static int +pjdlog_printf_arginfo_humanized_number(const struct printf_info *pi __unused, +size_t n, int *argt) +{ + + assert(n >= 1); + argt[0] = PA_INT | PA_FLAG_INTMAX; + return (1); +} + +static int +pjdlog_printf_render_humanized_number(struct __printf_io *io, +const struct printf_info *pi, const void * const *arg) +{ + char buf[5]; + intmax_t num; + int ret; + + num = *(const intmax_t *)arg[0]; + humanize_number(buf, sizeof(buf), (int64_t)num, "", HN_AUTOSCALE, + HN_NOSPACE | HN_DECIMAL); + ret = __printf_out(io, pi, buf, strlen(buf)); + __printf_flush(io); + return (ret); +} + +static int +pjdlog_printf_arginfo_sockaddr(const struct printf_info *pi __unused, +size_t n, int *argt) +{ + + assert(n >= 1); + argt[0] = PA_POINTER; + return (1); +} + +static int +pjdlog_printf_render_sockaddr(struct __printf_io *io, +const struct printf_info *pi, const void * const *arg) +{ + const struct sockaddr *sa; + char buf[64]; + int ret; + + sa = *(const struct sockaddr * const *)arg[0]; + switch (sa->sa_family) { + case AF_INET: + { + const struct sockaddr_in *sin; + in_addr_t ip; + unsigned int port; + + sin = (const struct sockaddr_in *)sa; + ip = ntohl(sin->sin_addr.s_addr); + port = ntohs(sin->sin_port); + + snprintf(buf, sizeof(buf), "%u.%u.%u.%u:%u", + ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), + ((ip >> 8) & 0xff), (ip & 0xff), port); + break; + } + default: + snprintf(buf, sizeof(buf), "[unsupported family %u]", + (unsigned int)sa->sa_family); + break; + } + ret = __printf_out(io, pi, buf, strlen(buf)); + __printf_flush(io); + return (ret); +} + void pjdlog_init(int mode) { @@ -57,6 +134,17 @@ pjdlog_init(int mode) pjdlog_initialized == PJDLOG_NOT_INITIALIZED); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); + if (pjdlog_initialized == PJDLOG_NEVER_INITIALIZED) { + __use_xprintf = 1; + register_printf_render_std("T"); + register_printf_render('N', + pjdlog_printf_render_humanized_number, + pjdlog_printf_arginfo_humanized_number); + register_printf_render('S', + pjdlog_printf_render_sockaddr, + pjdlog_printf_arginfo_sockaddr); + } + if (mode == PJDLOG_MODE_SYSLOG) openlog(NULL, LOG_PID | LO
svn commit: r219371 - head/sbin/hastd
Author: pjd Date: Mon Mar 7 10:39:26 2011 New Revision: 219371 URL: http://svn.freebsd.org/changeset/base/219371 Log: Use %S to print IP address and port number. MFC after:2 weeks Modified: head/sbin/hastd/proto_tcp4.c Modified: head/sbin/hastd/proto_tcp4.c == --- head/sbin/hastd/proto_tcp4.cMon Mar 7 10:38:18 2011 (r219370) +++ head/sbin/hastd/proto_tcp4.cMon Mar 7 10:39:26 2011 (r219371) @@ -475,22 +475,6 @@ tcp4_descriptor(const void *ctx) return (tctx->tc_fd); } -static void -sin2str(struct sockaddr_in *sinp, char *addr, size_t size) -{ - in_addr_t ip; - unsigned int port; - - PJDLOG_ASSERT(addr != NULL); - PJDLOG_ASSERT(sinp->sin_family == AF_INET); - - ip = ntohl(sinp->sin_addr.s_addr); - port = ntohs(sinp->sin_port); - PJDLOG_VERIFY(snprintf(addr, size, "tcp4://%u.%u.%u.%u:%u", - ((ip >> 24) & 0xff), ((ip >> 16) & 0xff), ((ip >> 8) & 0xff), - (ip & 0xff), port) < (ssize_t)size); -} - static bool tcp4_address_match(const void *ctx, const char *addr) { @@ -529,7 +513,7 @@ tcp4_local_address(const void *ctx, char PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - sin2str(&sin, addr, size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp4://%S", &sin) < (ssize_t)size); } static void @@ -547,7 +531,7 @@ tcp4_remote_address(const void *ctx, cha PJDLOG_VERIFY(strlcpy(addr, "N/A", size) < size); return; } - sin2str(&sin, addr, size); + PJDLOG_VERIFY(snprintf(addr, size, "tcp4://%S", &sin) < (ssize_t)size); } static void ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219372 - head/sbin/hastd
Author: pjd Date: Mon Mar 7 10:41:12 2011 New Revision: 219372 URL: http://svn.freebsd.org/changeset/base/219372 Log: - Log size of data to synchronize in human readable form (using %N). - Log synchronization time (using %T). - Log synchronization speed in human readable form (using %N). MFC after:2 weeks Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Mon Mar 7 10:39:26 2011(r219371) +++ head/sbin/hastd/primary.c Mon Mar 7 10:41:12 2011(r219372) @@ -1667,6 +1667,7 @@ sync_thread(void *arg __unused) struct hast_resource *res = arg; struct hio *hio; struct g_gate_ctl_io *ggio; + struct timeval tstart, tend, tdiff; unsigned int ii, ncomp, ncomps; off_t offset, length, synced; bool dorewind; @@ -1680,8 +1681,10 @@ sync_thread(void *arg __unused) for (;;) { mtx_lock(&sync_lock); if (offset >= 0 && !sync_inprogress) { - pjdlog_info("Synchronization interrupted. " - "%jd bytes synchronized so far.", + gettimeofday(&tend, NULL); + timersub(&tend, &tstart, &tdiff); + pjdlog_info("Synchronization interrupted after %#.0T. " + "%NB synchronized so far.", &tdiff, (intmax_t)synced); event_send(res, EVENT_SYNCINTR); } @@ -1713,10 +1716,11 @@ sync_thread(void *arg __unused) if (offset < 0) pjdlog_info("Nodes are in sync."); else { - pjdlog_info("Synchronization started. %ju bytes to go.", - (uintmax_t)(res->hr_extentsize * + pjdlog_info("Synchronization started. %NB to go.", + (intmax_t)(res->hr_extentsize * activemap_ndirty(res->hr_amp))); event_send(res, EVENT_SYNCSTART); + gettimeofday(&tstart, NULL); } } if (offset < 0) { @@ -1730,9 +1734,17 @@ sync_thread(void *arg __unused) rw_rlock(&hio_remote_lock[ncomp]); if (ISCONNECTED(res, ncomp)) { if (synced > 0) { + int64_t bps; + + gettimeofday(&tend, NULL); + timersub(&tend, &tstart, &tdiff); + bps = (int64_t)((double)synced / + ((double)tdiff.tv_sec + + (double)tdiff.tv_usec / 100)); pjdlog_info("Synchronization complete. " - "%jd bytes synchronized.", - (intmax_t)synced); + "%NB synchronized in %#.0lT (%NB/sec).", + (intmax_t)synced, &tdiff, + (intmax_t)bps); event_send(res, EVENT_SYNCDONE); } mtx_lock(&metadata_lock); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219373 - head/sbin/hastctl
Author: pjd Date: Mon Mar 7 10:42:28 2011 New Revision: 219373 URL: http://svn.freebsd.org/changeset/base/219373 Log: Print some of the numbers in human readable form (using %N). MFC after:2 weeks Modified: head/sbin/hastctl/hastctl.c Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Mon Mar 7 10:41:12 2011(r219372) +++ head/sbin/hastctl/hastctl.c Mon Mar 7 10:42:28 2011(r219373) @@ -213,8 +213,10 @@ dump_one(struct hast_resource *res) return (ret); printf("resource: %s\n", res->hr_name); - printf("datasize: %ju\n", (uintmax_t)res->hr_datasize); - printf("extentsize: %d\n", res->hr_extentsize); + printf("datasize: %ju (%NB)\n", (uintmax_t)res->hr_datasize, + (intmax_t)res->hr_datasize); + printf("extentsize: %d (%NB)\n", res->hr_extentsize, + (intmax_t)res->hr_extentsize); printf("keepdirty: %d\n", res->hr_keepdirty); printf("localoff: %ju\n", (uintmax_t)res->hr_localoff); printf("resuid: %ju\n", (uintmax_t)res->hr_resuid); @@ -321,8 +323,9 @@ control_status(struct nv *nv) nv_get_string(nv, "provname%u", ii)); printf(" localpath: %s\n", nv_get_string(nv, "localpath%u", ii)); - printf(" extentsize: %u\n", - (unsigned int)nv_get_uint32(nv, "extentsize%u", ii)); + printf(" extentsize: %u (%NB)\n", + (unsigned int)nv_get_uint32(nv, "extentsize%u", ii), + (intmax_t)nv_get_uint32(nv, "extentsize%u", ii)); printf(" keepdirty: %u\n", (unsigned int)nv_get_uint32(nv, "keepdirty%u", ii)); printf(" remoteaddr: %s\n", @@ -332,8 +335,9 @@ control_status(struct nv *nv) str = nv_get_string(nv, "status%u", ii); if (str != NULL) printf(" status: %s\n", str); - printf(" dirty: %ju bytes\n", - (uintmax_t)nv_get_uint64(nv, "dirty%u", ii)); + printf(" dirty: %ju (%NB)\n", + (uintmax_t)nv_get_uint64(nv, "dirty%u", ii), + (intmax_t)nv_get_uint64(nv, "dirty%u", ii)); } return (ret); } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r219372 - head/sbin/hastd
On Mon, Mar 07, 2011 at 10:41:12AM +, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Mon Mar 7 10:41:12 2011 > New Revision: 219372 > URL: http://svn.freebsd.org/changeset/base/219372 > > Log: > - Log size of data to synchronize in human readable form (using %N). > - Log synchronization time (using %T). > - Log synchronization speed in human readable form (using %N). With those changes: [INFO] [test] (primary) Synchronization started. 37GB to go. [INFO] [test] (primary) Synchronization complete. 37GB synchronized in 7m24s (86MB/sec). -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpCdrjmhkWLR.pgp Description: PGP signature
svn commit: r219385 - head/sbin/hastd
Author: pjd Date: Mon Mar 7 19:54:51 2011 New Revision: 219385 URL: http://svn.freebsd.org/changeset/base/219385 Log: Unbreak the build. MFC after:2 weeks Modified: head/sbin/hastd/pjdlog.c Modified: head/sbin/hastd/pjdlog.c == --- head/sbin/hastd/pjdlog.cMon Mar 7 18:33:29 2011(r219384) +++ head/sbin/hastd/pjdlog.cMon Mar 7 19:54:51 2011(r219385) @@ -95,19 +95,19 @@ static int pjdlog_printf_render_sockaddr(struct __printf_io *io, const struct printf_info *pi, const void * const *arg) { - const struct sockaddr *sa; + const struct sockaddr_storage *ss; char buf[64]; int ret; - sa = *(const struct sockaddr * const *)arg[0]; - switch (sa->sa_family) { + ss = *(const struct sockaddr_storage * const *)arg[0]; + switch (ss->ss_family) { case AF_INET: { const struct sockaddr_in *sin; in_addr_t ip; unsigned int port; - sin = (const struct sockaddr_in *)sa; + sin = (const struct sockaddr_in *)ss; ip = ntohl(sin->sin_addr.s_addr); port = ntohs(sin->sin_port); @@ -118,7 +118,7 @@ pjdlog_printf_render_sockaddr(struct __p } default: snprintf(buf, sizeof(buf), "[unsupported family %u]", - (unsigned int)sa->sa_family); + (unsigned int)ss->ss_family); break; } ret = __printf_out(io, pi, buf, strlen(buf)); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219404 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Tue Mar 8 18:39:41 2011 New Revision: 219404 URL: http://svn.freebsd.org/changeset/base/219404 Log: Correct readdir over ZFS handling. Reported by: Pierre Beyssac MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Mar 8 17:43:35 2011(r219403) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Tue Mar 8 18:39:41 2011(r219404) @@ -2394,7 +2394,8 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre * Minimum entry size is dirent size and 1 byte for a file name. */ ncooks = uio->uio_resid / (sizeof(struct dirent) - sizeof(((struct dirent *)NULL)->d_name) + 1); - *cookies = malloc(ncooks * sizeof(u_long), M_TEMP, M_WAITOK); + cooks = malloc(ncooks * sizeof(u_long), M_TEMP, M_WAITOK); + *cookies = cooks; *ncookies = ncooks; } /* @@ -2541,16 +2542,6 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre if (prefetch) dmu_prefetch(os, objnum, 0, 0); - if (ncookies != NULL) { - if (cooks == NULL) - cooks = *cookies; - else { - *cooks++ = offset; - ncooks--; - KASSERT(ncooks >= 0, ("ncookies=%d", ncooks)); - } - } - skip_entry: /* * Move to the next entry, fill in the previous offset. @@ -2561,6 +2552,12 @@ zfs_readdir(vnode_t *vp, uio_t *uio, cre } else { offset += 1; } + + if (cooks != NULL) { + *cooks++ = offset; + ncooks--; + KASSERT(ncooks >= 0, ("ncookies=%d", ncooks)); + } } zp->z_zn_prefetch = B_FALSE; /* a lookup will re-enable pre-fetching */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r219404 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
On Tue, Mar 08, 2011 at 06:39:41PM +, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Tue Mar 8 18:39:41 2011 > New Revision: 219404 > URL: http://svn.freebsd.org/changeset/base/219404 > > Log: > Correct readdir over ZFS handling. s/ZFS/NFS/ -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp7PkpefLwhg.pgp Description: PGP signature
svn commit: r219424 - head/sbin/geom/class/eli
Author: pjd Date: Wed Mar 9 07:43:51 2011 New Revision: 219424 URL: http://svn.freebsd.org/changeset/base/219424 Log: Change example to not be controversial. I'm sorry to anyone who felt offended by this. PR: docs/155385 Reported by: maga_lena MFC after:1 week Modified: head/sbin/geom/class/eli/geli.8 Modified: head/sbin/geom/class/eli/geli.8 == --- head/sbin/geom/class/eli/geli.8 Wed Mar 9 06:14:57 2011 (r219423) +++ head/sbin/geom/class/eli/geli.8 Wed Mar 9 07:43:51 2011 (r219424) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 3, 2010 +.Dd March 9, 2011 .Dt GELI 8 .Os .Sh NAME @@ -694,15 +694,17 @@ Enter passphrase: .Ed .Pp Create an encrypted provider, but use two keys: -one for your girlfriend and one for -you (so there will be no tragedy if she forgets her passphrase): +one for your employee and one for you as company's security officer +(so there is no tragedy if the employee +.Qq accidentally +forgets his passphrase): .Bd -literal -offset indent # geli init /dev/da2 -Enter new passphrase: (enter your passphrase) +Enter new passphrase: (enter security officer passphrase) Reenter new passphrase: # geli setkey -n 1 /dev/da2 -Enter passphrase: (enter your passphrase) -Enter new passphrase: (let your girlfriend enter her passphrase ...) +Enter passphrase: (enter security officer passphrase) +Enter new passphrase: (let your employee enter his passphrase ...) Reenter new passphrase:(... twice) .Ed .Pp ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219437 - in head/tools/regression/pjdfstest: . tests/chmod
Author: pjd Date: Wed Mar 9 22:39:10 2011 New Revision: 219437 URL: http://svn.freebsd.org/changeset/base/219437 Log: Add support for the following syscalls: - fchmod(2), - fchown(2), - fchflags(2), - fstat(2), - ftruncate(2), - fpathconf(2), - lpathconf(2). Make write(2) syscall to take descriptor instead of file name. We implement descriptors by keeping track of open files and allowing to reference them by the following syscalls. Because pjdfstest already supports executing multiple syscalls from one command it works pretty well. For example, the following command: pjdfstest open foo "O_CREAT,O_RDWR" 0 : open bar "O_CREAT,O_RDONLY" 640 : fchmod 0 0666 : fchown 0 -1 20 : fchmod 1 0444 is equivalent of (error checking omitted): int fd[2]; fd[0] = open("foo", O_CREAT | O_RDWR, 0); fd[1] = open("bar", O_CREAT | O_RDONLY, 0640); fchmod(fd[0], 0666); fchown(fd[0], -1, 20); fchmod(fd[1], 0444); Modified: head/tools/regression/pjdfstest/Makefile head/tools/regression/pjdfstest/pjdfstest.c head/tools/regression/pjdfstest/tests/chmod/12.t Modified: head/tools/regression/pjdfstest/Makefile == --- head/tools/regression/pjdfstest/MakefileWed Mar 9 21:07:09 2011 (r219436) +++ head/tools/regression/pjdfstest/MakefileWed Mar 9 22:39:10 2011 (r219437) @@ -6,7 +6,7 @@ ${PROG}:${PROG}.c @OSTYPE=`uname`; \ CFLAGS=-D__OS_$${OSTYPE}__; \ if [ $$OSTYPE = "FreeBSD" ]; then \ - CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL"; \ + CFLAGS="$$CFLAGS -DHAS_LCHMOD -DHAS_CHFLAGS -DHAS_FCHFLAGS -DHAS_LCHFLAGS -DHAS_FREEBSD_ACL"; \ elif [ $$OSTYPE = "SunOS" ]; then \ CFLAGS="$$CFLAGS -DHAS_TRUNCATE64 -DHAS_STAT64"; \ CFLAGS="$$CFLAGS -lsocket"; \ Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Wed Mar 9 21:07:09 2011 (r219436) +++ head/tools/regression/pjdfstest/pjdfstest.c Wed Mar 9 22:39:10 2011 (r219437) @@ -47,9 +47,11 @@ #ifndef HAS_TRUNCATE64 #definetruncate64 truncate +#defineftruncate64 ftruncate #endif #ifndef HAS_STAT64 #definestat64 stat +#definefstat64 fstat #definelstat64 lstat #endif #ifdef HAS_FREEBSD_ACL @@ -74,21 +76,30 @@ enum action { ACTION_BIND, ACTION_CONNECT, ACTION_CHMOD, + ACTION_FCHMOD, #ifdef HAS_LCHMOD ACTION_LCHMOD, #endif ACTION_CHOWN, + ACTION_FCHOWN, ACTION_LCHOWN, #ifdef HAS_CHFLAGS ACTION_CHFLAGS, #endif +#ifdef HAS_FCHFLAGS + ACTION_FCHFLAGS, +#endif #ifdef HAS_LCHFLAGS ACTION_LCHFLAGS, #endif ACTION_TRUNCATE, + ACTION_FTRUNCATE, ACTION_STAT, + ACTION_FSTAT, ACTION_LSTAT, ACTION_PATHCONF, + ACTION_FPATHCONF, + ACTION_LPATHCONF, #ifdef HAS_FREEBSD_ACL ACTION_PREPENDACL, ACTION_READACL, @@ -124,26 +135,35 @@ static struct syscall_desc syscalls[] = { "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } }, { "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } }, { "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "fchmod", ACTION_FCHMOD, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, #ifdef HAS_LCHMOD { "lchmod", ACTION_LCHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, #endif { "chown", ACTION_CHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchown", ACTION_FCHOWN, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, { "lchown", ACTION_LCHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, #ifdef HAS_CHFLAGS { "chflags", ACTION_CHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, #endif +#ifdef HAS_FCHFLAGS + { "fchflags", ACTION_FCHFLAGS, { TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, +#endif #ifdef HAS_LCHFLAGS { "lchflags", ACTION_LCHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, #endif { "truncate", ACTION_TRUNCATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "ftruncate", ACTION_FTRUNCATE, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, { "stat", ACTION_STAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "fstat", ACTION_FSTAT, { TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, { "lstat", ACTION_LSTAT, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "pathconf", ACTION_PATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "fpathconf", ACTION_FPATHCONF, { TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, + { "lpathconf", ACTION_LPATHCONF, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, #ifdef HAS_FREEBSD_ACL { "prepend
svn commit: r219438 - in head/tools/regression/pjdfstest: . tests/chmod
Author: pjd Date: Wed Mar 9 22:50:15 2011 New Revision: 219438 URL: http://svn.freebsd.org/changeset/base/219438 Log: Pass descriptor number to write(2), now that it is possible. Modified: head/tools/regression/pjdfstest/pjdfstest.c head/tools/regression/pjdfstest/tests/chmod/12.t Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Wed Mar 9 22:39:10 2011 (r219437) +++ head/tools/regression/pjdfstest/pjdfstest.c Wed Mar 9 22:50:15 2011 (r219438) @@ -163,7 +163,7 @@ static struct syscall_desc syscalls[] = { "prependacl", ACTION_PREPENDACL, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "readacl", ACTION_READACL, { TYPE_STRING, TYPE_NONE } }, #endif - { "write", ACTION_WRITE, { TYPE_NUMBER, TYPE_NONE } }, + { "write", ACTION_WRITE, { TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, { NULL, -1, { TYPE_NONE } } }; @@ -745,7 +745,7 @@ call_syscall(struct syscall_desc *scall, break; #endif case ACTION_WRITE: - rval = write(DESC(0), "x", 1); + rval = write(DESC(0), STR(1), strlen(STR(1))); break; default: fprintf(stderr, "unsupported syscall\n"); Modified: head/tools/regression/pjdfstest/tests/chmod/12.t == --- head/tools/regression/pjdfstest/tests/chmod/12.tWed Mar 9 22:39:10 2011(r219437) +++ head/tools/regression/pjdfstest/tests/chmod/12.tWed Mar 9 22:50:15 2011(r219438) @@ -18,13 +18,13 @@ cd ${n2} # Check whether writing to the file by non-owner clears the SUID. expect 0 create ${n0} 04777 -expect 0 -u 65534 -g 65534 write ${n0} x +expect 0 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x expect 0777 stat ${n0} mode expect 0 unlink ${n0} # Check whether writing to the file by non-owner clears the SGID. expect 0 create ${n0} 02777 -expect 0 -u 65534 -g 65534 write ${n0} x +expect 0 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x expect 0777 stat ${n0} mode expect 0 unlink ${n0} ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219439 - head/tools/regression/pjdfstest/tests/ftruncate
Author: pjd Date: Wed Mar 9 23:11:30 2011 New Revision: 219439 URL: http://svn.freebsd.org/changeset/base/219439 Log: Few initial ftruncate(2) tests. One of them covers stand/154873. PR: stand/154873 Added: head/tools/regression/pjdfstest/tests/ftruncate/ head/tools/regression/pjdfstest/tests/ftruncate/00.t (contents, props changed) Added: head/tools/regression/pjdfstest/tests/ftruncate/00.t == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/pjdfstest/tests/ftruncate/00.tWed Mar 9 23:11:30 2011(r219439) @@ -0,0 +1,58 @@ +#!/bin/sh +# $FreeBSD$ + +desc="ftruncate descrease/increase file size" + +dir=`dirname $0` +. ${dir}/../misc.sh + +echo "1..21" + +n0=`namegen` +n1=`namegen` + +expect 0 mkdir ${n1} 0755 +cdir=`pwd` +cd ${n1} + +expect 0 create ${n0} 0644 +expect 0 open ${n0} O_RDWR : ftruncate 0 1234567 +expect 1234567 lstat ${n0} size +expect 0 open ${n0} O_WRONLY : ftruncate 0 567 +expect 567 lstat ${n0} size +expect 0 unlink ${n0} + +dd if=/dev/random of=${n0} bs=12345 count=1 >/dev/null 2>&1 +expect 0 open ${n0} O_RDWR : ftruncate 0 23456 +expect 23456 lstat ${n0} size +expect 0 open ${n0} O_WRONLY : ftruncate 0 1 +expect 1 lstat ${n0} size +expect 0 unlink ${n0} + +# successful ftruncate(2) updates ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect 0 open ${n0} O_RDWR : ftruncate 0 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -lt $ctime2 +expect 0 unlink ${n0} + +# unsuccessful ftruncate(2) does not update ctime. +expect 0 create ${n0} 0644 +ctime1=`${fstest} stat ${n0} ctime` +sleep 1 +expect EINVAL -u 65534 open ${n0} O_RDONLY : ftruncate 0 123 +ctime2=`${fstest} stat ${n0} ctime` +test_check $ctime1 -eq $ctime2 +expect 0 unlink ${n0} + +# third argument should not affect permission. +expect 0 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0 +expect 0 unlink ${n0} +expect 0 chmod . 0777 +expect 0 -u 65534 open ${n0} O_CREAT,O_RDWR 0 : ftruncate 0 0 +expect 0 unlink ${n0} + +cd ${cdir} +expect 0 rmdir ${n1} ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219463 - head/tools/regression/pjdfstest/tests/chmod
Author: pjd Date: Thu Mar 10 20:59:02 2011 New Revision: 219463 URL: http://svn.freebsd.org/changeset/base/219463 Log: Improve test a bit, now that we have fstat(2) support. The test was support to check if SUID/SGID bits are removed on first write, but actually we were checking if they were removed after close. Now we can check if SUID/SGID bits are gone after first write. While here add checks to see if when both SUID and SGID bits are set they are both cleared on first write. Modified: head/tools/regression/pjdfstest/tests/chmod/12.t Modified: head/tools/regression/pjdfstest/tests/chmod/12.t == --- head/tools/regression/pjdfstest/tests/chmod/12.tThu Mar 10 20:37:54 2011(r219462) +++ head/tools/regression/pjdfstest/tests/chmod/12.tThu Mar 10 20:59:02 2011(r219463) @@ -6,7 +6,7 @@ desc="verify SUID/SGID bit behaviour" dir=`dirname $0` . ${dir}/../misc.sh -echo "1..10" +echo "1..14" n0=`namegen` n1=`namegen` @@ -18,13 +18,19 @@ cd ${n2} # Check whether writing to the file by non-owner clears the SUID. expect 0 create ${n0} 04777 -expect 0 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x +expect 0777 -u 65534 -g 65534 open ${n0} O_WRONLY : write 0 x : fstat 0 mode expect 0777 stat ${n0} mode expect 0 unlink ${n0} # Check whether writing to the file by non-owner clears the SGID. expect 0 create ${n0} 02777 -expect 0 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode +expect 0777 stat ${n0} mode +expect 0 unlink ${n0} + +# Check whether writing to the file by non-owner clears the SUID+SGID. +expect 0 create ${n0} 06777 +expect 0777 -u 65534 -g 65534 open ${n0} O_RDWR : write 0 x : fstat 0 mode expect 0777 stat ${n0} mode expect 0 unlink ${n0} ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219464 - head/tools/regression/pjdfstest
Author: pjd Date: Thu Mar 10 21:00:30 2011 New Revision: 219464 URL: http://svn.freebsd.org/changeset/base/219464 Log: Add support for *at syscalls: - openat(2) - unlinkat(2) - mkdirat(2) - linkat(2) - symlinkat(2) - renameat(2) - mkfifoat(2) - mknodat(2) - fchmodat(2) - fchownat(2) - fstatat(2) Modified: head/tools/regression/pjdfstest/pjdfstest.c Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Thu Mar 10 20:59:02 2011 (r219463) +++ head/tools/regression/pjdfstest/pjdfstest.c Thu Mar 10 21:00:30 2011 (r219464) @@ -64,15 +64,23 @@ enum action { ACTION_OPEN, + ACTION_OPENAT, ACTION_CREATE, ACTION_UNLINK, + ACTION_UNLINKAT, ACTION_MKDIR, + ACTION_MKDIRAT, ACTION_RMDIR, ACTION_LINK, + ACTION_LINKAT, ACTION_SYMLINK, + ACTION_SYMLINKAT, ACTION_RENAME, + ACTION_RENAMEAT, ACTION_MKFIFO, + ACTION_MKFIFOAT, ACTION_MKNOD, + ACTION_MKNODAT, ACTION_BIND, ACTION_CONNECT, ACTION_CHMOD, @@ -80,9 +88,11 @@ enum action { #ifdef HAS_LCHMOD ACTION_LCHMOD, #endif + ACTION_FCHMODAT, ACTION_CHOWN, ACTION_FCHOWN, ACTION_LCHOWN, + ACTION_FCHOWNAT, #ifdef HAS_CHFLAGS ACTION_CHFLAGS, #endif @@ -97,6 +107,7 @@ enum action { ACTION_STAT, ACTION_FSTAT, ACTION_LSTAT, + ACTION_FSTATAT, ACTION_PATHCONF, ACTION_FPATHCONF, ACTION_LPATHCONF, @@ -110,6 +121,8 @@ enum action { #defineTYPE_NONE 0x #defineTYPE_STRING 0x0001 #defineTYPE_NUMBER 0x0002 +#defineTYPE_DESCRIPTOR 0x0003 +#defineTYPE_MASK 0x000f #defineTYPE_OPTIONAL 0x0100 @@ -123,47 +136,58 @@ struct syscall_desc { static struct syscall_desc syscalls[] = { { "open", ACTION_OPEN, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, + { "openat", ACTION_OPENAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } }, { "create", ACTION_CREATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "unlink", ACTION_UNLINK, { TYPE_STRING, TYPE_NONE } }, + { "unlinkat", ACTION_UNLINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "mkdir", ACTION_MKDIR, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkdirat", ACTION_MKDIRAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "rmdir", ACTION_RMDIR, { TYPE_STRING, TYPE_NONE } }, { "link", ACTION_LINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "linkat", ACTION_LINKAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NONE } }, { "symlink", ACTION_SYMLINK, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "symlinkat", ACTION_SYMLINKAT, { TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, { "rename", ACTION_RENAME, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, + { "renameat", ACTION_RENAMEAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NONE } }, { "mkfifo", ACTION_MKFIFO, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, + { "mkfifoat", ACTION_MKFIFOAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, { "mknod", ACTION_MKNOD, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, + { "mknodat", ACTION_MKNODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE} }, { "bind", ACTION_BIND, { TYPE_STRING, TYPE_NONE } }, { "connect", ACTION_CONNECT, { TYPE_STRING, TYPE_NONE } }, { "chmod", ACTION_CHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, - { "fchmod", ACTION_FCHMOD, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchmod", ACTION_FCHMOD, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NONE } }, #ifdef HAS_LCHMOD { "lchmod", ACTION_LCHMOD, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } }, #endif + { "fchmodat", ACTION_FCHMODAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, { "chown", ACTION_CHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, - { "fchown", ACTION_FCHOWN, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchown", ACTION_FCHOWN, { TYPE_DESCRIPTOR, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, { "lchown", ACTION_LCHOWN, { TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } }, + { "fchownat", ACTION_FCHOWNAT, { TYPE_DESCRIPTOR, TYPE_STRING, TYPE_NUMBER, TYPE_NUMBER, TYPE_STRING, TYPE_NONE } }, #ifdef HAS_CHFLAGS { "chflags", ACTION_CHFLAGS, { TYPE_STRING, TYPE_STRING, TYPE_NONE } }, #endif #ifdef HAS_FCHFLAGS - { "fchflags", ACTION_FCHFLAGS, { TYPE
Re: svn commit: r219483 - head/sys/boot/i386/gptboot
On Fri, Mar 11, 2011 at 01:11:15PM +, John Baldwin wrote: > Author: jhb > Date: Fri Mar 11 13:11:15 2011 > New Revision: 219483 > URL: http://svn.freebsd.org/changeset/base/219483 > > Log: > Remove all object files during 'make clean'. Oops, I think that was me. Thank you, John. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpx7DknItH5Z.pgp Description: PGP signature
svn commit: r219566 - head/tools/regression/pjdfstest
Author: pjd Date: Sat Mar 12 14:09:43 2011 New Revision: 219566 URL: http://svn.freebsd.org/changeset/base/219566 Log: Add some missing consts. Modified: head/tools/regression/pjdfstest/pjdfstest.c Modified: head/tools/regression/pjdfstest/pjdfstest.c == --- head/tools/regression/pjdfstest/pjdfstest.c Sat Mar 12 12:10:17 2011 (r219565) +++ head/tools/regression/pjdfstest/pjdfstest.c Sat Mar 12 14:09:43 2011 (r219566) @@ -129,7 +129,7 @@ enum action { #defineMAX_ARGS8 struct syscall_desc { - char*sd_name; + const char *sd_name; enum action sd_action; int sd_args[MAX_ARGS]; }; @@ -193,7 +193,7 @@ static struct syscall_desc syscalls[] = struct flag { long longf_flag; - char*f_str; + const char *f_str; }; static struct flag open_flags[] = { @@ -310,8 +310,8 @@ static struct flag fstatat_flags[] = { }; struct name { - int n_name; - char*n_str; + int n_name; + const char *n_str; }; static struct name pathconf_names[] = { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219621 - head/tools/regression/pjdfstest/tests/open
Author: pjd Date: Sun Mar 13 19:35:13 2011 New Revision: 219621 URL: http://svn.freebsd.org/changeset/base/219621 Log: POSIX accepts only ELOOP if O_NOFOLLOW is specified and target is a symlink. Modified: head/tools/regression/pjdfstest/tests/open/16.t Modified: head/tools/regression/pjdfstest/tests/open/16.t == --- head/tools/regression/pjdfstest/tests/open/16.t Sun Mar 13 19:23:32 2011(r219620) +++ head/tools/regression/pjdfstest/tests/open/16.t Sun Mar 13 19:35:13 2011(r219621) @@ -1,7 +1,7 @@ #!/bin/sh # $FreeBSD$ -desc="open returns EMLINK/ELOOP when O_NOFOLLOW was specified and the target is a symbolic link" +desc="open returns ELOOP when O_NOFOLLOW was specified and the target is a symbolic link" dir=`dirname $0` . ${dir}/../misc.sh @@ -12,8 +12,8 @@ n0=`namegen` n1=`namegen` expect 0 symlink ${n0} ${n1} -expect "EMLINK|ELOOP" open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 -expect "EMLINK|ELOOP" open ${n1} O_RDONLY,O_NOFOLLOW -expect "EMLINK|ELOOP" open ${n1} O_WRONLY,O_NOFOLLOW -expect "EMLINK|ELOOP" open ${n1} O_RDWR,O_NOFOLLOW +expect ELOOP open ${n1} O_RDONLY,O_CREAT,O_NOFOLLOW 0644 +expect ELOOP open ${n1} O_RDONLY,O_NOFOLLOW +expect ELOOP open ${n1} O_WRONLY,O_NOFOLLOW +expect ELOOP open ${n1} O_RDWR,O_NOFOLLOW expect 0 unlink ${n1} ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219636 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Mon Mar 14 11:07:12 2011 New Revision: 219636 URL: http://svn.freebsd.org/changeset/base/219636 Log: Fix potential panic in dbuf_sync_list() relate to spill blocks handling. Obtained from:IllumOS MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Mon Mar 14 10:51:24 2011(r219635) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Mon Mar 14 11:07:12 2011(r219636) @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. */ #include @@ -1300,13 +1301,17 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_ * it, since one of the current holders may be in the * middle of an update. Note that users of dbuf_undirty() * should not place a hold on the dbuf before the call. +* Also note: we can get here with a spill block, so +* test for that similar to how dbuf_dirty does. */ if (refcount_count(&db->db_holds) > db->db_dirtycnt) { mutex_exit(&db->db_mtx); /* Make sure we don't toss this buffer at sync phase */ - mutex_enter(&dn->dn_mtx); - dnode_clear_range(dn, db->db_blkid, 1, tx); - mutex_exit(&dn->dn_mtx); + if (db->db_blkid != DMU_SPILL_BLKID) { + mutex_enter(&dn->dn_mtx); + dnode_clear_range(dn, db->db_blkid, 1, tx); + mutex_exit(&dn->dn_mtx); + } DB_DNODE_EXIT(db); return (0); } @@ -1319,11 +1324,18 @@ dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_ *drp = dr->dr_next; + /* +* Note that there are three places in dbuf_dirty() +* where this dirty record may be put on a list. +* Make sure to do a list_remove corresponding to +* every one of those list_insert calls. +*/ if (dr->dr_parent) { mutex_enter(&dr->dr_parent->dt.di.dr_mtx); list_remove(&dr->dr_parent->dt.di.dr_children, dr); mutex_exit(&dr->dr_parent->dt.di.dr_mtx); - } else if (db->db_level+1 == dn->dn_nlevels) { + } else if (db->db_blkid == DMU_SPILL_BLKID || + db->db_level+1 == dn->dn_nlevels) { ASSERT(db->db_blkptr == NULL || db->db_parent == dn->dn_dbuf); mutex_enter(&dn->dn_mtx); list_remove(&dn->dn_dirty_records[txg & TXG_MASK], dr); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r219641 - in head: etc release
On Mon, Mar 14, 2011 at 01:47:17PM +, Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Mon Mar 14 13:47:17 2011 > New Revision: 219641 > URL: http://svn.freebsd.org/changeset/base/219641 > > Log: > Thanks to sysinstall for its 15 years of service. And now to sleep, > perchance to dream... And yes, I just heard, it is snowing in hell. This is for you, Nathan: http://www.youtube.com/watch?v=4m8ltkjO7Pg -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpYUDCPMRaNQ.pgp Description: PGP signature
svn commit: r219669 - head/sbin/hastd
Author: pjd Date: Tue Mar 15 13:53:39 2011 New Revision: 219669 URL: http://svn.freebsd.org/changeset/base/219669 Log: Remove #include needed for debugging. MFC after:1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Tue Mar 15 13:40:47 2011 (r219668) +++ head/sbin/hastd/proto_common.c Tue Mar 15 13:53:39 2011 (r219669) @@ -104,7 +104,6 @@ proto_common_send(int sock, const unsign return (proto_descriptor_send(sock, fd)); } -#include static int proto_descriptor_recv(int sock, int *fdp) { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219696 - head/lib/libc/gen
Author: pjd Date: Wed Mar 16 08:58:09 2011 New Revision: 219696 URL: http://svn.freebsd.org/changeset/base/219696 Log: From fts.c comment: The "FTS_NOSTAT" option can avoid a lot of calls to stat(2) if it knows that a directory could not possibly have subdirectories. This is decided by looking at the link count: a subdirectory would increment its parent's link count by virtue of its own ".." entry. This assumption only holds for UFS-like filesystems that implement links and directories this way, so we must punt for others. It looks like ZFS is a UFS-like file system, as the above also holds for ZFS. Add ZFS to the list of file systems that allow for such optimization. MFC after:1 month Modified: head/lib/libc/gen/fts-compat.c head/lib/libc/gen/fts.c Modified: head/lib/libc/gen/fts-compat.c == --- head/lib/libc/gen/fts-compat.c Wed Mar 16 08:56:22 2011 (r219695) +++ head/lib/libc/gen/fts-compat.c Wed Mar 16 08:58:09 2011 (r219696) @@ -110,6 +110,7 @@ struct _fts_private { static const char *ufslike_filesystems[] = { "ufs", + "zfs", "nfs", "nfs4", "ext2fs", Modified: head/lib/libc/gen/fts.c == --- head/lib/libc/gen/fts.c Wed Mar 16 08:56:22 2011(r219695) +++ head/lib/libc/gen/fts.c Wed Mar 16 08:58:09 2011(r219696) @@ -100,6 +100,7 @@ struct _fts_private { static const char *ufslike_filesystems[] = { "ufs", + "zfs", "nfs", "nfs4", "ext2fs", ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219813 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:31:35 2011 New Revision: 219813 URL: http://svn.freebsd.org/changeset/base/219813 Log: If there is any traffic on one of out descriptors, we were not checking for long running hooks. Fix it by not using select(2) timeout to decide if we want to check hooks or not. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 06:18:26 2011(r219812) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:31:35 2011(r219813) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -877,9 +878,11 @@ main_loop(void) struct timeval seltimeout; struct timespec sigtimeout; int fd, maxfd, ret, signo; + time_t lastcheck, now; sigset_t mask; fd_set rfds; + lastcheck = time(NULL); seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; sigtimeout.tv_sec = 0; @@ -943,9 +946,18 @@ main_loop(void) PJDLOG_ASSERT(maxfd + 1 <= (int)FD_SETSIZE); ret = select(maxfd + 1, &rfds, NULL, NULL, &seltimeout); - if (ret == 0) + now = time(NULL); + if (lastcheck + REPORT_INTERVAL <= now) { hook_check(); - else if (ret == -1) { + lastcheck = now; + } + if (ret == 0) { + /* +* select(2) timed out, so there should be no +* descriptors to check. +*/ + continue; + } else if (ret == -1) { if (errno == EINTR) continue; KEEP_ERRNO((void)pidfile_remove(pfh)); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219814 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:33:58 2011 New Revision: 219814 URL: http://svn.freebsd.org/changeset/base/219814 Log: When creating connection on behalf of primary worker, set pjdlog prefix to resource name and role, so that any logs related to that can be identified properly. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 08:31:35 2011(r219813) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:33:58 2011(r219814) @@ -842,6 +842,8 @@ connection_migrate(struct hast_resource struct proto_conn *conn; int16_t val = 0; + pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { pjdlog_errno(LOG_WARNING, "Unable to receive connection command"); @@ -869,6 +871,8 @@ out: } if (val == 0 && proto_connection_send(res->hr_conn, conn) < 0) pjdlog_errno(LOG_WARNING, "Unable to send connection"); + + pjdlog_prefix_set("%s", ""); } static void ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219815 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:36:50 2011 New Revision: 219815 URL: http://svn.freebsd.org/changeset/base/219815 Log: Add snprlcat() and vsnprlcat() - the functions I'm always missing. They work as a combination of snprintf(3) and strlcat(3) - the caller can append a string build based on the given format. MFC after:1 week Modified: head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Mon Mar 21 08:33:58 2011(r219814) +++ head/sbin/hastd/subr.c Mon Mar 21 08:36:50 2011(r219815) @@ -38,6 +38,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #include @@ -46,6 +49,27 @@ __FBSDID("$FreeBSD$"); #include "subr.h" int +vsnprlcat(char *str, size_t size, const char *fmt, va_list ap) +{ + size_t len; + + len = strlen(str); + return (vsnprintf(str + len, size - len, fmt, ap)); +} + +int +snprlcat(char *str, size_t size, const char *fmt, ...) +{ + va_list ap; + int result; + + va_start(ap, fmt); + result = vsnprlcat(str, size, fmt, ap); + va_end(ap); + return (result); +} + +int provinfo(struct hast_resource *res, bool dowrite) { struct stat sb; Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Mon Mar 21 08:33:58 2011(r219814) +++ head/sbin/hastd/subr.h Mon Mar 21 08:36:50 2011(r219815) @@ -45,6 +45,9 @@ errno = _rerrno;\ } while (0) +int vsnprlcat(char *str, size_t size, const char *fmt, va_list ap); +int snprlcat(char *str, size_t size, const char *fmt, ...); + int provinfo(struct hast_resource *res, bool dowrite); const char *role2str(int role); int drop_privs(void); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219816 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:37:50 2011 New Revision: 219816 URL: http://svn.freebsd.org/changeset/base/219816 Log: Use snprlcat() instead of two strlcat(3)s. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 08:36:50 2011(r219815) +++ head/sbin/hastd/hooks.c Mon Mar 21 08:37:50 2011(r219816) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include "hooks.h" +#include "subr.h" #include "synch.h" /* Report processes that are running for too long not often than this value. */ @@ -184,8 +185,8 @@ hook_alloc(const char *path, char **args (void)strlcpy(hp->hp_comm, path, sizeof(hp->hp_comm)); /* We start at 2nd argument as we don't want to have exec name twice. */ for (ii = 1; args[ii] != NULL; ii++) { - (void)strlcat(hp->hp_comm, " ", sizeof(hp->hp_comm)); - (void)strlcat(hp->hp_comm, args[ii], sizeof(hp->hp_comm)); + (void)snprlcat(hp->hp_comm, sizeof(hp->hp_comm), " %s", + args[ii]); } if (strlen(hp->hp_comm) >= sizeof(hp->hp_comm) - 1) { pjdlog_error("Exec path too long, correct configuration file."); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219817 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:38:24 2011 New Revision: 219817 URL: http://svn.freebsd.org/changeset/base/219817 Log: Log when we start hooks checking and when we execute a hook. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 08:37:50 2011(r219816) +++ head/sbin/hastd/hooks.c Mon Mar 21 08:38:24 2011(r219817) @@ -288,6 +288,8 @@ hook_check(void) assert(hooks_initialized); + pjdlog_debug(1, "Checking hooks."); + /* * Report about processes that are running for a long time. */ @@ -363,6 +365,8 @@ hook_execv(const char *path, va_list ap) if (hp == NULL) return; + pjdlog_debug(1, "Executing hook: %s", hp->hp_comm); + pid = fork(); switch (pid) { case -1:/* Error. */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219818 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 08:54:59 2011 New Revision: 219818 URL: http://svn.freebsd.org/changeset/base/219818 Log: In hast.conf we define the other node's address in 'remote' variable. This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. MFC after:1 week Modified: head/sbin/hastd/control.c head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h head/sbin/hastd/hastd.c head/sbin/hastd/parse.y head/sbin/hastd/primary.c head/sbin/hastd/proto.c head/sbin/hastd/proto.h head/sbin/hastd/proto_impl.h head/sbin/hastd/proto_socketpair.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/proto_uds.c head/sbin/hastd/secondary.c head/sbin/hastd/token.l Modified: head/sbin/hastd/control.c == --- head/sbin/hastd/control.c Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/control.c Mon Mar 21 08:54:59 2011(r219818) @@ -234,6 +234,8 @@ control_status(struct hastd_config *cfg, nv_add_string(nvout, res->hr_provname, "provname%u", no); nv_add_string(nvout, res->hr_localpath, "localpath%u", no); nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); + if (res->hr_sourceaddr[0] != '\0') + nv_add_string(nvout, res->hr_sourceaddr, "sourceaddr%u", no); switch (res->hr_replication) { case HAST_REPLICATION_FULLSYNC: nv_add_string(nvout, "fullsync", "replication%u", no); Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hast.conf.5 Mon Mar 21 08:54:59 2011(r219818) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 30, 2010 +.Dd March 20, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -93,6 +93,7 @@ resource { local # Required remote + source } on { # Resource-node section @@ -101,6 +102,7 @@ resource { local # Required remote + source } } .Ed @@ -337,6 +339,14 @@ A special value of .Va none can be used when the remote address is not yet known (eg. the other node is not set up yet). +.It Ic source Aq addr +.Pp +Local address to bind to before connecting to the remote +.Nm hastd +daemon. +Format is the same as for the +.Ic listen +statement. .El .Sh FILES .Bl -tag -width ".Pa /var/run/hastctl" -compact @@ -367,10 +377,12 @@ resource shared { resource tank { on hasta { local /dev/mirror/tanka + source tcp4://10.0.0.1 remote tcp4://10.0.0.2 } on hastb { local /dev/mirror/tankb + source tcp4://10.0.0.2 remote tcp4://10.0.0.1 } } Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hast.h Mon Mar 21 08:54:59 2011(r219818) @@ -169,6 +169,8 @@ struct hast_resource { /* Address of the remote component. */ charhr_remoteaddr[HAST_ADDRSIZE]; + /* Local address to bind to for outgoing connections. */ + charhr_sourceaddr[HAST_ADDRSIZE]; /* Connection for incoming data. */ struct proto_conn *hr_remotein; /* Connection for outgoing data. */ Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 08:38:24 2011(r219817) +++ head/sbin/hastd/hastd.c Mon Mar 21 08:54:59 2011(r219818) @@ -360,6 +360,8 @@ resource_needs_restart(const struct hast res0->hr_role == HAST_ROLE_SECONDARY) { if (strcmp(res0->hr_remoteaddr, res1->hr_remoteaddr) != 0) return (true); + if (strcmp(res0->hr_sourceaddr, res1->hr_sourceaddr) != 0) + return (true); if (res0->hr_replication != res1->hr_replication)
svn commit: r219821 - head/sbin/hastctl
Author: pjd Date: Mon Mar 21 11:52:00 2011 New Revision: 219821 URL: http://svn.freebsd.org/changeset/base/219821 Log: Forgot to commit this as a part of r219818. MFC after:1 week Modified: head/sbin/hastctl/hastctl.c Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Mon Mar 21 09:58:24 2011(r219820) +++ head/sbin/hastctl/hastctl.c Mon Mar 21 11:52:00 2011(r219821) @@ -330,6 +330,9 @@ control_status(struct nv *nv) (unsigned int)nv_get_uint32(nv, "keepdirty%u", ii)); printf(" remoteaddr: %s\n", nv_get_string(nv, "remoteaddr%u", ii)); + str = nv_get_string(nv, "sourceaddr%u", ii); + if (str != NULL) + printf(" sourceaddr: %s\n", str); printf(" replication: %s\n", nv_get_string(nv, "replication%u", ii)); str = nv_get_string(nv, "status%u", ii); @@ -466,7 +469,7 @@ main(int argc, char *argv[]) } /* Setup control connection... */ - if (proto_client(cfg->hc_controladdr, &controlconn) < 0) { + if (proto_client(NULL, cfg->hc_controladdr, &controlconn) < 0) { pjdlog_exit(EX_OSERR, "Unable to setup control connection to %s", cfg->hc_controladdr); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219830 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:50:12 2011 New Revision: 219830 URL: http://svn.freebsd.org/changeset/base/219830 Log: Detect situation where resource internal identifier differs. This means that both nodes have separately managed resources that don't have the same data. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 14:29:35 2011(r219829) +++ head/sbin/hastd/secondary.c Mon Mar 21 14:50:12 2011(r219830) @@ -259,6 +259,19 @@ init_remote(struct hast_resource *res, s memset(map, 0xff, mapsize); } nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); + } else if (res->hr_resuid != resuid) { + char errmsg[256]; + + (void)snprintf(errmsg, sizeof(errmsg), + "Resource unique ID mismatch (primary=%ju, secondary=%ju).", + (uintmax_t)resuid, (uintmax_t)res->hr_resuid); + pjdlog_error("%s", errmsg); + nv_add_string(nvout, errmsg, "errmsg"); + if (hast_proto_send(res, res->hr_remotein, nvout, NULL, 0) < 0) { + pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", + res->hr_remoteaddr); + } + exit(EX_CONFIG); } else if ( /* Is primary is out-of-date? */ (res->hr_secondary_localcnt > res->hr_primary_remotecnt && ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219831 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:51:16 2011 New Revision: 219831 URL: http://svn.freebsd.org/changeset/base/219831 Log: Be pedantic and free nvout before exiting. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 14:50:12 2011(r219830) +++ head/sbin/hastd/secondary.c Mon Mar 21 14:51:16 2011(r219831) @@ -271,6 +271,7 @@ init_remote(struct hast_resource *res, s pjdlog_exit(EX_TEMPFAIL, "Unable to send response to %s", res->hr_remoteaddr); } + nv_free(nvout); exit(EX_CONFIG); } else if ( /* Is primary is out-of-date? */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219832 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 14:53:27 2011 New Revision: 219832 URL: http://svn.freebsd.org/changeset/base/219832 Log: Increase debug level of "Checking hooks." message. MFC after:1 week Modified: head/sbin/hastd/hooks.c Modified: head/sbin/hastd/hooks.c == --- head/sbin/hastd/hooks.c Mon Mar 21 14:51:16 2011(r219831) +++ head/sbin/hastd/hooks.c Mon Mar 21 14:53:27 2011(r219832) @@ -288,7 +288,7 @@ hook_check(void) assert(hooks_initialized); - pjdlog_debug(1, "Checking hooks."); + pjdlog_debug(2, "Checking hooks."); /* * Report about processes that are running for a long time. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219833 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 15:08:10 2011 New Revision: 219833 URL: http://svn.freebsd.org/changeset/base/219833 Log: Remove stale comment. Yes, it is valid to set role back to init. MFC after:1 week Modified: head/sbin/hastd/control.c Modified: head/sbin/hastd/control.c == --- head/sbin/hastd/control.c Mon Mar 21 14:53:27 2011(r219832) +++ head/sbin/hastd/control.c Mon Mar 21 15:08:10 2011(r219833) @@ -327,7 +327,7 @@ control_handle(struct hastd_config *cfg) if (cmd == HASTCTL_SET_ROLE) { role = nv_get_uint8(nvin, "role"); switch (role) { - case HAST_ROLE_INIT:/* Is that valid to set, hmm? */ + case HAST_ROLE_INIT: case HAST_ROLE_PRIMARY: case HAST_ROLE_SECONDARY: break; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219837 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 15:29:20 2011 New Revision: 219837 URL: http://svn.freebsd.org/changeset/base/219837 Log: Before handling any events on descriptors check signals so we can update our info about worker processes if any of them was terminated in the meantime. This fixes the problem with 'hastctl status' running from a hook called on split-brain: 1. Secondary calls a hooks and terminates. 2. Hook asks for resource status via 'hastctl status'. 3. The main hastd handles the status request by sending it to the secondary worker who is already dead, but because signals weren't checked yet he doesn't know that and we get EPIPE. MFC after:1 week Modified: head/sbin/hastd/hastd.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Mon Mar 21 15:23:10 2011(r219836) +++ head/sbin/hastd/hastd.c Mon Mar 21 15:29:20 2011(r219837) @@ -884,19 +884,12 @@ out: } static void -main_loop(void) +check_signals(void) { - struct hast_resource *res; - struct timeval seltimeout; struct timespec sigtimeout; - int fd, maxfd, ret, signo; - time_t lastcheck, now; sigset_t mask; - fd_set rfds; + int signo; - lastcheck = time(NULL); - seltimeout.tv_sec = REPORT_INTERVAL; - seltimeout.tv_usec = 0; sigtimeout.tv_sec = 0; sigtimeout.tv_nsec = 0; @@ -906,29 +899,45 @@ main_loop(void) PJDLOG_VERIFY(sigaddset(&mask, SIGTERM) == 0); PJDLOG_VERIFY(sigaddset(&mask, SIGCHLD) == 0); + while ((signo = sigtimedwait(&mask, NULL, &sigtimeout)) != -1) { + switch (signo) { + case SIGINT: + case SIGTERM: + sigexit_received = true; + terminate_workers(); + proto_close(cfg->hc_controlconn); + exit(EX_OK); + break; + case SIGCHLD: + child_exit(); + break; + case SIGHUP: + hastd_reload(); + break; + default: + PJDLOG_ABORT("Unexpected signal (%d).", signo); + } + } +} + +static void +main_loop(void) +{ + struct hast_resource *res; + struct timeval seltimeout; + int fd, maxfd, ret; + time_t lastcheck, now; + fd_set rfds; + + lastcheck = time(NULL); + seltimeout.tv_sec = REPORT_INTERVAL; + seltimeout.tv_usec = 0; + pjdlog_info("Started successfully, running protocol version %d.", HAST_PROTO_VERSION); for (;;) { - while ((signo = sigtimedwait(&mask, NULL, &sigtimeout)) != -1) { - switch (signo) { - case SIGINT: - case SIGTERM: - sigexit_received = true; - terminate_workers(); - proto_close(cfg->hc_controlconn); - exit(EX_OK); - break; - case SIGCHLD: - child_exit(); - break; - case SIGHUP: - hastd_reload(); - break; - default: - PJDLOG_ABORT("Unexpected signal (%d).", signo); - } - } + check_signals(); /* Setup descriptors for select(2). */ FD_ZERO(&rfds); @@ -976,6 +985,12 @@ main_loop(void) pjdlog_exit(EX_OSERR, "select() failed"); } + /* +* Check for signals before we do anything to update our +* info about terminated workers in the meantime. +*/ + check_signals(); + if (FD_ISSET(proto_descriptor(cfg->hc_controlconn), &rfds)) control_handle(cfg); if (FD_ISSET(proto_descriptor(cfg->hc_listenconn), &rfds)) ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219843 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 21:14:07 2011 New Revision: 219843 URL: http://svn.freebsd.org/changeset/base/219843 Log: Fix typo. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 18:39:42 2011(r219842) +++ head/sbin/hastd/secondary.c Mon Mar 21 21:14:07 2011(r219843) @@ -277,7 +277,7 @@ init_remote(struct hast_resource *res, s /* Is primary is out-of-date? */ (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_secondary_remotecnt == res->hr_primary_localcnt) || - /* Node are more or less in sync? */ + /* Nodes are more or less in sync? */ (res->hr_secondary_localcnt == res->hr_primary_remotecnt && res->hr_secondary_remotecnt == res->hr_primary_localcnt) || /* Is secondary is out-of-date? */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219844 - head/sbin/hastd
Author: pjd Date: Mon Mar 21 21:16:12 2011 New Revision: 219844 URL: http://svn.freebsd.org/changeset/base/219844 Log: Initialize localcnt on first write. This fixes assertion when we create resource, set role to primary, do no writes, then sent it to secondary and accept connection from primary. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Mon Mar 21 21:14:07 2011(r219843) +++ head/sbin/hastd/primary.c Mon Mar 21 21:16:12 2011(r219844) @@ -478,7 +478,7 @@ init_local(struct hast_resource *res) * that there were no writes yet, so there is no need to synchronize * anything. */ - res->hr_primary_localcnt = 1; + res->hr_primary_localcnt = 0; res->hr_primary_remotecnt = 0; if (metadata_write(res) < 0) exit(EX_NOINPUT); @@ -1093,7 +1093,11 @@ ggate_recv_thread(void *arg) break; case BIO_WRITE: if (res->hr_resuid == 0) { - /* This is first write, initialize resuid. */ + /* +* This is first write, initialize localcnt and +* resuid. +*/ + res->hr_primary_localcnt = 1; (void)init_resuid(res); } for (;;) { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219847 - in head/sbin: hastctl hastd
Author: pjd Date: Mon Mar 21 21:31:50 2011 New Revision: 219847 URL: http://svn.freebsd.org/changeset/base/219847 Log: When dropping privileges prefer capsicum over chroot+setgid+setuid. We can use capsicum for secondary worker processes and hastctl. When working as primary we drop privileges using chroot+setgid+setuid still as we need to send ioctl(2)s to ggate device, for which capsicum doesn't allow (yet). X-MFC after: capsicum is merged to stable/8 Modified: head/sbin/hastctl/hastctl.c head/sbin/hastd/primary.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastctl/hastctl.c == --- head/sbin/hastctl/hastctl.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastctl/hastctl.c Mon Mar 21 21:31:50 2011(r219847) @@ -480,9 +480,8 @@ main(int argc, char *argv[]) cfg->hc_controladdr); } - if (drop_privs() != 0) + if (drop_privs(true) != 0) exit(EX_CONFIG); - pjdlog_debug(1, "Privileges successfully dropped."); /* Send the command to the server... */ if (hast_proto_send(NULL, controlconn, nv, NULL, 0) < 0) { Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/primary.c Mon Mar 21 21:31:50 2011(r219847) @@ -874,7 +874,7 @@ hastd_primary(struct hast_resource *res) init_ggate(res); init_environment(res); - if (drop_privs() != 0) { + if (drop_privs(true) != 0) { cleanup(res); exit(EX_CONFIG); } Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/secondary.c Mon Mar 21 21:31:50 2011(r219847) @@ -440,7 +440,7 @@ hastd_secondary(struct hast_resource *re init_local(res); init_environment(); - if (drop_privs() != 0) + if (drop_privs(true) != 0) exit(EX_CONFIG); pjdlog_info("Privileges successfully dropped."); Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/subr.c Mon Mar 21 21:31:50 2011(r219847) @@ -30,6 +30,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -39,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -144,13 +146,22 @@ role2str(int role) } int -drop_privs(void) +drop_privs(bool usecapsicum) { struct passwd *pw; uid_t ruid, euid, suid; gid_t rgid, egid, sgid; gid_t gidset[1]; + if (usecapsicum) { + if (cap_enter() == 0) { + pjdlog_debug(1, + "Privileges successfully dropped using capsicum."); + return (0); + } + pjdlog_errno(LOG_WARNING, "Unable to sandbox using capsicum"); + } + /* * According to getpwnam(3) we have to clear errno before calling the * function to be able to distinguish between an error and missing @@ -208,5 +219,8 @@ drop_privs(void) PJDLOG_VERIFY(getgroups(1, gidset) == 1); PJDLOG_VERIFY(gidset[0] == pw->pw_gid); + pjdlog_debug(1, + "Privileges successfully dropped using chroot+setgid+setuid."); + return (0); } Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Mon Mar 21 21:16:40 2011(r219846) +++ head/sbin/hastd/subr.h Mon Mar 21 21:31:50 2011(r219847) @@ -50,6 +50,6 @@ int snprlcat(char *str, size_t size, con int provinfo(struct hast_resource *res, bool dowrite); const char *role2str(int role); -int drop_privs(void); +int drop_privs(bool usecapsicum); #endif /* !_SUBR_H_ */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219864 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 10:39:34 2011 New Revision: 219864 URL: http://svn.freebsd.org/changeset/base/219864 Log: White space cleanups. MFC after:1 week Modified: head/sbin/hastd/activemap.c head/sbin/hastd/hastd.8 head/sbin/hastd/hastd.c head/sbin/hastd/primary.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/secondary.c head/sbin/hastd/subr.c Modified: head/sbin/hastd/activemap.c == --- head/sbin/hastd/activemap.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/activemap.c Tue Mar 22 10:39:34 2011(r219864) @@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$"); #defineACTIVEMAP_MAGIC 0xac71e4 struct activemap { int am_magic; /* Magic value. */ - off_tam_mediasize; /* Media size in bytes. */ + off_tam_mediasize; /* Media size in bytes. */ uint32_t am_extentsize; /* Extent size in bytes, must be power of 2. */ uint8_t am_extentshift;/* 2 ^ extentbits == extentsize */ Modified: head/sbin/hastd/hastd.8 == --- head/sbin/hastd/hastd.8 Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/hastd.8 Tue Mar 22 10:39:34 2011(r219864) @@ -95,7 +95,7 @@ following option: .Bd -ragged -offset indent .Cd "options GEOM_GATE" .Ed -.Pp +.Pp The connection between two .Nm daemons is always initiated from the one running as primary to the one Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/hastd.c Tue Mar 22 10:39:34 2011(r219864) @@ -132,19 +132,19 @@ dtype2str(mode_t mode) if (S_ISBLK(mode)) return ("block device"); - else if (S_ISCHR(mode)) + else if (S_ISCHR(mode)) return ("character device"); - else if (S_ISDIR(mode)) + else if (S_ISDIR(mode)) return ("directory"); else if (S_ISFIFO(mode)) return ("pipe or FIFO"); - else if (S_ISLNK(mode)) + else if (S_ISLNK(mode)) return ("symbolic link"); - else if (S_ISREG(mode)) + else if (S_ISREG(mode)) return ("regular file"); else if (S_ISSOCK(mode)) return ("socket"); - else if (S_ISWHT(mode)) + else if (S_ISWHT(mode)) return ("whiteout"); else return ("unknown"); @@ -929,7 +929,7 @@ main_loop(void) time_t lastcheck, now; fd_set rfds; - lastcheck = time(NULL); + lastcheck = time(NULL); seltimeout.tv_sec = REPORT_INTERVAL; seltimeout.tv_usec = 0; Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Tue Mar 22 10:29:36 2011(r219863) +++ head/sbin/hastd/primary.c Tue Mar 22 10:39:34 2011(r219864) @@ -183,7 +183,7 @@ static pthread_mutex_t metadata_lock; while (((hio) = TAILQ_FIRST(&hio_##name##_list[(ncomp)])) == NULL && !_last) { \ cv_timedwait(&hio_##name##_list_cond[(ncomp)], \ &hio_##name##_list_lock[(ncomp)], (timeout)); \ - if ((timeout) != 0) \ + if ((timeout) != 0) \ _last = true; \ } \ if (hio != NULL) { \ @@ -1268,7 +1268,7 @@ keepalive_send(struct hast_resource *res rw_unlock(&hio_remote_lock[ncomp]); return; } - + PJDLOG_ASSERT(res->hr_remotein != NULL); PJDLOG_ASSERT(res->hr_remoteout != NULL); @@ -1314,7 +1314,7 @@ remote_send_thread(void *arg) /* Remote component is 1 for now. */ ncomp = 1; - lastcheck = time(NULL); + lastcheck = time(NULL); for (;;) { pjdlog_debug(2, "remote_send: Taking request."); Modified: head/sbin/hastd/proto_tcp4.c == --- head/sbin/hastd/proto_tcp4.cTue Mar 22 10:29:36 2011 (r219863) +++ head/sbin/hastd/proto_tcp4.cTue Mar 22 10:39:34 2011 (r219864) @@ -337,7 +337,7 @@ tcp4_connect_wait(void *ctx, int timeout tv.tv_usec = 0; again: FD_ZERO(&fdset); - FD_SET(tctx->tc_fd, &fdset); + FD_SET(tctx->tc_fd, &fdset); ret = select(tctx->tc_fd + 1, NULL, &fdset, NULL, &tv); if (ret == 0) { error = ETI
svn commit: r219873 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 16:21:11 2011 New Revision: 219873 URL: http://svn.freebsd.org/changeset/base/219873 Log: The proto API is a general purpose API, so don't use 'hast' in structures or function names. It can now be used outside of HAST. MFC after:1 week Modified: head/sbin/hastd/Makefile head/sbin/hastd/hast.h head/sbin/hastd/proto.c head/sbin/hastd/proto_impl.h head/sbin/hastd/proto_socketpair.c head/sbin/hastd/proto_tcp4.c head/sbin/hastd/proto_uds.c Modified: head/sbin/hastd/Makefile == --- head/sbin/hastd/MakefileTue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/MakefileTue Mar 22 16:21:11 2011(r219873) @@ -20,6 +20,7 @@ SRCS+=y.tab.h MAN= hastd.8 hast.conf.5 NO_WFORMAT= +CFLAGS+=-DPROTO_TCP4_DEFAULT_PORT=8457 CFLAGS+=-I${.CURDIR} CFLAGS+=-DINET .if ${MK_INET6_SUPPORT} != "no" Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Tue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/hast.h Tue Mar 22 16:21:11 2011(r219873) @@ -86,7 +86,6 @@ #defineHAST_TIMEOUT5 #defineHAST_CONFIG "/etc/hast.conf" #defineHAST_CONTROL"/var/run/hastctl" -#defineHASTD_PORT 8457 #defineHASTD_LISTEN"tcp4://0.0.0.0:8457" #defineHASTD_PIDFILE "/var/run/hastd.pid" Modified: head/sbin/hastd/proto.c == --- head/sbin/hastd/proto.c Tue Mar 22 14:55:31 2011(r219872) +++ head/sbin/hastd/proto.c Tue Mar 22 16:21:11 2011(r219873) @@ -45,33 +45,33 @@ __FBSDID("$FreeBSD$"); #definePROTO_CONN_MAGIC0x907041c struct proto_conn { - int pc_magic; - struct hast_proto *pc_proto; - void*pc_ctx; - int pc_side; + int pc_magic; + struct proto*pc_proto; + void*pc_ctx; + int pc_side; #definePROTO_SIDE_CLIENT 0 #definePROTO_SIDE_SERVER_LISTEN1 #definePROTO_SIDE_SERVER_WORK 2 }; -static TAILQ_HEAD(, hast_proto) protos = TAILQ_HEAD_INITIALIZER(protos); +static TAILQ_HEAD(, proto) protos = TAILQ_HEAD_INITIALIZER(protos); void -proto_register(struct hast_proto *proto, bool isdefault) +proto_register(struct proto *proto, bool isdefault) { static bool seen_default = false; if (!isdefault) - TAILQ_INSERT_HEAD(&protos, proto, hp_next); + TAILQ_INSERT_HEAD(&protos, proto, prt_next); else { PJDLOG_ASSERT(!seen_default); seen_default = true; - TAILQ_INSERT_TAIL(&protos, proto, hp_next); + TAILQ_INSERT_TAIL(&protos, proto, prt_next); } } static struct proto_conn * -proto_alloc(struct hast_proto *proto, int side) +proto_alloc(struct proto *proto, int side) { struct proto_conn *conn; @@ -108,7 +108,7 @@ static int proto_common_setup(const char *srcaddr, const char *dstaddr, struct proto_conn **connp, int side) { - struct hast_proto *proto; + struct proto *proto; struct proto_conn *conn; void *ctx; int ret; @@ -116,17 +116,17 @@ proto_common_setup(const char *srcaddr, PJDLOG_ASSERT(side == PROTO_SIDE_CLIENT || side == PROTO_SIDE_SERVER_LISTEN); - TAILQ_FOREACH(proto, &protos, hp_next) { + TAILQ_FOREACH(proto, &protos, prt_next) { if (side == PROTO_SIDE_CLIENT) { - if (proto->hp_client == NULL) + if (proto->prt_client == NULL) ret = -1; else - ret = proto->hp_client(srcaddr, dstaddr, &ctx); + ret = proto->prt_client(srcaddr, dstaddr, &ctx); } else /* if (side == PROTO_SIDE_SERVER_LISTEN) */ { - if (proto->hp_server == NULL) + if (proto->prt_server == NULL) ret = -1; else - ret = proto->hp_server(dstaddr, &ctx); + ret = proto->prt_server(dstaddr, &ctx); } /* * ret == 0 - success @@ -148,8 +148,8 @@ proto_common_setup(const char *srcaddr, } conn = proto_alloc(proto, side); if (conn == NULL) { - if (proto->hp_close != NULL) - proto->hp_close(ctx); + if (proto->prt_close != NULL) + proto->prt_close(ctx); errno = ENOMEM; return (-1); } @@ -176,10 +17
svn commit: r219884 - head/sbin/hastctl
Author: pjd Date: Tue Mar 22 21:11:36 2011 New Revision: 219884 URL: http://svn.freebsd.org/changeset/base/219884 Log: Forgot to commit this as part of r219873. MFC after:1 week Modified: head/sbin/hastctl/Makefile Modified: head/sbin/hastctl/Makefile == --- head/sbin/hastctl/Makefile Tue Mar 22 21:05:56 2011(r219883) +++ head/sbin/hastctl/Makefile Tue Mar 22 21:11:36 2011(r219884) @@ -13,7 +13,7 @@ SRCS+=lzf.c SRCS+= metadata.c SRCS+= nv.c SRCS+= parse.y pjdlog.c -SRCS+= proto.c proto_common.c proto_tcp4.c proto_uds.c +SRCS+= proto.c proto_common.c proto_uds.c SRCS+= token.l SRCS+= subr.c SRCS+= y.tab.h ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219887 - head/sbin/hastd
Author: pjd Date: Tue Mar 22 21:19:51 2011 New Revision: 219887 URL: http://svn.freebsd.org/changeset/base/219887 Log: Add my copyright. MFC after:1 week Modified: head/sbin/hastd/subr.c head/sbin/hastd/subr.h Modified: head/sbin/hastd/subr.c == --- head/sbin/hastd/subr.c Tue Mar 22 21:16:14 2011(r219886) +++ head/sbin/hastd/subr.c Tue Mar 22 21:19:51 2011(r219887) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from Modified: head/sbin/hastd/subr.h == --- head/sbin/hastd/subr.h Tue Mar 22 21:16:14 2011(r219886) +++ head/sbin/hastd/subr.h Tue Mar 22 21:19:51 2011(r219887) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219900 - head/sbin/hastd
Author: pjd Date: Wed Mar 23 11:09:04 2011 New Revision: 219900 URL: http://svn.freebsd.org/changeset/base/219900 Log: Don't create socketpair for connection forwarding between parent and secondary. Secondary doesn't need to connect anywhere. MFC after:1 week Modified: head/sbin/hastd/hastd.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/hastd.c == --- head/sbin/hastd/hastd.c Wed Mar 23 08:33:12 2011(r219899) +++ head/sbin/hastd/hastd.c Wed Mar 23 11:09:04 2011(r219900) @@ -224,7 +224,8 @@ descriptors_assert(const struct hast_res fd, dtype2str(mode), dtype2str(S_IFSOCK)); break; } - } else if (fd == proto_descriptor(res->hr_conn)) { + } else if (res->hr_role == HAST_ROLE_PRIMARY && + fd == proto_descriptor(res->hr_conn)) { if (!isopen) { (void)snprintf(msg, sizeof(msg), "Descriptor %d (conn) is closed, but should be open.", @@ -238,6 +239,15 @@ descriptors_assert(const struct hast_res break; } } else if (res->hr_role == HAST_ROLE_SECONDARY && + res->hr_conn != NULL && + fd == proto_descriptor(res->hr_conn)) { + if (isopen) { + (void)snprintf(msg, sizeof(msg), + "Descriptor %d (conn) is open, but should be closed.", + fd); + break; + } + } else if (res->hr_role == HAST_ROLE_SECONDARY && fd == proto_descriptor(res->hr_remotein)) { if (!isopen) { (void)snprintf(msg, sizeof(msg), @@ -851,6 +861,8 @@ connection_migrate(struct hast_resource pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); + if (proto_recv(res->hr_conn, &val, sizeof(val)) < 0) { pjdlog_errno(LOG_WARNING, "Unable to receive connection command"); @@ -951,17 +963,19 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; - PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_event); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; if (res->hr_role == HAST_ROLE_PRIMARY) { /* Only primary workers asks for connections. */ + PJDLOG_ASSERT(res->hr_conn != NULL); fd = proto_descriptor(res->hr_conn); PJDLOG_ASSERT(fd >= 0); FD_SET(fd, &rfds); maxfd = fd > maxfd ? fd : maxfd; + } else { + PJDLOG_ASSERT(res->hr_conn == NULL); } } @@ -998,20 +1012,26 @@ main_loop(void) TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (res->hr_event == NULL) continue; - PJDLOG_ASSERT(res->hr_conn != NULL); if (FD_ISSET(proto_descriptor(res->hr_event), &rfds)) { if (event_recv(res) == 0) continue; /* The worker process exited? */ proto_close(res->hr_event); res->hr_event = NULL; - proto_close(res->hr_conn); - res->hr_conn = NULL; + if (res->hr_conn != NULL) { + proto_close(res->hr_conn); + res->hr_conn = NULL; + } continue; } - if (res->hr_role == HAST_ROLE_PRIMARY && - FD_ISSET(proto_descriptor(res->hr_conn), &rfds)) { - connection_migrate(res); + if (res->hr_role == HAST_ROLE_PRIMARY) { + PJDLOG_ASSERT(res->hr_conn != NULL); + if (FD_ISSET(proto_descriptor(res->hr_conn), + &rfds)) { + con
svn commit: r219959 - head/cddl/contrib/opensolaris/lib/libzfs/common
Author: pjd Date: Thu Mar 24 14:12:41 2011 New Revision: 219959 URL: http://svn.freebsd.org/changeset/base/219959 Log: Properly print characters larger than 127. Submitted by: noordsij Reviewed by: Eric Schrock MFC after:1 month Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c == --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Thu Mar 24 13:52:59 2011(r219958) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c Thu Mar 24 14:12:41 2011(r219959) @@ -138,8 +138,10 @@ stream_bytes(FILE *fp, const char *strin while (*string) { if (*string > ' ' && *string != '\\' && *string < '\177') (void) fprintf(fp, "%c", *string++); - else - (void) fprintf(fp, "\\%03o", *string++); + else { + (void) fprintf(fp, "\\%03hho", + (unsigned char)*string++); + } } } ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r219973 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: pjd Date: Thu Mar 24 20:28:09 2011 New Revision: 219973 URL: http://svn.freebsd.org/changeset/base/219973 Log: Checking file access on size change is bogus. The checks are done earlier by VFS where we know if this is truncate(2) or ftruncate(2). If this is the latter we should depend on the mode the file was opened and not on the current permission. PR: standards/154873 Reported by: Mark Martinec Discussed with: Eric Schrock Discussed with: Mark Maybee MFC after:1 month Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 24 20:15:42 2011(r219972) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Thu Mar 24 20:28:09 2011(r219973) @@ -2962,11 +2962,6 @@ top: */ if (mask & AT_SIZE) { - err = zfs_zaccess(zp, ACE_WRITE_DATA, 0, skipaclchk, cr); - if (err) { - ZFS_EXIT(zfsvfs); - return (err); - } /* * XXX - Note, we are not providing any open * mode flags here (like FNDELAY), so we may ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220005 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:13:38 2011 New Revision: 220005 URL: http://svn.freebsd.org/changeset/base/220005 Log: Use role2str() when setting process title. MFC after:1 week Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Fri Mar 25 18:23:10 2011(r220004) +++ head/sbin/hastd/primary.c Fri Mar 25 20:13:38 2011(r220005) @@ -868,7 +868,7 @@ hastd_primary(struct hast_resource *res) pjdlog_init(mode); pjdlog_debug_set(debuglevel); pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); - setproctitle("%s (primary)", res->hr_name); + setproctitle("%s (%s)", res->hr_name, role2str(res->hr_role)); init_local(res); init_ggate(res); Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Fri Mar 25 18:23:10 2011(r220004) +++ head/sbin/hastd/secondary.c Fri Mar 25 20:13:38 2011(r220005) @@ -414,7 +414,7 @@ hastd_secondary(struct hast_resource *re pjdlog_init(mode); pjdlog_debug_set(debuglevel); pjdlog_prefix_set("[%s] (%s) ", res->hr_name, role2str(res->hr_role)); - setproctitle("%s (secondary)", res->hr_name); + setproctitle("%s (%s)", res->hr_name, role2str(res->hr_role)); PJDLOG_VERIFY(sigemptyset(&mask) == 0); PJDLOG_VERIFY(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220006 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:15:16 2011 New Revision: 220006 URL: http://svn.freebsd.org/changeset/base/220006 Log: Use timeout from configuration file not only when sending and receiving, but also when establishing connection. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Fri Mar 25 20:13:38 2011(r220005) +++ head/sbin/hastd/primary.c Fri Mar 25 20:15:16 2011(r220006) @@ -509,7 +509,7 @@ primary_connect(struct hast_resource *re primary_exit(EX_TEMPFAIL, "Unable to receive connection from parent"); } - if (proto_connect_wait(conn, HAST_TIMEOUT) < 0) { + if (proto_connect_wait(conn, res->hr_timeout) < 0) { pjdlog_errno(LOG_WARNING, "Unable to connect to %s", res->hr_remoteaddr); proto_close(conn); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220007 - head/sbin/hastd
Author: pjd Date: Fri Mar 25 20:19:15 2011 New Revision: 220007 URL: http://svn.freebsd.org/changeset/base/220007 Log: Add mapsize to the header just before sending the packet. Before it could change later and we were sending invalid mapsize. Some time ago I added optimization where when nodes are connected for the first time and there were no writes to them yet, there is no initial full synchronization. This bug prevented it from working. MFC after:1 week Modified: head/sbin/hastd/secondary.c Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Fri Mar 25 20:15:16 2011(r220006) +++ head/sbin/hastd/secondary.c Fri Mar 25 20:19:15 2011(r220007) @@ -201,7 +201,6 @@ init_remote(struct hast_resource *res, s "Unable to allocate memory (%zu bytes) for activemap.", mapsize); } - nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); /* * When we work as primary and secondary is missing we will increase * localcnt in our metadata. When secondary is connected and synced @@ -339,6 +338,7 @@ init_remote(struct hast_resource *res, s (uintmax_t)res->hr_secondary_localcnt, (uintmax_t)res->hr_secondary_remotecnt); } + nv_add_uint32(nvout, (uint32_t)mapsize, "mapsize"); if (hast_proto_send(res, res->hr_remotein, nvout, map, mapsize) < 0) { pjdlog_exit(EX_TEMPFAIL, "Unable to send activemap to %s", res->hr_remoteaddr); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220023 - head/lib/libc/gen
Author: pjd Date: Sat Mar 26 07:15:57 2011 New Revision: 220023 URL: http://svn.freebsd.org/changeset/base/220023 Log: Follow style(9) in example code and handle opendir(3) error. Modified: head/lib/libc/gen/directory.3 Modified: head/lib/libc/gen/directory.3 == --- head/lib/libc/gen/directory.3 Sat Mar 26 07:15:35 2011 (r220022) +++ head/lib/libc/gen/directory.3 Sat Mar 26 07:15:57 2011 (r220023) @@ -209,13 +209,16 @@ Sample code which searches a directory f .Bd -literal -offset indent len = strlen(name); dirp = opendir("."); -while ((dp = readdir(dirp)) != NULL) - if (dp->d_namlen == len && !strcmp(dp->d_name, name)) { +if (dirp == NULL) + return (ERROR); +while ((dp = readdir(dirp)) != NULL) { + if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) { (void)closedir(dirp); - return FOUND; + return (FOUND); } +} (void)closedir(dirp); -return NOT_FOUND; +return (NOT_FOUND); .Ed .Sh SEE ALSO .Xr close 2 , ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220024 - head/lib/libc/gen
Author: pjd Date: Sat Mar 26 07:17:24 2011 New Revision: 220024 URL: http://svn.freebsd.org/changeset/base/220024 Log: Don't calculate len too early. Modified: head/lib/libc/gen/directory.3 Modified: head/lib/libc/gen/directory.3 == --- head/lib/libc/gen/directory.3 Sat Mar 26 07:15:57 2011 (r220023) +++ head/lib/libc/gen/directory.3 Sat Mar 26 07:17:24 2011 (r220024) @@ -207,10 +207,10 @@ see .Pp Sample code which searches a directory for entry ``name'' is: .Bd -literal -offset indent -len = strlen(name); dirp = opendir("."); if (dirp == NULL) return (ERROR); +len = strlen(name); while ((dp = readdir(dirp)) != NULL) { if (dp->d_namlen == len && strcmp(dp->d_name, name) == 0) { (void)closedir(dirp); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220264 - head/sys/geom/gate
Author: pjd Date: Sat Apr 2 06:56:06 2011 New Revision: 220264 URL: http://svn.freebsd.org/changeset/base/220264 Log: GEOM has an internal mechanism to deal with ENOMEM errors returned via g_io_deliver(). In such case it increases 'pace' counter on each ENOMEM and reschedules the request. The 'pace' counter is decreased for each request going down, but until 'pace' is greater than zero, GEOM will handle at most 10 requests per second. For GEOM GATE users that are proxy to local GEOM providers (like ggatel(8) and HAST) we can end up with almost permanent slow down of GEOM down queue. This is because once we reach GEOM GATE queue limit, we return ENOMEM to the GEOM. This means that we have, eg. 1024 I/O requests in the GEOM GATE queue. To make room in the queue and stop returning ENOMEM we need to proceed the requests of course, but those requests are handled by userland daemons that handle them by reading/writing also from/to local GEOM providers. For example with HAST, a new requests comes to /dev/hast/data, which is GEOM GATE provider. GEOM GATE passes the request to hastd(8) and hastd(8) reads/writes from/to /dev/da0. Once we reach GEOM GATE queue limit, to free up a slot in GEOM GATE queue, hastd(8) has to read/write from/to /dev/da0, but this request will also be very slow, because GEOM now slows down all the requests. We end up with full queue that we can unload at the speed of 10 requests per second. This simply looks like a deadlock. Fix it by allowing userland daemons that work with both GEOM GATE and local GEOM providers to specify unlimited queue size, so GEOM GATE will never return ENOMEM to the GEOM. MFC after:1 week Modified: head/sys/geom/gate/g_gate.c Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.c Sat Apr 2 06:25:13 2011(r220263) +++ head/sys/geom/gate/g_gate.c Sat Apr 2 06:56:06 2011(r220264) @@ -194,7 +194,7 @@ g_gate_start(struct bio *bp) } mtx_lock(&sc->sc_queue_mtx); - if (sc->sc_queue_count > sc->sc_queue_size) { + if (sc->sc_queue_size > 0 && sc->sc_queue_count > sc->sc_queue_size) { mtx_unlock(&sc->sc_queue_mtx); G_GATE_LOGREQ(1, bp, "Queue full, request canceled."); g_io_deliver(bp, ENOMEM); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220265 - head/sbin/ggate/ggatel
Author: pjd Date: Sat Apr 2 06:59:05 2011 New Revision: 220265 URL: http://svn.freebsd.org/changeset/base/220265 Log: Because ggatel(8) operates on local GEOM providers, use unlimited queue size in GEOM GATE to fix the issue described in r220264. This also means that we no longer need -q option, remove it. Don't bother to leaving it as a no-op, as ggatel(8) is just an example utility. Modified: head/sbin/ggate/ggatel/ggatel.8 head/sbin/ggate/ggatel/ggatel.c Modified: head/sbin/ggate/ggatel/ggatel.8 == --- head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.8 Sat Apr 2 06:59:05 2011 (r220265) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 26, 2004 +.Dd April 2, 2011 .Dt GGATEL 8 .Os .Sh NAME @@ -35,7 +35,6 @@ .Cm create .Op Fl v .Op Fl o Cm ro | wo | rw -.Op Fl q Ar queue_size .Op Fl s Ar sectorsize .Op Fl t Ar timeout .Op Fl u Ar unit @@ -100,10 +99,6 @@ or read-write .Pq Cm rw . Default is .Cm rw . -.It Fl q Ar queue_size -Number of pending I/O requests that can be queued before they will -start to be canceled. -Default is 1024. .It Fl s Ar sectorsize Sector size for .Nm ggate Modified: head/sbin/ggate/ggatel/ggatel.c == --- head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:56:06 2011 (r220264) +++ head/sbin/ggate/ggatel/ggatel.c Sat Apr 2 06:59:05 2011 (r220265) @@ -53,7 +53,6 @@ static const char *path = NULL; static int unit = G_GATE_UNIT_AUTO; static unsigned flags = 0; static int force = 0; -static unsigned queue_size = G_GATE_QUEUE_SIZE; static unsigned sectorsize = 0; static unsigned timeout = G_GATE_TIMEOUT; @@ -61,7 +60,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s create [-v] [-o ] [-q queue_size] " + fprintf(stderr, "usage: %s create [-v] [-o ] " "[-s sectorsize] [-t timeout] [-u unit] \n", getprogname()); fprintf(stderr, " %s rescue [-v] [-o ] <-u unit> " "\n", getprogname()); @@ -182,7 +181,7 @@ g_gatel_create(void) ggioc.gctl_sectorsize = sectorsize; ggioc.gctl_timeout = timeout; ggioc.gctl_flags = flags; - ggioc.gctl_maxcount = queue_size; + ggioc.gctl_maxcount = 0; strlcpy(ggioc.gctl_info, path, sizeof(ggioc.gctl_info)); g_gate_ioctl(G_GATE_CMD_CREATE, &ggioc); if (unit == -1) @@ -230,7 +229,7 @@ main(int argc, char *argv[]) for (;;) { int ch; - ch = getopt(argc, argv, "fo:q:s:t:u:v"); + ch = getopt(argc, argv, "fo:s:t:u:v"); if (ch == -1) break; switch (ch) { @@ -253,14 +252,6 @@ main(int argc, char *argv[]) "Invalid argument for '-o' option."); } break; - case 'q': - if (action != CREATE) - usage(); - errno = 0; - queue_size = strtoul(optarg, NULL, 10); - if (queue_size == 0 && errno != 0) - errx(EXIT_FAILURE, "Invalid queue_size."); - break; case 's': if (action != CREATE) usage(); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220266 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 07:01:09 2011 New Revision: 220266 URL: http://svn.freebsd.org/changeset/base/220266 Log: Handle the problem described in r220264 by using GEOM GATE queue of unlimited length. This should fix deadlocks reported by HAST users. MFC after:1 week Modified: head/sbin/hastd/primary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Sat Apr 2 06:59:05 2011(r220265) +++ head/sbin/hastd/primary.c Sat Apr 2 07:01:09 2011(r220266) @@ -761,7 +761,7 @@ init_ggate(struct hast_resource *res) ggiocreate.gctl_mediasize = res->hr_datasize; ggiocreate.gctl_sectorsize = res->hr_local_sectorsize; ggiocreate.gctl_flags = 0; - ggiocreate.gctl_maxcount = G_GATE_MAX_QUEUE_SIZE; + ggiocreate.gctl_maxcount = 0; ggiocreate.gctl_timeout = 0; ggiocreate.gctl_unit = G_GATE_NAME_GIVEN; snprintf(ggiocreate.gctl_name, sizeof(ggiocreate.gctl_name), "hast/%s", ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220270 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:22:06 2011 New Revision: 220270 URL: http://svn.freebsd.org/changeset/base/220270 Log: Allow to disable sends or receives on a socket using shutdown(2) by interpreting NULL 'data' argument passed to proto_common_send() or proto_common_recv() as a will to do so. MFC after:1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 08:45:13 2011 (r220269) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:22:06 2011 (r220270) @@ -82,6 +82,17 @@ proto_common_send(int sock, const unsign size_t sendsize; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_RD) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); @@ -141,6 +152,17 @@ proto_common_recv(int sock, unsigned cha ssize_t done; PJDLOG_ASSERT(sock >= 0); + + if (data == NULL) { + /* The caller is just trying to decide about direction. */ + + PJDLOG_ASSERT(size == 0); + + if (shutdown(sock, SHUT_WR) == -1) + return (errno); + return (0); + } + PJDLOG_ASSERT(data != NULL); PJDLOG_ASSERT(size > 0); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220271 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:25:13 2011 New Revision: 220271 URL: http://svn.freebsd.org/changeset/base/220271 Log: Declare directions for sockets between primary and secondary. In HAST we use two sockets - one for only sending the data and one for only receiving the data. MFC after:1 month Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Sat Apr 2 09:22:06 2011(r220270) +++ head/sbin/hastd/primary.c Sat Apr 2 09:25:13 2011(r220271) @@ -701,6 +701,11 @@ init_remote(struct hast_resource *res, s (void)hast_activemap_flush(res); } nv_free(nvin); + /* Setup directions. */ + if (proto_send(out, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + if (proto_recv(in, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); pjdlog_info("Connected to %s.", res->hr_remoteaddr); if (inp != NULL && outp != NULL) { *inp = in; Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Sat Apr 2 09:22:06 2011(r220270) +++ head/sbin/hastd/secondary.c Sat Apr 2 09:25:13 2011(r220271) @@ -183,6 +183,10 @@ init_remote(struct hast_resource *res, s unsigned char *map; size_t mapsize; + /* Setup direction. */ + if (proto_send(res->hr_remoteout, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); + map = NULL; mapsize = 0; nvout = nv_alloc(); @@ -346,6 +350,9 @@ init_remote(struct hast_resource *res, s if (map != NULL) free(map); nv_free(nvout); + /* Setup direction. */ + if (proto_recv(res->hr_remotein, NULL, 0) == -1) + pjdlog_errno(LOG_WARNING, "Unable to set connection direction"); if (res->hr_secondary_localcnt > res->hr_primary_remotecnt && res->hr_primary_localcnt > res->hr_secondary_remotecnt) { /* Exit on split-brain. */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220272 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:29:53 2011 New Revision: 220272 URL: http://svn.freebsd.org/changeset/base/220272 Log: When we are operating on blocking socket and get EAGAIN on send(2) or recv(2) this means that request timed out. Translate the meaningless EAGAIN to ETIMEDOUT to give administrator a hint that he might need to increase timeout in configuration file. MFC after:1 month Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 09:25:13 2011 (r220271) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2009-2010 The FreeBSD Foundation + * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * This software was developed by Pawel Jakub Dawidek under sponsorship from @@ -34,8 +35,11 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include +#include #include "pjdlog.h" #include "proto_impl.h" @@ -45,6 +49,16 @@ __FBSDID("$FreeBSD$"); #defineMAX_SEND_SIZE 32768 #endif +static bool +blocking_socket(int sock) +{ + int flags; + + flags = fcntl(sock, F_GETFL); + PJDLOG_ASSERT(flags >= 0); + return ((flags & O_NONBLOCK) == 0); +} + static int proto_descriptor_send(int sock, int fd) { @@ -99,11 +113,19 @@ proto_common_send(int sock, const unsign do { sendsize = size < MAX_SEND_SIZE ? size : MAX_SEND_SIZE; done = send(sock, data, sendsize, MSG_NOSIGNAL); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) { + } else if (done < 0) { if (errno == EINTR) continue; + /* +* If this is blocking socket and we got EAGAIN, this +* means the request timed out. Translate errno to +* ETIMEDOUT, to give administrator a hint to +* eventually increase timeout. +*/ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); } data += done; @@ -169,10 +191,19 @@ proto_common_recv(int sock, unsigned cha do { done = recv(sock, data, size, MSG_WAITALL); } while (done == -1 && errno == EINTR); - if (done == 0) + if (done == 0) { return (ENOTCONN); - else if (done < 0) + } else if (done < 0) { + /* +* If this is blocking socket and we got EAGAIN, this +* means the request timed out. Translate errno to +* ETIMEDOUT, to give administrator a hint to +* eventually increase timeout. +*/ + if (errno == EAGAIN && blocking_socket(sock)) + errno = ETIMEDOUT; return (errno); + } if (fdp == NULL) return (0); return (proto_descriptor_recv(sock, fdp)); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220273 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:31:02 2011 New Revision: 220273 URL: http://svn.freebsd.org/changeset/base/220273 Log: Handle ENOBUFS on send(2) by retrying for a while and logging the problem. MFC after:1 week Modified: head/sbin/hastd/proto_common.c Modified: head/sbin/hastd/proto_common.c == --- head/sbin/hastd/proto_common.c Sat Apr 2 09:29:53 2011 (r220272) +++ head/sbin/hastd/proto_common.c Sat Apr 2 09:31:02 2011 (r220273) @@ -94,6 +94,7 @@ proto_common_send(int sock, const unsign { ssize_t done; size_t sendsize; + int errcount = 0; PJDLOG_ASSERT(sock >= 0); @@ -118,6 +119,23 @@ proto_common_send(int sock, const unsign } else if (done < 0) { if (errno == EINTR) continue; + if (errno == ENOBUFS) { + /* +* If there are no buffers we retry. +* After each try we increase delay before the +* next one and we give up after fifteen times. +* This gives 11s of total wait time. +*/ + if (errcount == 15) { + pjdlog_warning("Getting ENOBUFS errors for 11s on send(), giving up."); + } else { + if (errcount == 0) + pjdlog_warning("Got ENOBUFS error on send(), retrying for a bit."); + errcount++; + usleep(10 * errcount); + continue; + } + } /* * If this is blocking socket and we got EAGAIN, this * means the request timed out. Translate errno to @@ -131,6 +149,10 @@ proto_common_send(int sock, const unsign data += done; size -= done; } while (size > 0); + if (errcount > 0) { + pjdlog_info("Data sent successfully after %d ENOBUFS error%s.", + errcount, errcount == 1 ? "" : "s"); + } if (fd == -1) return (0); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r220270 - head/sbin/hastd
On Sat, Apr 02, 2011 at 09:22:06AM +, Pawel Jakub Dawidek wrote: > Author: pjd > Date: Sat Apr 2 09:22:06 2011 > New Revision: 220270 > URL: http://svn.freebsd.org/changeset/base/220270 > > Log: > Allow to disable sends or receives on a socket using shutdown(2) by > interpreting NULL 'data' argument passed to proto_common_send() or > proto_common_recv() as a will to do so. > > MFC after: 1 month This should've been 1 week here in the next two commits. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpvKK9czWaAL.pgp Description: PGP signature
svn commit: r220274 - head/sbin/hastd
Author: pjd Date: Sat Apr 2 09:34:33 2011 New Revision: 220274 URL: http://svn.freebsd.org/changeset/base/220274 Log: Increase default timeout from 5 seconds to 20 seconds. 5 seconds is definitely to short under heavy load and I was experiencing those timeouts in my recent tests. MFC after:1 week Modified: head/sbin/hastd/hast.conf.5 head/sbin/hastd/hast.h Modified: head/sbin/hastd/hast.conf.5 == --- head/sbin/hastd/hast.conf.5 Sat Apr 2 09:31:02 2011(r220273) +++ head/sbin/hastd/hast.conf.5 Sat Apr 2 09:34:33 2011(r220274) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 20, 2011 +.Dd April 2, 2011 .Dt HAST.CONF 5 .Os .Sh NAME @@ -241,7 +241,7 @@ LZF is very fast, general purpose compre .Pp Connection timeout in seconds. The default value is -.Va 5 . +.Va 20 . .It Ic exec Aq path .Pp Execute the given program on various HAST events. Modified: head/sbin/hastd/hast.h == --- head/sbin/hastd/hast.h Sat Apr 2 09:31:02 2011(r220273) +++ head/sbin/hastd/hast.h Sat Apr 2 09:34:33 2011(r220274) @@ -83,7 +83,7 @@ #defineHIO_KEEPALIVE 5 #defineHAST_USER "hast" -#defineHAST_TIMEOUT5 +#defineHAST_TIMEOUT20 #defineHAST_CONFIG "/etc/hast.conf" #defineHAST_CONTROL"/var/run/hastctl" #defineHASTD_LISTEN"tcp4://0.0.0.0:8457" ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220573 - head/sbin/hastd
Author: pjd Date: Tue Apr 12 19:13:10 2011 New Revision: 220573 URL: http://svn.freebsd.org/changeset/base/220573 Log: The replication mode that is currently support is fullsync, not memsync. Correct this and print a warning if different replication mode is configured. MFC after:1 week Modified: head/sbin/hastd/parse.y Modified: head/sbin/hastd/parse.y == --- head/sbin/hastd/parse.y Tue Apr 12 17:02:40 2011(r220572) +++ head/sbin/hastd/parse.y Tue Apr 12 19:13:10 2011(r220573) @@ -169,7 +169,7 @@ yy_config_parse(const char *config, bool lineno = 0; depth0_timeout = HAST_TIMEOUT; - depth0_replication = HAST_REPLICATION_MEMSYNC; + depth0_replication = HAST_REPLICATION_FULLSYNC; depth0_checksum = HAST_CHECKSUM_NONE; depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); @@ -228,6 +228,13 @@ yy_config_parse(const char *config, bool */ curres->hr_replication = depth0_replication; } + if (curres->hr_replication == HAST_REPLICATION_MEMSYNC || + curres->hr_replication == HAST_REPLICATION_ASYNC) { + pjdlog_warning("Replication mode \"%s\" is not implemented, falling back to \"%s\".", + curres->hr_replication == HAST_REPLICATION_MEMSYNC ? + "memsync" : "async", "fullsync"); + curres->hr_replication = HAST_REPLICATION_FULLSYNC; + } if (curres->hr_checksum == -1) { /* * Checksum is not set at resource-level. ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r220575 - head/cddl/contrib/opensolaris/lib/libzfs/common
Author: pjd Date: Tue Apr 12 20:31:33 2011 New Revision: 220575 URL: http://svn.freebsd.org/changeset/base/220575 Log: Fix 'zfs list ' handling. If the path was found, the 'ret' variable was uninitialized. PR: kern/155940 Submitted by: KOIE Hidetaka MFC after:1 week Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c == --- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Apr 12 20:10:15 2011(r220574) +++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c Tue Apr 12 20:31:33 2011(r220575) @@ -734,12 +734,13 @@ zfs_path_to_zhandle(libzfs_handle_t *hdl { struct statfs sfs; - if (statfs(path, &sfs) != 0) { + ret = statfs(path, &sfs); + if (ret == 0) + statfs2mnttab(&sfs, &entry); + else { (void) fprintf(stderr, "%s: %s\n", path, strerror(errno)); - ret = -1; } - statfs2mnttab(&sfs, &entry); } #endif /* sun */ if (ret != 0) { ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r220559 - in head/sys: conf geom
e_int_value("map", i, "offset", &off); > + ret = resource_int_value("map", i, "readonly", &readonly); > + ret = resource_string_value("map", i, "name", &name); > + /* No name or error read name */ > + if (ret) > + continue; First and second 'ret' is not checked. > + if (off > size) > + printf("%s: off(%d) > size(%d) for \"%s\"\n", > + __func__, off, size, name); Is this a leftover debug printf? > + error = g_slice_config(gp, i, G_SLICE_CONFIG_SET, start + off, > + size - off, sectorsize, "map/%s", name); Four spaces. > + printf("MAP: %08x-%08x, offset=%08x \"map/%s\"\n", > +(uint32_t) start, > +(uint32_t) size, > +(uint32_t) off, > +name > +); Four spaces. Not need to separate cast and variable with space. > + if (error) > + printf("%s g_slice_config returns %d for \"%s\"\n", > + __func__, error, name); Leftover debug printf? > + sc->entry[i] = off; > + sc->dsize[i] = size - off; > + sc->readonly[i] = readonly ? 1 : 0; > + } > + > + > + if (i == 0) > + return (NULL); Redundant empty line before 'if'. > +static void > +g_map_config(struct gctl_req *req, struct g_class *mp, const char *verb) > +{ > + struct g_geom *gp; > + > + g_topology_assert(); > + gp = gctl_get_geom(req, mp, "geom"); > + if (gp == NULL) > + return; > + gctl_error(req, "Unknown verb"); > +} Seems to be a no-op. GEOM can cope if this method is not specified. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp19Ub8WGjYs.pgp Description: PGP signature
Re: svn commit: r220755 - in head: . contrib/gcc/doc contrib/gcc/objc contrib/libobjc etc/mtree gnu/lib gnu/lib/libobjc gnu/usr.bin/cc gnu/usr.bin/cc/cc1obj gnu/usr.bin/cc/cc_tools gnu/usr.bin/cc/doc
On Mon, Apr 18, 2011 at 11:06:42AM -0600, Warner Losh wrote: > > On Apr 18, 2011, at 1:01 AM, Roman Divacky wrote: > > > please mark this in src/UPDATING, maybe bump freebsd_version too? > > Please do not bump freebsd_version just for this. Ports wishing to know can > go off the last bump, if there are any. > > Every freebsd_version bump forces rebuilding all modules and such and is a > pita. I agree that this is a PITA, but there also should be a way to force module load even on version bump. This is PITA especially for developers. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpjKKiEu9H70.pgp Description: PGP signature
Re: svn commit: r220791 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys
On Mon, Apr 18, 2011 at 10:28:10PM +0300, Kostik Belousov wrote: > > + if (offset + len > vap->va_size) { > > + VATTR_NULL(vap); > > + vap->va_size = offset + len; > > + error = VOP_SETATTR(vp, vap, td->td_ucred); > > + if (error != 0) > > + goto out; > > + } > I still do not see a reason to do VOP_SETATTR() there. VOP_WRITE() will > do auto-extend as needed. Also, see below. Yeah, also when we extend file size we could skip reading zeros. > > + if (offset < vap->va_size) { [...] > > + } else { > > + bzero(buf, cur); > > + } > Wouldn't VOP_SETATTR() at the start of the function mostly prevent > this bzero from executing ? Once we drop the vnode lock, the file size can change under us, no? > I estimated what it would take to do the optimized implementation for UFS, > and I think that the following change would allow to lessen the code > duplication much. > > What if the vnode lock drop and looping be handled by the syscall, instead > of the vop implementation ? In other words, allow the VOP_ALLOCATE() > to allocate less then requested, and return the allocated amount to > the caller. The loop would be centralized then, freeing fs from doing > the dance. Also, if fs considers that suitable, it would do a whole > allocation in one run. I'd still go with SEEK_DATA/SEEK_HOLE loop as I suggested on arch@. If you would like to spend time on it, having SEEK_DATA/SEEK_HOLE support in UFS would be beneficial for other purposes too. -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgp7uMUMXLSum.pgp Description: PGP signature
Re: svn commit: r220791 - in head: lib/libc/sys sys/compat/freebsd32 sys/kern sys/sys
On Mon, Apr 18, 2011 at 11:13:02PM +0300, Kostik Belousov wrote: > > The need is, as commented, to return EFBIG when the new file size will > > be larger than the FS supports. Without this code, passing in > > something like posix_fallocate(fd, 0, OFF_MAX) will run the filesystem > > out of space. > Handling max file size and not overflowing the fs are different things. > VOP_WRITE() will handle file size on its own too. I see no problem with > exhausting free space if this is what user asked for. This makes me wonder that current implementation isn't atomic. If we get out of space error, we won't shrink the file back. Even if we could shirk it at the end, we won't be able to put holes in the middle of it. Not sure if this is a big issue, but one doesn't expect from rename(2) to create new link and not remove old one. All in all, making it atomic would be impossible currently for various reasons (we can't put holes back and we can crash in the middle). -- Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com pgpGDsNehES8J.pgp Description: PGP signature
svn commit: r220865 - head/sbin/hastd
Author: pjd Date: Tue Apr 19 19:26:27 2011 New Revision: 220865 URL: http://svn.freebsd.org/changeset/base/220865 Log: Scenario: - We have two nodes connected and synchronized (local counters on both sides are 0). - We take secondary down and recreate it. - Primary connects to it and starts synchronization (but local counters are still 0). - We switch the roles. - Synchronization restarts but data is synchronized now from new primary (because local counters are 0) that doesn't have new data yet. This fix this issue we bump local counter on primary when we discover that connected secondary was recreated and has no data yet. Reported by: trociny Discussed with: trociny Tested by:trociny MFC after:1 week Modified: head/sbin/hastd/primary.c head/sbin/hastd/secondary.c Modified: head/sbin/hastd/primary.c == --- head/sbin/hastd/primary.c Tue Apr 19 18:18:02 2011(r220864) +++ head/sbin/hastd/primary.c Tue Apr 19 19:26:27 2011(r220865) @@ -667,6 +667,25 @@ init_remote(struct hast_resource *res, s res->hr_secondary_localcnt = nv_get_uint64(nvin, "localcnt"); res->hr_secondary_remotecnt = nv_get_uint64(nvin, "remotecnt"); res->hr_syncsrc = nv_get_uint8(nvin, "syncsrc"); + if (nv_exists(nvin, "virgin")) { + /* +* Secondary was reinitialized, bump localcnt if it is 0 as +* only we have the data. +*/ + PJDLOG_ASSERT(res->hr_syncsrc == HAST_SYNCSRC_PRIMARY); + PJDLOG_ASSERT(res->hr_secondary_localcnt == 0); + + if (res->hr_primary_localcnt == 0) { + PJDLOG_ASSERT(res->hr_secondary_remotecnt == 0); + + mtx_lock(&metadata_lock); + res->hr_primary_localcnt++; + pjdlog_debug(1, "Increasing localcnt to %ju.", + (uintmax_t)res->hr_primary_localcnt); + (void)metadata_write(res); + mtx_unlock(&metadata_lock); + } + } map = NULL; mapsize = nv_get_uint32(nvin, "mapsize"); if (mapsize > 0) { Modified: head/sbin/hastd/secondary.c == --- head/sbin/hastd/secondary.c Tue Apr 19 18:18:02 2011(r220864) +++ head/sbin/hastd/secondary.c Tue Apr 19 19:26:27 2011(r220865) @@ -261,6 +261,7 @@ init_remote(struct hast_resource *res, s } else { memset(map, 0xff, mapsize); } + nv_add_int8(nvout, 1, "virgin"); nv_add_uint8(nvout, HAST_SYNCSRC_PRIMARY, "syncsrc"); } else if (res->hr_resuid != resuid) { char errmsg[256]; ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"