svn commit: r220465 - in head: bin/setfacl lib/libc/posix1e sys/sys
Author: trasz Date: Sat Apr 9 07:42:25 2011 New Revision: 220465 URL: http://svn.freebsd.org/changeset/base/220465 Log: Make it possible to use permission sets (full_set, modify_set, read_set and write_set) with setfacl(1). PR: kern/154113 Submitted by: Shawn Webb lattera at gmail dot com (earlier version) MFC after:1 month Modified: head/bin/setfacl/setfacl.1 head/lib/libc/posix1e/acl_support_nfs4.c head/sys/sys/acl.h Modified: head/bin/setfacl/setfacl.1 == --- head/bin/setfacl/setfacl.1 Sat Apr 9 06:01:37 2011(r220464) +++ head/bin/setfacl/setfacl.1 Sat Apr 9 07:42:25 2011(r220465) @@ -1,5 +1,6 @@ .\- .\ Copyright (c) 2001 Chris D. Faulhaber +.\ Copyright (c) 2011 Edward Tomasz NapieraĆa .\ All rights reserved. .\ .\ Redistribution and use in source and binary forms, with or without @@ -25,7 +26,7 @@ .\ .\ $FreeBSD$ .\ -.Dd July 27, 2010 +.Dd April 9, 2011 .Dt SETFACL 1 .Os .Sh NAME @@ -307,7 +308,7 @@ Permissions in long form are separated b .Ql / character; in short form, they are concatenated together. Valid permissions are: -.Bl -tag -width .Dv short +.Bl -tag -width .Dv modify_set .It Short Long .It r @@ -339,6 +340,20 @@ write_owner .It S synchronize .El +.Pp +In addition, the following permission sets may be used: +.Bl -tag -width .Dv modify_set +.It Set +Permissions +.It full_set +all permissions, as shown above +.It modify_set +all permissions except write_acl and write_owner +.It read_set +read_data, read_attributes, read_xattr and read_acl +.It write_set +write_data, append_data, write_attributes and write_xattr +.El .It Ar ACL inheritance flags Inheritance flags may be specified in either short or long form. Short and long forms may not be mixed. Modified: head/lib/libc/posix1e/acl_support_nfs4.c == --- head/lib/libc/posix1e/acl_support_nfs4.cSat Apr 9 06:01:37 2011 (r220464) +++ head/lib/libc/posix1e/acl_support_nfs4.cSat Apr 9 07:42:25 2011 (r220465) @@ -70,6 +70,10 @@ struct flagnames_struct a_access_masks[] { ACL_WRITE_ACL, write_acl, 'C'}, { ACL_WRITE_OWNER, write_owner, 'o'}, { ACL_SYNCHRONIZE, synchronize, 's'}, + { ACL_FULL_SET, full_set, '\0'}, + { ACL_MODIFY_SET, modify_set, '\0'}, + { ACL_READ_SET, read_set, '\0'}, + { ACL_WRITE_SET, write_set, '\0'}, { 0, 0, 0}}; static const char * @@ -117,7 +121,7 @@ format_flags_compact(char *str, size_t s { size_t i; - for (i = 0; flags[i].name != NULL; i++) { + for (i = 0; flags[i].letter != '\0'; i++) { assert(i size); if ((flags[i].flag var) == 0) str[i] = '-'; Modified: head/sys/sys/acl.h == --- head/sys/sys/acl.h Sat Apr 9 06:01:37 2011(r220464) +++ head/sys/sys/acl.h Sat Apr 9 07:42:25 2011(r220465) @@ -217,12 +217,23 @@ typedef void *acl_t; #defineACL_WRITE_OWNER 0x4000 #defineACL_SYNCHRONIZE 0x8000 -#defineACL_NFS4_PERM_BITS (ACL_READ_DATA | ACL_WRITE_DATA | \ +#defineACL_FULL_SET(ACL_READ_DATA | ACL_WRITE_DATA | \ ACL_APPEND_DATA | ACL_READ_NAMED_ATTRS | ACL_WRITE_NAMED_ATTRS | \ ACL_EXECUTE | ACL_DELETE_CHILD | ACL_READ_ATTRIBUTES | \ ACL_WRITE_ATTRIBUTES | ACL_DELETE | ACL_READ_ACL | ACL_WRITE_ACL | \ ACL_WRITE_OWNER | ACL_SYNCHRONIZE) +#defineACL_MODIFY_SET (ACL_FULL_SET \ +~(ACL_WRITE_ACL | ACL_WRITE_OWNER)) + +#defineACL_READ_SET(ACL_READ_DATA | ACL_READ_NAMED_ATTRS | \ +ACL_READ_ATTRIBUTES | ACL_READ_ACL) + +#defineACL_WRITE_SET (ACL_WRITE_DATA | ACL_APPEND_DATA | \ +ACL_WRITE_NAMED_ATTRS | ACL_WRITE_ATTRIBUTES) + +#defineACL_NFS4_PERM_BITS ACL_FULL_SET + /* * Possible entry_id values for acl_get_entry(3). */ ___ 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: r220470 - in head/sys/modules: arcnet dtrace/dtraceall
Author: uqs Date: Sat Apr 9 09:07:31 2011 New Revision: 220470 URL: http://svn.freebsd.org/changeset/base/220470 Log: Fix make buildworld -DMODULES_WITH_WORLD on i386 Modified: head/sys/modules/arcnet/Makefile head/sys/modules/dtrace/dtraceall/Makefile Modified: head/sys/modules/arcnet/Makefile == --- head/sys/modules/arcnet/MakefileSat Apr 9 08:52:22 2011 (r220469) +++ head/sys/modules/arcnet/MakefileSat Apr 9 09:07:31 2011 (r220470) @@ -4,7 +4,7 @@ KMOD= arcnet SRCS= if_arcsubr.c -SRCS+= opt_inet.h opt_inet6.h opt_ipx.h +SRCS+= opt_inet.h opt_inet6.h opt_ipx.h opt_ofed.h EXPORT_SYMS= arc_frag_init \ arc_frag_next \ Modified: head/sys/modules/dtrace/dtraceall/Makefile == --- head/sys/modules/dtrace/dtraceall/Makefile Sat Apr 9 08:52:22 2011 (r220469) +++ head/sys/modules/dtrace/dtraceall/Makefile Sat Apr 9 09:07:31 2011 (r220470) @@ -6,8 +6,8 @@ SRCS= dtraceall.c opt_compat.h CFLAGS+= -I${.CURDIR}/../../.. .if !defined(KERNBUILDDIR) -opt_compat.h: .if ${MACHINE_ARCH} == amd64 +opt_compat.h: echo #define COMPAT_FREEBSD32 1 ${.TARGET} .endif .endif ___ 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: r220496 - head/lib/libmd
Author: markm Date: Sat Apr 9 13:56:29 2011 New Revision: 220496 URL: http://svn.freebsd.org/changeset/base/220496 Log: Add SHA512 (Actually, this is Colin Percival's code for SHA256, with relevant constants changed). While I'm here clean up the tests and Makefile. PR: misc/124164 Submitted by: KIMURA Yasuhiro yasu utahime org MFC after:1 month Added: head/lib/libmd/sha512.3 (contents, props changed) head/lib/libmd/sha512.h (contents, props changed) head/lib/libmd/sha512c.c (contents, props changed) Modified: head/lib/libmd/Makefile head/lib/libmd/mddriver.c head/lib/libmd/rmddriver.c head/lib/libmd/shadriver.c Modified: head/lib/libmd/Makefile == --- head/lib/libmd/Makefile Sat Apr 9 13:45:13 2011(r220495) +++ head/lib/libmd/Makefile Sat Apr 9 13:56:29 2011(r220496) @@ -5,12 +5,13 @@ SHLIBDIR?= /lib SRCS= md2c.c md4c.c md5c.c md2hl.c md4hl.c md5hl.c \ rmd160c.c rmd160hl.c \ sha0c.c sha0hl.c sha1c.c sha1hl.c \ - sha256c.c sha256hl.c -INCS= md2.h md4.h md5.h ripemd.h sha.h sha256.h + sha256c.c sha256hl.c \ + sha512c.c sha512hl.c +INCS= md2.h md4.h md5.h ripemd.h sha.h sha256.h sha512.h WARNS?=0 -MAN+= md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3 +MAN+= md2.3 md4.3 md5.3 ripemd.3 sha.3 sha256.3 sha512.3 MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3 MLINKS+=md2.3 MD2End.3 md2.3 MD2File.3 md2.3 MD2FileChunk.3 MLINKS+=md2.3 MD2Data.3 @@ -34,10 +35,15 @@ MLINKS+=sha256.3 SHA256_Init.3 sha256.3 MLINKS+=sha256.3 SHA256_Final.3 sha256.3 SHA256_End.3 MLINKS+=sha256.3 SHA256_File.3 sha256.3 SHA256_FileChunk.3 MLINKS+=sha256.3 SHA256_Data.3 +MLINKS+=sha512.3 SHA512_Init.3 sha512.3 SHA512_Update.3 +MLINKS+=sha512.3 SHA512_Final.3 sha512.3 SHA512_End.3 +MLINKS+=sha512.3 SHA512_File.3 sha512.3 SHA512_FileChunk.3 +MLINKS+=sha512.3 SHA512_Data.3 CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \ rmd160.ref rmd160hl.c rmddriver \ sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver \ - sha256.ref sha256hl.c + sha256.ref sha256hl.c sha512.ref sha512hl.c + CFLAGS+= -I${.CURDIR} .PATH: ${.CURDIR}/${MACHINE_ARCH} @@ -81,6 +87,12 @@ sha256hl.c: mdXhl.c -e 's/SHA256__/SHA256_/g' \ ${.ALLSRC}) ${.TARGET} +sha512hl.c: mdXhl.c + (echo '#define LENGTH 64'; \ + sed -e 's/mdX/sha512/g' -e 's/MDX/SHA512_/g'\ + -e 's/SHA512__/SHA512_/g' \ + ${.ALLSRC}) ${.TARGET} + rmd160hl.c: mdXhl.c (echo '#define LENGTH 20'; \ sed -e 's/mdX/ripemd/g' -e 's/MDX/RIPEMD160_/g' \ @@ -110,8 +122,10 @@ md4.ref: @echo 'MD4 (abc) = a448017aaf21d8525fc10ae87aa6729d' ${.TARGET} @echo 'MD4 (message digest) = d9130a8164549fe818874806e1c7014b' ${.TARGET} @echo 'MD4 (abcdefghijklmnopqrstuvwxyz) = d79e1c308aa5bbcdeea8ed63df412da9' ${.TARGET} - @echo 'MD4 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789) = 043f8582f241db351ce627e153e7f0e4' ${.TARGET} - @echo 'MD4 (12345678901234567890123456789012345678901234567890123456789012345678901234567890) = e33b4ddc9c38f2199c3e7b164fcc0536' ${.TARGET} + @echo 'MD4 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789) =' \ + '043f8582f241db351ce627e153e7f0e4' ${.TARGET} + @echo 'MD4 (12345678901234567890123456789012345678901234567890123456789012345678901234567890) =' \ + 'e33b4ddc9c38f2199c3e7b164fcc0536' ${.TARGET} md5.ref: echo 'MD5 test suite:' ${.TARGET} @@ -124,54 +138,74 @@ md5.ref: @echo 'MD5 (12345678901234567890123456789012345678901234567890123456789012345678901234567890) = 57edf4a22be3c955ac49da2e2107b67a' ${.TARGET} sha0.ref: - (echo 'SHA-0 test suite:'; \ - echo 'SHA-0 () = f96cea198ad1dd5617ac084a3d92c6107708c0ef'; \ - echo 'SHA-0 (abc) = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880'; \ - echo 'SHA-0 (message digest) =' \ - 'c1b0f222d150ebb9aa36a40cafdc8bcbed830b14'; \ - echo 'SHA-0 (abcdefghijklmnopqrstuvwxyz) =' \ - 'b40ce07a430cfd3c033039b9fe9afec95dc1bdcd'; \ - echo 'SHA-0 (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789) =' \ - '79e966f7a3a990df33e40e3d7f8f18d2caebadfa'; \ - echo 'SHA-0 (12345678901234567890123456789012345678901234567890123456789012345678901234567890) =' \ - '4aa29d14d171522ece47bee8957e35a41f3e9cff' ) ${.TARGET} + echo 'SHA-0 test suite:' ${.TARGET} + @echo 'SHA-0 () = f96cea198ad1dd5617ac084a3d92c6107708c0ef' ${.TARGET} + @echo 'SHA-0 (abc) = 0164b8a914cd2a5e74c4f7ff082c4d97f1edf880' ${.TARGET} + @echo 'SHA-0 (message digest) =' \ +
svn commit: r220497 - head/lib/libcrypt
Author: markm Date: Sat Apr 9 14:02:04 2011 New Revision: 220497 URL: http://svn.freebsd.org/changeset/base/220497 Log: Add SHA256/512 ($5$ and $6$) to crypt(3). Used in linux-world, doesn't hurt us. PR: misc/124164 Submitted by: KIMURA Yasuhiro yasu utahime org MFC after:1 month Added: head/lib/libcrypt/crypt-sha256.c (contents, props changed) head/lib/libcrypt/crypt-sha512.c (contents, props changed) Modified: head/lib/libcrypt/Makefile head/lib/libcrypt/crypt.c head/lib/libcrypt/crypt.h head/lib/libcrypt/misc.c Modified: head/lib/libcrypt/Makefile == --- head/lib/libcrypt/Makefile Sat Apr 9 13:56:29 2011(r220496) +++ head/lib/libcrypt/Makefile Sat Apr 9 14:02:04 2011(r220497) @@ -12,7 +12,9 @@ LIB= crypt .PATH: ${.CURDIR}/../libmd SRCS= crypt.c misc.c \ crypt-md5.c md5c.c \ - crypt-nthash.c md4c.c + crypt-nthash.c md4c.c \ + crypt-sha256.c sha256c.c \ + crypt-sha512.c sha512c.c MAN= crypt.3 MLINKS=crypt.3 crypt_get_format.3 crypt.3 crypt_set_format.3 CFLAGS+= -I${.CURDIR}/../libmd -I${.CURDIR}/../libutil Added: head/lib/libcrypt/crypt-sha256.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libcrypt/crypt-sha256.cSat Apr 9 14:02:04 2011 (r220497) @@ -0,0 +1,477 @@ +/* + * Copyright (c) 2011 The FreeBSD Project. 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 AUTHOR 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 AUTHOR 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. + */ + +/* Based on: + * SHA256-based Unix crypt implementation. Released into the Public Domain by + * Ulrich Drepper drep...@redhat.com. */ + +#include sys/cdefs.h +__FBSDID($FreeBSD$); + +#include sys/endian.h +#include sys/param.h + +#include errno.h +#include limits.h +#include sha256.h +#include stdbool.h +#include stdint.h +#include stdio.h +#include stdlib.h +#include string.h + +#include crypt.h + +/* Define our magic string to mark salt for SHA256 encryption replacement. */ +static const char sha256_salt_prefix[] = $5$; + +/* Prefix for optional rounds specification. */ +static const char sha256_rounds_prefix[] = rounds=; + +/* Maximum salt string length. */ +#define SALT_LEN_MAX 16 +/* Default number of rounds if not explicitly specified. */ +#define ROUNDS_DEFAULT 5000 +/* Minimum number of rounds. */ +#define ROUNDS_MIN 1000 +/* Maximum number of rounds. */ +#define ROUNDS_MAX 9 + +static char * +sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen) +{ + u_long srounds; + int n; + uint8_t alt_result[32], temp_result[32]; + SHA256_CTX ctx, alt_ctx; + size_t salt_len, key_len, cnt, rounds; + char *cp, *copied_key, *copied_salt, *p_bytes, *s_bytes, *endp; + const char *num; + bool rounds_custom; + + copied_key = NULL; + copied_salt = NULL; + + /* Default number of rounds. */ + rounds = ROUNDS_DEFAULT; + rounds_custom = false; + + /* Find beginning of salt string. The prefix should normally always +* be present. Just in case it is not. */ + if (strncmp(sha256_salt_prefix, salt, sizeof(sha256_salt_prefix) - 1) == 0) + /* Skip salt prefix. */ + salt += sizeof(sha256_salt_prefix) - 1; + + if (strncmp(salt, sha256_rounds_prefix, sizeof(sha256_rounds_prefix) - 1) + == 0) { + num = salt + sizeof(sha256_rounds_prefix) - 1; + srounds = strtoul(num, endp, 10); + + if (*endp == '$')
svn commit: r220499 - head/usr.sbin/bsdinstall/scripts
Author: nwhitehorn Date: Sat Apr 9 14:18:03 2011 New Revision: 220499 URL: http://svn.freebsd.org/changeset/base/220499 Log: Rename the Reboot option to Exit, which reflects what it actually does. The rc.local wrapper script will also soon grow an option to use the live environment after installation, so an immediate reboot isn't even necessarily implied. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto == --- head/usr.sbin/bsdinstall/scripts/auto Sat Apr 9 14:09:46 2011 (r220498) +++ head/usr.sbin/bsdinstall/scripts/auto Sat Apr 9 14:18:03 2011 (r220499) @@ -167,7 +167,7 @@ finalconfig() { Services Set daemons to run on startup \ Time Zone Set system timezone \ Shell Open a shell in the new system \ - Reboot Apply configuration and reboot 21 13) + Exit Apply configuration and exit installer 21 13) exec 3- case $REVISIT in ___ 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: r220500 - head/release
Author: nwhitehorn Date: Sat Apr 9 14:25:58 2011 New Revision: 220500 URL: http://svn.freebsd.org/changeset/base/220500 Log: Allow the user to use the live environment post-installation, as well as improving error handling. Modified: head/release/rc.local Modified: head/release/rc.local == --- head/release/rc.local Sat Apr 9 14:18:03 2011(r220499) +++ head/release/rc.local Sat Apr 9 14:25:58 2011(r220500) @@ -17,8 +17,11 @@ $DIALOG_OK) # Install BSDINSTALL_CONFIGCURRENT=yes; export BSDINSTALL_CONFIGCURRENT trap true SIGINT# Ignore cntrl-C here bsdinstall - dialog --backtitle FreeBSD Installer --title Complete --msgbox Installation of FreeBSD complete! The system will now reboot. 0 0 - reboot + if [ $? -eq 0 ]; then + dialog --backtitle FreeBSD Installer --title Complete --yes-label Reboot --no-label Live CD --yesno Installation of FreeBSD complete! Would you like to reboot into the installed system now? 0 0 reboot + else + . /etc/rc.local + fi ;; $DIALOG_CANCEL)# Live CD exit 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: r220506 - head/sys/fs/fdescfs
Author: kib Date: Sat Apr 9 21:40:48 2011 New Revision: 220506 URL: http://svn.freebsd.org/changeset/base/220506 Log: Linuxolator calls VOP_READDIR with ncookies pointer. Implement a workaround for fdescfs to not panic when ncookies is not NULL, similar to the one committed as r152254, but simpler, due to fdescfs_readdir() not calling vfs_read_dirent(). PR: kern/156177 MFC after:1 week Modified: head/sys/fs/fdescfs/fdesc_vnops.c Modified: head/sys/fs/fdescfs/fdesc_vnops.c == --- head/sys/fs/fdescfs/fdesc_vnops.c Sat Apr 9 19:07:44 2011 (r220505) +++ head/sys/fs/fdescfs/fdesc_vnops.c Sat Apr 9 21:40:48 2011 (r220506) @@ -500,16 +500,12 @@ fdesc_readdir(ap) struct dirent *dp = d; int error, i, off, fcnt; - /* -* We don't allow exporting fdesc mounts, and currently local -* requests do not need cookies. -*/ - if (ap-a_ncookies) - panic(fdesc_readdir: not hungry); - if (VTOFDESC(ap-a_vp)-fd_type != Froot) panic(fdesc_readdir: not dir); + if (ap-a_ncookies != NULL) + *ap-a_ncookies = 0; + off = (int)uio-uio_offset; if (off != uio-uio_offset || off 0 || (u_int)off % UIO_MX != 0 || uio-uio_resid UIO_MX) ___ 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: r220510 - head/usr.sbin/nfsd
Author: rmacklem Date: Sun Apr 10 01:54:42 2011 New Revision: 220510 URL: http://svn.freebsd.org/changeset/base/220510 Log: Add support for a backup stable restart file to the nfsd, used for NFSv4 restart. This permits the nfsd to create the stable restart file as required and minimizes the risk of trouble if the file is lost. Suggested by: Tim Kientzle Reviewed by: jhb MFC after:2 weeks Modified: head/usr.sbin/nfsd/nfsd.c Modified: head/usr.sbin/nfsd/nfsd.c == --- head/usr.sbin/nfsd/nfsd.c Sun Apr 10 01:21:02 2011(r220509) +++ head/usr.sbin/nfsd/nfsd.c Sun Apr 10 01:54:42 2011(r220510) @@ -51,6 +51,9 @@ static const char rcsid[] = #include sys/fcntl.h #include sys/linker.h #include sys/module.h +#include sys/types.h +#include sys/stat.h +#include sys/ucred.h #include rpc/rpc.h #include rpc/pmap_clnt.h @@ -79,6 +82,7 @@ int debug = 0; #endif #defineNFSD_STABLERESTART /var/db/nfs-stablerestart +#defineNFSD_STABLEBACKUP /var/db/nfs-stablerestart.bak #defineMAXNFSDCNT 256 #defineDEFNFSDCNT 4 pid_t children[MAXNFSDCNT]; /* PIDs of children */ @@ -86,6 +90,8 @@ int nfsdcnt;/* number of children */ intnew_syscall; intrun_v4server = 0; /* Force running of nfsv4 server */ intnfssvc_nfsd;/* Set to correct NFSSVC_xxx flag */ +intstablefd = -1; /* Fd for the stable restart file */ +intbackupfd; /* Fd for the backup stable restart file */ void cleanup(int); void child_cleanup(int); @@ -98,6 +104,9 @@ int setbindhost(struct addrinfo **ia, co void start_server(int); void unregistration(void); void usage(void); +void open_stable(int *, int *); +void copy_stable(int, int); +void backup_stable(int); /* * Nfs server daemon mostly just a user context for nfssvc() @@ -136,7 +145,7 @@ main(int argc, char **argv) int tcp6sock, ip6flag, tcpflag, tcpsock; int udpflag, ecode, error, s, srvcnt; int bindhostc, bindanyflag, rpcbreg, rpcbregcnt; - int stablefd, nfssvc_addsock; + int nfssvc_addsock; char **bindhost = NULL; pid_t pid; @@ -346,6 +355,7 @@ main(int argc, char **argv) } (void)signal(SIGSYS, nonfs); (void)signal(SIGCHLD, reapchild); + (void)signal(SIGUSR2, backup_stable); openlog(nfsd, LOG_PID, LOG_DAEMON); @@ -355,22 +365,21 @@ main(int argc, char **argv) * regular nfssvc() call to service NFS requests. * (This way the file remains open until the last nfsd is killed * off.) -* Note that this file is not created by this daemon and can -* only be relocated by recompiling the daemon, in order to -* minimize accidentally starting up with the wrong file. -* If should be created as an empty file Read and Write for -* root before the first time you run NFS v4 and should never -* be re-initialized if at all possible. It should live on a +* It and the backup copy will be created as empty files +* the first time this nfsd is started and should never be +* deleted/replaced if at all possible. It should live on a * local, non-volatile storage device that does not do hardware * level write-back caching. (See SCSI doc for more information * on how to prevent write-back caching on SCSI disks.) */ if (run_v4server 0) { - stablefd = open(NFSD_STABLERESTART, O_RDWR, 0); + open_stable(stablefd, backupfd); if (stablefd 0) { syslog(LOG_ERR, Can't open %s\n, NFSD_STABLERESTART); exit(1); } + /* This system call will fail for old kernels, but that's ok. */ + nfssvc(NFSSVC_BACKUPSTABLE, NULL); if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)stablefd) 0) { syslog(LOG_ERR, Can't read stable storage file\n); exit(1); @@ -739,9 +748,9 @@ main(int argc, char **argv) if (select(maxsock + 1, ready, NULL, NULL, NULL) 1) { error = errno; - syslog(LOG_ERR, select failed: %m); if (error == EINTR) continue; + syslog(LOG_ERR, select failed: %m); nfsd_exit(1); } } @@ -973,3 +982,95 @@ start_server(int master) else exit(status); } + +/* + * Open the stable restart file and return the file descriptor for it. + */ +void +open_stable(int *stable_fdp, int *backup_fdp) +{ + int stable_fd, backup_fd = -1, ret; +
svn commit: r220511 - head/sys/ufs/ffs
Author: jeff Date: Sun Apr 10 03:49:53 2011 New Revision: 220511 URL: http://svn.freebsd.org/changeset/base/220511 Log: Fix a long standing SUJ performance problem: - Keep a hash of indirect blocks that have recently been freed and are still referenced in the journal. - Lookup blocks in this hash before forcing a new block write to wait on the journal entry to hit the disk. This is only necessary to avoid confusion between old identities as indirects and new identities as file blocks. - Don't free jseg structures until the journal has written a record that invalidates it. This keeps the indirect block information around for as long as is required to be safe. - Force an empty journal block write when required to flush out stale journal data that is simply waiting for the oldest valid sequence number to advance beyond it. Modified: head/sys/ufs/ffs/ffs_softdep.c head/sys/ufs/ffs/softdep.h Modified: head/sys/ufs/ffs/ffs_softdep.c == --- head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 01:54:42 2011 (r220510) +++ head/sys/ufs/ffs/ffs_softdep.c Sun Apr 10 03:49:53 2011 (r220511) @@ -753,8 +753,7 @@ static void handle_written_jnewblk(struc static void handle_written_jfreeblk(struct jfreeblk *); static void handle_written_jfreefrag(struct jfreefrag *); static void complete_jseg(struct jseg *); -static void jseg_write(struct ufsmount *ump, struct jblocks *, struct jseg *, - uint8_t *); +static void jseg_write(struct ufsmount *ump, struct jseg *, uint8_t *); static void jaddref_write(struct jaddref *, struct jseg *, uint8_t *); static void jremref_write(struct jremref *, struct jseg *, uint8_t *); static void jmvref_write(struct jmvref *, struct jseg *, uint8_t *); @@ -769,6 +768,7 @@ static void handle_allocdirect_partdone( static struct jnewblk *cancel_newblk(struct newblk *, struct worklist *, struct workhead *); static void indirdep_complete(struct indirdep *); +static int indirblk_inseg(struct mount *, ufs2_daddr_t); static void handle_allocindir_partdone(struct allocindir *); static void initiate_write_filepage(struct pagedep *, struct buf *); static void initiate_write_indirdep(struct indirdep*, struct buf *); @@ -802,7 +802,9 @@ static void free_newdirblk(struct newdir static void free_jremref(struct jremref *); static void free_jaddref(struct jaddref *); static void free_jsegdep(struct jsegdep *); -static void free_jseg(struct jseg *); +static void free_jsegs(struct jblocks *); +static void rele_jseg(struct jseg *); +static void free_jseg(struct jseg *, struct jblocks *); static void free_jnewblk(struct jnewblk *); static void free_jfreeblk(struct jfreeblk *); static void free_jfreefrag(struct jfreefrag *); @@ -872,7 +874,7 @@ static int journal_unsuspend(struct ufsm static void softdep_prelink(struct vnode *, struct vnode *); static void add_to_journal(struct worklist *); static void remove_from_journal(struct worklist *); -static void softdep_process_journal(struct mount *, int); +static void softdep_process_journal(struct mount *, struct worklist *, int); static struct jremref *newjremref(struct dirrem *, struct inode *, struct inode *ip, off_t, nlink_t); static struct jaddref *newjaddref(struct inode *, ino_t, off_t, int16_t, @@ -1376,7 +1378,7 @@ softdep_process_worklist(mp, full) ump = VFSTOUFS(mp); ACQUIRE_LOCK(lk); starttime = time_second; - softdep_process_journal(mp, full?MNT_WAIT:0); + softdep_process_journal(mp, NULL, full?MNT_WAIT:0); while (ump-softdep_on_worklist 0) { if ((cnt = process_worklist_item(mp, LK_NOWAIT)) == -1) break; @@ -1999,6 +2001,37 @@ newblk_lookup(mp, newblkno, flags, newbl } /* + * Structures and routines associated with indir caching. + */ +struct workhead *indir_hashtbl; +u_long indir_hash; /* size of hash table - 1 */ +#defineINDIR_HASH(mp, blkno) \ + (indir_hashtbl[register_t)(mp)) 13) + (blkno)) indir_hash]) + +static int +indirblk_inseg(mp, blkno) + struct mount *mp; + ufs2_daddr_t blkno; +{ + struct freework *freework; + struct workhead *wkhd; + struct worklist *wk; + + wkhd = INDIR_HASH(mp, blkno); + LIST_FOREACH(wk, wkhd, wk_list) { + freework = WK_FREEWORK(wk); + if (freework-fw_blkno == blkno + freework-fw_list.wk_mp == mp) { + LIST_REMOVE(freework, fw_next); + WORKLIST_REMOVE(freework-fw_list); + WORKITEM_FREE(freework, D_FREEWORK); + return (1); + } + } + return (0); +} + +/* * Executed during filesystem system initialization before * mounting any filesystems. */ @@ -2012,6 +2045,7 @@