From owner-svn-src-user@FreeBSD.ORG Thu May 14 03:42:59 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0742F106566B; Thu, 14 May 2009 03:42:59 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CF9068FC13; Thu, 14 May 2009 03:42:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4E3gwvI076140; Thu, 14 May 2009 03:42:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4E3gwxn076139; Thu, 14 May 2009 03:42:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905140342.n4E3gwxn076139@svn.freebsd.org> From: Kip Macy Date: Thu, 14 May 2009 03:42:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192082 - user/kmacy/releng_7_2_fast_net X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 May 2009 03:42:59 -0000 Author: kmacy Date: Thu May 14 03:42:58 2009 New Revision: 192082 URL: http://svn.freebsd.org/changeset/base/192082 Log: Create branch for backporting networking optimizations to 7.2 RELEASE Added: user/kmacy/releng_7_2_fast_net/ - copied from r192081, releng/7.2/ From owner-svn-src-user@FreeBSD.ORG Fri May 15 04:53:56 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 444FE1065673; Fri, 15 May 2009 04:53:56 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 19E638FC15; Fri, 15 May 2009 04:53:56 +0000 (UTC) (envelope-from gad@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4F4rtAR012687; Fri, 15 May 2009 04:53:55 GMT (envelope-from gad@svn.freebsd.org) Received: (from gad@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4F4rtbN012686; Fri, 15 May 2009 04:53:55 GMT (envelope-from gad@svn.freebsd.org) Message-Id: <200905150453.n4F4rtbN012686@svn.freebsd.org> From: Garance A Drosehn Date: Fri, 15 May 2009 04:53:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192136 - user/gad X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 04:53:56 -0000 Author: gad Date: Fri May 15 04:53:55 2009 New Revision: 192136 URL: http://svn.freebsd.org/changeset/base/192136 Log: Let's see about starting a few of my side-projects here, instead of having them scattered across a myriad of freebsd installs on a half-dozen different machines of my own. Also tests whether I have the right 'svn' setup with all the right stuff for the freebsd reop. Added: user/gad/ From owner-svn-src-user@FreeBSD.ORG Fri May 15 21:12:11 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71D79106566C; Fri, 15 May 2009 21:12:11 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 47D3A8FC1D; Fri, 15 May 2009 21:12:11 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FLCAHO034745; Fri, 15 May 2009 21:12:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FLCACU034744; Fri, 15 May 2009 21:12:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152112.n4FLCACU034744@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 21:12:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192159 - user/kmacy/ZFS_MFC X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 21:12:11 -0000 Author: kmacy Date: Fri May 15 21:12:10 2009 New Revision: 192159 URL: http://svn.freebsd.org/changeset/base/192159 Log: work branch for ZFS MFC Added: user/kmacy/ZFS_MFC/ - copied from r192158, stable/7/ From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:07:46 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D12B910656C5; Fri, 15 May 2009 23:07:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FD518FC1B; Fri, 15 May 2009 23:07:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FN7kPl037154; Fri, 15 May 2009 23:07:46 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FN7kF5037150; Fri, 15 May 2009 23:07:46 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152307.n4FN7kF5037150@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:07:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192162 - in user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic: amd64 i386 ia64 sparc64 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:07:47 -0000 Author: kmacy Date: Fri May 15 23:07:46 2009 New Revision: 192162 URL: http://svn.freebsd.org/changeset/base/192162 Log: rename opensolaris specific atomic functions Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S (contents, props changed) Deleted: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/atomic.S Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .file "atomic.s" + +#define _ASM +#include + + ENTRY(atomic_add_64_nv) + movq (%rdi), %rax +1: + movq %rsi, %rcx + addq %rax, %rcx + lock + cmpxchgq %rcx, (%rdi) + jne 1b + movq %rcx, %rax + ret + SET_SIZE(atomic_add_64_nv) + + ENTRY(atomic_or_8_nv) + movb (%rdi), %al // %al = old value +1: + movb %sil, %cl + orb %al, %cl // %cl = new value + lock + cmpxchgb %cl, (%rdi) // try to stick it in + jne 1b + movzbl %cl, %eax // return new value + ret + SET_SIZE(atomic_or_8_nv) + + ENTRY(atomic_cas_64) + movq %rsi, %rax + lock + cmpxchgq %rdx, (%rdi) + ret + SET_SIZE(atomic_cas_64) + + ENTRY(membar_producer) + sfence + ret + SET_SIZE(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .file "atomic.s" + +#define _ASM +#include + + /* + * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever + * separated, it is important to edit the libc i386 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_dec_64_nv. + */ + ENTRY(atomic_dec_64) + ALTENTRY(atomic_dec_64_nv) + pushl %edi + pushl %ebx + movl 12(%esp), %edi // %edi = target address + movl (%edi), %eax + movl 4(%edi), %edx // %edx:%eax = old value +1: + xorl %ebx, %ebx + xorl %ecx, %ecx + not %ecx + not %ebx // %ecx:%ebx = -1 + addl %eax, %ebx + adcl %edx, %ecx // add in the carry from inc + lock + cmpxchg8b (%edi) // try to stick it in + jne 1b + movl %ebx, %eax + movl %ecx, %edx // return new value + popl %ebx + popl %edi + ret + SET_SIZE(atomic_dec_64_nv) + SET_SIZE(atomic_dec_64) + + /* + * NOTE: If atomic_add_64 and atomic_add_64_nv are ever + * separated, it is important to edit the libc i386 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_add_64_nv. + */ + ENTRY(atomic_add_64) + ALTENTRY(atomic_add_64_nv) + pushl %edi + pushl %ebx + movl 12(%esp), %edi // %edi = target address + movl (%edi), %eax + movl 4(%edi), %edx // %edx:%eax = old value +1: + movl 16(%esp), %ebx + movl 20(%esp), %ecx // %ecx:%ebx = delta + addl %eax, %ebx + adcl %edx, %ecx // %ecx:%ebx = new value + lock + cmpxchg8b (%edi) // try to stick it in + jne 1b + movl %ebx, %eax + movl %ecx, %edx // return new value + popl %ebx + popl %edi + ret + SET_SIZE(atomic_add_64_nv) + SET_SIZE(atomic_add_64) + + ENTRY(atomic_or_8_nv) + movl 4(%esp), %edx // %edx = target address + movb (%edx), %al // %al = old value +1: + movl 8(%esp), %ecx // %ecx = delta + orb %al, %cl // %cl = new value + lock + cmpxchgb %cl, (%edx) // try to stick it in + jne 1b + movzbl %cl, %eax // return new value + ret + SET_SIZE(atomic_or_8_nv) + + ENTRY(atomic_cas_ptr) + movl 4(%esp), %edx + movl 8(%esp), %eax + movl 12(%esp), %ecx + lock + cmpxchgl %ecx, (%edx) + ret + SET_SIZE(atomic_cas_ptr) + + ENTRY(atomic_cas_64) + pushl %ebx + pushl %esi + movl 12(%esp), %esi + movl 16(%esp), %eax + movl 20(%esp), %edx + movl 24(%esp), %ebx + movl 28(%esp), %ecx + lock + cmpxchg8b (%esi) + popl %esi + popl %ebx + ret + SET_SIZE(atomic_cas_64) + + ENTRY(membar_producer) + lock + xorl $0, (%esp) + ret + SET_SIZE(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 2007 Marcel Moolenaar + * 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 ``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 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$ + */ + +#include + + .text + +/* + * uint64_t atomic_cas_64(volatile uint64_t *p, uint64_t cmp, uint64_t v) + */ +ENTRY(atomic_cas_64, 3) + mov ar.ccv = r33 + ;; + cmpxchg8.acq r8 = [r32], r34, ar.ccv + ;; + br.ret.sptk rp +END(atomic_cas_64) + +/* + * uint64_t atomic_add_64_nv(volatile uint64_t *p, uint64_t v) + */ +ENTRY(atomic_add_64_nv, 2) +1: + ld8 r16 = [r32] + ;; + mov ar.ccv = r16 + add r8 = r16, r33 + ;; + cmpxchg8.acq r17 = [r32], r8, ar.ccv + ;; + cmp.eq p6, p7 = r16, r17 +(p6) br.ret.sptk rp +(p7) br.cond.spnt 1b +END(atomic_add_64_nv) + +/* + * uint8_t atomic_or_8_nv(volatile uint8_t *p, uint8_t v) + */ +ENTRY(atomic_or_8_nv, 2) +1: + ld8 r16 = [r32] + ;; + mov ar.ccv = r16 + or r8 = r16, r33 + ;; + cmpxchg1.acq r17 = [r32], r8, ar.ccv + ;; + cmp.eq p6, p7 = r16, r17 +(p6) br.ret.sptk rp +(p7) br.cond.spnt 1b +END(atomic_or_8_nv) + +ENTRY(membar_producer, 0) + mf.a + ;; + br.ret.sptk rp +END(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .ident "%Z%%M% %I% %E% SMI" + + .file "%M%" + +#define _ASM +#include + +#include + +/* Userland needs different ASIs. */ +#ifdef _KERNEL +#define __ASI_ATOMIC ASI_N +#else +#define __ASI_ATOMIC ASI_P +#endif + + /* + * NOTE: If atomic_add_64 and atomic_add_64_nv are ever + * separated, you need to also edit the libc sparcv9 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_add_64_nv. + */ + ENTRY(atomic_add_64) + ALTENTRY(atomic_add_64_nv) + ALTENTRY(atomic_add_ptr) + ALTENTRY(atomic_add_ptr_nv) + ALTENTRY(atomic_add_long) + ALTENTRY(atomic_add_long_nv) +add_64: + ldx [%o0], %o2 +1: + add %o2, %o1, %o3 + casxa [%o0] __ASI_ATOMIC, %o2, %o3 + cmp %o2, %o3 + bne,a,pn %xcc, 1b + mov %o3, %o2 + retl + add %o2, %o1, %o0 ! return new value + SET_SIZE(atomic_add_long_nv) + SET_SIZE(atomic_add_long) + SET_SIZE(atomic_add_ptr_nv) + SET_SIZE(atomic_add_ptr) + SET_SIZE(atomic_add_64_nv) + SET_SIZE(atomic_add_64) + + /* + * NOTE: If atomic_or_8 and atomic_or_8_nv are ever + * separated, you need to also edit the libc sparcv9 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_or_8_nv. + */ + ENTRY(atomic_or_8) + ALTENTRY(atomic_or_8_nv) + ALTENTRY(atomic_or_uchar) + ALTENTRY(atomic_or_uchar_nv) + and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right + xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left + sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left + set 0xff, %o3 ! %o3 = mask + sll %o3, %g1, %o3 ! %o3 = shifted to bit offset + sll %o1, %g1, %o1 ! %o1 = shifted to bit offset + and %o1, %o3, %o1 ! %o1 = single byte value + andn %o0, 0x3, %o0 ! %o0 = word address + ld [%o0], %o2 ! read old value +1: + or %o2, %o1, %o5 ! or in the new value + casa [%o0] __ASI_ATOMIC, %o2, %o5 + cmp %o2, %o5 + bne,a,pn %icc, 1b + mov %o5, %o2 ! %o2 = old value + or %o2, %o1, %o5 + and %o5, %o3, %o5 + retl + srl %o5, %g1, %o0 ! %o0 = new value + SET_SIZE(atomic_or_uchar_nv) + SET_SIZE(atomic_or_uchar) + SET_SIZE(atomic_or_8_nv) + SET_SIZE(atomic_or_8) + + /* + * Spitfires and Blackbirds have a problem with membars in the + * delay slot (SF_ERRATA_51). For safety's sake, we assume + * that the whole world needs the workaround. + */ + + ENTRY(membar_producer) + membar #StoreStore + retl + nop + SET_SIZE(membar_producer) From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:08:16 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4585A1065676; Fri, 15 May 2009 23:08:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 319EC8FC15; Fri, 15 May 2009 23:08:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FN8GnT037202; Fri, 15 May 2009 23:08:16 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FN8G6V037198; Fri, 15 May 2009 23:08:16 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152308.n4FN8G6V037198@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:08:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192163 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:08:16 -0000 Author: kmacy Date: Fri May 15 23:08:15 2009 New Revision: 192163 URL: http://svn.freebsd.org/changeset/base/192163 Log: rename opensolaris xdr files Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_array.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_mem.c (contents, props changed) Deleted: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_array.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr_mem.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr.c Fri May 15 23:08:15 2009 (r192163) @@ -0,0 +1,621 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * xdr.c, generic XDR routines implementation. + * These are the "generic" xdr routines used to serialize and de-serialize + * most common data items. See xdr.h for more info on the interface to + * xdr. + */ + +#include +#include +#include +#include + +#include +#include + +#pragma weak xdr_int32_t = xdr_int +#pragma weak xdr_uint32_t = xdr_u_int +#pragma weak xdr_int64_t = xdr_longlong_t +#pragma weak xdr_uint64_t = xdr_u_longlong_t + +#if defined(sun) +#if !defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +#error "Exactly one of _BIG_ENDIAN or _LITTLE_ENDIAN must be defined" +#elif defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) +#error "Only one of _BIG_ENDIAN or _LITTLE_ENDIAN may be defined" +#endif +#endif + +/* + * constants specific to the xdr "protocol" + */ +#define XDR_FALSE ((int32_t)0) +#define XDR_TRUE ((int32_t)1) +#define LASTUNSIGNED ((uint_t)0-1) + +/* + * for unit alignment + */ +static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; + +/* + * Free a data structure using XDR + * Not a filter, but a convenient utility nonetheless + */ +void +xdr_free(xdrproc_t proc, char *objp) +{ + XDR x; + + x.x_op = XDR_FREE; + (*proc)(&x, objp); +} + +/* + * XDR nothing + */ +bool_t +xdr_void(void) +{ + return (TRUE); +} + +/* + * XDR integers + * + * PSARC 2003/523 Contract Private Interface + * xdr_int + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +bool_t +xdr_int(XDR *xdrs, int *ip) +{ + if (xdrs->x_op == XDR_ENCODE) + return (XDR_PUTINT32(xdrs, ip)); + + if (xdrs->x_op == XDR_DECODE) + return (XDR_GETINT32(xdrs, ip)); + + if (xdrs->x_op == XDR_FREE) + return (TRUE); + + return (FALSE); +} + +/* + * XDR unsigned integers + * + * PSARC 2003/523 Contract Private Interface + * xdr_u_int + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +bool_t +xdr_u_int(XDR *xdrs, uint_t *up) +{ + if (xdrs->x_op == XDR_ENCODE) + return (XDR_PUTINT32(xdrs, (int32_t *)up)); + + if (xdrs->x_op == XDR_DECODE) + return (XDR_GETINT32(xdrs, (int32_t *)up)); + + if (xdrs->x_op == XDR_FREE) + return (TRUE); + + return (FALSE); +} + + +#if defined(_ILP32) +/* + * xdr_long and xdr_u_long for binary compatability on ILP32 kernels. + * + * No prototypes since new code should not be using these interfaces. + */ +bool_t +xdr_long(XDR *xdrs, long *ip) +{ + return (xdr_int(xdrs, (int *)ip)); +} + +bool_t +xdr_u_long(XDR *xdrs, unsigned long *up) +{ + return (xdr_u_int(xdrs, (uint_t *)up)); +} +#endif /* _ILP32 */ + + +/* + * XDR long long integers + */ +bool_t +xdr_longlong_t(XDR *xdrs, longlong_t *hp) +{ + if (xdrs->x_op == XDR_ENCODE) { +#if BYTE_ORDER == _LITTLE_ENDIAN + if (XDR_PUTINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT)) == TRUE) { + return (XDR_PUTINT32(xdrs, (int32_t *)hp)); + } +#else + if (XDR_PUTINT32(xdrs, (int32_t *)hp) == TRUE) { + return (XDR_PUTINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT))); + } +#endif + return (FALSE); + + } + if (xdrs->x_op == XDR_DECODE) { +#if BYTE_ORDER == _LITTLE_ENDIAN + if (XDR_GETINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT)) == TRUE) { + return (XDR_GETINT32(xdrs, (int32_t *)hp)); + } +#else + if (XDR_GETINT32(xdrs, (int32_t *)hp) == TRUE) { + return (XDR_GETINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT))); + } +#endif + return (FALSE); + } + return (TRUE); +} + +/* + * XDR unsigned long long integers + */ +bool_t +xdr_u_longlong_t(XDR *xdrs, u_longlong_t *hp) +{ + + if (xdrs->x_op == XDR_ENCODE) { +#if BYTE_ORDER == _LITTLE_ENDIAN + if (XDR_PUTINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT)) == TRUE) { + return (XDR_PUTINT32(xdrs, (int32_t *)hp)); + } +#else + if (XDR_PUTINT32(xdrs, (int32_t *)hp) == TRUE) { + return (XDR_PUTINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT))); + } +#endif + return (FALSE); + + } + if (xdrs->x_op == XDR_DECODE) { +#if BYTE_ORDER == _LITTLE_ENDIAN + if (XDR_GETINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT)) == TRUE) { + return (XDR_GETINT32(xdrs, (int32_t *)hp)); + } +#else + if (XDR_GETINT32(xdrs, (int32_t *)hp) == TRUE) { + return (XDR_GETINT32(xdrs, (int32_t *)((char *)hp + + BYTES_PER_XDR_UNIT))); + } +#endif + return (FALSE); + } + return (TRUE); +} + +/* + * XDR short integers + */ +bool_t +xdr_short(XDR *xdrs, short *sp) +{ + int32_t l; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + l = (int32_t)*sp; + return (XDR_PUTINT32(xdrs, &l)); + + case XDR_DECODE: + if (!XDR_GETINT32(xdrs, &l)) + return (FALSE); + *sp = (short)l; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + +/* + * XDR unsigned short integers + */ +bool_t +xdr_u_short(XDR *xdrs, ushort_t *usp) +{ + uint32_t l; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + l = (uint32_t)*usp; + return (XDR_PUTINT32(xdrs, (int32_t *)&l)); + + case XDR_DECODE: + if (!XDR_GETINT32(xdrs, (int32_t *)&l)) { + return (FALSE); + } + *usp = (ushort_t)l; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + + +/* + * XDR a char + */ +bool_t +xdr_char(XDR *xdrs, char *cp) +{ + int i; + + i = (*cp); + if (!xdr_int(xdrs, &i)) { + return (FALSE); + } + *cp = (char)i; + return (TRUE); +} + +/* + * XDR booleans + * + * PSARC 2003/523 Contract Private Interface + * xdr_bool + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +bool_t +xdr_bool(XDR *xdrs, bool_t *bp) +{ + int32_t i32b; + + switch (xdrs->x_op) { + + case XDR_ENCODE: + i32b = *bp ? XDR_TRUE : XDR_FALSE; + return (XDR_PUTINT32(xdrs, &i32b)); + + case XDR_DECODE: + if (!XDR_GETINT32(xdrs, &i32b)) { + return (FALSE); + } + *bp = (i32b == XDR_FALSE) ? FALSE : TRUE; + return (TRUE); + + case XDR_FREE: + return (TRUE); + } + return (FALSE); +} + +/* + * XDR enumerations + * + * PSARC 2003/523 Contract Private Interface + * xdr_enum + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +#ifndef lint +enum sizecheck { SIZEVAL } sizecheckvar; /* used to find the size of */ + /* an enum */ +#endif +bool_t +xdr_enum(XDR *xdrs, enum_t *ep) +{ +#ifndef lint + /* + * enums are treated as ints + */ + if (sizeof (sizecheckvar) == sizeof (int32_t)) { + return (xdr_int(xdrs, (int32_t *)ep)); + } else if (sizeof (sizecheckvar) == sizeof (short)) { + return (xdr_short(xdrs, (short *)ep)); + } else { + return (FALSE); + } +#else + (void) (xdr_short(xdrs, (short *)ep)); + return (xdr_int(xdrs, (int32_t *)ep)); +#endif +} + +/* + * XDR opaque data + * Allows the specification of a fixed size sequence of opaque bytes. + * cp points to the opaque object and cnt gives the byte length. + * + * PSARC 2003/523 Contract Private Interface + * xdr_opaque + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +bool_t +xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt) +{ + uint_t rndup; + static char crud[BYTES_PER_XDR_UNIT]; + + /* + * if no data we are done + */ + if (cnt == 0) + return (TRUE); + + /* + * round byte count to full xdr units + */ + rndup = cnt % BYTES_PER_XDR_UNIT; + if (rndup != 0) + rndup = BYTES_PER_XDR_UNIT - rndup; + + if (xdrs->x_op == XDR_DECODE) { + if (!XDR_GETBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_GETBYTES(xdrs, (caddr_t)crud, rndup)); + } + + if (xdrs->x_op == XDR_ENCODE) { + if (!XDR_PUTBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); + } + + if (xdrs->x_op == XDR_FREE) + return (TRUE); + + return (FALSE); +} + +/* + * XDR counted bytes + * *cpp is a pointer to the bytes, *sizep is the count. + * If *cpp is NULL maxsize bytes are allocated + * + * PSARC 2003/523 Contract Private Interface + * xdr_bytes + * Changes must be reviewed by Solaris File Sharing + * Changes must be communicated to contract-2003-523@sun.com + */ +bool_t +xdr_bytes(XDR *xdrs, char **cpp, uint_t *sizep, const uint_t maxsize) +{ + char *sp = *cpp; /* sp is the actual string pointer */ + uint_t nodesize; + + /* + * first deal with the length since xdr bytes are counted + */ + if (!xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + nodesize = *sizep; + if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { + return (FALSE); + } + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + case XDR_DECODE: + if (nodesize == 0) + return (TRUE); + if (sp == NULL) + *cpp = sp = (char *)mem_alloc(nodesize); + /* FALLTHROUGH */ + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, nodesize)); + + case XDR_FREE: + if (sp != NULL) { + mem_free(sp, nodesize); + *cpp = NULL; + } + return (TRUE); + } + return (FALSE); +} + +/* + * Implemented here due to commonality of the object. + */ +bool_t +xdr_netobj(XDR *xdrs, struct netobj *np) +{ + return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); +} + +/* + * XDR a descriminated union + * Support routine for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * an entry with a null procedure pointer. The routine gets + * the discriminant value and then searches the array of xdrdiscrims + * looking for that value. It calls the procedure given in the xdrdiscrim + * to handle the discriminant. If there is no specific routine a default + * routine may be called. + * If there is no specific or default routine an error is returned. + */ +bool_t +xdr_union(XDR *xdrs, enum_t *dscmp, char *unp, + const struct xdr_discrim *choices, const xdrproc_t dfault) +{ + enum_t dscm; + + /* + * we deal with the discriminator; it's an enum + */ + if (!xdr_enum(xdrs, dscmp)) { + return (FALSE); + } + dscm = *dscmp; + + /* + * search choices for a value that matches the discriminator. + * if we find one, execute the xdr routine for that value. + */ + for (; choices->proc != NULL_xdrproc_t; choices++) { + if (choices->value == dscm) + return ((*(choices->proc))(xdrs, unp, LASTUNSIGNED)); + } + + /* + * no match - execute the default xdr routine if there is one + */ + return ((dfault == NULL_xdrproc_t) ? FALSE : + (*dfault)(xdrs, unp, LASTUNSIGNED)); +} + + +/* + * Non-portable xdr primitives. + * Care should be taken when moving these routines to new architectures. + */ + + +/* + * XDR null terminated ASCII strings + * xdr_string deals with "C strings" - arrays of bytes that are + * terminated by a NULL character. The parameter cpp references a + * pointer to storage; If the pointer is null, then the necessary + * storage is allocated. The last parameter is the max allowed length + * of the string as specified by a protocol. + */ +bool_t +xdr_string(XDR *xdrs, char **cpp, const uint_t maxsize) +{ + char *sp = *cpp; /* sp is the actual string pointer */ + uint_t size; + uint_t nodesize; + + /* + * first deal with the length since xdr strings are counted-strings + */ + switch (xdrs->x_op) { + case XDR_FREE: + if (sp == NULL) + return (TRUE); /* already free */ + /* FALLTHROUGH */ + case XDR_ENCODE: + size = (sp != NULL) ? (uint_t)strlen(sp) : 0; + break; + case XDR_DECODE: + break; + } + if (!xdr_u_int(xdrs, &size)) { + return (FALSE); + } + if (size > maxsize) { + return (FALSE); + } + nodesize = size + 1; + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + case XDR_DECODE: + if (nodesize == 0) + return (TRUE); + if (sp == NULL) + sp = (char *)mem_alloc(nodesize); + sp[size] = 0; + if (!xdr_opaque(xdrs, sp, size)) { + /* + * free up memory if allocated here + */ + if (*cpp == NULL) { + mem_free(sp, nodesize); + } + return (FALSE); + } + if (strlen(sp) != size) { + if (*cpp == NULL) { + mem_free(sp, nodesize); + } + return (FALSE); + } + *cpp = sp; + return (TRUE); + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, size)); + + case XDR_FREE: + mem_free(sp, nodesize); + *cpp = NULL; + return (TRUE); + } + return (FALSE); +} + +/* + * Wrapper for xdr_string that can be called directly from + * routines like clnt_call + */ +bool_t +xdr_wrapstring(XDR *xdrs, char **cpp) +{ + if (xdr_string(xdrs, cpp, LASTUNSIGNED)) + return (TRUE); + return (FALSE); +} Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_array.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_array.c Fri May 15 23:08:15 2009 (r192163) @@ -0,0 +1,114 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +/* + * xdr_array.c, Generic XDR routines impelmentation. + * These are the "non-trivial" xdr primitives used to serialize and de-serialize + * arrays. See xdr.h for more info on the interface to xdr. + */ + +#include +#include +#include +#include + +#include +#include + +#define LASTUNSIGNED ((uint_t)0-1) + +/* + * XDR an array of arbitrary elements + * *addrp is a pointer to the array, *sizep is the number of elements. + * If addrp is NULL (*sizep * elsize) bytes are allocated. + * elsize is the size (in bytes) of each element, and elproc is the + * xdr procedure to call to handle each element of the array. + */ +bool_t +xdr_array(XDR *xdrs, caddr_t *addrp, uint_t *sizep, const uint_t maxsize, + const uint_t elsize, const xdrproc_t elproc) +{ + uint_t i; + caddr_t target = *addrp; + uint_t c; /* the actual element count */ + bool_t stat = TRUE; + uint_t nodesize; + + /* like strings, arrays are really counted arrays */ + if (!xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + c = *sizep; + if ((c > maxsize || LASTUNSIGNED / elsize < c) && + xdrs->x_op != XDR_FREE) { + return (FALSE); + } + nodesize = c * elsize; + + /* + * if we are deserializing, we may need to allocate an array. + * We also save time by checking for a null array if we are freeing. + */ + if (target == NULL) + switch (xdrs->x_op) { + case XDR_DECODE: + if (c == 0) + return (TRUE); + *addrp = target = (char *)mem_alloc(nodesize); + bzero(target, nodesize); + break; + + case XDR_FREE: + return (TRUE); + + case XDR_ENCODE: + break; + } + + /* + * now we xdr each element of array + */ + for (i = 0; (i < c) && stat; i++) { + stat = (*elproc)(xdrs, target, LASTUNSIGNED); + target += elsize; + } + + /* + * the array may need freeing + */ + if (xdrs->x_op == XDR_FREE) { + mem_free(*addrp, nodesize); + *addrp = NULL; + } + return (stat); +} Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_mem.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/opensolaris_xdr_mem.c Fri May 15 23:08:15 2009 (r192163) @@ -0,0 +1,209 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * Portions of this source code were derived from Berkeley 4.3 BSD + * under license from the Regents of the University of California. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + * xdr_mem.c, XDR implementation using memory buffers. + * + * If you have some data to be interpreted as external data representation + * or to be converted to external data representation in a memory buffer, + * then this is the package for you. + */ + +#include +#include +#include + +#include +#include + +static struct xdr_ops *xdrmem_ops(void); + +/* + * The procedure xdrmem_create initializes a stream descriptor for a + * memory buffer. + */ +void +xdrmem_create(XDR *xdrs, caddr_t addr, uint_t size, enum xdr_op op) +{ + xdrs->x_op = op; + xdrs->x_ops = xdrmem_ops(); + xdrs->x_private = xdrs->x_base = addr; + xdrs->x_handy = size; + xdrs->x_public = NULL; +} + +/* ARGSUSED */ +static void +xdrmem_destroy(XDR *xdrs) +{ +} + +static bool_t +xdrmem_getint32(XDR *xdrs, int32_t *int32p) +{ + if ((xdrs->x_handy -= (int)sizeof (int32_t)) < 0) + return (FALSE); + /* LINTED pointer alignment */ + *int32p = (int32_t)ntohl((uint32_t)(*((int32_t *)(xdrs->x_private)))); + xdrs->x_private += sizeof (int32_t); + return (TRUE); +} + +static bool_t +xdrmem_putint32(XDR *xdrs, int32_t *int32p) +{ + if ((xdrs->x_handy -= (int)sizeof (int32_t)) < 0) + return (FALSE); + /* LINTED pointer alignment */ + *(int32_t *)xdrs->x_private = (int32_t)htonl((uint32_t)(*int32p)); + xdrs->x_private += sizeof (int32_t); + return (TRUE); +} + +static bool_t +xdrmem_getbytes(XDR *xdrs, caddr_t addr, int len) +{ + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + bcopy(xdrs->x_private, addr, len); + xdrs->x_private += len; + return (TRUE); +} + +static bool_t +xdrmem_putbytes(XDR *xdrs, caddr_t addr, int len) +{ + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + bcopy(addr, xdrs->x_private, len); + xdrs->x_private += len; + return (TRUE); +} + +static uint_t +xdrmem_getpos(XDR *xdrs) +{ + return ((uint_t)((uintptr_t)xdrs->x_private - (uintptr_t)xdrs->x_base)); +} + +static bool_t +xdrmem_setpos(XDR *xdrs, uint_t pos) +{ + caddr_t newaddr = xdrs->x_base + pos; + caddr_t lastaddr = xdrs->x_private + xdrs->x_handy; + ptrdiff_t diff; + + if (newaddr > lastaddr) + return (FALSE); + xdrs->x_private = newaddr; + diff = lastaddr - newaddr; + xdrs->x_handy = (int)diff; + return (TRUE); +} + +static rpc_inline_t * +xdrmem_inline(XDR *xdrs, int len) +{ + rpc_inline_t *buf = NULL; + + if (xdrs->x_handy >= len) { + xdrs->x_handy -= len; + /* LINTED pointer alignment */ + buf = (rpc_inline_t *)xdrs->x_private; + xdrs->x_private += len; + } + return (buf); +} + +static bool_t +xdrmem_control(XDR *xdrs, int request, void *info) +{ + xdr_bytesrec *xptr; + int32_t *int32p; + int len; + + switch (request) { + + case XDR_GET_BYTES_AVAIL: + xptr = (xdr_bytesrec *)info; + xptr->xc_is_last_record = TRUE; + xptr->xc_num_avail = xdrs->x_handy; + return (TRUE); + + case XDR_PEEK: + /* + * Return the next 4 byte unit in the XDR stream. + */ + if (xdrs->x_handy < sizeof (int32_t)) + return (FALSE); + int32p = (int32_t *)info; + *int32p = (int32_t)ntohl((uint32_t) + (*((int32_t *)(xdrs->x_private)))); + return (TRUE); + + case XDR_SKIPBYTES: + /* + * Skip the next N bytes in the XDR stream. + */ + int32p = (int32_t *)info; + len = RNDUP((int)(*int32p)); + if ((xdrs->x_handy -= len) < 0) + return (FALSE); + xdrs->x_private += len; + return (TRUE); + + } + return (FALSE); +} + +static struct xdr_ops * +xdrmem_ops(void) +{ + static struct xdr_ops ops; + + if (ops.x_getint32 == NULL) { + ops.x_getbytes = xdrmem_getbytes; + ops.x_putbytes = xdrmem_putbytes; + ops.x_getpostn = xdrmem_getpos; + ops.x_setpostn = xdrmem_setpos; + ops.x_inline = xdrmem_inline; + ops.x_destroy = xdrmem_destroy; + ops.x_control = xdrmem_control; + ops.x_getint32 = xdrmem_getint32; + ops.x_putint32 = xdrmem_putint32; + } + return (&ops); +} Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h Fri May 15 23:07:46 2009 (r192162) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/rpc/xdr.h Fri May 15 23:08:15 2009 (r192163) @@ -2,9 +2,8 @@ * CDDL HEADER START * * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. @@ -19,7 +18,7 @@ * * CDDL HEADER END * - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -38,8 +37,6 @@ #ifndef _RPC_XDR_H #define _RPC_XDR_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include /* For all ntoh* and hton*() kind of macros */ #include /* For all ntoh* and hton*() kind of macros */ #ifndef _KERNEL @@ -365,7 +362,7 @@ struct xdr_discrim { #endif -#if BYTE_ORDER == _BIG_ENDIAN +#if BYTE_ORDER == _LITTLE_ENDIAN #define IXDR_GET_HYPER(buf, v) { \ *((int32_t *)(&v)) = ntohl(*(uint32_t *)buf++); \ *((int32_t *)(((char *)&v) + BYTES_PER_XDR_UNIT)) \ @@ -543,8 +540,14 @@ typedef struct xdr_bytesrec xdr_bytesrec #ifdef _KERNEL #define XDR_PEEK 2 #define XDR_SKIPBYTES 3 -#define XDR_RDMAGET 4 -#define XDR_RDMASET 5 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:09:53 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7055E106564A; Fri, 15 May 2009 23:09:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CCA78FC08; Fri, 15 May 2009 23:09:53 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FN9r5i037280; Fri, 15 May 2009 23:09:53 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FN9rBn037278; Fri, 15 May 2009 23:09:53 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152309.n4FN9rBn037278@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:09:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192164 - in user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris: common/unicode uts/common/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:09:53 -0000 Author: kmacy Date: Fri May 15 23:09:53 2009 New Revision: 192164 URL: http://svn.freebsd.org/changeset/base/192164 Log: MFC unicode support files Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/unicode/ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/unicode/u8_textprep.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/u8_textprep_data.h (contents, props changed) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/unicode/u8_textprep.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/unicode/u8_textprep.c Fri May 15 23:09:53 2009 (r192164) @@ -0,0 +1,2130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + + +/* + * UTF-8 text preparation functions (PSARC/2007/149, PSARC/2007/458). + * + * Man pages: u8_textprep_open(9F), u8_textprep_buf(9F), u8_textprep_close(9F), + * u8_textprep_str(9F), u8_strcmp(9F), and u8_validate(9F). See also + * the section 3C man pages. + * Interface stability: Committed. + */ + +#include +#ifdef _KERNEL +#include +#include +#include +#include +#include +#else +#include +#endif /* _KERNEL */ +#include +#include +#include +#include + + +/* The maximum possible number of bytes in a UTF-8 character. */ +#define U8_MB_CUR_MAX (4) + +/* + * The maximum number of bytes needed for a UTF-8 character to cover + * U+0000 - U+FFFF, i.e., the coding space of now deprecated UCS-2. + */ +#define U8_MAX_BYTES_UCS2 (3) + +/* The maximum possible number of bytes in a Stream-Safe Text. */ +#define U8_STREAM_SAFE_TEXT_MAX (128) + +/* + * The maximum number of characters in a combining/conjoining sequence and + * the actual upperbound limit of a combining/conjoining sequence. + */ +#define U8_MAX_CHARS_A_SEQ (32) +#define U8_UPPER_LIMIT_IN_A_SEQ (31) + +/* The combining class value for Starter. */ +#define U8_COMBINING_CLASS_STARTER (0) + +/* + * Some Hangul related macros at below. + * + * The first and the last of Hangul syllables, Hangul Jamo Leading consonants, + * Vowels, and optional Trailing consonants in Unicode scalar values. + * + * Please be noted that the U8_HANGUL_JAMO_T_FIRST is 0x11A7 at below not + * the actual U+11A8. This is due to that the trailing consonant is optional + * and thus we are doing a pre-calculation of subtracting one. + * + * Each of 19 modern leading consonants has total 588 possible syllables since + * Hangul has 21 modern vowels and 27 modern trailing consonants plus 1 for + * no trailing consonant case, i.e., 21 x 28 = 588. + * + * We also have bunch of Hangul related macros at below. Please bear in mind + * that the U8_HANGUL_JAMO_1ST_BYTE can be used to check whether it is + * a Hangul Jamo or not but the value does not guarantee that it is a Hangul + * Jamo; it just guarantee that it will be most likely. + */ +#define U8_HANGUL_SYL_FIRST (0xAC00U) +#define U8_HANGUL_SYL_LAST (0xD7A3U) + +#define U8_HANGUL_JAMO_L_FIRST (0x1100U) +#define U8_HANGUL_JAMO_L_LAST (0x1112U) +#define U8_HANGUL_JAMO_V_FIRST (0x1161U) +#define U8_HANGUL_JAMO_V_LAST (0x1175U) +#define U8_HANGUL_JAMO_T_FIRST (0x11A7U) +#define U8_HANGUL_JAMO_T_LAST (0x11C2U) + +#define U8_HANGUL_V_COUNT (21) +#define U8_HANGUL_VT_COUNT (588) +#define U8_HANGUL_T_COUNT (28) + +#define U8_HANGUL_JAMO_1ST_BYTE (0xE1U) + +#define U8_SAVE_HANGUL_AS_UTF8(s, i, j, k, b) \ + (s)[(i)] = (uchar_t)(0xE0U | ((uint32_t)(b) & 0xF000U) >> 12); \ + (s)[(j)] = (uchar_t)(0x80U | ((uint32_t)(b) & 0x0FC0U) >> 6); \ + (s)[(k)] = (uchar_t)(0x80U | ((uint32_t)(b) & 0x003FU)); + +#define U8_HANGUL_JAMO_L(u) \ + ((u) >= U8_HANGUL_JAMO_L_FIRST && (u) <= U8_HANGUL_JAMO_L_LAST) + +#define U8_HANGUL_JAMO_V(u) \ + ((u) >= U8_HANGUL_JAMO_V_FIRST && (u) <= U8_HANGUL_JAMO_V_LAST) + +#define U8_HANGUL_JAMO_T(u) \ + ((u) > U8_HANGUL_JAMO_T_FIRST && (u) <= U8_HANGUL_JAMO_T_LAST) + +#define U8_HANGUL_JAMO(u) \ + ((u) >= U8_HANGUL_JAMO_L_FIRST && (u) <= U8_HANGUL_JAMO_T_LAST) + +#define U8_HANGUL_SYLLABLE(u) \ + ((u) >= U8_HANGUL_SYL_FIRST && (u) <= U8_HANGUL_SYL_LAST) + +#define U8_HANGUL_COMPOSABLE_L_V(s, u) \ + ((s) == U8_STATE_HANGUL_L && U8_HANGUL_JAMO_V((u))) + +#define U8_HANGUL_COMPOSABLE_LV_T(s, u) \ + ((s) == U8_STATE_HANGUL_LV && U8_HANGUL_JAMO_T((u))) + +/* The types of decomposition mappings. */ +#define U8_DECOMP_BOTH (0xF5U) +#define U8_DECOMP_CANONICAL (0xF6U) + +/* The indicator for 16-bit table. */ +#define U8_16BIT_TABLE_INDICATOR (0x8000U) + +/* The following are some convenience macros. */ +#define U8_PUT_3BYTES_INTO_UTF32(u, b1, b2, b3) \ + (u) = ((uint32_t)(b1) & 0x0F) << 12 | ((uint32_t)(b2) & 0x3F) << 6 | \ + (uint32_t)(b3) & 0x3F; + +#define U8_SIMPLE_SWAP(a, b, t) \ + (t) = (a); \ + (a) = (b); \ + (b) = (t); + +#define U8_ASCII_TOUPPER(c) \ + (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c)) + +#define U8_ASCII_TOLOWER(c) \ + (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c)) + +#define U8_ISASCII(c) (((uchar_t)(c)) < 0x80U) +/* + * The following macro assumes that the two characters that are to be + * swapped are adjacent to each other and 'a' comes before 'b'. + * + * If the assumptions are not met, then, the macro will fail. + */ +#define U8_SWAP_COMB_MARKS(a, b) \ + for (k = 0; k < disp[(a)]; k++) \ + u8t[k] = u8s[start[(a)] + k]; \ + for (k = 0; k < disp[(b)]; k++) \ + u8s[start[(a)] + k] = u8s[start[(b)] + k]; \ + start[(b)] = start[(a)] + disp[(b)]; \ + for (k = 0; k < disp[(a)]; k++) \ + u8s[start[(b)] + k] = u8t[k]; \ + U8_SIMPLE_SWAP(comb_class[(a)], comb_class[(b)], tc); \ + U8_SIMPLE_SWAP(disp[(a)], disp[(b)], tc); + +/* The possible states during normalization. */ +typedef enum { + U8_STATE_START = 0, + U8_STATE_HANGUL_L = 1, + U8_STATE_HANGUL_LV = 2, + U8_STATE_HANGUL_LVT = 3, + U8_STATE_HANGUL_V = 4, + U8_STATE_HANGUL_T = 5, + U8_STATE_COMBINING_MARK = 6 +} u8_normalization_states_t; + +/* + * The three vectors at below are used to check bytes of a given UTF-8 + * character are valid and not containing any malformed byte values. + * + * We used to have a quite relaxed UTF-8 binary representation but then there + * was some security related issues and so the Unicode Consortium defined + * and announced the UTF-8 Corrigendum at Unicode 3.1 and then refined it + * one more time at the Unicode 3.2. The following three tables are based on + * that. + */ + +#define U8_ILLEGAL_NEXT_BYTE_COMMON(c) ((c) < 0x80 || (c) > 0xBF) + +#define I_ U8_ILLEGAL_CHAR +#define O_ U8_OUT_OF_RANGE_CHAR + +const int8_t u8_number_of_bytes[0x100] = { + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + +/* 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F */ + I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, + +/* 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F */ + I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, + +/* A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF */ + I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, + +/* B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF */ + I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, I_, + +/* C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF */ + I_, I_, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + +/* D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF */ + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + +/* E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF */ + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + +/* F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF */ + 4, 4, 4, 4, 4, O_, O_, O_, O_, O_, O_, O_, O_, O_, O_, O_, +}; + +#undef I_ +#undef O_ + +const uint8_t u8_valid_min_2nd_byte[0x100] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +/* C0 C1 C2 C3 C4 C5 C6 C7 */ + 0, 0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* C8 C9 CA CB CC CD CE CF */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* D0 D1 D2 D3 D4 D5 D6 D7 */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* D8 D9 DA DB DC DD DE DF */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* E0 E1 E2 E3 E4 E5 E6 E7 */ + 0xa0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* E8 E9 EA EB EC ED EE EF */ + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, +/* F0 F1 F2 F3 F4 F5 F6 F7 */ + 0x90, 0x80, 0x80, 0x80, 0x80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + +const uint8_t u8_valid_max_2nd_byte[0x100] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +/* C0 C1 C2 C3 C4 C5 C6 C7 */ + 0, 0, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, +/* C8 C9 CA CB CC CD CE CF */ + 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, +/* D0 D1 D2 D3 D4 D5 D6 D7 */ + 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, +/* D8 D9 DA DB DC DD DE DF */ + 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, +/* E0 E1 E2 E3 E4 E5 E6 E7 */ + 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, +/* E8 E9 EA EB EC ED EE EF */ + 0xbf, 0xbf, 0xbf, 0xbf, 0xbf, 0x9f, 0xbf, 0xbf, +/* F0 F1 F2 F3 F4 F5 F6 F7 */ + 0xbf, 0xbf, 0xbf, 0xbf, 0x8f, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, +}; + + +/* + * The u8_validate() validates on the given UTF-8 character string and + * calculate the byte length. It is quite similar to mblen(3C) except that + * this will validate against the list of characters if required and + * specific to UTF-8 and Unicode. + */ +int +u8_validate(char *u8str, size_t n, char **list, int flag, int *errnum) +{ + uchar_t *ib; + uchar_t *ibtail; + uchar_t **p; + uchar_t *s1; + uchar_t *s2; + uchar_t f; + int sz; + size_t i; + int ret_val; + boolean_t second; + boolean_t no_need_to_validate_entire; + boolean_t check_additional; + boolean_t validate_ucs2_range_only; + + if (! u8str) + return (0); + + ib = (uchar_t *)u8str; + ibtail = ib + n; + + ret_val = 0; + + no_need_to_validate_entire = ! (flag & U8_VALIDATE_ENTIRE); + check_additional = flag & U8_VALIDATE_CHECK_ADDITIONAL; + validate_ucs2_range_only = flag & U8_VALIDATE_UCS2_RANGE; + + while (ib < ibtail) { + /* + * The first byte of a UTF-8 character tells how many + * bytes will follow for the character. If the first byte + * is an illegal byte value or out of range value, we just + * return -1 with an appropriate error number. + */ + sz = u8_number_of_bytes[*ib]; + if (sz == U8_ILLEGAL_CHAR) { + *errnum = EILSEQ; + return (-1); + } + + if (sz == U8_OUT_OF_RANGE_CHAR || + (validate_ucs2_range_only && sz > U8_MAX_BYTES_UCS2)) { + *errnum = ERANGE; + return (-1); + } + + /* + * If we don't have enough bytes to check on, that's also + * an error. As you can see, we give illegal byte sequence + * checking higher priority then EINVAL cases. + */ + if ((ibtail - ib) < sz) { + *errnum = EINVAL; + return (-1); + } + + if (sz == 1) { + ib++; + ret_val++; + } else { + /* + * Check on the multi-byte UTF-8 character. For more + * details on this, see comment added for the used + * data structures at the beginning of the file. + */ + f = *ib++; + ret_val++; + second = B_TRUE; + for (i = 1; i < sz; i++) { + if (second) { + if (*ib < u8_valid_min_2nd_byte[f] || + *ib > u8_valid_max_2nd_byte[f]) { + *errnum = EILSEQ; + return (-1); + } + second = B_FALSE; + } else if (U8_ILLEGAL_NEXT_BYTE_COMMON(*ib)) { + *errnum = EILSEQ; + return (-1); + } + ib++; + ret_val++; + } + } + + if (check_additional) { + for (p = (uchar_t **)list, i = 0; p[i]; i++) { + s1 = ib - sz; + s2 = p[i]; + while (s1 < ib) { + if (*s1 != *s2 || *s2 == '\0') + break; + s1++; + s2++; + } + + if (s1 >= ib && *s2 == '\0') { + *errnum = EBADF; + return (-1); + } + } + } + + if (no_need_to_validate_entire) + break; + } + + return (ret_val); +} + +/* + * The do_case_conv() looks at the mapping tables and returns found + * bytes if any. If not found, the input bytes are returned. The function + * always terminate the return bytes with a null character assuming that + * there are plenty of room to do so. + * + * The case conversions are simple case conversions mapping a character to + * another character as specified in the Unicode data. The byte size of + * the mapped character could be different from that of the input character. + * + * The return value is the byte length of the returned character excluding + * the terminating null byte. + */ +static size_t +do_case_conv(int uv, uchar_t *u8s, uchar_t *s, int sz, boolean_t is_it_toupper) +{ + size_t i; + uint16_t b1 = 0; + uint16_t b2 = 0; + uint16_t b3 = 0; + uint16_t b3_tbl; + uint16_t b3_base; + uint16_t b4 = 0; + size_t start_id; + size_t end_id; + + /* + * At this point, the only possible values for sz are 2, 3, and 4. + * The u8s should point to a vector that is well beyond the size of + * 5 bytes. + */ + if (sz == 2) { + b3 = u8s[0] = s[0]; + b4 = u8s[1] = s[1]; + } else if (sz == 3) { + b2 = u8s[0] = s[0]; + b3 = u8s[1] = s[1]; + b4 = u8s[2] = s[2]; + } else if (sz == 4) { + b1 = u8s[0] = s[0]; + b2 = u8s[1] = s[1]; + b3 = u8s[2] = s[2]; + b4 = u8s[3] = s[3]; + } else { + /* This is not possible but just in case as a fallback. */ + if (is_it_toupper) + *u8s = U8_ASCII_TOUPPER(*s); + else + *u8s = U8_ASCII_TOLOWER(*s); + u8s[1] = '\0'; + + return (1); + } + u8s[sz] = '\0'; + + /* + * Let's find out if we have a corresponding character. + */ + b1 = u8_common_b1_tbl[uv][b1]; + if (b1 == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + b2 = u8_case_common_b2_tbl[uv][b1][b2]; + if (b2 == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + if (is_it_toupper) { + b3_tbl = u8_toupper_b3_tbl[uv][b2][b3].tbl_id; + if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + start_id = u8_toupper_b4_tbl[uv][b3_tbl][b4]; + end_id = u8_toupper_b4_tbl[uv][b3_tbl][b4 + 1]; + + /* Either there is no match or an error at the table. */ + if (start_id >= end_id || (end_id - start_id) > U8_MB_CUR_MAX) + return ((size_t)sz); + + b3_base = u8_toupper_b3_tbl[uv][b2][b3].base; + + for (i = 0; start_id < end_id; start_id++) + u8s[i++] = u8_toupper_final_tbl[uv][b3_base + start_id]; + } else { + b3_tbl = u8_tolower_b3_tbl[uv][b2][b3].tbl_id; + if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + start_id = u8_tolower_b4_tbl[uv][b3_tbl][b4]; + end_id = u8_tolower_b4_tbl[uv][b3_tbl][b4 + 1]; + + if (start_id >= end_id || (end_id - start_id) > U8_MB_CUR_MAX) + return ((size_t)sz); + + b3_base = u8_tolower_b3_tbl[uv][b2][b3].base; + + for (i = 0; start_id < end_id; start_id++) + u8s[i++] = u8_tolower_final_tbl[uv][b3_base + start_id]; + } + + /* + * If i is still zero, that means there is no corresponding character. + */ + if (i == 0) + return ((size_t)sz); + + u8s[i] = '\0'; + + return (i); +} + +/* + * The do_case_compare() function compares the two input strings, s1 and s2, + * one character at a time doing case conversions if applicable and return + * the comparison result as like strcmp(). + * + * Since, in empirical sense, most of text data are 7-bit ASCII characters, + * we treat the 7-bit ASCII characters as a special case trying to yield + * faster processing time. + */ +static int +do_case_compare(size_t uv, uchar_t *s1, uchar_t *s2, size_t n1, + size_t n2, boolean_t is_it_toupper, int *errnum) +{ + int f; + int sz1; + int sz2; + size_t j; + size_t i1; + size_t i2; + uchar_t u8s1[U8_MB_CUR_MAX + 1]; + uchar_t u8s2[U8_MB_CUR_MAX + 1]; + + i1 = i2 = 0; + while (i1 < n1 && i2 < n2) { + /* + * Find out what would be the byte length for this UTF-8 + * character at string s1 and also find out if this is + * an illegal start byte or not and if so, issue a proper + * error number and yet treat this byte as a character. + */ + sz1 = u8_number_of_bytes[*s1]; + if (sz1 < 0) { + *errnum = EILSEQ; + sz1 = 1; + } + + /* + * For 7-bit ASCII characters mainly, we do a quick case + * conversion right at here. + * + * If we don't have enough bytes for this character, issue + * an EINVAL error and use what are available. + * + * If we have enough bytes, find out if there is + * a corresponding uppercase character and if so, copy over + * the bytes for a comparison later. If there is no + * corresponding uppercase character, then, use what we have + * for the comparison. + */ + if (sz1 == 1) { + if (is_it_toupper) + u8s1[0] = U8_ASCII_TOUPPER(*s1); + else + u8s1[0] = U8_ASCII_TOLOWER(*s1); + s1++; + u8s1[1] = '\0'; + } else if ((i1 + sz1) > n1) { + *errnum = EINVAL; + for (j = 0; (i1 + j) < n1; ) + u8s1[j++] = *s1++; + u8s1[j] = '\0'; + } else { + (void) do_case_conv(uv, u8s1, s1, sz1, is_it_toupper); + s1 += sz1; + } + + /* Do the same for the string s2. */ + sz2 = u8_number_of_bytes[*s2]; + if (sz2 < 0) { + *errnum = EILSEQ; + sz2 = 1; + } + + if (sz2 == 1) { + if (is_it_toupper) + u8s2[0] = U8_ASCII_TOUPPER(*s2); + else + u8s2[0] = U8_ASCII_TOLOWER(*s2); + s2++; + u8s2[1] = '\0'; + } else if ((i2 + sz2) > n2) { + *errnum = EINVAL; + for (j = 0; (i2 + j) < n2; ) + u8s2[j++] = *s2++; + u8s2[j] = '\0'; + } else { + (void) do_case_conv(uv, u8s2, s2, sz2, is_it_toupper); + s2 += sz2; + } + + /* Now compare the two characters. */ + if (sz1 == 1 && sz2 == 1) { + if (*u8s1 > *u8s2) + return (1); + if (*u8s1 < *u8s2) + return (-1); + } else { + f = strcmp((const char *)u8s1, (const char *)u8s2); + if (f != 0) + return (f); + } + + /* + * They were the same. Let's move on to the next + * characters then. + */ + i1 += sz1; + i2 += sz2; + } + + /* + * We compared until the end of either or both strings. + * + * If we reached to or went over the ends for the both, that means + * they are the same. + * + * If we reached only one of the two ends, that means the other string + * has something which then the fact can be used to determine + * the return value. + */ + if (i1 >= n1) { + if (i2 >= n2) + return (0); + return (-1); + } + return (1); +} + +/* + * The combining_class() function checks on the given bytes and find out + * the corresponding Unicode combining class value. The return value 0 means + * it is a Starter. Any illegal UTF-8 character will also be treated as + * a Starter. + */ +static uchar_t +combining_class(size_t uv, uchar_t *s, size_t sz) +{ + uint16_t b1 = 0; + uint16_t b2 = 0; + uint16_t b3 = 0; + uint16_t b4 = 0; + + if (sz == 1 || sz > 4) + return (0); + + if (sz == 2) { + b3 = s[0]; + b4 = s[1]; + } else if (sz == 3) { + b2 = s[0]; + b3 = s[1]; + b4 = s[2]; + } else if (sz == 4) { + b1 = s[0]; + b2 = s[1]; + b3 = s[2]; + b4 = s[3]; + } + + b1 = u8_common_b1_tbl[uv][b1]; + if (b1 == U8_TBL_ELEMENT_NOT_DEF) + return (0); + + b2 = u8_combining_class_b2_tbl[uv][b1][b2]; + if (b2 == U8_TBL_ELEMENT_NOT_DEF) + return (0); + + b3 = u8_combining_class_b3_tbl[uv][b2][b3]; + if (b3 == U8_TBL_ELEMENT_NOT_DEF) + return (0); + + return (u8_combining_class_b4_tbl[uv][b3][b4]); +} + +/* + * The do_decomp() function finds out a matching decomposition if any + * and return. If there is no match, the input bytes are copied and returned. + * The function also checks if there is a Hangul, decomposes it if necessary + * and returns. + * + * To save time, a single byte 7-bit ASCII character should be handled by + * the caller. + * + * The function returns the number of bytes returned sans always terminating + * the null byte. It will also return a state that will tell if there was + * a Hangul character decomposed which then will be used by the caller. + */ +static size_t +do_decomp(size_t uv, uchar_t *u8s, uchar_t *s, int sz, + boolean_t canonical_decomposition, u8_normalization_states_t *state) +{ + uint16_t b1 = 0; + uint16_t b2 = 0; + uint16_t b3 = 0; + uint16_t b3_tbl; + uint16_t b3_base; + uint16_t b4 = 0; + size_t start_id; + size_t end_id; + size_t i; + uint32_t u1; + + if (sz == 2) { + b3 = u8s[0] = s[0]; + b4 = u8s[1] = s[1]; + u8s[2] = '\0'; + } else if (sz == 3) { + /* Convert it to a Unicode scalar value. */ + U8_PUT_3BYTES_INTO_UTF32(u1, s[0], s[1], s[2]); + + /* + * If this is a Hangul syllable, we decompose it into + * a leading consonant, a vowel, and an optional trailing + * consonant and then return. + */ + if (U8_HANGUL_SYLLABLE(u1)) { + u1 -= U8_HANGUL_SYL_FIRST; + + b1 = U8_HANGUL_JAMO_L_FIRST + u1 / U8_HANGUL_VT_COUNT; + b2 = U8_HANGUL_JAMO_V_FIRST + (u1 % U8_HANGUL_VT_COUNT) + / U8_HANGUL_T_COUNT; + b3 = u1 % U8_HANGUL_T_COUNT; + + U8_SAVE_HANGUL_AS_UTF8(u8s, 0, 1, 2, b1); + U8_SAVE_HANGUL_AS_UTF8(u8s, 3, 4, 5, b2); + if (b3) { + b3 += U8_HANGUL_JAMO_T_FIRST; + U8_SAVE_HANGUL_AS_UTF8(u8s, 6, 7, 8, b3); + + u8s[9] = '\0'; + *state = U8_STATE_HANGUL_LVT; + return (9); + } + + u8s[6] = '\0'; + *state = U8_STATE_HANGUL_LV; + return (6); + } + + b2 = u8s[0] = s[0]; + b3 = u8s[1] = s[1]; + b4 = u8s[2] = s[2]; + u8s[3] = '\0'; + + /* + * If this is a Hangul Jamo, we know there is nothing + * further that we can decompose. + */ + if (U8_HANGUL_JAMO_L(u1)) { + *state = U8_STATE_HANGUL_L; + return (3); + } + + if (U8_HANGUL_JAMO_V(u1)) { + if (*state == U8_STATE_HANGUL_L) + *state = U8_STATE_HANGUL_LV; + else + *state = U8_STATE_HANGUL_V; + return (3); + } + + if (U8_HANGUL_JAMO_T(u1)) { + if (*state == U8_STATE_HANGUL_LV) + *state = U8_STATE_HANGUL_LVT; + else + *state = U8_STATE_HANGUL_T; + return (3); + } + } else if (sz == 4) { + b1 = u8s[0] = s[0]; + b2 = u8s[1] = s[1]; + b3 = u8s[2] = s[2]; + b4 = u8s[3] = s[3]; + u8s[4] = '\0'; + } else { + /* + * This is a fallback and should not happen if the function + * was called properly. + */ + u8s[0] = s[0]; + u8s[1] = '\0'; + *state = U8_STATE_START; + return (1); + } + + /* + * At this point, this rountine does not know what it would get. + * The caller should sort it out if the state isn't a Hangul one. + */ + *state = U8_STATE_START; + + /* Try to find matching decomposition mapping byte sequence. */ + b1 = u8_common_b1_tbl[uv][b1]; + if (b1 == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + b2 = u8_decomp_b2_tbl[uv][b1][b2]; + if (b2 == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + b3_tbl = u8_decomp_b3_tbl[uv][b2][b3].tbl_id; + if (b3_tbl == U8_TBL_ELEMENT_NOT_DEF) + return ((size_t)sz); + + /* + * If b3_tbl is bigger than or equal to U8_16BIT_TABLE_INDICATOR + * which is 0x8000, this means we couldn't fit the mappings into + * the cardinality of a unsigned byte. + */ + if (b3_tbl >= U8_16BIT_TABLE_INDICATOR) { + b3_tbl -= U8_16BIT_TABLE_INDICATOR; + start_id = u8_decomp_b4_16bit_tbl[uv][b3_tbl][b4]; + end_id = u8_decomp_b4_16bit_tbl[uv][b3_tbl][b4 + 1]; + } else { + start_id = u8_decomp_b4_tbl[uv][b3_tbl][b4]; + end_id = u8_decomp_b4_tbl[uv][b3_tbl][b4 + 1]; + } + + /* This also means there wasn't any matching decomposition. */ + if (start_id >= end_id) + return ((size_t)sz); + + /* + * The final table for decomposition mappings has three types of + * byte sequences depending on whether a mapping is for compatibility + * decomposition, canonical decomposition, or both like the following: + * + * (1) Compatibility decomposition mappings: + * + * +---+---+-...-+---+ + * | B0| B1| ... | Bm| + * +---+---+-...-+---+ + * + * The first byte, B0, is always less then 0xF5 (U8_DECOMP_BOTH). + * + * (2) Canonical decomposition mappings: + * + * +---+---+---+-...-+---+ + * | T | b0| b1| ... | bn| + * +---+---+---+-...-+---+ + * + * where the first byte, T, is 0xF6 (U8_DECOMP_CANONICAL). + * + * (3) Both mappings: + * + * +---+---+---+---+-...-+---+---+---+-...-+---+ + * | T | D | b0| b1| ... | bn| B0| B1| ... | Bm| + * +---+---+---+---+-...-+---+---+---+-...-+---+ + * + * where T is 0xF5 (U8_DECOMP_BOTH) and D is a displacement + * byte, b0 to bn are canonical mapping bytes and B0 to Bm are + * compatibility mapping bytes. + * + * Note that compatibility decomposition means doing recursive + * decompositions using both compatibility decomposition mappings and + * canonical decomposition mappings. On the other hand, canonical + * decomposition means doing recursive decompositions using only + * canonical decomposition mappings. Since the table we have has gone + * through the recursions already, we do not need to do so during + * runtime, i.e., the table has been completely flattened out + * already. + */ + + b3_base = u8_decomp_b3_tbl[uv][b2][b3].base; + + /* Get the type, T, of the byte sequence. */ + b1 = u8_decomp_final_tbl[uv][b3_base + start_id]; + + /* + * If necessary, adjust start_id, end_id, or both. Note that if + * this is compatibility decomposition mapping, there is no + * adjustment. + */ + if (canonical_decomposition) { + /* Is the mapping only for compatibility decomposition? */ + if (b1 < U8_DECOMP_BOTH) + return ((size_t)sz); + + start_id++; + + if (b1 == U8_DECOMP_BOTH) { + end_id = start_id + + u8_decomp_final_tbl[uv][b3_base + start_id]; + start_id++; + } + } else { + /* + * Unless this is a compatibility decomposition mapping, + * we adjust the start_id. + */ + if (b1 == U8_DECOMP_BOTH) { + start_id++; + start_id += u8_decomp_final_tbl[uv][b3_base + start_id]; + } else if (b1 == U8_DECOMP_CANONICAL) { + start_id++; + } + } + + for (i = 0; start_id < end_id; start_id++) + u8s[i++] = u8_decomp_final_tbl[uv][b3_base + start_id]; + u8s[i] = '\0'; + + return (i); +} + +/* + * The find_composition_start() function uses the character bytes given and + * find out the matching composition mappings if any and return the address + * to the composition mappings as explained in the do_composition(). + */ +static uchar_t * +find_composition_start(size_t uv, uchar_t *s, size_t sz) +{ + uint16_t b1 = 0; + uint16_t b2 = 0; + uint16_t b3 = 0; + uint16_t b3_tbl; + uint16_t b3_base; + uint16_t b4 = 0; + size_t start_id; + size_t end_id; + + if (sz == 1) { + b4 = s[0]; + } else if (sz == 2) { + b3 = s[0]; + b4 = s[1]; + } else if (sz == 3) { + b2 = s[0]; + b3 = s[1]; + b4 = s[2]; + } else if (sz == 4) { + b1 = s[0]; + b2 = s[1]; + b3 = s[2]; + b4 = s[3]; + } else { + /* + * This is a fallback and should not happen if the function + * was called properly. + */ + return (NULL); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:10:22 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 798CF1065686; Fri, 15 May 2009 23:10:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 66B1C8FC18; Fri, 15 May 2009 23:10:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNAMuU037336; Fri, 15 May 2009 23:10:22 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNAMbN037334; Fri, 15 May 2009 23:10:22 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152310.n4FNAMbN037334@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:10:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192165 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:10:22 -0000 Author: kmacy Date: Fri May 15 23:10:22 2009 New Revision: 192165 URL: http://svn.freebsd.org/changeset/base/192165 Log: rename crc32.c Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c (contents, props changed) Deleted: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/crc32.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.c Fri May 15 23:10:22 2009 (r192165) @@ -0,0 +1,428 @@ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* crc32.c -- compute the CRC-32 of a data stream + * Copyright (C) 1995-2005 Mark Adler + * For conditions of distribution and use, see copyright notice in zlib.h + * + * Thanks to Rodney Brown for his contribution of faster + * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing + * tables for updating the shift register in one step with three exclusive-ors + * instead of four steps with four exclusive-ors. This results in about a + * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +/* + Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore + protection on the static variables used to control the first-use generation + of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should + first call get_crc_table() to initialize the tables before allowing more than + one thread to use crc32(). + */ + +#ifdef MAKECRCH +# include +# ifndef DYNAMIC_CRC_TABLE +# define DYNAMIC_CRC_TABLE +# endif /* !DYNAMIC_CRC_TABLE */ +#endif /* MAKECRCH */ + +#include "zutil.h" /* for STDC and FAR definitions */ + +#define local static + +/* Find a four-byte integer type for crc32_little() and crc32_big(). */ +#ifndef NOBYFOUR +# ifdef STDC /* need ANSI C limits.h to determine sizes */ +# include +# define BYFOUR +# if (UINT_MAX == 0xffffffffUL) + typedef unsigned int u4; +# else +# if (ULONG_MAX == 0xffffffffUL) + typedef unsigned long u4; +# else +# if (USHRT_MAX == 0xffffffffUL) + typedef unsigned short u4; +# else +# undef BYFOUR /* can't find a four-byte integer type! */ +# endif +# endif +# endif +# endif /* STDC */ +#endif /* !NOBYFOUR */ + +/* Definitions for doing the crc four data bytes at a time. */ +#ifdef BYFOUR +# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ + (((w)&0xff00)<<8)+(((w)&0xff)<<24)) + local unsigned long crc32_little OF((unsigned long, + const unsigned char FAR *, unsigned)); + local unsigned long crc32_big OF((unsigned long, + const unsigned char FAR *, unsigned)); +# define TBLS 8 +#else +# define TBLS 1 +#endif /* BYFOUR */ + +/* Local functions for crc concatenation */ +local unsigned long gf2_matrix_times OF((unsigned long *mat, + unsigned long vec)); +local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); + +#ifdef DYNAMIC_CRC_TABLE + +local volatile int crc_table_empty = 1; +local unsigned long FAR crc_table[TBLS][256]; +local void make_crc_table OF((void)); +#ifdef MAKECRCH + local void write_table OF((FILE *, const unsigned long FAR *)); +#endif /* MAKECRCH */ +/* + Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: + x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. + + Polynomials over GF(2) are represented in binary, one bit per coefficient, + with the lowest powers in the most significant bit. Then adding polynomials + is just exclusive-or, and multiplying a polynomial by x is a right shift by + one. If we call the above polynomial p, and represent a byte as the + polynomial q, also with the lowest power in the most significant bit (so the + byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p, + where a mod b means the remainder after dividing a by b. + + This calculation is done using the shift-register method of multiplying and + taking the remainder. The register is initialized to zero, and for each + incoming bit, x^32 is added mod p to the register if the bit is a one (where + x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by + x (which is shifting right by one and adding x^32 mod p if the bit shifted + out is a one). We start with the highest power (least significant bit) of + q and repeat for all eight bits of q. + + The first table is simply the CRC of all possible eight bit values. This is + all the information needed to generate CRCs on data a byte at a time for all + combinations of CRC register values and incoming bytes. The remaining tables + allow for word-at-a-time CRC calculation for both big-endian and little- + endian machines, where a word is four bytes. +*/ +local void make_crc_table() +{ + unsigned long c; + int n, k; + unsigned long poly; /* polynomial exclusive-or pattern */ + /* terms of polynomial defining this crc (except x^32): */ + static volatile int first = 1; /* flag to limit concurrent making */ + static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; + + /* See if another task is already doing this (not thread-safe, but better + than nothing -- significantly reduces duration of vulnerability in + case the advice about DYNAMIC_CRC_TABLE is ignored) */ + if (first) { + first = 0; + + /* make exclusive-or pattern from polynomial (0xedb88320UL) */ + poly = 0UL; + for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) + poly |= 1UL << (31 - p[n]); + + /* generate a crc for every 8-bit value */ + for (n = 0; n < 256; n++) { + c = (unsigned long)n; + for (k = 0; k < 8; k++) + c = c & 1 ? poly ^ (c >> 1) : c >> 1; + crc_table[0][n] = c; + } + +#ifdef BYFOUR + /* generate crc for each value followed by one, two, and three zeros, + and then the byte reversal of those as well as the first table */ + for (n = 0; n < 256; n++) { + c = crc_table[0][n]; + crc_table[4][n] = REV(c); + for (k = 1; k < 4; k++) { + c = crc_table[0][c & 0xff] ^ (c >> 8); + crc_table[k][n] = c; + crc_table[k + 4][n] = REV(c); + } + } +#endif /* BYFOUR */ + + crc_table_empty = 0; + } + else { /* not first */ + /* wait for the other guy to finish (not efficient, but rare) */ + while (crc_table_empty) + ; + } + +#ifdef MAKECRCH + /* write out CRC tables to crc32.h */ + { + FILE *out; + + out = fopen("crc32.h", "w"); + if (out == NULL) return; + fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n"); + fprintf(out, " * Generated automatically by crc32.c\n */\n\n"); + fprintf(out, "local const unsigned long FAR "); + fprintf(out, "crc_table[TBLS][256] =\n{\n {\n"); + write_table(out, crc_table[0]); +# ifdef BYFOUR + fprintf(out, "#ifdef BYFOUR\n"); + for (k = 1; k < 8; k++) { + fprintf(out, " },\n {\n"); + write_table(out, crc_table[k]); + } + fprintf(out, "#endif\n"); +# endif /* BYFOUR */ + fprintf(out, " }\n};\n"); + fclose(out); + } +#endif /* MAKECRCH */ +} + +#ifdef MAKECRCH +local void write_table(out, table) + FILE *out; + const unsigned long FAR *table; +{ + int n; + + for (n = 0; n < 256; n++) + fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n], + n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", ")); +} +#endif /* MAKECRCH */ + +#else /* !DYNAMIC_CRC_TABLE */ +/* ======================================================================== + * Tables of CRC-32s of all single-byte values, made by make_crc_table(). + */ +#include "crc32.h" +#endif /* DYNAMIC_CRC_TABLE */ + +/* ========================================================================= + * This function can be used by asm versions of crc32() + */ +const unsigned long FAR * ZEXPORT get_crc_table() +{ +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + return (const unsigned long FAR *)crc_table; +} + +/* ========================================================================= */ +#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8) +#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1 + +/* ========================================================================= */ +unsigned long ZEXPORT crc32(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + if (buf == Z_NULL) return 0UL; + +#ifdef DYNAMIC_CRC_TABLE + if (crc_table_empty) + make_crc_table(); +#endif /* DYNAMIC_CRC_TABLE */ + +#ifdef BYFOUR + if (sizeof(void *) == sizeof(ptrdiff_t)) { + u4 endian; + + endian = 1; + if (*((unsigned char *)(&endian))) + return crc32_little(crc, buf, len); + else + return crc32_big(crc, buf, len); + } +#endif /* BYFOUR */ + crc = crc ^ 0xffffffffUL; + while (len >= 8) { + DO8; + len -= 8; + } + if (len) do { + DO1; + } while (--len); + return crc ^ 0xffffffffUL; +} + +#ifdef BYFOUR + +/* ========================================================================= */ +#define DOLIT4 c ^= *buf4++; \ + c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \ + crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24] +#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4 + +/* ========================================================================= */ +local unsigned long crc32_little(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = (u4)crc; + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + while (len >= 32) { + DOLIT32; + len -= 32; + } + while (len >= 4) { + DOLIT4; + len -= 4; + } + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); + } while (--len); + c = ~c; + return (unsigned long)c; +} + +/* ========================================================================= */ +#define DOBIG4 c ^= *++buf4; \ + c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \ + crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24] +#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4 + +/* ========================================================================= */ +local unsigned long crc32_big(crc, buf, len) + unsigned long crc; + const unsigned char FAR *buf; + unsigned len; +{ + register u4 c; + register const u4 FAR *buf4; + + c = REV((u4)crc); + c = ~c; + while (len && ((ptrdiff_t)buf & 3)) { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + len--; + } + + buf4 = (const u4 FAR *)(const void FAR *)buf; + buf4--; + while (len >= 32) { + DOBIG32; + len -= 32; + } + while (len >= 4) { + DOBIG4; + len -= 4; + } + buf4++; + buf = (const unsigned char FAR *)buf4; + + if (len) do { + c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); + } while (--len); + c = ~c; + return (unsigned long)(REV(c)); +} + +#endif /* BYFOUR */ + +#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */ + +/* ========================================================================= */ +local unsigned long gf2_matrix_times(mat, vec) + unsigned long *mat; + unsigned long vec; +{ + unsigned long sum; + + sum = 0; + while (vec) { + if (vec & 1) + sum ^= *mat; + vec >>= 1; + mat++; + } + return sum; +} + +/* ========================================================================= */ +local void gf2_matrix_square(square, mat) + unsigned long *square; + unsigned long *mat; +{ + int n; + + for (n = 0; n < GF2_DIM; n++) + square[n] = gf2_matrix_times(mat, mat[n]); +} + +/* ========================================================================= */ +uLong ZEXPORT crc32_combine(crc1, crc2, len2) + uLong crc1; + uLong crc2; + z_off_t len2; +{ + int n; + unsigned long row; + unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ + unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ + + /* degenerate case */ + if (len2 == 0) + return crc1; + + /* put operator for one zero bit in odd */ + odd[0] = 0xedb88320UL; /* CRC-32 polynomial */ + row = 1; + for (n = 1; n < GF2_DIM; n++) { + odd[n] = row; + row <<= 1; + } + + /* put operator for two zero bits in even */ + gf2_matrix_square(even, odd); + + /* put operator for four zero bits in odd */ + gf2_matrix_square(odd, even); + + /* apply len2 zeros to crc1 (first square will put the operator for one + zero byte, eight zero bits, in even) */ + do { + /* apply zeros operator for this bit of len2 */ + gf2_matrix_square(even, odd); + if (len2 & 1) + crc1 = gf2_matrix_times(even, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + if (len2 == 0) + break; + + /* another iteration of the loop with odd and even swapped */ + gf2_matrix_square(odd, even); + if (len2 & 1) + crc1 = gf2_matrix_times(odd, crc1); + len2 >>= 1; + + /* if no more bits set, then done */ + } while (len2 != 0); + + /* return combined crc */ + crc1 ^= crc2; + return crc1; +} Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c Fri May 15 23:09:53 2009 (r192164) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.c Fri May 15 23:10:22 2009 (r192165) @@ -20,16 +20,15 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include "zlib.h" +#include "zutil.h" /* * Uncompress the buffer 'src' into the buffer 'dst'. The caller must store @@ -49,7 +48,12 @@ z_uncompress(void *dst, size_t *dstlen, zs.next_out = dst; zs.avail_out = *dstlen; - if ((err = inflateInit(&zs)) != Z_OK) + /* + * Call inflateInit2() specifying a window size of DEF_WBITS + * with the 6th bit set to indicate that the compression format + * type (zlib or gzip) should be automatically detected. + */ + if ((err = inflateInit2(&zs, DEF_WBITS | 0x20)) != Z_OK) return (err); if ((err = inflate(&zs, Z_FINISH)) != Z_STREAM_END) { From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:10:45 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEEEE1065678; Fri, 15 May 2009 23:10:45 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DCBCC8FC17; Fri, 15 May 2009 23:10:45 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNAjjm037376; Fri, 15 May 2009 23:10:45 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNAjhe037375; Fri, 15 May 2009 23:10:45 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152310.n4FNAjhe037375@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:10:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192166 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:10:46 -0000 Author: kmacy Date: Fri May 15 23:10:45 2009 New Revision: 192166 URL: http://svn.freebsd.org/changeset/base/192166 Log: add vnode support routines Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c (contents, props changed) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/vnode.c Fri May 15 23:10:45 2009 (r192166) @@ -0,0 +1,213 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include +#include +#include +#include +#include + +/* Extensible attribute (xva) routines. */ + +/* + * Zero out the structure, set the size of the requested/returned bitmaps, + * set AT_XVATTR in the embedded vattr_t's va_mask, and set up the pointer + * to the returned attributes array. + */ +void +xva_init(xvattr_t *xvap) +{ + bzero(xvap, sizeof (xvattr_t)); + xvap->xva_mapsize = XVA_MAPSIZE; + xvap->xva_magic = XVA_MAGIC; + xvap->xva_vattr.va_mask = AT_XVATTR; + xvap->xva_rtnattrmapp = &(xvap->xva_rtnattrmap)[0]; +} + +/* + * If AT_XVATTR is set, returns a pointer to the embedded xoptattr_t + * structure. Otherwise, returns NULL. + */ +xoptattr_t * +xva_getxoptattr(xvattr_t *xvap) +{ + xoptattr_t *xoap = NULL; + if (xvap->xva_vattr.va_mask & AT_XVATTR) + xoap = &xvap->xva_xoptattrs; + return (xoap); +} + +static STAILQ_HEAD(, vnode) vn_rele_async_list; +static struct mtx vn_rele_async_lock; +static struct cv vn_rele_async_cv; +static int vn_rele_list_length; +static int vn_rele_async_thread_exit; + +typedef struct { + struct vnode *stqe_next; +} vnode_link_t; + +/* + * Like vn_rele() except if we are going to call VOP_INACTIVE() then do it + * asynchronously using a taskq. This can avoid deadlocks caused by re-entering + * the file system as a result of releasing the vnode. Note, file systems + * already have to handle the race where the vnode is incremented before the + * inactive routine is called and does its locking. + * + * Warning: Excessive use of this routine can lead to performance problems. + * This is because taskqs throttle back allocation if too many are created. + */ +void +vn_rele_async(vnode_t *vp, taskq_t *taskq /* unused */) +{ + + KASSERT(vp != NULL, ("vrele: null vp")); + VFS_ASSERT_GIANT(vp->v_mount); + VI_LOCK(vp); + + if (vp->v_usecount > 1 || ((vp->v_iflag & VI_DOINGINACT) && + vp->v_usecount == 1)) { + vp->v_usecount--; + vdropl(vp); + return; + } + if (vp->v_usecount != 1) { +#ifdef DIAGNOSTIC + vprint("vrele: negative ref count", vp); +#endif + VI_UNLOCK(vp); + panic("vrele: negative ref cnt"); + } + /* + * We are exiting + */ + if (vn_rele_async_thread_exit != 0) { + vrele(vp); + return; + } + + mtx_lock(&vn_rele_async_lock); + + /* STAILQ_INSERT_TAIL */ + (*(vnode_link_t *)&vp->v_cstart).stqe_next = NULL; + *vn_rele_async_list.stqh_last = vp; + vn_rele_async_list.stqh_last = + &((vnode_link_t *)&vp->v_cstart)->stqe_next; + + /****************************************/ + vn_rele_list_length++; + if ((vn_rele_list_length % 100) == 0) + cv_signal(&vn_rele_async_cv); + mtx_unlock(&vn_rele_async_lock); + VI_UNLOCK(vp); +} + +static void +vn_rele_async_init(void *arg) +{ + + mtx_init(&vn_rele_async_lock, "valock", NULL, MTX_DEF); + STAILQ_INIT(&vn_rele_async_list); + + /* cv_init(&vn_rele_async_cv, "vacv"); */ + vn_rele_async_cv.cv_description = "vacv"; + vn_rele_async_cv.cv_waiters = 0; +} + +void +vn_rele_async_fini(void) +{ + + mtx_lock(&vn_rele_async_lock); + vn_rele_async_thread_exit = 1; + cv_signal(&vn_rele_async_cv); + while (vn_rele_async_thread_exit != 0) + cv_wait(&vn_rele_async_cv, &vn_rele_async_lock); + mtx_unlock(&vn_rele_async_lock); + mtx_destroy(&vn_rele_async_lock); +} + + +static void +vn_rele_async_cleaner(void) +{ + STAILQ_HEAD(, vnode) vn_tmp_list; + struct vnode *curvnode; + + STAILQ_INIT(&vn_tmp_list); + mtx_lock(&vn_rele_async_lock); + while (vn_rele_async_thread_exit == 0) { + STAILQ_CONCAT(&vn_tmp_list, &vn_rele_async_list); + vn_rele_list_length = 0; + mtx_unlock(&vn_rele_async_lock); + + while (!STAILQ_EMPTY(&vn_tmp_list)) { + curvnode = STAILQ_FIRST(&vn_tmp_list); + + /* STAILQ_REMOVE_HEAD */ + STAILQ_FIRST(&vn_tmp_list) = + ((vnode_link_t *)&curvnode->v_cstart)->stqe_next; + if (STAILQ_FIRST(&vn_tmp_list) == NULL) + vn_tmp_list.stqh_last = &STAILQ_FIRST(&vn_tmp_list); + /***********************/ + vrele(curvnode); + } + mtx_lock(&vn_rele_async_lock); + if (vn_rele_list_length == 0) + cv_timedwait(&vn_rele_async_cv, &vn_rele_async_lock, + hz/10); + } + + vn_rele_async_thread_exit = 0; + cv_broadcast(&vn_rele_async_cv); + mtx_unlock(&vn_rele_async_lock); + thread_exit(); +} + +static struct proc *vn_rele_async_proc; +static struct kproc_desc up_kp = { + "vaclean", + vn_rele_async_cleaner, + &vn_rele_async_proc +}; +SYSINIT(vaclean, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp); +SYSINIT(vn_rele_async_setup, SI_SUB_VFS, SI_ORDER_FIRST, vn_rele_async_init, NULL); From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:11:07 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48A9E1065673; Fri, 15 May 2009 23:11:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 369148FC23; Fri, 15 May 2009 23:11:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNB7gF037435; Fri, 15 May 2009 23:11:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNB7vA037434; Fri, 15 May 2009 23:11:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152311.n4FNB7vA037434@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:11:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192167 - user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:11:07 -0000 Author: kmacy Date: Fri May 15 23:11:06 2009 New Revision: 192167 URL: http://svn.freebsd.org/changeset/base/192167 Log: consolidate lookup functions Added: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c (contents, props changed) Added: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_lookup.c Fri May 15 23:11:06 2009 (r192167) @@ -0,0 +1,111 @@ +/*- + * Copyright (c) 2007 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 + +int +lookupname(char *dirname, enum uio_seg seg, enum symfollow follow, + vnode_t **dirvpp, vnode_t **compvpp) +{ + + return (lookupnameat(dirname, seg, follow, dirvpp, compvpp, NULL)); +} + +int +lookupnameat(char *dirname, enum uio_seg seg, enum symfollow follow, + vnode_t **dirvpp, vnode_t **compvpp, vnode_t *startvp) +{ + struct nameidata nd; + int error, ltype; + + ASSERT(dirvpp == NULL); + + vref(startvp); + ltype = VOP_ISLOCKED(startvp, curthread); + VOP_UNLOCK(startvp, 0, curthread); + NDINIT_ATVP(&nd, LOOKUP, LOCKLEAF | MPSAFE | follow, seg, dirname, + startvp, curthread); + error = namei(&nd); + *compvpp = nd.ni_vp; + NDFREE(&nd, NDF_ONLY_PNBUF); + vn_lock(startvp, ltype | LK_RETRY, curthread); + return (error); +} + +int +traverse(vnode_t **cvpp, int lktype) +{ + vnode_t *cvp; + vnode_t *tvp; + vfs_t *vfsp; + int error; + + cvp = *cvpp; + tvp = NULL; + + /* + * If this vnode is mounted on, then we transparently indirect + * to the vnode which is the root of the mounted file system. + * Before we do this we must check that an unmount is not in + * progress on this vnode. + */ + + for (;;) { + /* + * Reached the end of the mount chain? + */ + vfsp = vn_mountedvfs(cvp); + if (vfsp == NULL) + break; + /* + * tvp is NULL for *cvpp vnode, which we can't unlock. + */ + if (tvp != NULL) + vput(cvp); + else + vrele(cvp); + + /* + * The read lock must be held across the call to VFS_ROOT() to + * prevent a concurrent unmount from destroying the vfs. + */ + error = VFS_ROOT(vfsp, lktype, &tvp, curthread); + if (error != 0) + return (error); + cvp = tvp; + } + + *cvpp = cvp; + return (0); +} From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:11:34 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2FFF1065740; Fri, 15 May 2009 23:11:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BFA978FC08; Fri, 15 May 2009 23:11:34 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNBYEH037479; Fri, 15 May 2009 23:11:34 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNBYcm037473; Fri, 15 May 2009 23:11:34 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152311.n4FNBYcm037473@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:11:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192168 - in user/kmacy/ZFS_MFC/sys/cddl/boot: . zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:11:35 -0000 Author: kmacy Date: Fri May 15 23:11:34 2009 New Revision: 192168 URL: http://svn.freebsd.org/changeset/base/192168 Log: add ZFS boot support Added: user/kmacy/ZFS_MFC/sys/cddl/boot/ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfssubr.c (contents, props changed) Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README Fri May 15 23:11:34 2009 (r192168) @@ -0,0 +1,28 @@ +$FreeBSD$ + +This directory contains various files derived from CDDL sources that +are used by the ZFS bootstrap: + + fletcher.c checksum support + sha256.c checksum support + lzjb.c compression support + zfssubr.c mostly checksum and compression support + zfsimpl.h mostly describing the physical layout + +The files fletcher.c, lzjb.c and sha256.c are largely identical to the +ZFS base code (with write support removed) and could be shared but +that might complicate future imports from OpenSolaris. +$FreeBSD$ + +This directory contains various files derived from CDDL sources that +are used by the ZFS bootstrap: + + fletcher.c checksum support + sha256.c checksum support + lzjb.c compression support + zfssubr.c mostly checksum and compression support + zfsimpl.h mostly describing the physical layout + +The files fletcher.c, lzjb.c and sha256.c are largely identical to the +ZFS base code (with write support removed) and could be shared but +that might complicate future imports from OpenSolaris. Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c Fri May 15 23:11:34 2009 (r192168) @@ -0,0 +1,120 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +static void +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + const uint64_t *ip = buf; + const uint64_t *ipend = ip + (size / sizeof (uint64_t)); + uint64_t a0, b0, a1, b1; + + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) { + a0 += ip[0]; + a1 += ip[1]; + b0 += a0; + b1 += a1; + } + + ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); +} + +static void +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + const uint32_t *ip = buf; + const uint32_t *ipend = ip + (size / sizeof (uint32_t)); + uint64_t a, b, c, d; + + for (a = b = c = d = 0; ip < ipend; ip++) { + a += ip[0]; + b += a; + c += b; + d += c; + } + + ZIO_SET_CHECKSUM(zcp, a, b, c, d); +} +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +static void +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + const uint64_t *ip = buf; + const uint64_t *ipend = ip + (size / sizeof (uint64_t)); + uint64_t a0, b0, a1, b1; + + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) { + a0 += ip[0]; + a1 += ip[1]; + b0 += a0; + b1 += a1; + } + + ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); +} + +static void +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + const uint32_t *ip = buf; + const uint32_t *ipend = ip + (size / sizeof (uint32_t)); + uint64_t a, b, c, d; + + for (a = b = c = d = 0; ip < ipend; ip++) { + a += ip[0]; + b += a; + c += b; + d += c; + } + + ZIO_SET_CHECKSUM(zcp, a, b, c, d); +} Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c Fri May 15 23:11:34 2009 (r192168) @@ -0,0 +1,148 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +/* + * We keep our own copy of this algorithm for 2 main reasons: + * 1. If we didn't, anyone modifying common/os/compress.c would + * directly break our on disk format + * 2. Our version of lzjb does not have a number of checks that the + * common/os version needs and uses + * In particular, we are adding the "feature" that compress() can + * take a destination buffer size and return -1 if the data will not + * compress to d_len or less. + */ + +#define MATCH_BITS 6 +#define MATCH_MIN 3 +#define MATCH_MAX ((1 << MATCH_BITS) + (MATCH_MIN - 1)) +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) +#define LEMPEL_SIZE 256 + +/*ARGSUSED*/ +static int +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) +{ + unsigned char *src = s_start; + unsigned char *dst = d_start; + unsigned char *d_end = (unsigned char *)d_start + d_len; + unsigned char *cpy, copymap = 0; + int copymask = 1 << (NBBY - 1); + + while (dst < d_end) { + if ((copymask <<= 1) == (1 << NBBY)) { + copymask = 1; + copymap = *src++; + } + if (copymap & copymask) { + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; + src += 2; + if ((cpy = dst - offset) < (unsigned char *)d_start) + return (-1); + while (--mlen >= 0 && dst < d_end) + *dst++ = *cpy++; + } else { + *dst++ = *src++; + } + } + return (0); +} +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +/* + * We keep our own copy of this algorithm for 2 main reasons: + * 1. If we didn't, anyone modifying common/os/compress.c would + * directly break our on disk format + * 2. Our version of lzjb does not have a number of checks that the + * common/os version needs and uses + * In particular, we are adding the "feature" that compress() can + * take a destination buffer size and return -1 if the data will not + * compress to d_len or less. + */ + +#define MATCH_BITS 6 +#define MATCH_MIN 3 +#define MATCH_MAX ((1 << MATCH_BITS) + (MATCH_MIN - 1)) +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) +#define LEMPEL_SIZE 256 + +/*ARGSUSED*/ +static int +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n) +{ + unsigned char *src = s_start; + unsigned char *dst = d_start; + unsigned char *d_end = (unsigned char *)d_start + d_len; + unsigned char *cpy, copymap = 0; + int copymask = 1 << (NBBY - 1); + + while (dst < d_end) { + if ((copymask <<= 1) == (1 << NBBY)) { + copymask = 1; + copymap = *src++; + } + if (copymap & copymask) { + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; + src += 2; + if ((cpy = dst - offset) < (unsigned char *)d_start) + return (-1); + while (--mlen >= 0 && dst < d_end) + *dst++ = *cpy++; + } else { + *dst++ = *src++; + } + } + return (0); +} Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c Fri May 15 23:11:34 2009 (r192168) @@ -0,0 +1,254 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +/* + * SHA-256 checksum, as specified in FIPS 180-2, available at: + * http://csrc.nist.gov/cryptval + * + * This is a very compact implementation of SHA-256. + * It is designed to be simple and portable, not to be fast. + */ + +/* + * The literal definitions according to FIPS180-2 would be: + * + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) + * + * We use logical equivalents which require one less op. + */ +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) + +static const uint32_t SHA256_K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static void +SHA256Transform(uint32_t *H, const uint8_t *cp) +{ + uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; + + for (t = 0; t < 16; t++, cp += 4) + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; + + for (t = 16; t < 64; t++) + W[t] = sigma1(W[t - 2]) + W[t - 7] + + sigma0(W[t - 15]) + W[t - 16]; + + a = H[0]; b = H[1]; c = H[2]; d = H[3]; + e = H[4]; f = H[5]; g = H[6]; h = H[7]; + + for (t = 0; t < 64; t++) { + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; + T2 = SIGMA0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + T1; + d = c; c = b; b = a; a = T1 + T2; + } + + H[0] += a; H[1] += b; H[2] += c; H[3] += d; + H[4] += e; H[5] += f; H[6] += g; H[7] += h; +} + +static void +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + uint8_t pad[128]; + int padsize = size & 63; + int i; + + for (i = 0; i < size - padsize; i += 64) + SHA256Transform(H, (uint8_t *)buf + i); + + for (i = 0; i < padsize; i++) + pad[i] = ((uint8_t *)buf)[i]; + + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) + pad[padsize] = 0; + + for (i = 0; i < 8; i++) + pad[padsize++] = (size << 3) >> (56 - 8 * i); + + for (i = 0; i < padsize; i += 64) + SHA256Transform(H, pad + i); + + ZIO_SET_CHECKSUM(zcp, + (uint64_t)H[0] << 32 | H[1], + (uint64_t)H[2] << 32 | H[3], + (uint64_t)H[4] << 32 | H[5], + (uint64_t)H[6] << 32 | H[7]); +} +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ + +/* + * SHA-256 checksum, as specified in FIPS 180-2, available at: + * http://csrc.nist.gov/cryptval + * + * This is a very compact implementation of SHA-256. + * It is designed to be simple and portable, not to be fast. + */ + +/* + * The literal definitions according to FIPS180-2 would be: + * + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) + * + * We use logical equivalents which require one less op. + */ +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) + +static const uint32_t SHA256_K[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +}; + +static void +SHA256Transform(uint32_t *H, const uint8_t *cp) +{ + uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; + + for (t = 0; t < 16; t++, cp += 4) + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; + + for (t = 16; t < 64; t++) + W[t] = sigma1(W[t - 2]) + W[t - 7] + + sigma0(W[t - 15]) + W[t - 16]; + + a = H[0]; b = H[1]; c = H[2]; d = H[3]; + e = H[4]; f = H[5]; g = H[6]; h = H[7]; + + for (t = 0; t < 64; t++) { + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; + T2 = SIGMA0(a) + Maj(a, b, c); + h = g; g = f; f = e; e = d + T1; + d = c; c = b; b = a; a = T1 + T2; + } + + H[0] += a; H[1] += b; H[2] += c; H[3] += d; + H[4] += e; H[5] += f; H[6] += g; H[7] += h; +} + +static void +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) +{ + uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; + uint8_t pad[128]; + int padsize = size & 63; + int i; + + for (i = 0; i < size - padsize; i += 64) + SHA256Transform(H, (uint8_t *)buf + i); + + for (i = 0; i < padsize; i++) + pad[i] = ((uint8_t *)buf)[i]; + + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) + pad[padsize] = 0; + + for (i = 0; i < 8; i++) + pad[padsize++] = (size << 3) >> (56 - 8 * i); + + for (i = 0; i < padsize; i += 64) + SHA256Transform(H, pad + i); + + ZIO_SET_CHECKSUM(zcp, + (uint64_t)H[0] << 32 | H[1], + (uint64_t)H[2] << 32 | H[3], + (uint64_t)H[4] << 32 | H[5], + (uint64_t)H[6] << 32 | H[7]); +} Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h Fri May 15 23:11:34 2009 (r192168) @@ -0,0 +1,2340 @@ +/*- + * Copyright (c) 2002 McAfee, Inc. + * All rights reserved. + * + * This software was developed for the FreeBSD Project by Marshall + * Kirk McKusick and McAfee Research,, the Security Research Division of + * McAfee, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as + * part of the DARPA CHATS research program + * + * 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. + */ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* CRC64 table */ +#define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected form */ + +/* + * Macros for various sorts of alignment and rounding when the alignment + * is known to be a power of 2. + */ +#define P2ALIGN(x, align) ((x) & -(align)) +#define P2PHASE(x, align) ((x) & ((align) - 1)) +#define P2NPHASE(x, align) (-(x) & ((align) - 1)) +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) +#define P2END(x, align) (-(~(x) & -(align))) +#define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align))) +#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) + +/* + * General-purpose 32-bit and 64-bit bitfield encodings. + */ +#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len)) +#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len)) +#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low)) +#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << (low)) + +#define BF32_GET(x, low, len) BF32_DECODE(x, low, len) +#define BF64_GET(x, low, len) BF64_DECODE(x, low, len) + +#define BF32_SET(x, low, len, val) \ + ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len)) +#define BF64_SET(x, low, len, val) \ + ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)) + +#define BF32_GET_SB(x, low, len, shift, bias) \ + ((BF32_GET(x, low, len) + (bias)) << (shift)) +#define BF64_GET_SB(x, low, len, shift, bias) \ + ((BF64_GET(x, low, len) + (bias)) << (shift)) + +#define BF32_SET_SB(x, low, len, shift, bias, val) \ + BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) +#define BF64_SET_SB(x, low, len, shift, bias, val) \ + BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) + +/* + * We currently support nine block sizes, from 512 bytes to 128K. + * We could go higher, but the benefits are near-zero and the cost + * of COWing a giant block to modify one byte would become excessive. + */ +#define SPA_MINBLOCKSHIFT 9 +#define SPA_MAXBLOCKSHIFT 17 +#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) +#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) + +#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1) + +/* + * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB. + * The ASIZE encoding should be at least 64 times larger (6 more bits) + * to support up to 4-way RAID-Z mirror mode with worst-case gang block + * overhead, three DVAs per bp, plus one more bit in case we do anything + * else that expands the ASIZE. + */ +#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */ +#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */ +#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */ + +/* + * All SPA data is represented by 128-bit data virtual addresses (DVAs). + * The members of the dva_t should be considered opaque outside the SPA. + */ +typedef struct dva { + uint64_t dva_word[2]; +} dva_t; + +/* + * Each block has a 256-bit checksum -- strong enough for cryptographic hashes. + */ +typedef struct zio_cksum { + uint64_t zc_word[4]; +} zio_cksum_t; + +/* + * Each block is described by its DVAs, time of birth, checksum, etc. + * The word-by-word, bit-by-bit layout of the blkptr is as follows: + * + * 64 56 48 40 32 24 16 8 0 + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 0 | vdev1 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 1 |G| offset1 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 2 | vdev2 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 3 |G| offset2 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 4 | vdev3 | GRID | ASIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 5 |G| offset3 | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 7 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 8 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * 9 | padding | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * a | birth txg | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * b | fill count | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * c | checksum[0] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * d | checksum[1] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * e | checksum[2] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * f | checksum[3] | + * +-------+-------+-------+-------+-------+-------+-------+-------+ + * + * Legend: + * + * vdev virtual device ID + * offset offset into virtual device + * LSIZE logical size + * PSIZE physical size (after compression) + * ASIZE allocated size (including RAID-Z parity and gang block headers) + * GRID RAID-Z layout information (reserved for future use) + * cksum checksum function + * comp compression function + * G gang block indicator + * E endianness + * type DMU object type + * lvl level of indirection + * birth txg transaction group in which the block was born + * fill count number of non-zero blocks under this bp + * checksum[4] 256-bit checksum of the data this bp describes + */ +typedef struct blkptr { + dva_t blk_dva[3]; /* 128-bit Data Virtual Address */ + uint64_t blk_prop; /* size, compression, type, etc */ + uint64_t blk_pad[3]; /* Extra space for the future */ + uint64_t blk_birth; /* transaction group at birth */ + uint64_t blk_fill; /* fill count */ + zio_cksum_t blk_cksum; /* 256-bit checksum */ +} blkptr_t; + +#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */ +#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */ + +/* + * Macros to get and set fields in a bp or DVA. + */ +#define DVA_GET_ASIZE(dva) \ + BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0) +#define DVA_SET_ASIZE(dva, x) \ + BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x) + +#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8) +#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x) + +#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32) +#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x) + +#define DVA_GET_OFFSET(dva) \ + BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0) +#define DVA_SET_OFFSET(dva, x) \ + BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x) + +#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1) +#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x) + +#define BP_GET_LSIZE(bp) \ + (BP_IS_HOLE(bp) ? 0 : \ + BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)) +#define BP_SET_LSIZE(bp, x) \ + BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) + +#define BP_GET_PSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1) +#define BP_SET_PSIZE(bp, x) \ + BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x) + +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) + +#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) +#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) + +#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8) +#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x) + +#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) +#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) + +#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1)) +#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x) + +#define BP_GET_ASIZE(bp) \ + (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_GET_UCSIZE(bp) \ + ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \ + BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); + +#define BP_GET_NDVAS(bp) \ + (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ + !!DVA_GET_ASIZE(&(bp)->blk_dva[2])) + +#define BP_COUNT_GANG(bp) \ + (DVA_GET_GANG(&(bp)->blk_dva[0]) + \ + DVA_GET_GANG(&(bp)->blk_dva[1]) + \ + DVA_GET_GANG(&(bp)->blk_dva[2])) + +#define DVA_EQUAL(dva1, dva2) \ + ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \ + (dva1)->dva_word[0] == (dva2)->dva_word[0]) + +#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \ + (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ + ((zc1).zc_word[1] - (zc2).zc_word[1]) | \ + ((zc1).zc_word[2] - (zc2).zc_word[2]) | \ + ((zc1).zc_word[3] - (zc2).zc_word[3]))) + + +#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0) + +#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \ +{ \ + (zcp)->zc_word[0] = w0; \ + (zcp)->zc_word[1] = w1; \ + (zcp)->zc_word[2] = w2; \ + (zcp)->zc_word[3] = w3; \ +} + +#define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) +#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) +#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) +#define BP_IS_OLDER(bp, txg) (!BP_IS_HOLE(bp) && (bp)->blk_birth < (txg)) + +#define BP_ZERO(bp) \ +{ \ + (bp)->blk_dva[0].dva_word[0] = 0; \ + (bp)->blk_dva[0].dva_word[1] = 0; \ + (bp)->blk_dva[1].dva_word[0] = 0; \ + (bp)->blk_dva[1].dva_word[1] = 0; \ + (bp)->blk_dva[2].dva_word[0] = 0; \ + (bp)->blk_dva[2].dva_word[1] = 0; \ + (bp)->blk_prop = 0; \ + (bp)->blk_pad[0] = 0; \ + (bp)->blk_pad[1] = 0; \ + (bp)->blk_pad[2] = 0; \ + (bp)->blk_birth = 0; \ + (bp)->blk_fill = 0; \ + ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ +} + +#define ZBT_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ + +typedef struct zio_block_tail { + uint64_t zbt_magic; /* for validation, endianness */ + zio_cksum_t zbt_cksum; /* 256-bit checksum */ +} zio_block_tail_t; + +#define VDEV_SKIP_SIZE (8 << 10) +#define VDEV_BOOT_HEADER_SIZE (8 << 10) +#define VDEV_PHYS_SIZE (112 << 10) +#define VDEV_UBERBLOCK_RING (128 << 10) + +#define VDEV_UBERBLOCK_SHIFT(vd) \ + MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT) +#define VDEV_UBERBLOCK_COUNT(vd) \ + (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd)) +#define VDEV_UBERBLOCK_OFFSET(vd, n) \ + offsetof(vdev_label_t, vl_uberblock[(n) << VDEV_UBERBLOCK_SHIFT(vd)]) +#define VDEV_UBERBLOCK_SIZE(vd) (1ULL << VDEV_UBERBLOCK_SHIFT(vd)) + +/* ZFS boot block */ +#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL +#define VDEV_BOOT_VERSION 1 /* version number */ + +typedef struct vdev_boot_header { + uint64_t vb_magic; /* VDEV_BOOT_MAGIC */ + uint64_t vb_version; /* VDEV_BOOT_VERSION */ + uint64_t vb_offset; /* start offset (bytes) */ + uint64_t vb_size; /* size (bytes) */ + char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (uint64_t)]; +} vdev_boot_header_t; + +typedef struct vdev_phys { + char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_block_tail_t)]; + zio_block_tail_t vp_zbt; +} vdev_phys_t; + +typedef struct vdev_label { + char vl_pad[VDEV_SKIP_SIZE]; /* 8K */ + vdev_boot_header_t vl_boot_header; /* 8K */ + vdev_phys_t vl_vdev_phys; /* 112K */ + char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */ +} vdev_label_t; /* 256K total */ + +/* + * vdev_dirty() flags + */ +#define VDD_METASLAB 0x01 +#define VDD_DTL 0x02 + +/* + * Size and offset of embedded boot loader region on each label. + * The total size of the first two labels plus the boot area is 4MB. + */ +#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t)) +#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */ + +/* + * Size of label regions at the start and end of each leaf device. + */ +#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE) +#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t)) +#define VDEV_LABELS 4 + +enum zio_checksum { + ZIO_CHECKSUM_INHERIT = 0, + ZIO_CHECKSUM_ON, + ZIO_CHECKSUM_OFF, + ZIO_CHECKSUM_LABEL, + ZIO_CHECKSUM_GANG_HEADER, + ZIO_CHECKSUM_ZILOG, + ZIO_CHECKSUM_FLETCHER_2, + ZIO_CHECKSUM_FLETCHER_4, + ZIO_CHECKSUM_SHA256, + ZIO_CHECKSUM_FUNCTIONS +}; + +#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 +#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON + +enum zio_compress { + ZIO_COMPRESS_INHERIT = 0, + ZIO_COMPRESS_ON, + ZIO_COMPRESS_OFF, + ZIO_COMPRESS_LZJB, + ZIO_COMPRESS_EMPTY, + ZIO_COMPRESS_GZIP_1, + ZIO_COMPRESS_GZIP_2, + ZIO_COMPRESS_GZIP_3, + ZIO_COMPRESS_GZIP_4, + ZIO_COMPRESS_GZIP_5, + ZIO_COMPRESS_GZIP_6, + ZIO_COMPRESS_GZIP_7, + ZIO_COMPRESS_GZIP_8, + ZIO_COMPRESS_GZIP_9, + ZIO_COMPRESS_FUNCTIONS +}; + +#define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB +#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF + +/* nvlist pack encoding */ +#define NV_ENCODE_NATIVE 0 +#define NV_ENCODE_XDR 1 + +typedef enum { + DATA_TYPE_UNKNOWN = 0, + DATA_TYPE_BOOLEAN, + DATA_TYPE_BYTE, + DATA_TYPE_INT16, + DATA_TYPE_UINT16, + DATA_TYPE_INT32, + DATA_TYPE_UINT32, + DATA_TYPE_INT64, + DATA_TYPE_UINT64, + DATA_TYPE_STRING, + DATA_TYPE_BYTE_ARRAY, + DATA_TYPE_INT16_ARRAY, + DATA_TYPE_UINT16_ARRAY, + DATA_TYPE_INT32_ARRAY, + DATA_TYPE_UINT32_ARRAY, + DATA_TYPE_INT64_ARRAY, + DATA_TYPE_UINT64_ARRAY, *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:14:07 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D2331065672; Fri, 15 May 2009 23:14:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 569098FC08; Fri, 15 May 2009 23:14:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNE5fD037580; Fri, 15 May 2009 23:14:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNE5vd037570; Fri, 15 May 2009 23:14:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152314.n4FNE5vd037570@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:14:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192169 - in user/kmacy/ZFS_MFC: cddl cddl/compat/opensolaris/include cddl/compat/opensolaris/misc cddl/contrib/opensolaris/cmd/zdb cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensol... X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:14:07 -0000 Author: kmacy Date: Fri May 15 23:14:05 2009 New Revision: 192169 URL: http://svn.freebsd.org/changeset/base/192169 Log: MFC ZFS version 13 to RELENG_7 Added: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/libshare.h (contents, props changed) user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zinject/ user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zinject/translate.c (contents, props changed) user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zinject/zinject.c (contents, props changed) user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zinject/zinject.h (contents, props changed) user/kmacy/ZFS_MFC/cddl/usr.bin/zinject/ user/kmacy/ZFS_MFC/cddl/usr.bin/zinject/Makefile (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/file.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kidmap.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/pathname.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/refstr.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/sid.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/sig.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_deleg.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zprop_common.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_deleg2.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scrub2.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_deleg.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/rrwlock.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_boot.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_fuid.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fuid2.c (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/acl.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/acl_impl.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/extdirent.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/idmap.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h (contents, props changed) user/kmacy/ZFS_MFC/sys/libkern/memmove.c (contents, props changed) Deleted: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/acl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/vfs.h Modified: user/kmacy/ZFS_MFC/cddl/Makefile.inc user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/mnttab.h user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/deviceid.c user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/mnttab.c user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zmount.c user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zone.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.8 user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zfs/zfs.8 user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zfs/zfs_iter.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool.8 user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool_util.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/ztest/ztest.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/head/assert.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/head/libintl.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/head/synch.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/head/thread.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/libuutil.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/libuutil_common.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/uu_alloc.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/uu_avl.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/uu_dprintf.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libuutil/common/uu_list.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_graph.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/kernel.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/taskq.c user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzpool/common/util.c user/kmacy/ZFS_MFC/cddl/lib/Makefile user/kmacy/ZFS_MFC/cddl/lib/libnvpair/Makefile user/kmacy/ZFS_MFC/cddl/lib/libzfs/Makefile user/kmacy/ZFS_MFC/cddl/lib/libzpool/Makefile user/kmacy/ZFS_MFC/cddl/sbin/zpool/Makefile user/kmacy/ZFS_MFC/cddl/usr.bin/Makefile user/kmacy/ZFS_MFC/cddl/usr.bin/ztest/Makefile user/kmacy/ZFS_MFC/cddl/usr.sbin/Makefile user/kmacy/ZFS_MFC/cddl/usr.sbin/zdb/Makefile user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_kmem.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_misc.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/rpc/xdr.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/atomic.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/cpuvar.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/cred.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/dnlc.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/kmem.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/lock.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/misc.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/mntent.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/param.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/policy.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/proc.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/sunddi.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/sysmacros.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/time.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/types.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/uio.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/vfs.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/vnode.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/zone.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/acl/acl_common.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/acl/acl_common.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/avl/avl.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/zfs/zfs_prop.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/Makefile.files user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/bplist.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_object.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dnode_sync.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_prop.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/refcount.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sha256.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_errlog.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/space_map.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/bplist.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dbuf.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_objset.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_traverse.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dmu_tx.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dnode.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dataset.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_dir.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_pool.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_prop.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/dsl_synctask.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/metaslab.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/txg_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/uberblock_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/unique.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_disk.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zap_leaf.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_acl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ctldir.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_dir.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_ioctl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_vfsops.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_checksum.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zvol.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/txg.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/unique.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_disk.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_file.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_missing.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_root.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_leaf.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zap_micro.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_byteswap.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ctldir.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_fm.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_checksum.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio_inject.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/os/callb.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/os/list.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/os/taskq.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/byteorder.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/callb.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/cpuvar.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/cred.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/dkio.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/dklabel.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/fm/fs/zfs.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/fm/protocol.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/fm/util.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/gfs.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/isa_defs.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/list.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/nvpair.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/processor.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/synch.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/sys/sysmacros.h user/kmacy/ZFS_MFC/sys/compat/linprocfs/linprocfs.c user/kmacy/ZFS_MFC/sys/conf/files user/kmacy/ZFS_MFC/sys/fs/coda/coda_vfsops.c user/kmacy/ZFS_MFC/sys/fs/msdosfs/msdosfs_vfsops.c user/kmacy/ZFS_MFC/sys/fs/nullfs/null_vfsops.c user/kmacy/ZFS_MFC/sys/fs/unionfs/union_vfsops.c user/kmacy/ZFS_MFC/sys/kern/kern_environment.c user/kmacy/ZFS_MFC/sys/kern/kern_jail.c user/kmacy/ZFS_MFC/sys/kern/vfs_acl.c user/kmacy/ZFS_MFC/sys/kern/vfs_extattr.c user/kmacy/ZFS_MFC/sys/kern/vfs_lookup.c user/kmacy/ZFS_MFC/sys/kern/vfs_mount.c user/kmacy/ZFS_MFC/sys/kern/vfs_subr.c user/kmacy/ZFS_MFC/sys/modules/opensolaris/Makefile user/kmacy/ZFS_MFC/sys/modules/zfs/Makefile user/kmacy/ZFS_MFC/sys/security/mac/mac_syscalls.c user/kmacy/ZFS_MFC/sys/sys/_types.h user/kmacy/ZFS_MFC/sys/sys/conf.h user/kmacy/ZFS_MFC/sys/sys/fcntl.h user/kmacy/ZFS_MFC/sys/sys/jail.h user/kmacy/ZFS_MFC/sys/sys/kernel.h user/kmacy/ZFS_MFC/sys/sys/mount.h user/kmacy/ZFS_MFC/sys/sys/namei.h user/kmacy/ZFS_MFC/sys/sys/sysctl.h user/kmacy/ZFS_MFC/sys/sys/systm.h user/kmacy/ZFS_MFC/sys/sys/types.h user/kmacy/ZFS_MFC/sys/sys/vnode.h user/kmacy/ZFS_MFC/sys/ufs/ffs/ffs_snapshot.c Modified: user/kmacy/ZFS_MFC/cddl/Makefile.inc ============================================================================== --- user/kmacy/ZFS_MFC/cddl/Makefile.inc Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/Makefile.inc Fri May 15 23:14:05 2009 (r192169) @@ -6,3 +6,5 @@ OPENSOLARIS_SYS_DISTDIR= ${.CURDIR}/../. IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN + +CSTD?= gnu89 Added: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/libshare.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/libshare.h Fri May 15 23:14:05 2009 (r192169) @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 2007 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_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 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_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 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_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ +/*- + * Copyright (c) 2007 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_LIBSHARE_H_ +#define _OPENSOLARIS_LIBSHARE_H_ + +#define SA_OK 0 + +#define SA_INIT_CONTROL_API 0 + +#endif /* !_OPENSOLARIS_LIBSHARE_H_ */ Modified: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/mnttab.h ============================================================================== --- user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/mnttab.h Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/include/mnttab.h Fri May 15 23:14:05 2009 (r192169) @@ -9,6 +9,8 @@ #define MNTTAB _PATH_DEVNULL #define MNT_LINE_MAX 1024 +#define umount2(p, f) unmount(p, f) + struct mnttab { char *mnt_special; char *mnt_mountp; Modified: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/deviceid.c ============================================================================== --- user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/deviceid.c Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/deviceid.c Fri May 15 23:14:05 2009 (r192169) @@ -94,11 +94,7 @@ int devid_get(int fd, ddi_devid_t *retdevid) { - if (ioctl(fd, DIOCGIDENT, retdevid->devid) == -1) - return (errno); - if (retdevid->devid[0] == '\0') - return (ENOENT); - return (0); + return (ENOENT); } int Modified: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/mnttab.c ============================================================================== --- user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/mnttab.c Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/mnttab.c Fri May 15 23:14:05 2009 (r192169) @@ -37,6 +37,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include static char * mntopt(char **p) Modified: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zmount.c ============================================================================== --- user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zmount.c Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zmount.c Fri May 15 23:14:05 2009 (r192169) @@ -35,9 +35,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include -#include +#include static void build_iovec(struct iovec **iov, int *iovlen, const char *name, void *val, @@ -86,7 +87,7 @@ zmount(const char *spec, const char *dir assert(optlen > 0); optstr = strdup(optptr); - assert(optptr != NULL); + assert(optstr != NULL); iov = NULL; iovlen = 0; Modified: user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zone.c ============================================================================== --- user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zone.c Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/compat/opensolaris/misc/zone.c Fri May 15 23:14:05 2009 (r192169) @@ -32,7 +32,7 @@ #include #include -int +zoneid_t getzoneid(void) { size_t size; @@ -42,5 +42,5 @@ getzoneid(void) size = sizeof(jailid); if (sysctlbyname("security.jail.jailed", &jailid, &size, NULL, 0) == -1) assert(!"No security.jail.jailed sysctl!"); - return (jailid); + return ((zoneid_t)jailid); } Modified: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Fri May 15 23:14:05 2009 (r192169) @@ -28,13 +28,18 @@ zdb \- ZFS debugger .fi .SH DESCRIPTION +.sp .LP The \fBzdb\fR command is used by support engineers to diagnose failures and gather statistics. Since the \fBZFS\fR file system is always consistent on disk and is self-repairing, \fBzdb\fR should only be run under the direction by a support engineer. +.sp .LP If no arguments are specified, \fBzdb\fR, performs basic consistency checks on the pool and associated datasets, and report any problems detected. +.sp .LP Any options supported by this command are internal to Sun and subject to change at any time. .SH EXIT STATUS + +.sp .LP The following exit values are returned: .sp @@ -71,6 +76,9 @@ Invalid command line options were specif .RE .SH ATTRIBUTES + +.sp + .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp @@ -89,5 +97,6 @@ Interface StabilityUnstable .TE .SH SEE ALSO +.sp .LP \fBzfs\fR(1M), \fBzpool\fR(1M), \fBattributes\fR(5) Modified: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri May 15 23:11:34 2009 (r192168) +++ user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/cmd/zdb/zdb.c Fri May 15 23:14:05 2009 (r192169) @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include #include #include @@ -51,6 +49,10 @@ #include #include #include +#include +#undef ZFS_MAXNAMELEN +#undef verify +#include const char cmdname[] = "zdb"; uint8_t dump_opt[256]; @@ -62,6 +64,9 @@ uint64_t *zopt_object = NULL; int zopt_objects = 0; int zdb_advance = ADVANCE_PRE; zbookmark_t zdb_noread = { 0, 0, ZB_NO_LEVEL, 0 }; +libzfs_handle_t *g_zfs; +boolean_t zdb_sig_user_data = B_TRUE; +int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; /* * These libumem hooks provide a reasonable set of defaults for the allocator's @@ -83,12 +88,15 @@ static void usage(void) { (void) fprintf(stderr, - "Usage: %s [-udibcsvLU] [-O order] [-B os:obj:level:blkid] " + "Usage: %s [-udibcsvL] [-U cachefile_path] [-O order] " + "[-B os:obj:level:blkid] [-S user:cksumalg] " "dataset [object...]\n" " %s -C [pool]\n" " %s -l dev\n" - " %s -R vdev:offset:size:flags\n", - cmdname, cmdname, cmdname, cmdname); + " %s -R pool:vdev:offset:size:flags\n" + " %s [-p path_to_vdev_dir]\n" + " %s -e pool | GUID | devid ...\n", + cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); (void) fprintf(stderr, " -u uberblock\n"); (void) fprintf(stderr, " -d datasets\n"); @@ -97,16 +105,22 @@ usage(void) (void) fprintf(stderr, " -b block statistics\n"); (void) fprintf(stderr, " -c checksum all data blocks\n"); (void) fprintf(stderr, " -s report stats on zdb's I/O\n"); + (void) fprintf(stderr, " -S : -- " + "dump blkptr signatures\n"); (void) fprintf(stderr, " -v verbose (applies to all others)\n"); (void) fprintf(stderr, " -l dump label contents\n"); (void) fprintf(stderr, " -L live pool (allows some errors)\n"); (void) fprintf(stderr, " -O [!] " "visitation order\n"); - (void) fprintf(stderr, " -U use zpool.cache in /tmp\n"); + (void) fprintf(stderr, " -U cachefile_path -- use alternate " + "cachefile\n"); (void) fprintf(stderr, " -B objset:object:level:blkid -- " "simulate bad block\n"); - (void) fprintf(stderr, " -R read and display block from a" + (void) fprintf(stderr, " -R read and display block from a " "device\n"); + (void) fprintf(stderr, " -e Pool is exported/destroyed/" + "has altroot\n"); + (void) fprintf(stderr, " -p (use with -e)\n"); (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " "to make only that option verbose\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); @@ -367,6 +381,44 @@ dump_zap(objset_t *os, uint64_t object, zap_cursor_fini(&zc); } +/*ARGSUSED*/ +static void +dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) +{ + zap_cursor_t zc; + zap_attribute_t attr; + const char *typenames[] = { + /* 0 */ "not specified", + /* 1 */ "FIFO", + /* 2 */ "Character Device", + /* 3 */ "3 (invalid)", + /* 4 */ "Directory", + /* 5 */ "5 (invalid)", + /* 6 */ "Block Device", + /* 7 */ "7 (invalid)", + /* 8 */ "Regular File", + /* 9 */ "9 (invalid)", + /* 10 */ "Symbolic Link", + /* 11 */ "11 (invalid)", + /* 12 */ "Socket", + /* 13 */ "Door", + /* 14 */ "Event Port", + /* 15 */ "15 (invalid)", + }; + + dump_zap_stats(os, object); + (void) printf("\n"); + + for (zap_cursor_init(&zc, os, object); + zap_cursor_retrieve(&zc, &attr) == 0; + zap_cursor_advance(&zc)) { + (void) printf("\t\t%s = %lld (type: %s)\n", + attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer), + typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]); + } + zap_cursor_fini(&zc); +} + static void dump_spacemap(objset_t *os, space_map_obj_t *smo, space_map_t *sm) { @@ -456,10 +508,7 @@ dump_metaslabs(spa_t *spa) for (c = 0; c < rvd->vdev_children; c++) { vd = rvd->vdev_child[c]; - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\n vdev %llu = %s\n\n", - (u_longlong_t)vd->vdev_id, vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\n vdev %llu\n\n", (u_longlong_t)vd->vdev_id); if (dump_opt['d'] <= 5) { (void) printf("\t%10s %10s %5s\n", @@ -477,7 +526,6 @@ static void dump_dtl(vdev_t *vd, int indent) { avl_tree_t *t = &vd->vdev_dtl_map.sm_root; - spa_t *spa = vd->vdev_spa; space_seg_t *ss; vdev_t *pvd; int c; @@ -485,9 +533,10 @@ dump_dtl(vdev_t *vd, int indent) if (indent == 0) (void) printf("\nDirty time logs:\n\n"); - spa_config_enter(spa, RW_READER, FTAG); - (void) printf("\t%*s%s\n", indent, "", vdev_description(vd)); - spa_config_exit(spa, FTAG); + (void) printf("\t%*s%s\n", indent, "", + vd->vdev_path ? vd->vdev_path : + vd->vdev_parent ? vd->vdev_ops->vdev_op_type : + spa_name(vd->vdev_spa)); for (ss = avl_first(t); ss; ss = AVL_NEXT(t, ss)) { /* @@ -670,36 +719,49 @@ dump_dsl_dir(objset_t *os, uint64_t obje { dsl_dir_phys_t *dd = data; time_t crtime; - char used[6], compressed[6], uncompressed[6], quota[6], resv[6]; + char nice[6]; if (dd == NULL) return; - ASSERT(size == sizeof (*dd)); + ASSERT3U(size, >=, sizeof (dsl_dir_phys_t)); crtime = dd->dd_creation_time; - nicenum(dd->dd_used_bytes, used); - nicenum(dd->dd_compressed_bytes, compressed); - nicenum(dd->dd_uncompressed_bytes, uncompressed); - nicenum(dd->dd_quota, quota); - nicenum(dd->dd_reserved, resv); - (void) printf("\t\tcreation_time = %s", ctime(&crtime)); (void) printf("\t\thead_dataset_obj = %llu\n", (u_longlong_t)dd->dd_head_dataset_obj); (void) printf("\t\tparent_dir_obj = %llu\n", (u_longlong_t)dd->dd_parent_obj); - (void) printf("\t\tclone_parent_obj = %llu\n", - (u_longlong_t)dd->dd_clone_parent_obj); + (void) printf("\t\torigin_obj = %llu\n", + (u_longlong_t)dd->dd_origin_obj); (void) printf("\t\tchild_dir_zapobj = %llu\n", (u_longlong_t)dd->dd_child_dir_zapobj); - (void) printf("\t\tused_bytes = %s\n", used); - (void) printf("\t\tcompressed_bytes = %s\n", compressed); - (void) printf("\t\tuncompressed_bytes = %s\n", uncompressed); - (void) printf("\t\tquota = %s\n", quota); - (void) printf("\t\treserved = %s\n", resv); + nicenum(dd->dd_used_bytes, nice); + (void) printf("\t\tused_bytes = %s\n", nice); + nicenum(dd->dd_compressed_bytes, nice); + (void) printf("\t\tcompressed_bytes = %s\n", nice); + nicenum(dd->dd_uncompressed_bytes, nice); + (void) printf("\t\tuncompressed_bytes = %s\n", nice); + nicenum(dd->dd_quota, nice); + (void) printf("\t\tquota = %s\n", nice); + nicenum(dd->dd_reserved, nice); + (void) printf("\t\treserved = %s\n", nice); (void) printf("\t\tprops_zapobj = %llu\n", (u_longlong_t)dd->dd_props_zapobj); + (void) printf("\t\tdeleg_zapobj = %llu\n", + (u_longlong_t)dd->dd_deleg_zapobj); + (void) printf("\t\tflags = %llx\n", + (u_longlong_t)dd->dd_flags); + +#define DO(which) \ + nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \ + (void) printf("\t\tused_breakdown[" #which "] = %s\n", nice) + DO(HEAD); + DO(SNAP); + DO(CHILD); + DO(CHILD_RSRV); + DO(REFRSRV); +#undef DO } /*ARGSUSED*/ @@ -722,7 +784,7 @@ dump_dsl_dataset(objset_t *os, uint64_t nicenum(ds->ds_unique_bytes, unique); sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &ds->ds_bp); - (void) printf("\t\tdataset_obj = %llu\n", + (void) printf("\t\tdir_obj = %llu\n", (u_longlong_t)ds->ds_dir_obj); (void) printf("\t\tprev_snap_obj = %llu\n", (u_longlong_t)ds->ds_prev_snap_obj); @@ -749,6 +811,10 @@ dump_dsl_dataset(objset_t *os, uint64_t (u_longlong_t)ds->ds_guid); (void) printf("\t\tflags = %llx\n", (u_longlong_t)ds->ds_flags); + (void) printf("\t\tnext_clones_obj = %llu\n", + (u_longlong_t)ds->ds_next_clones_obj); + (void) printf("\t\tprops_obj = %llu\n", + (u_longlong_t)ds->ds_props_obj); (void) printf("\t\tbp = %s\n", blkbuf); } @@ -765,9 +831,11 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 3) return; + mutex_init(&bpl.bpl_lock, NULL, MUTEX_DEFAULT, NULL); VERIFY(0 == bplist_open(&bpl, mos, object)); if (bplist_empty(&bpl)) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -785,6 +853,7 @@ dump_bplist(objset_t *mos, uint64_t obje if (dump_opt['d'] < 5) { bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); return; } @@ -800,6 +869,65 @@ dump_bplist(objset_t *mos, uint64_t obje } bplist_close(&bpl); + mutex_destroy(&bpl.bpl_lock); +} + +static avl_tree_t idx_tree; +static avl_tree_t domain_tree; +static boolean_t fuid_table_loaded; + +static void +fuid_table_destroy() +{ + if (fuid_table_loaded) { + zfs_fuid_table_destroy(&idx_tree, &domain_tree); + fuid_table_loaded = B_FALSE; + } +} + +/* + * print uid or gid information. + * For normal POSIX id just the id is printed in decimal format. + * For CIFS files with FUID the fuid is printed in hex followed by + * the doman-rid string. + */ +static void +print_idstr(uint64_t id, const char *id_type) +{ + if (FUID_INDEX(id)) { + char *domain; + + domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); + (void) printf("\t%s %llx [%s-%d]\n", id_type, + (u_longlong_t)id, domain, (int)FUID_RID(id)); + } else { + (void) printf("\t%s %llu\n", id_type, (u_longlong_t)id); + } + +} + +static void +dump_uidgid(objset_t *os, znode_phys_t *zp) +{ + uint32_t uid_idx, gid_idx; + + uid_idx = FUID_INDEX(zp->zp_uid); + gid_idx = FUID_INDEX(zp->zp_gid); + + /* Load domain table, if not already loaded */ + if (!fuid_table_loaded && (uid_idx || gid_idx)) { + uint64_t fuid_obj; + + /* first find the fuid object. It lives in the master node */ + VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES, + 8, 1, &fuid_obj) == 0); + (void) zfs_fuid_table_load(os, fuid_obj, + &idx_tree, &domain_tree); + fuid_table_loaded = B_TRUE; + } + + print_idstr(zp->zp_uid, "uid"); + print_idstr(zp->zp_gid, "gid"); } /*ARGSUSED*/ @@ -830,6 +958,7 @@ dump_znode(objset_t *os, uint64_t object z_ctime = (time_t)zp->zp_ctime[0]; (void) printf("\tpath %s\n", path); + dump_uidgid(os, zp); (void) printf("\tatime %s", ctime(&z_atime)); (void) printf("\tmtime %s", ctime(&z_mtime)); (void) printf("\tctime %s", ctime(&z_ctime)); @@ -874,9 +1003,9 @@ static object_viewer_t *object_viewer[DM dump_zap, /* DSL props */ dump_dsl_dataset, /* DSL dataset */ dump_znode, /* ZFS znode */ - dump_acl, /* ZFS ACL */ + dump_acl, /* ZFS V0 ACL */ dump_uint8, /* ZFS plain file */ - dump_zap, /* ZFS directory */ + dump_zpldir, /* ZFS directory */ dump_zap, /* ZFS master node */ dump_zap, /* ZFS delete queue */ dump_uint8, /* zvol object */ @@ -888,6 +1017,13 @@ static object_viewer_t *object_viewer[DM dump_uint8, /* SPA history */ dump_uint64, /* SPA history offsets */ dump_zap, /* Pool properties */ + dump_zap, /* DSL permissions */ + dump_acl, /* ZFS ACL */ + dump_uint8, /* ZFS SYSACL */ + dump_none, /* FUID nvlist */ + dump_packed_nvlist, /* FUID nvlist size */ + dump_zap, /* DSL dataset next clones */ + dump_zap, /* DSL scrub queue */ }; static void @@ -930,13 +1066,15 @@ dump_object(objset_t *os, uint64_t objec aux[0] = '\0'; - if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) + if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)", zio_checksum_table[doi.doi_checksum].ci_name); + } - if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) + if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) { (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)", zio_compress_table[doi.doi_compress].ci_name); + } (void) printf("%10lld %3u %5s %5s %5s %5s %s%s\n", (u_longlong_t)object, doi.doi_indirection, iblk, dblk, lsize, @@ -972,13 +1110,13 @@ dump_object(objset_t *os, uint64_t objec } for (;;) { - error = dnode_next_offset(dn, B_FALSE, &start, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + 0, &start, minlvl, blkfill, 0); if (error) break; end = start; - error = dnode_next_offset(dn, B_TRUE, &end, minlvl, - blkfill, 0); + error = dnode_next_offset(dn, + DNODE_FIND_HOLE, &end, minlvl, blkfill, 0); nicenum(end - start, segsize); (void) printf("\t\tsegment [%016llx, %016llx)" " size %5s\n", (u_longlong_t)start, @@ -996,7 +1134,6 @@ dump_object(objset_t *os, uint64_t objec static char *objset_types[DMU_OST_NUMTYPES] = { "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; -/*ARGSUSED*/ static void dump_dir(objset_t *os) { @@ -1019,8 +1156,8 @@ dump_dir(objset_t *os) if (dds.dds_type == DMU_OST_META) { dds.dds_creation_txg = TXG_INITIAL; usedobjs = os->os->os_rootbp->blk_fill; - refdbytes = - os->os->os_spa->spa_dsl_pool->dp_mos_dir->dd_used_bytes; + refdbytes = os->os->os_spa->spa_dsl_pool-> + dp_mos_dir->dd_phys->dd_used_bytes; } else { dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch); } @@ -1054,6 +1191,9 @@ dump_dir(objset_t *os) if (verbosity < 2) return; + if (os->os->os_rootbp->blk_birth == 0) + return; + if (zopt_objects != 0) { for (i = 0; i < zopt_objects; i++) dump_object(os, zopt_object[i], verbosity, @@ -1115,6 +1255,52 @@ dump_config(const char *pool) } static void +dump_cachefile(const char *cachefile) +{ + int fd; + struct stat64 statbuf; + char *buf; + nvlist_t *config; + + if ((fd = open64(cachefile, O_RDONLY)) < 0) { + (void) printf("cannot open '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if (fstat64(fd, &statbuf) != 0) { + (void) printf("failed to stat '%s': %s\n", cachefile, + strerror(errno)); + exit(1); + } + + if ((buf = malloc(statbuf.st_size)) == NULL) { + (void) fprintf(stderr, "failed to allocate %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + if (read(fd, buf, statbuf.st_size) != statbuf.st_size) { + (void) fprintf(stderr, "failed to read %llu bytes\n", + (u_longlong_t)statbuf.st_size); + exit(1); + } + + (void) close(fd); + + if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) { + (void) fprintf(stderr, "failed to unpack nvlist\n"); + exit(1); + } + + free(buf); + + dump_nvlist(config, 0); + + nvlist_free(config); +} + +static void dump_label(const char *dev) { int fd; @@ -1178,170 +1364,84 @@ dump_one_dir(char *dsname, void *arg) objset_t *os; error = dmu_objset_open(dsname, DMU_OST_ANY, - DS_MODE_STANDARD | DS_MODE_READONLY, &os); + DS_MODE_USER | DS_MODE_READONLY, &os); if (error) { (void) printf("Could not open %s\n", dsname); return (0); } dump_dir(os); dmu_objset_close(os); + fuid_table_destroy(); return (0); } static void -zdb_space_map_load(spa_t *spa) +zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) { - vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m, error; + vdev_t *vd = sm->sm_ppd; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { - metaslab_t *msp = vd->vdev_ms[m]; - mutex_enter(&msp->ms_lock); - error = space_map_load(&msp->ms_allocmap[0], NULL, - SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset); - mutex_exit(&msp->ms_lock); - if (error) - fatal("%s bad space map #%d, error %d", - spa->spa_name, c, error); - } - } + (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", + (u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size); } -static int -zdb_space_map_claim(spa_t *spa, blkptr_t *bp, zbookmark_t *zb) +/* ARGSUSED */ +static void +zdb_space_map_load(space_map_t *sm) { - dva_t *dva = bp->blk_dva; - vdev_t *vd; - metaslab_t *msp; - space_map_t *allocmap, *freemap; - int error; - int d; - blkptr_t blk = *bp; - - for (d = 0; d < BP_GET_NDVAS(bp); d++) { - uint64_t vdev = DVA_GET_VDEV(&dva[d]); - uint64_t offset = DVA_GET_OFFSET(&dva[d]); - uint64_t size = DVA_GET_ASIZE(&dva[d]); - - if ((vd = vdev_lookup_top(spa, vdev)) == NULL) - return (ENXIO); - - if ((offset >> vd->vdev_ms_shift) >= vd->vdev_ms_count) - return (ENXIO); - - msp = vd->vdev_ms[offset >> vd->vdev_ms_shift]; - allocmap = &msp->ms_allocmap[0]; - freemap = &msp->ms_freemap[0]; - - /* Prepare our copy of the bp in case we need to read GBHs */ - if (DVA_GET_GANG(&dva[d])) { - size = vdev_psize_to_asize(vd, SPA_GANGBLOCKSIZE); - DVA_SET_ASIZE(&blk.blk_dva[d], size); - DVA_SET_GANG(&blk.blk_dva[d], 0); - } - - mutex_enter(&msp->ms_lock); - if (space_map_contains(freemap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (EAGAIN); /* allocated more than once */ - } - - if (!space_map_contains(allocmap, offset, size)) { - mutex_exit(&msp->ms_lock); - return (ESTALE); /* not allocated at all */ - } - - space_map_remove(allocmap, offset, size); - space_map_add(freemap, offset, size); - - mutex_exit(&msp->ms_lock); - } - - if (BP_IS_GANG(bp)) { - zio_gbh_phys_t gbh; - int g; - - /* LINTED - compile time assert */ - ASSERT(sizeof (zio_gbh_phys_t) == SPA_GANGBLOCKSIZE); - - BP_SET_CHECKSUM(&blk, ZIO_CHECKSUM_GANG_HEADER); - BP_SET_PSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_LSIZE(&blk, SPA_GANGBLOCKSIZE); - BP_SET_COMPRESS(&blk, ZIO_COMPRESS_OFF); - error = zio_wait(zio_read(NULL, spa, &blk, &gbh, - SPA_GANGBLOCKSIZE, NULL, NULL, ZIO_PRIORITY_SYNC_READ, - ZIO_FLAG_CANFAIL | ZIO_FLAG_CONFIG_HELD, zb)); - if (error) - return (error); - if (BP_SHOULD_BYTESWAP(&blk)) - byteswap_uint64_array(&gbh, SPA_GANGBLOCKSIZE); - for (g = 0; g < SPA_GBH_NBLKPTRS; g++) { - if (BP_IS_HOLE(&gbh.zg_blkptr[g])) - break; - error = zdb_space_map_claim(spa, &gbh.zg_blkptr[g], zb); - if (error) - return (error); - } - } - - return (0); } static void -zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) +zdb_space_map_unload(space_map_t *sm) { - metaslab_t *msp; - - /* LINTED */ - msp = (metaslab_t *)((char *)sm - offsetof(metaslab_t, ms_allocmap[0])); + space_map_vacate(sm, zdb_leak, sm); +} - (void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", - (u_longlong_t)msp->ms_group->mg_vd->vdev_id, - (u_longlong_t)start, - (u_longlong_t)size); +/* ARGSUSED */ +static void +zdb_space_map_claim(space_map_t *sm, uint64_t start, uint64_t size) +{ } +static space_map_ops_t zdb_space_map_ops = { + zdb_space_map_load, + zdb_space_map_unload, + NULL, /* alloc */ + zdb_space_map_claim, + NULL /* free */ +}; + static void -zdb_space_map_unload(spa_t *spa) +zdb_leak_init(spa_t *spa) { vdev_t *rvd = spa->spa_root_vdev; - vdev_t *vd; - int c, m; - for (c = 0; c < rvd->vdev_children; c++) { - vd = rvd->vdev_child[c]; - for (m = 0; m < vd->vdev_ms_count; m++) { + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { metaslab_t *msp = vd->vdev_ms[m]; mutex_enter(&msp->ms_lock); - space_map_vacate(&msp->ms_allocmap[0], zdb_leak, - &msp->ms_allocmap[0]); - space_map_unload(&msp->ms_allocmap[0]); - space_map_vacate(&msp->ms_freemap[0], NULL, NULL); + VERIFY(space_map_load(&msp->ms_map, &zdb_space_map_ops, + SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset) == 0); + msp->ms_map.sm_ppd = vd; mutex_exit(&msp->ms_lock); } } } static void -zdb_refresh_ubsync(spa_t *spa) +zdb_leak_fini(spa_t *spa) { - uberblock_t ub = { 0 }; vdev_t *rvd = spa->spa_root_vdev; - zio_t *zio; - - /* - * Reload the uberblock. - */ - zio = zio_root(spa, NULL, NULL, - ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE); - vdev_uberblock_load(zio, rvd, &ub); - (void) zio_wait(zio); - if (ub.ub_txg != 0) - spa->spa_ubsync = ub; + for (int c = 0; c < rvd->vdev_children; c++) { + vdev_t *vd = rvd->vdev_child[c]; + for (int m = 0; m < vd->vdev_ms_count; m++) { + metaslab_t *msp = vd->vdev_ms[m]; + mutex_enter(&msp->ms_lock); + space_map_unload(&msp->ms_map); + mutex_exit(&msp->ms_lock); + } + } } /* @@ -1371,9 +1471,7 @@ typedef struct zdb_cb { static void zdb_count_block(spa_t *spa, zdb_cb_t *zcb, blkptr_t *bp, int type) { - int i, error; - - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL; int t = (i & 1) ? type : DMU_OT_TOTAL; zdb_blkstats_t *zb = &zcb->zcb_type[l][t]; @@ -1384,21 +1482,34 @@ zdb_count_block(spa_t *spa, zdb_cb_t *zc zb->zb_count++; } - if (dump_opt['L']) - return; + if (dump_opt['S']) { + boolean_t print_sig; - error = zdb_space_map_claim(spa, bp, &zcb->zcb_cache->bc_bookmark); - - if (error == 0) - return; + print_sig = !zdb_sig_user_data || (BP_GET_LEVEL(bp) == 0 && + BP_GET_TYPE(bp) == DMU_OT_PLAIN_FILE_CONTENTS); - if (error == EAGAIN) - (void) fatal("double-allocation, bp=%p", bp); + if (BP_GET_CHECKSUM(bp) < zdb_sig_cksumalg) + print_sig = B_FALSE; - if (error == ESTALE) - (void) fatal("reference to freed block, bp=%p", bp); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:39:51 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C834106566B; Fri, 15 May 2009 23:39:51 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EE9268FC17; Fri, 15 May 2009 23:39:50 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNdoMp038075; Fri, 15 May 2009 23:39:50 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNdoRF038074; Fri, 15 May 2009 23:39:50 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152339.n4FNdoRF038074@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:39:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192170 - user/kmacy/ZFS_MFC/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:39:51 -0000 Author: kmacy Date: Fri May 15 23:39:50 2009 New Revision: 192170 URL: http://svn.freebsd.org/changeset/base/192170 Log: add convenience config for testing Added: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Added: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Fri May 15 23:39:50 2009 (r192170) @@ -0,0 +1,319 @@ +# +# GENERIC -- Generic kernel configuration file for FreeBSD/amd64 +# +# For more information on this file, please read the handbook section on +# Kernel Configuration Files: +# +# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# +# $FreeBSD: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC 191034 2009-04-14 00:35:56Z jfv $ + +cpu HAMMER +ident GENERIC + +# To statically compile in device wiring instead of /boot/device.hints +#hints "GENERIC.hints" # Default places to look for devices. + +makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols +makeoptions MODULES_OVERRIDE="zfs" + +options SCHED_ULE # ULE scheduler +options PREEMPTION # Enable kernel thread preemption +options INET # InterNETworking +options INET6 # IPv6 communications protocols +options SCTP # Stream Control Transmission Protocol +options FFS # Berkeley Fast Filesystem +options SOFTUPDATES # Enable FFS soft updates support +options UFS_ACL # Support for access control lists +options UFS_DIRHASH # Improve performance on big directories +options UFS_GJOURNAL # Enable gjournal-based UFS journaling +options MD_ROOT # MD is a potential root device +options NFSCLIENT # Network Filesystem Client +options NFSSERVER # Network Filesystem Server +options NFSLOCKD # Network Lock Manager +options NFS_ROOT # NFS usable as /, requires NFSCLIENT +options MSDOSFS # MSDOS Filesystem +options CD9660 # ISO 9660 Filesystem +options PROCFS # Process filesystem (requires PSEUDOFS) +options PSEUDOFS # Pseudo-filesystem framework +options GEOM_PART_GPT # GUID Partition Tables. +options GEOM_LABEL # Provides labelization +options COMPAT_43TTY # BSD 4.3 TTY compat [KEEP THIS!] +options COMPAT_IA32 # Compatible with i386 binaries +options COMPAT_FREEBSD4 # Compatible with FreeBSD4 +options COMPAT_FREEBSD5 # Compatible with FreeBSD5 +options COMPAT_FREEBSD6 # Compatible with FreeBSD6 +options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI +options KTRACE # ktrace(1) support +options STACK # stack(9) support +options SYSVSHM # SYSV-style shared memory +options SYSVMSG # SYSV-style message queues +options SYSVSEM # SYSV-style semaphores +options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions +options KBD_INSTALL_CDEV # install a CDEV entry in /dev +options ADAPTIVE_GIANT # Giant mutex is adaptive. +options STOP_NMI # Stop CPUS using NMI instead of IPI +options AUDIT # Security event auditing +#options KDTRACE_FRAME # Ensure frames are compiled in +#options KDTRACE_HOOKS # Kernel DTrace hooks + + +options INVARIANTS +options INVARIANT_SUPPORT + +options WITNESS +options WITNESS_SKIPSPIN +options DEBUG + + +# Make an SMP-capable kernel by default +options SMP # Symmetric MultiProcessor Kernel + +# CPU frequency control +device cpufreq + +# Bus support. +device acpi +device pci + +# Floppy drives +device fdc + +# ATA and ATAPI devices +device ata +device atadisk # ATA disk drives +device ataraid # ATA RAID drives +device atapicd # ATAPI CDROM drives +device atapifd # ATAPI floppy drives +device atapist # ATAPI tape drives +options ATA_STATIC_ID # Static device numbering + +# SCSI Controllers +device ahc # AHA2940 and onboard AIC7xxx devices +options AHC_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~128k to driver. +device ahd # AHA39320/29320 and onboard AIC79xx devices +options AHD_REG_PRETTY_PRINT # Print register bitfields in debug + # output. Adds ~215k to driver. +device amd # AMD 53C974 (Tekram DC-390(T)) +device hptiop # Highpoint RocketRaid 3xxx series +device isp # Qlogic family +#device ispfw # Firmware for QLogic HBAs- normally a module +device mpt # LSI-Logic MPT-Fusion +#device ncr # NCR/Symbios Logic +device sym # NCR/Symbios Logic (newer chipsets + those of `ncr') +device trm # Tekram DC395U/UW/F DC315U adapters + +device adv # Advansys SCSI adapters +device adw # Advansys wide SCSI adapters +device aic # Adaptec 15[012]x SCSI adapters, AIC-6[23]60. +device bt # Buslogic/Mylex MultiMaster SCSI adapters + + +# SCSI peripherals +device scbus # SCSI bus (required for SCSI) +device ch # SCSI media changers +device da # Direct Access (disks) +device sa # Sequential Access (tape etc) +device cd # CD +device pass # Passthrough device (direct SCSI access) +device ses # SCSI Environmental Services (and SAF-TE) + +# RAID controllers interfaced to the SCSI subsystem +device amr # AMI MegaRAID +device arcmsr # Areca SATA II RAID +device ciss # Compaq Smart RAID 5* +device dpt # DPT Smartcache III, IV - See NOTES for options +device hptmv # Highpoint RocketRAID 182x +device hptrr # Highpoint RocketRAID 17xx, 22xx, 23xx, 25xx +device iir # Intel Integrated RAID +device ips # IBM (Adaptec) ServeRAID +device mly # Mylex AcceleRAID/eXtremeRAID +device twa # 3ware 9000 series PATA/SATA RAID + +# RAID controllers +device aac # Adaptec FSA RAID +device aacp # SCSI passthrough for aac (requires CAM) +device ida # Compaq Smart RAID +device mfi # LSI MegaRAID SAS +device mlx # Mylex DAC960 family +#XXX pointer/int warnings +#device pst # Promise Supertrak SX6000 +device twe # 3ware ATA RAID + +# atkbdc0 controls both the keyboard and the PS/2 mouse +device atkbdc # AT keyboard controller +device atkbd # AT keyboard +device psm # PS/2 mouse + +device kbdmux # keyboard multiplexer + +device vga # VGA video card driver + +device splash # Splash screen and screen saver support + +# syscons is the default console driver, resembling an SCO console +device sc + +device agp # support several AGP chipsets + +# PCCARD (PCMCIA) support +# PCMCIA and cardbus bridge support +device cbb # cardbus (yenta) bridge +device pccard # PC Card (16-bit) bus +device cardbus # CardBus (32-bit) bus + +# Serial (COM) ports +device sio # 8250, 16[45]50 based serial ports +device uart # Generic UART driver + +# Parallel port +device ppc +device ppbus # Parallel port bus (required) +device lpt # Printer +device plip # TCP/IP over parallel +device ppi # Parallel port interface device +#device vpo # Requires scbus and da + +# If you've got a "dumb" serial or parallel PCI card that is +# supported by the puc(4) glue driver, uncomment the following +# line to enable it (connects to sio, uart and/or ppc drivers): +#device puc + +# PCI Ethernet NICs. +device de # DEC/Intel DC21x4x (``Tulip'') +device em # Intel PRO/1000 Gigabit Ethernet Family +device igb # Intel PRO/1000 PCIE Server Gigabit Family +device ixgbe # Intel PRO/10GbE PCIE Ethernet Family +device le # AMD Am7900 LANCE and Am79C9xx PCnet +device txp # 3Com 3cR990 (``Typhoon'') +device vx # 3Com 3c590, 3c595 (``Vortex'') + +# PCI Ethernet NICs that use the common MII bus controller code. +# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs! +device miibus # MII bus support +device age # Attansic/Atheros L1 Gigabit Ethernet +device ale # Atheros AR8121/AR8113/AR8114 Ethernet +device bce # Broadcom BCM5706/BCM5708 Gigabit Ethernet +device bfe # Broadcom BCM440x 10/100 Ethernet +device bge # Broadcom BCM570xx Gigabit Ethernet +device dc # DEC/Intel 21143 and various workalikes +device et # Agere ET1310 10/100/Gigabit Ethernet +device fxp # Intel EtherExpress PRO/100B (82557, 82558) +device jme # JMicron JMC250 Gigabit/JMC260 Fast Ethernet +device lge # Level 1 LXT1001 gigabit Ethernet +device msk # Marvell/SysKonnect Yukon II Gigabit Ethernet +device nfe # nVidia nForce MCP on-board Ethernet +device nge # NatSemi DP83820 gigabit Ethernet +#device nve # nVidia nForce MCP on-board Ethernet Networking +device pcn # AMD Am79C97x PCI 10/100 (precedence over 'le') +device re # RealTek 8139C+/8169/8169S/8110S +device rl # RealTek 8129/8139 +device sf # Adaptec AIC-6915 (``Starfire'') +device sis # Silicon Integrated Systems SiS 900/SiS 7016 +device sk # SysKonnect SK-984x & SK-982x gigabit Ethernet +device ste # Sundance ST201 (D-Link DFE-550TX) +device ti # Alteon Networks Tigon I/II gigabit Ethernet +device tl # Texas Instruments ThunderLAN +device tx # SMC EtherPower II (83c170 ``EPIC'') +device vge # VIA VT612x gigabit Ethernet +device vr # VIA Rhine, Rhine II +device wb # Winbond W89C840F +device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'') + +# ISA Ethernet NICs. pccard NICs included. +device cs # Crystal Semiconductor CS89x0 NIC +# 'device ed' requires 'device miibus' +device ed # NE[12]000, SMC Ultra, 3c503, DS8390 cards +device ex # Intel EtherExpress Pro/10 and Pro/10+ +device ep # Etherlink III based cards +device fe # Fujitsu MB8696x based cards +device sn # SMC's 9000 series of Ethernet chips +device xe # Xircom pccard Ethernet + +# Wireless NIC cards +device wlan # 802.11 support +device wlan_wep # 802.11 WEP support +device wlan_ccmp # 802.11 CCMP support +device wlan_tkip # 802.11 TKIP support +device wlan_amrr # AMRR transmit rate control algorithm +device wlan_scan_ap # 802.11 AP mode scanning +device wlan_scan_sta # 802.11 STA mode scanning +device an # Aironet 4500/4800 802.11 wireless NICs. +device ath # Atheros pci/cardbus NIC's +device ath_hal # Atheros HAL (Hardware Access Layer) +options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors +device ath_rate_sample # SampleRate tx rate control for ath +device awi # BayStack 660 and others +device ral # Ralink Technology RT2500 wireless NICs. +device wi # WaveLAN/Intersil/Symbol 802.11 wireless NICs. + +# Pseudo devices. +device loop # Network loopback +device random # Entropy device +device ether # Ethernet support +device sl # Kernel SLIP +device ppp # Kernel PPP +device tun # Packet tunnel. +device pty # Pseudo-ttys (telnet etc) +device md # Memory "disks" +device gif # IPv6 and IPv4 tunneling +device faith # IPv6-to-IPv4 relaying (translation) +device firmware # firmware assist module + +# The `bpf' device enables the Berkeley Packet Filter. +# Be aware of the administrative consequences of enabling this! +# Note that 'bpf' is required for DHCP. +device bpf # Berkeley packet filter + +# USB support +device uhci # UHCI PCI->USB interface +device ohci # OHCI PCI->USB interface +device ehci # EHCI PCI->USB interface (USB 2.0) +device usb # USB Bus (required) +#device udbp # USB Double Bulk Pipe devices +device ugen # Generic +device uhid # "Human Interface Devices" +device ukbd # Keyboard +device ulpt # Printer +device umass # Disks/Mass storage - Requires scbus and da +device ums # Mouse +device ural # Ralink Technology RT2500USB wireless NICs +device urio # Diamond Rio 500 MP3 player +device uscanner # Scanners +# USB Serial devices +device ucom # Generic com ttys +device uark # Technologies ARK3116 based serial adapters +device ubsa # Belkin F5U103 and compatible serial adapters +device ubser # BWCT console serial adapters +device uftdi # For FTDI usb serial adapters +device uipaq # Some WinCE based devices +device uplcom # Prolific PL-2303 serial adapters +device uslcom # SI Labs CP2101/CP2102 serial adapters +device uvisor # Visor and Palm devices +device uvscom # USB serial support for DDI pocket's PHS +# USB Ethernet, requires miibus +device aue # ADMtek USB Ethernet +device axe # ASIX Electronics USB Ethernet +device cdce # Generic USB over Ethernet +device cue # CATC USB Ethernet +device kue # Kawasaki LSI USB Ethernet +device rue # RealTek RTL8150 USB Ethernet + +# FireWire support +device firewire # FireWire bus code +device sbp # SCSI over FireWire (Requires scbus and da) +device fwe # Ethernet over FireWire (non-standard!) +device fwip # IP over FireWire (RFC 2734,3146) +device dcons # Dumb console driver +device dcons_crom # Configuration ROM for dcons From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:40:08 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8E1AF106564A; Fri, 15 May 2009 23:40:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7942E8FC19; Fri, 15 May 2009 23:40:08 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNe8GS038129; Fri, 15 May 2009 23:40:08 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNe8va038121; Fri, 15 May 2009 23:40:08 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152340.n4FNe8va038121@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:40:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192171 - in user/kmacy/ZFS_MFC/sys: cddl/compat/opensolaris/kern cddl/contrib/opensolaris/uts/common/fs/zfs cddl/contrib/opensolaris/uts/common/fs/zfs/sys sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:40:08 -0000 Author: kmacy Date: Fri May 15 23:40:07 2009 New Revision: 192171 URL: http://svn.freebsd.org/changeset/base/192171 Log: import osd functionality Added: user/kmacy/ZFS_MFC/sys/sys/osd.h (contents, props changed) Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c user/kmacy/ZFS_MFC/sys/sys/proc.h Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c Fri May 15 23:40:07 2009 (r192171) @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Fri May 15 23:40:07 2009 (r192171) @@ -100,14 +100,12 @@ rrn_find(rrwlock_t *rrl) static void rrn_add(rrwlock_t *rrl) { -#if 0 rrw_node_t *rn; rn = kmem_alloc(sizeof (*rn), KM_SLEEP); rn->rn_rrl = rrl; rn->rn_next = tsd_get(rrw_tsd_key); VERIFY(tsd_set(rrw_tsd_key, rn) == 0); -#endif } /* @@ -122,7 +120,7 @@ rrn_find_and_remove(rrwlock_t *rrl) if (refcount_count(&rrl->rr_linked_rcount) == 0) return (B_FALSE); -#if 0 + for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) { if (prev) @@ -134,7 +132,6 @@ rrn_find_and_remove(rrwlock_t *rrl) } prev = rn; } -#endif return (B_FALSE); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h Fri May 15 23:40:07 2009 (r192171) @@ -53,6 +53,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -106,7 +107,6 @@ extern "C" { #define CPU_SEQID (curcpu) -#if 0 #define tsd_create(keyp, destructor) do { \ *(keyp) = osd_thread_register((destructor)); \ KASSERT(*(keyp) > 0, ("cannot register OSD")); \ @@ -114,7 +114,6 @@ extern "C" { #define tsd_destroy(keyp) osd_thread_deregister(*(keyp)) #define tsd_get(key) osd_thread_get(curthread, (key)) #define tsd_set(key, value) osd_thread_set(curthread, (key), (value)) -#endif #ifdef __cplusplus } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri May 15 23:40:07 2009 (r192171) @@ -3073,10 +3073,8 @@ zfs_start(void *context __unused, int pe zfs_init(); zvol_init(); -#if 0 tsd_create(&zfs_fsyncer_key, NULL); tsd_create(&rrw_tsd_key, NULL); -#endif printf("ZFS storage pool version " SPA_VERSION_STRING "\n"); root_mount_rel(zfs_root_token); @@ -3108,10 +3106,8 @@ zfs_modevent(module_t mod, int type, voi zfs_fini(); spa_fini(); zfsdev_fini(); -#if 0 tsd_destroy(&zfs_fsyncer_key); tsd_destroy(&rrw_tsd_key); -#endif mutex_destroy(&zfs_share_lock); error = 0; break; Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Fri May 15 23:40:07 2009 (r192171) @@ -486,11 +486,9 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * write_state = WR_COPIED; else write_state = WR_NEED_COPY; -#ifdef notyet if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) { (void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1)); } -#endif while (resid) { itx_t *itx; Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Fri May 15 23:40:07 2009 (r192171) @@ -2298,9 +2298,7 @@ zfs_fsync(vnode_t *vp, int syncflag, cre znode_t *zp = VTOZ(vp); zfsvfs_t *zfsvfs = zp->z_zfsvfs; -#ifdef notyet (void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt); -#endif ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); zil_commit(zfsvfs->z_log, zp->z_last_itx, zp->z_id); Added: user/kmacy/ZFS_MFC/sys/sys/osd.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/sys/osd.h Fri May 15 23:40:07 2009 (r192171) @@ -0,0 +1,101 @@ +/*- + * Copyright (c) 2007 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 _SYS_OSD_H_ +#define _SYS_OSD_H_ + +#include + +/* + * Lock key: + * (c) container lock (e.g. jail's pr_mtx) and/or osd_object_lock + * (l) osd_list_lock + */ +struct osd { + u_int osd_nslots; /* (c) */ + void **osd_slots; /* (c) */ + LIST_ENTRY(osd) osd_next; /* (l) */ +}; + +#ifdef _KERNEL + +#define OSD_THREAD 0 +#define OSD_JAIL 1 + +#define OSD_FIRST OSD_THREAD +#define OSD_LAST OSD_JAIL + +typedef void (*osd_destructor_t)(void *value); +typedef int (*osd_method_t)(void *obj, void *data); + +int osd_register(u_int type, osd_destructor_t destructor, + osd_method_t *methods); +void osd_deregister(u_int type, u_int slot); + +int osd_set(u_int type, struct osd *osd, u_int slot, void *value); +void *osd_get(u_int type, struct osd *osd, u_int slot); +void osd_del(u_int type, struct osd *osd, u_int slot); +int osd_call(u_int type, u_int method, void *obj, void *data); + +void osd_exit(u_int type, struct osd *osd); + +#define osd_thread_register(destructor) \ + osd_register(OSD_THREAD, (destructor), NULL) +#define osd_thread_deregister(slot) \ + osd_deregister(OSD_THREAD, (slot)) +#define osd_thread_set(td, slot, value) \ + osd_set(OSD_THREAD, &(td)->td_osd, (slot), (value)) +#define osd_thread_get(td, slot) \ + osd_get(OSD_THREAD, &(td)->td_osd, (slot)) +#define osd_thread_del(td, slot) do { \ + KASSERT((td) == curthread, ("Not curthread.")); \ + osd_del(OSD_THREAD, &(td)->td_osd, (slot)); \ +} while (0) +#define osd_thread_call(td, method, data) \ + osd_call(OSD_THREAD, (method), (td), (data)) +#define osd_thread_exit(td) \ + osd_exit(OSD_THREAD, &(td)->td_osd) + +#define osd_jail_register(destructor, methods) \ + osd_register(OSD_JAIL, (destructor), (methods)) +#define osd_jail_deregister(slot) \ + osd_deregister(OSD_JAIL, (slot)) +#define osd_jail_set(pr, slot, value) \ + osd_set(OSD_JAIL, &(pr)->pr_osd, (slot), (value)) +#define osd_jail_get(pr, slot) \ + osd_get(OSD_JAIL, &(pr)->pr_osd, (slot)) +#define osd_jail_del(pr, slot) \ + osd_del(OSD_JAIL, &(pr)->pr_osd, (slot)) +#define osd_jail_call(pr, method, data) \ + osd_call(OSD_JAIL, (method), (pr), (data)) +#define osd_jail_exit(pr) \ + osd_exit(OSD_JAIL, &(pr)->pr_osd) + +#endif /* _KERNEL */ + +#endif /* !_SYS_OSD_H_ */ Modified: user/kmacy/ZFS_MFC/sys/sys/proc.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/proc.h Fri May 15 23:39:50 2009 (r192170) +++ user/kmacy/ZFS_MFC/sys/sys/proc.h Fri May 15 23:40:07 2009 (r192171) @@ -46,6 +46,7 @@ #include #include #include +#include #include #include /* XXX. */ #include @@ -305,6 +306,7 @@ struct thread { struct file *td_fpop; /* (k) file referencing cdev under op */ struct kdtrace_thread *td_dtrace; /* (*) DTrace-specific data. */ int td_errno; /* Error returned by last syscall. */ + struct osd td_osd; /* (k) Object specific data. */ }; struct mtx *thread_lock_block(struct thread *); From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:45:58 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D365C106564A; Fri, 15 May 2009 23:45:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C26B28FC0C; Fri, 15 May 2009 23:45:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FNjwDP038298; Fri, 15 May 2009 23:45:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FNjw9j038297; Fri, 15 May 2009 23:45:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152345.n4FNjw9j038297@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:45:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192172 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:45:59 -0000 Author: kmacy Date: Fri May 15 23:45:58 2009 New Revision: 192172 URL: http://svn.freebsd.org/changeset/base/192172 Log: ensure that td_osd is zeroed on fork Modified: user/kmacy/ZFS_MFC/sys/kern/kern_fork.c Modified: user/kmacy/ZFS_MFC/sys/kern/kern_fork.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_fork.c Fri May 15 23:40:07 2009 (r192171) +++ user/kmacy/ZFS_MFC/sys/kern/kern_fork.c Fri May 15 23:45:58 2009 (r192172) @@ -505,6 +505,7 @@ again: bzero(&td2->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); + bzero(&td2->td_osd, sizeof(struct osd)); bcopy(&td->td_startcopy, &td2->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); From owner-svn-src-user@FreeBSD.ORG Sat May 16 00:05:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB99E1065672; Sat, 16 May 2009 00:05:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C852B8FC1E; Sat, 16 May 2009 00:05:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G05nSJ038705; Sat, 16 May 2009 00:05:49 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G05nTb038703; Sat, 16 May 2009 00:05:49 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160005.n4G05nTb038703@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 00:05:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192173 - in user/kmacy/ZFS_MFC/sys: conf kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 00:05:51 -0000 Author: kmacy Date: Sat May 16 00:05:49 2009 New Revision: 192173 URL: http://svn.freebsd.org/changeset/base/192173 Log: add kern_osd.c to build Added: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c (contents, props changed) Modified: user/kmacy/ZFS_MFC/sys/conf/files Modified: user/kmacy/ZFS_MFC/sys/conf/files ============================================================================== --- user/kmacy/ZFS_MFC/sys/conf/files Fri May 15 23:45:58 2009 (r192172) +++ user/kmacy/ZFS_MFC/sys/conf/files Sat May 16 00:05:49 2009 (r192173) @@ -1620,6 +1620,7 @@ kern/kern_module.c standard kern/kern_mtxpool.c standard kern/kern_mutex.c standard kern/kern_ntptime.c standard +kern/kern_osd.c standard kern/kern_physio.c standard kern/kern_pmc.c standard kern/kern_poll.c optional device_polling Added: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 00:05:49 2009 (r192173) @@ -0,0 +1,403 @@ +/*- + * Copyright (c) 2007 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 +#include +#include +#include +#include +#include + +/* OSD (Object Specific Data) */ + +static MALLOC_DEFINE(M_OSD, "osd", "Object Specific Data"); + +static int osd_debug = 0; +TUNABLE_INT("debug.osd", &osd_debug); +SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLAG_RW, &osd_debug, 0, "OSD debug level"); + +#define OSD_DEBUG(...) do { \ + if (osd_debug) { \ + printf("OSD (%s:%u): ", __func__, __LINE__); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ +} while (0) + +static void do_osd_del(u_int type, struct osd *osd, u_int slot, + int list_locked); + +/* + * Lists of objects with OSD. + * + * Lock key: + * (m) osd_module_lock + * (o) osd_object_lock + * (l) osd_list_lock + */ +static LIST_HEAD(, osd) osd_list[OSD_LAST + 1]; /* (m) */ +static osd_method_t *osd_methods[OSD_LAST + 1]; /* (m) */ +static u_int osd_nslots[OSD_LAST + 1]; /* (m) */ +static osd_destructor_t *osd_destructors[OSD_LAST + 1]; /* (o) */ +static const u_int osd_nmethods[OSD_LAST + 1] = { + [OSD_JAIL] = PR_MAXMETHOD, +}; + +static struct sx osd_module_lock[OSD_LAST + 1]; +static struct rmlock osd_object_lock[OSD_LAST + 1]; +static struct mtx osd_list_lock[OSD_LAST + 1]; + +static void +osd_default_destructor(void *value __unused) +{ + /* Do nothing. */ +} + +int +osd_register(u_int type, osd_destructor_t destructor, osd_method_t *methods) +{ + void *newptr; + u_int i, m; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + + /* + * If no destructor is given, use default one. We need to use some + * destructor, because NULL destructor means unused slot. + */ + if (destructor == NULL) + destructor = osd_default_destructor; + + sx_xlock(&osd_module_lock[type]); + /* + * First, we try to find unused slot. + */ + for (i = 0; i < osd_nslots[type]; i++) { + if (osd_destructors[type][i] == NULL) { + OSD_DEBUG("Unused slot found (type=%u, slot=%u).", + type, i); + break; + } + } + /* + * If no unused slot was found, allocate one. + */ + if (i == osd_nslots[type]) { + osd_nslots[type]++; + if (osd_nmethods[type] != 0) + osd_methods[type] = realloc(osd_methods[type], + sizeof(osd_method_t) * osd_nslots[type] * + osd_nmethods[type], M_OSD, M_WAITOK); + newptr = malloc(sizeof(osd_destructor_t) * osd_nslots[type], + M_OSD, M_WAITOK); + rm_wlock(&osd_object_lock[type]); + bcopy(osd_destructors[type], newptr, + sizeof(osd_destructor_t) * i); + free(osd_destructors[type], M_OSD); + osd_destructors[type] = newptr; + rm_wunlock(&osd_object_lock[type]); + OSD_DEBUG("New slot allocated (type=%u, slot=%u).", + type, i + 1); + } + + osd_destructors[type][i] = destructor; + if (osd_nmethods[type] != 0) { + for (m = 0; m < osd_nmethods[type]; m++) + osd_methods[type][i * osd_nmethods[type] + m] = + methods != NULL ? methods[m] : NULL; + } + sx_xunlock(&osd_module_lock[type]); + return (i + 1); +} + +void +osd_deregister(u_int type, u_int slot) +{ + struct osd *osd, *tosd; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + KASSERT(slot > 0, ("Invalid slot.")); + KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); + + sx_xlock(&osd_module_lock[type]); + rm_wlock(&osd_object_lock[type]); + /* + * Free all OSD for the given slot. + */ + mtx_lock(&osd_list_lock[type]); + LIST_FOREACH_SAFE(osd, &osd_list[type], osd_next, tosd) + do_osd_del(type, osd, slot, 1); + mtx_unlock(&osd_list_lock[type]); + /* + * Set destructor to NULL to free the slot. + */ + osd_destructors[type][slot - 1] = NULL; + if (slot == osd_nslots[type]) { + osd_nslots[type]--; + osd_destructors[type] = realloc(osd_destructors[type], + sizeof(osd_destructor_t) * osd_nslots[type], M_OSD, + M_NOWAIT | M_ZERO); + if (osd_nmethods[type] != 0) + osd_methods[type] = realloc(osd_methods[type], + sizeof(osd_method_t) * osd_nslots[type] * + osd_nmethods[type], M_OSD, M_NOWAIT | M_ZERO); + /* + * We always reallocate to smaller size, so we assume it will + * always succeed. + */ + KASSERT(osd_destructors[type] != NULL && + (osd_nmethods[type] == 0 || osd_methods[type] != NULL), + ("realloc() failed")); + OSD_DEBUG("Deregistration of the last slot (type=%u, slot=%u).", + type, slot); + } else { + OSD_DEBUG("Slot deregistration (type=%u, slot=%u).", + type, slot); + } + rm_wunlock(&osd_object_lock[type]); + sx_xunlock(&osd_module_lock[type]); +} + +int +osd_set(u_int type, struct osd *osd, u_int slot, void *value) +{ + struct rm_priotracker tracker; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + KASSERT(slot > 0, ("Invalid slot.")); + KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); + + rm_rlock(&osd_object_lock[type], &tracker); + if (slot > osd->osd_nslots) { + if (value == NULL) { + OSD_DEBUG( + "Not allocating null slot (type=%u, slot=%u).", + type, slot); + rm_runlock(&osd_object_lock[type], &tracker); + return (0); + } else if (osd->osd_nslots == 0) { + /* + * First OSD for this object, so we need to allocate + * space and put it onto the list. + */ + osd->osd_slots = malloc(sizeof(void *) * slot, M_OSD, + M_NOWAIT | M_ZERO); + if (osd->osd_slots == NULL) { + rm_runlock(&osd_object_lock[type], &tracker); + return (ENOMEM); + } + osd->osd_nslots = slot; + mtx_lock(&osd_list_lock[type]); + LIST_INSERT_HEAD(&osd_list[type], osd, osd_next); + mtx_unlock(&osd_list_lock[type]); + OSD_DEBUG("Setting first slot (type=%u).", type); + } else { + void *newptr; + + /* + * Too few slots allocated here, needs to extend + * the array. + */ + newptr = realloc(osd->osd_slots, sizeof(void *) * slot, + M_OSD, M_NOWAIT | M_ZERO); + if (newptr == NULL) { + rm_runlock(&osd_object_lock[type], &tracker); + return (ENOMEM); + } + osd->osd_slots = newptr; + osd->osd_nslots = slot; + OSD_DEBUG("Growing slots array (type=%u).", type); + } + } + OSD_DEBUG("Setting slot value (type=%u, slot=%u, value=%p).", type, + slot, value); + osd->osd_slots[slot - 1] = value; + rm_runlock(&osd_object_lock[type], &tracker); + return (0); +} + +void * +osd_get(u_int type, struct osd *osd, u_int slot) +{ + struct rm_priotracker tracker; + void *value; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + KASSERT(slot > 0, ("Invalid slot.")); + KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); + + rm_rlock(&osd_object_lock[type], &tracker); + if (slot > osd->osd_nslots) { + value = NULL; + OSD_DEBUG("Slot doesn't exist (type=%u, slot=%u).", type, slot); + } else { + value = osd->osd_slots[slot - 1]; + OSD_DEBUG("Returning slot value (type=%u, slot=%u, value=%p).", + type, slot, value); + } + rm_runlock(&osd_object_lock[type], &tracker); + return (value); +} + +void +osd_del(u_int type, struct osd *osd, u_int slot) +{ + struct rm_priotracker tracker; + + rm_rlock(&osd_object_lock[type], &tracker); + do_osd_del(type, osd, slot, 0); + rm_runlock(&osd_object_lock[type], &tracker); +} + +static void +do_osd_del(u_int type, struct osd *osd, u_int slot, int list_locked) +{ + int i; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + KASSERT(slot > 0, ("Invalid slot.")); + KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); + + OSD_DEBUG("Deleting slot (type=%u, slot=%u).", type, slot); + + if (slot > osd->osd_nslots) { + OSD_DEBUG("Slot doesn't exist (type=%u, slot=%u).", type, slot); + return; + } + if (osd->osd_slots[slot - 1] != NULL) { + osd_destructors[type][slot - 1](osd->osd_slots[slot - 1]); + osd->osd_slots[slot - 1] = NULL; + } + for (i = osd->osd_nslots - 1; i >= 0; i--) { + if (osd->osd_slots[i] != NULL) { + OSD_DEBUG("Slot still has a value (type=%u, slot=%u).", + type, i + 1); + break; + } + } + if (i == -1) { + /* No values left for this object. */ + OSD_DEBUG("No more slots left (type=%u).", type); + if (!list_locked) + mtx_lock(&osd_list_lock[type]); + LIST_REMOVE(osd, osd_next); + if (!list_locked) + mtx_unlock(&osd_list_lock[type]); + free(osd->osd_slots, M_OSD); + osd->osd_slots = NULL; + osd->osd_nslots = 0; + } else if (slot == osd->osd_nslots) { + /* This was the last slot. */ + osd->osd_slots = realloc(osd->osd_slots, + sizeof(void *) * (i + 1), M_OSD, M_NOWAIT | M_ZERO); + /* + * We always reallocate to smaller size, so we assume it will + * always succeed. + */ + KASSERT(osd->osd_slots != NULL, ("realloc() failed")); + osd->osd_nslots = i + 1; + OSD_DEBUG("Reducing slots array to %u (type=%u).", + osd->osd_nslots, type); + } +} + +int +osd_call(u_int type, u_int method, void *obj, void *data) +{ + osd_method_t methodfun; + int error, i; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + KASSERT(method < osd_nmethods[type], ("Invalid method.")); + + /* + * Call this method for every slot that defines it, stopping if an + * error is encountered. + */ + error = 0; + sx_slock(&osd_module_lock[type]); + for (i = 0; i < osd_nslots[type]; i++) { + methodfun = + osd_methods[type][i * osd_nmethods[type] + method]; + if (methodfun != NULL && (error = methodfun(obj, data)) != 0) + break; + } + sx_sunlock(&osd_module_lock[type]); + return (error); +} + +void +osd_exit(u_int type, struct osd *osd) +{ + struct rm_priotracker tracker; + u_int i; + + KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); + + if (osd->osd_nslots == 0) { + KASSERT(osd->osd_slots == NULL, ("Non-null osd_slots.")); + /* No OSD attached, just leave. */ + return; + } + + rm_rlock(&osd_object_lock[type], &tracker); + for (i = 1; i <= osd->osd_nslots; i++) { + if (osd_destructors[type][i - 1] != NULL) + do_osd_del(type, osd, i, 0); + else + OSD_DEBUG("Unused slot (type=%u, slot=%u).", type, i); + } + rm_runlock(&osd_object_lock[type], &tracker); + OSD_DEBUG("Object exit (type=%u).", type); +} + +static void +osd_init(void *arg __unused) +{ + u_int i; + + for (i = OSD_FIRST; i <= OSD_LAST; i++) { + osd_nslots[i] = 0; + LIST_INIT(&osd_list[i]); + sx_init(&osd_module_lock[i], "osd_module"); + rm_init(&osd_object_lock[i], "osd_object", 0); + mtx_init(&osd_list_lock[i], "osd_list", NULL, MTX_DEF); + osd_destructors[i] = NULL; + osd_methods[i] = NULL; + } +} +SYSINIT(osd, SI_SUB_LOCK, SI_ORDER_ANY, osd_init, NULL); From owner-svn-src-user@FreeBSD.ORG Sat May 16 00:21:03 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 522401065672; Sat, 16 May 2009 00:21:03 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 361228FC0A; Sat, 16 May 2009 00:21:03 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G0L3Ah039068; Sat, 16 May 2009 00:21:03 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G0L3B9039066; Sat, 16 May 2009 00:21:03 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160021.n4G0L3B9039066@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 00:21:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192174 - in user/kmacy/ZFS_MFC/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 00:21:03 -0000 Author: kmacy Date: Sat May 16 00:21:02 2009 New Revision: 192174 URL: http://svn.freebsd.org/changeset/base/192174 Log: remove rmlock dependency add PR_* defines Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c user/kmacy/ZFS_MFC/sys/sys/jail.h Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 00:05:49 2009 (r192173) +++ user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 00:21:02 2009 (r192174) @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ static const u_int osd_nmethods[OSD_LAST }; static struct sx osd_module_lock[OSD_LAST + 1]; -static struct rmlock osd_object_lock[OSD_LAST + 1]; +static struct rwlock osd_object_lock[OSD_LAST + 1]; static struct mtx osd_list_lock[OSD_LAST + 1]; static void @@ -124,12 +124,12 @@ osd_register(u_int type, osd_destructor_ osd_nmethods[type], M_OSD, M_WAITOK); newptr = malloc(sizeof(osd_destructor_t) * osd_nslots[type], M_OSD, M_WAITOK); - rm_wlock(&osd_object_lock[type]); + rw_wlock(&osd_object_lock[type]); bcopy(osd_destructors[type], newptr, sizeof(osd_destructor_t) * i); free(osd_destructors[type], M_OSD); osd_destructors[type] = newptr; - rm_wunlock(&osd_object_lock[type]); + rw_wunlock(&osd_object_lock[type]); OSD_DEBUG("New slot allocated (type=%u, slot=%u).", type, i + 1); } @@ -154,7 +154,7 @@ osd_deregister(u_int type, u_int slot) KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); sx_xlock(&osd_module_lock[type]); - rm_wlock(&osd_object_lock[type]); + rw_wlock(&osd_object_lock[type]); /* * Free all OSD for the given slot. */ @@ -188,26 +188,25 @@ osd_deregister(u_int type, u_int slot) OSD_DEBUG("Slot deregistration (type=%u, slot=%u).", type, slot); } - rm_wunlock(&osd_object_lock[type]); + rw_wunlock(&osd_object_lock[type]); sx_xunlock(&osd_module_lock[type]); } int osd_set(u_int type, struct osd *osd, u_int slot, void *value) { - struct rm_priotracker tracker; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); - rm_rlock(&osd_object_lock[type], &tracker); + rw_rlock(&osd_object_lock[type]); if (slot > osd->osd_nslots) { if (value == NULL) { OSD_DEBUG( "Not allocating null slot (type=%u, slot=%u).", type, slot); - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); return (0); } else if (osd->osd_nslots == 0) { /* @@ -217,7 +216,7 @@ osd_set(u_int type, struct osd *osd, u_i osd->osd_slots = malloc(sizeof(void *) * slot, M_OSD, M_NOWAIT | M_ZERO); if (osd->osd_slots == NULL) { - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); return (ENOMEM); } osd->osd_nslots = slot; @@ -235,7 +234,7 @@ osd_set(u_int type, struct osd *osd, u_i newptr = realloc(osd->osd_slots, sizeof(void *) * slot, M_OSD, M_NOWAIT | M_ZERO); if (newptr == NULL) { - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); return (ENOMEM); } osd->osd_slots = newptr; @@ -246,21 +245,20 @@ osd_set(u_int type, struct osd *osd, u_i OSD_DEBUG("Setting slot value (type=%u, slot=%u, value=%p).", type, slot, value); osd->osd_slots[slot - 1] = value; - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); return (0); } void * osd_get(u_int type, struct osd *osd, u_int slot) { - struct rm_priotracker tracker; void *value; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); - rm_rlock(&osd_object_lock[type], &tracker); + rw_rlock(&osd_object_lock[type]); if (slot > osd->osd_nslots) { value = NULL; OSD_DEBUG("Slot doesn't exist (type=%u, slot=%u).", type, slot); @@ -269,18 +267,17 @@ osd_get(u_int type, struct osd *osd, u_i OSD_DEBUG("Returning slot value (type=%u, slot=%u, value=%p).", type, slot, value); } - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); return (value); } void osd_del(u_int type, struct osd *osd, u_int slot) { - struct rm_priotracker tracker; - rm_rlock(&osd_object_lock[type], &tracker); + rw_rlock(&osd_object_lock[type]); do_osd_del(type, osd, slot, 0); - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); } static void @@ -363,7 +360,6 @@ osd_call(u_int type, u_int method, void void osd_exit(u_int type, struct osd *osd) { - struct rm_priotracker tracker; u_int i; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); @@ -374,14 +370,14 @@ osd_exit(u_int type, struct osd *osd) return; } - rm_rlock(&osd_object_lock[type], &tracker); + rw_rlock(&osd_object_lock[type]); for (i = 1; i <= osd->osd_nslots; i++) { if (osd_destructors[type][i - 1] != NULL) do_osd_del(type, osd, i, 0); else OSD_DEBUG("Unused slot (type=%u, slot=%u).", type, i); } - rm_runlock(&osd_object_lock[type], &tracker); + rw_runlock(&osd_object_lock[type]); OSD_DEBUG("Object exit (type=%u).", type); } @@ -394,7 +390,7 @@ osd_init(void *arg __unused) osd_nslots[i] = 0; LIST_INIT(&osd_list[i]); sx_init(&osd_module_lock[i], "osd_module"); - rm_init(&osd_object_lock[i], "osd_object", 0); + rw_init(&osd_object_lock[i], "osd_object"); mtx_init(&osd_list_lock[i], "osd_list", NULL, MTX_DEF); osd_destructors[i] = NULL; osd_methods[i] = NULL; Modified: user/kmacy/ZFS_MFC/sys/sys/jail.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/jail.h Sat May 16 00:05:49 2009 (r192173) +++ user/kmacy/ZFS_MFC/sys/sys/jail.h Sat May 16 00:21:02 2009 (r192174) @@ -142,6 +142,22 @@ struct prison { #ifdef _KERNEL /* + * Flag bits set via options or internally + */ +#define PR_PERSIST 0x00000001 /* Can exist without processes */ +#define PR_REMOVE 0x01000000 /* In process of being removed */ + +/* + * OSD methods + */ +#define PR_METHOD_CREATE 0 +#define PR_METHOD_GET 1 +#define PR_METHOD_SET 2 +#define PR_METHOD_CHECK 3 +#define PR_METHOD_ATTACH 4 +#define PR_MAXMETHOD 5 + +/* * Sysctl-set variables that determine global jail policy * * XXX MIB entries will need to be protected by a mutex. From owner-svn-src-user@FreeBSD.ORG Sat May 16 00:56:55 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 34C73106566B; Sat, 16 May 2009 00:56:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 203018FC21; Sat, 16 May 2009 00:56:55 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G0utsD039758; Sat, 16 May 2009 00:56:55 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G0utwq039757; Sat, 16 May 2009 00:56:55 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160056.n4G0utwq039757@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 00:56:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192175 - user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 00:56:55 -0000 Author: kmacy Date: Sat May 16 00:56:54 2009 New Revision: 192175 URL: http://svn.freebsd.org/changeset/base/192175 Log: add missed file Added: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c (contents, props changed) Added: user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Sat May 16 00:56:54 2009 (r192175) @@ -0,0 +1,2104 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "zfs_namecheck.h" +#include "zfs_prop.h" +#include "libzfs_impl.h" + +#include /* XXX */ + +/* We need to use something for ENODATA. */ +#define ENODATA EIDRM + +static int zfs_receive_impl(libzfs_handle_t *, const char *, recvflags_t, + int, avl_tree_t *, char **); + +/* + * Routines for dealing with the AVL tree of fs-nvlists + */ +typedef struct fsavl_node { + avl_node_t fn_node; + nvlist_t *fn_nvfs; + char *fn_snapname; + uint64_t fn_guid; +} fsavl_node_t; + +static int +fsavl_compare(const void *arg1, const void *arg2) +{ + const fsavl_node_t *fn1 = arg1; + const fsavl_node_t *fn2 = arg2; + + if (fn1->fn_guid > fn2->fn_guid) + return (+1); + else if (fn1->fn_guid < fn2->fn_guid) + return (-1); + else + return (0); +} + +/* + * Given the GUID of a snapshot, find its containing filesystem and + * (optionally) name. + */ +static nvlist_t * +fsavl_find(avl_tree_t *avl, uint64_t snapguid, char **snapname) +{ + fsavl_node_t fn_find; + fsavl_node_t *fn; + + fn_find.fn_guid = snapguid; + + fn = avl_find(avl, &fn_find, NULL); + if (fn) { + if (snapname) + *snapname = fn->fn_snapname; + return (fn->fn_nvfs); + } + return (NULL); +} + +static void +fsavl_destroy(avl_tree_t *avl) +{ + fsavl_node_t *fn; + void *cookie; + + if (avl == NULL) + return; + + cookie = NULL; + while ((fn = avl_destroy_nodes(avl, &cookie)) != NULL) + free(fn); + avl_destroy(avl); + free(avl); +} + +static avl_tree_t * +fsavl_create(nvlist_t *fss) +{ + avl_tree_t *fsavl; + nvpair_t *fselem = NULL; + + if ((fsavl = malloc(sizeof (avl_tree_t))) == NULL) + return (NULL); + + avl_create(fsavl, fsavl_compare, sizeof (fsavl_node_t), + offsetof(fsavl_node_t, fn_node)); + + while ((fselem = nvlist_next_nvpair(fss, fselem)) != NULL) { + nvlist_t *nvfs, *snaps; + nvpair_t *snapelem = NULL; + + VERIFY(0 == nvpair_value_nvlist(fselem, &nvfs)); + VERIFY(0 == nvlist_lookup_nvlist(nvfs, "snaps", &snaps)); + + while ((snapelem = + nvlist_next_nvpair(snaps, snapelem)) != NULL) { + fsavl_node_t *fn; + uint64_t guid; + + VERIFY(0 == nvpair_value_uint64(snapelem, &guid)); + if ((fn = malloc(sizeof (fsavl_node_t))) == NULL) { + fsavl_destroy(fsavl); + return (NULL); + } + fn->fn_nvfs = nvfs; + fn->fn_snapname = nvpair_name(snapelem); + fn->fn_guid = guid; + + /* + * Note: if there are multiple snaps with the + * same GUID, we ignore all but one. + */ + if (avl_find(fsavl, fn, NULL) == NULL) + avl_add(fsavl, fn); + else + free(fn); + } + } + + return (fsavl); +} + +/* + * Routines for dealing with the giant nvlist of fs-nvlists, etc. + */ +typedef struct send_data { + uint64_t parent_fromsnap_guid; + nvlist_t *parent_snaps; + nvlist_t *fss; + nvlist_t *snapprops; + const char *fromsnap; + const char *tosnap; + + /* + * The header nvlist is of the following format: + * { + * "tosnap" -> string + * "fromsnap" -> string (if incremental) + * "fss" -> { + * id -> { + * + * "name" -> string (full name; for debugging) + * "parentfromsnap" -> number (guid of fromsnap in parent) + * + * "props" -> { name -> value (only if set here) } + * "snaps" -> { name (lastname) -> number (guid) } + * "snapprops" -> { name (lastname) -> { name -> value } } + * + * "origin" -> number (guid) (if clone) + * "sent" -> boolean (not on-disk) + * } + * } + * } + * + */ +} send_data_t; + +static void send_iterate_prop(zfs_handle_t *zhp, nvlist_t *nv); + +static int +send_iterate_snap(zfs_handle_t *zhp, void *arg) +{ + send_data_t *sd = arg; + uint64_t guid = zhp->zfs_dmustats.dds_guid; + char *snapname; + nvlist_t *nv; + + snapname = strrchr(zhp->zfs_name, '@')+1; + + VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid)); + /* + * NB: if there is no fromsnap here (it's a newly created fs in + * an incremental replication), we will substitute the tosnap. + */ + if ((sd->fromsnap && strcmp(snapname, sd->fromsnap) == 0) || + (sd->parent_fromsnap_guid == 0 && sd->tosnap && + strcmp(snapname, sd->tosnap) == 0)) { + sd->parent_fromsnap_guid = guid; + } + + VERIFY(0 == nvlist_alloc(&nv, NV_UNIQUE_NAME, 0)); + send_iterate_prop(zhp, nv); + VERIFY(0 == nvlist_add_nvlist(sd->snapprops, snapname, nv)); + nvlist_free(nv); + + zfs_close(zhp); + return (0); +} + +static void +send_iterate_prop(zfs_handle_t *zhp, nvlist_t *nv) +{ + nvpair_t *elem = NULL; + + while ((elem = nvlist_next_nvpair(zhp->zfs_props, elem)) != NULL) { + char *propname = nvpair_name(elem); + zfs_prop_t prop = zfs_name_to_prop(propname); + nvlist_t *propnv; + + if (!zfs_prop_user(propname) && zfs_prop_readonly(prop)) + continue; + + verify(nvpair_value_nvlist(elem, &propnv) == 0); + if (prop == ZFS_PROP_QUOTA || prop == ZFS_PROP_RESERVATION) { + /* these guys are modifyable, but have no source */ + uint64_t value; + verify(nvlist_lookup_uint64(propnv, + ZPROP_VALUE, &value) == 0); + if (zhp->zfs_type == ZFS_TYPE_SNAPSHOT) + continue; + } else { + char *source; + if (nvlist_lookup_string(propnv, + ZPROP_SOURCE, &source) != 0) + continue; + if (strcmp(source, zhp->zfs_name) != 0) + continue; + } + + if (zfs_prop_user(propname) || + zfs_prop_get_type(prop) == PROP_TYPE_STRING) { + char *value; + verify(nvlist_lookup_string(propnv, + ZPROP_VALUE, &value) == 0); + VERIFY(0 == nvlist_add_string(nv, propname, value)); + } else { + uint64_t value; + verify(nvlist_lookup_uint64(propnv, + ZPROP_VALUE, &value) == 0); + VERIFY(0 == nvlist_add_uint64(nv, propname, value)); + } + } +} + +static int +send_iterate_fs(zfs_handle_t *zhp, void *arg) +{ + send_data_t *sd = arg; + nvlist_t *nvfs, *nv; + int rv; + uint64_t parent_fromsnap_guid_save = sd->parent_fromsnap_guid; + uint64_t guid = zhp->zfs_dmustats.dds_guid; + char guidstring[64]; + + VERIFY(0 == nvlist_alloc(&nvfs, NV_UNIQUE_NAME, 0)); + VERIFY(0 == nvlist_add_string(nvfs, "name", zhp->zfs_name)); + VERIFY(0 == nvlist_add_uint64(nvfs, "parentfromsnap", + sd->parent_fromsnap_guid)); + + if (zhp->zfs_dmustats.dds_origin[0]) { + zfs_handle_t *origin = zfs_open(zhp->zfs_hdl, + zhp->zfs_dmustats.dds_origin, ZFS_TYPE_SNAPSHOT); + if (origin == NULL) + return (-1); + VERIFY(0 == nvlist_add_uint64(nvfs, "origin", + origin->zfs_dmustats.dds_guid)); + } + + /* iterate over props */ + VERIFY(0 == nvlist_alloc(&nv, NV_UNIQUE_NAME, 0)); + send_iterate_prop(zhp, nv); + VERIFY(0 == nvlist_add_nvlist(nvfs, "props", nv)); + nvlist_free(nv); + + /* iterate over snaps, and set sd->parent_fromsnap_guid */ + sd->parent_fromsnap_guid = 0; + VERIFY(0 == nvlist_alloc(&sd->parent_snaps, NV_UNIQUE_NAME, 0)); + VERIFY(0 == nvlist_alloc(&sd->snapprops, NV_UNIQUE_NAME, 0)); + (void) zfs_iter_snapshots(zhp, send_iterate_snap, sd); + VERIFY(0 == nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps)); + VERIFY(0 == nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops)); + nvlist_free(sd->parent_snaps); + nvlist_free(sd->snapprops); + + /* add this fs to nvlist */ + (void) snprintf(guidstring, sizeof (guidstring), + "0x%llx", (longlong_t)guid); + VERIFY(0 == nvlist_add_nvlist(sd->fss, guidstring, nvfs)); + nvlist_free(nvfs); + + /* iterate over children */ + rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd); + + sd->parent_fromsnap_guid = parent_fromsnap_guid_save; + + zfs_close(zhp); + return (rv); +} + +static int +gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap, + const char *tosnap, nvlist_t **nvlp, avl_tree_t **avlp) +{ + zfs_handle_t *zhp; + send_data_t sd = { 0 }; + int error; + + zhp = zfs_open(hdl, fsname, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME); + if (zhp == NULL) + return (EZFS_BADTYPE); + + VERIFY(0 == nvlist_alloc(&sd.fss, NV_UNIQUE_NAME, 0)); + sd.fromsnap = fromsnap; + sd.tosnap = tosnap; + + if ((error = send_iterate_fs(zhp, &sd)) != 0) { + nvlist_free(sd.fss); + if (avlp != NULL) + *avlp = NULL; + *nvlp = NULL; + return (error); + } + + if (avlp != NULL && (*avlp = fsavl_create(sd.fss)) == NULL) { + nvlist_free(sd.fss); + *nvlp = NULL; + return (EZFS_NOMEM); + } + + *nvlp = sd.fss; + return (0); +} + +/* + * Routines for dealing with the sorted snapshot functionality + */ +typedef struct zfs_node { + zfs_handle_t *zn_handle; + avl_node_t zn_avlnode; +} zfs_node_t; + +static int +zfs_sort_snaps(zfs_handle_t *zhp, void *data) +{ + avl_tree_t *avl = data; + zfs_node_t *node = zfs_alloc(zhp->zfs_hdl, sizeof (zfs_node_t)); + + node->zn_handle = zhp; + avl_add(avl, node); + return (0); +} + +/* ARGSUSED */ +static int +zfs_snapshot_compare(const void *larg, const void *rarg) +{ + zfs_handle_t *l = ((zfs_node_t *)larg)->zn_handle; + zfs_handle_t *r = ((zfs_node_t *)rarg)->zn_handle; + uint64_t lcreate, rcreate; + + /* + * Sort them according to creation time. We use the hidden + * CREATETXG property to get an absolute ordering of snapshots. + */ + lcreate = zfs_prop_get_int(l, ZFS_PROP_CREATETXG); + rcreate = zfs_prop_get_int(r, ZFS_PROP_CREATETXG); + + if (lcreate < rcreate) + return (-1); + else if (lcreate > rcreate) + return (+1); + else + return (0); +} + +static int +zfs_iter_snapshots_sorted(zfs_handle_t *zhp, zfs_iter_f callback, void *data) +{ + int ret = 0; + zfs_node_t *node; + avl_tree_t avl; + void *cookie = NULL; + + avl_create(&avl, zfs_snapshot_compare, + sizeof (zfs_node_t), offsetof(zfs_node_t, zn_avlnode)); + + ret = zfs_iter_snapshots(zhp, zfs_sort_snaps, &avl); + + for (node = avl_first(&avl); node != NULL; node = AVL_NEXT(&avl, node)) + ret |= callback(node->zn_handle, data); + + while ((node = avl_destroy_nodes(&avl, &cookie)) != NULL) + free(node); + + avl_destroy(&avl); + + return (ret); +} + +/* + * Routines specific to "zfs send" + */ +typedef struct send_dump_data { + /* these are all just the short snapname (the part after the @) */ + const char *fromsnap; + const char *tosnap; + char lastsnap[ZFS_MAXNAMELEN]; + boolean_t seenfrom, seento, replicate, doall, fromorigin; + boolean_t verbose; + int outfd; + boolean_t err; + nvlist_t *fss; + avl_tree_t *fsavl; +} send_dump_data_t; + +/* + * Dumps a backup of the given snapshot (incremental from fromsnap if it's not + * NULL) to the file descriptor specified by outfd. + */ +static int +dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, boolean_t fromorigin, + int outfd) +{ + zfs_cmd_t zc = { 0 }; + libzfs_handle_t *hdl = zhp->zfs_hdl; + + assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT); + assert(fromsnap == NULL || fromsnap[0] == '\0' || !fromorigin); + + (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name)); + if (fromsnap) + (void) strlcpy(zc.zc_value, fromsnap, sizeof (zc.zc_value)); + zc.zc_cookie = outfd; + zc.zc_obj = fromorigin; + + if (ioctl(zhp->zfs_hdl->libzfs_fd, ZFS_IOC_SEND, &zc) != 0) { + char errbuf[1024]; + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, + "warning: cannot send '%s'"), zhp->zfs_name); + + switch (errno) { + + case EXDEV: + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "not an earlier snapshot from the same fs")); + return (zfs_error(hdl, EZFS_CROSSTARGET, errbuf)); + + case ENOENT: + if (zfs_dataset_exists(hdl, zc.zc_name, + ZFS_TYPE_SNAPSHOT)) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "incremental source (@%s) does not exist"), + zc.zc_value); + } + return (zfs_error(hdl, EZFS_NOENT, errbuf)); + + case EDQUOT: + case EFBIG: + case EIO: + case ENOLINK: + case ENOSPC: + case ENXIO: + case EPIPE: + case ERANGE: + case EFAULT: + case EROFS: + zfs_error_aux(hdl, strerror(errno)); + return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); + + default: + return (zfs_standard_error(hdl, errno, errbuf)); + } + } + + return (0); +} + +static int +dump_snapshot(zfs_handle_t *zhp, void *arg) +{ + send_dump_data_t *sdd = arg; + const char *thissnap; + int err; + + thissnap = strchr(zhp->zfs_name, '@') + 1; + + if (sdd->fromsnap && !sdd->seenfrom && + strcmp(sdd->fromsnap, thissnap) == 0) { + sdd->seenfrom = B_TRUE; + (void) strcpy(sdd->lastsnap, thissnap); + zfs_close(zhp); + return (0); + } + + if (sdd->seento || !sdd->seenfrom) { + zfs_close(zhp); + return (0); + } + + /* send it */ + if (sdd->verbose) { + (void) fprintf(stderr, "sending from @%s to %s\n", + sdd->lastsnap, zhp->zfs_name); + } + + err = dump_ioctl(zhp, sdd->lastsnap, + sdd->lastsnap[0] == '\0' && (sdd->fromorigin || sdd->replicate), + sdd->outfd); + + if (!sdd->seento && strcmp(sdd->tosnap, thissnap) == 0) + sdd->seento = B_TRUE; + + (void) strcpy(sdd->lastsnap, thissnap); + zfs_close(zhp); + return (err); +} + +static int +dump_filesystem(zfs_handle_t *zhp, void *arg) +{ + int rv = 0; + send_dump_data_t *sdd = arg; + boolean_t missingfrom = B_FALSE; + zfs_cmd_t zc = { 0 }; + + (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", + zhp->zfs_name, sdd->tosnap); + if (ioctl(zhp->zfs_hdl->libzfs_fd, ZFS_IOC_OBJSET_STATS, &zc) != 0) { + (void) fprintf(stderr, "WARNING: " + "could not send %s@%s: does not exist\n", + zhp->zfs_name, sdd->tosnap); + sdd->err = B_TRUE; + return (0); + } + + if (sdd->replicate && sdd->fromsnap) { + /* + * If this fs does not have fromsnap, and we're doing + * recursive, we need to send a full stream from the + * beginning (or an incremental from the origin if this + * is a clone). If we're doing non-recursive, then let + * them get the error. + */ + (void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s", + zhp->zfs_name, sdd->fromsnap); + if (ioctl(zhp->zfs_hdl->libzfs_fd, + ZFS_IOC_OBJSET_STATS, &zc) != 0) { + missingfrom = B_TRUE; + } + } + + if (sdd->doall) { + sdd->seenfrom = sdd->seento = sdd->lastsnap[0] = 0; + if (sdd->fromsnap == NULL || missingfrom) + sdd->seenfrom = B_TRUE; + + rv = zfs_iter_snapshots_sorted(zhp, dump_snapshot, arg); + if (!sdd->seenfrom) { + (void) fprintf(stderr, + "WARNING: could not send %s@%s:\n" + "incremental source (%s@%s) does not exist\n", + zhp->zfs_name, sdd->tosnap, + zhp->zfs_name, sdd->fromsnap); + sdd->err = B_TRUE; + } else if (!sdd->seento) { + (void) fprintf(stderr, + "WARNING: could not send %s@%s:\n" + "incremental source (%s@%s) " + "is not earlier than it\n", + zhp->zfs_name, sdd->tosnap, + zhp->zfs_name, sdd->fromsnap); + sdd->err = B_TRUE; + } + } else { + zfs_handle_t *snapzhp; + char snapname[ZFS_MAXNAMELEN]; + + (void) snprintf(snapname, sizeof (snapname), "%s@%s", + zfs_get_name(zhp), sdd->tosnap); + snapzhp = zfs_open(zhp->zfs_hdl, snapname, ZFS_TYPE_SNAPSHOT); + if (snapzhp == NULL) { + rv = -1; + } else { + rv = dump_ioctl(snapzhp, + missingfrom ? NULL : sdd->fromsnap, + sdd->fromorigin || missingfrom, + sdd->outfd); + sdd->seento = B_TRUE; + zfs_close(snapzhp); + } + } + + return (rv); +} + +static int +dump_filesystems(zfs_handle_t *rzhp, void *arg) +{ + send_dump_data_t *sdd = arg; + nvpair_t *fspair; + boolean_t needagain, progress; + + if (!sdd->replicate) + return (dump_filesystem(rzhp, sdd)); + +again: + needagain = progress = B_FALSE; + for (fspair = nvlist_next_nvpair(sdd->fss, NULL); fspair; + fspair = nvlist_next_nvpair(sdd->fss, fspair)) { + nvlist_t *fslist; + char *fsname; + zfs_handle_t *zhp; + int err; + uint64_t origin_guid = 0; + nvlist_t *origin_nv; + + VERIFY(nvpair_value_nvlist(fspair, &fslist) == 0); + if (nvlist_lookup_boolean(fslist, "sent") == 0) + continue; + + VERIFY(nvlist_lookup_string(fslist, "name", &fsname) == 0); + (void) nvlist_lookup_uint64(fslist, "origin", &origin_guid); + + origin_nv = fsavl_find(sdd->fsavl, origin_guid, NULL); + if (origin_nv && + nvlist_lookup_boolean(origin_nv, "sent") == ENOENT) { + /* + * origin has not been sent yet; + * skip this clone. + */ + needagain = B_TRUE; + continue; + } + + zhp = zfs_open(rzhp->zfs_hdl, fsname, ZFS_TYPE_DATASET); + if (zhp == NULL) + return (-1); + err = dump_filesystem(zhp, sdd); + VERIFY(nvlist_add_boolean(fslist, "sent") == 0); + progress = B_TRUE; + zfs_close(zhp); + if (err) + return (err); + } + if (needagain) { + assert(progress); + goto again; + } + return (0); +} + +/* + * Dumps a backup of tosnap, incremental from fromsnap if it isn't NULL. + * If 'doall', dump all intermediate snaps. + * If 'replicate', dump special header and do recursively. + */ +int +zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap, + boolean_t replicate, boolean_t doall, boolean_t fromorigin, + boolean_t verbose, int outfd) +{ + char errbuf[1024]; + send_dump_data_t sdd = { 0 }; + int err; + nvlist_t *fss = NULL; + avl_tree_t *fsavl = NULL; + + (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, + "cannot send '%s'"), zhp->zfs_name); + + if (fromsnap && fromsnap[0] == '\0') { + zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, + "zero-length incremental source")); + return (zfs_error(zhp->zfs_hdl, EZFS_NOENT, errbuf)); + } + + if (replicate || doall) { + dmu_replay_record_t drr = { 0 }; + char *packbuf = NULL; + size_t buflen = 0; + zio_cksum_t zc = { 0 }; + + assert(fromsnap || doall); + + if (replicate) { + nvlist_t *hdrnv; + + VERIFY(0 == nvlist_alloc(&hdrnv, NV_UNIQUE_NAME, 0)); + if (fromsnap) { + VERIFY(0 == nvlist_add_string(hdrnv, + "fromsnap", fromsnap)); + } + VERIFY(0 == nvlist_add_string(hdrnv, "tosnap", tosnap)); + + err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name, + fromsnap, tosnap, &fss, &fsavl); + if (err) + return (err); + VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss)); + err = nvlist_pack(hdrnv, &packbuf, &buflen, + NV_ENCODE_XDR, 0); + nvlist_free(hdrnv); + if (err) { + fsavl_destroy(fsavl); + nvlist_free(fss); + return (zfs_standard_error(zhp->zfs_hdl, + err, errbuf)); + } + } + + /* write first begin record */ + drr.drr_type = DRR_BEGIN; + drr.drr_u.drr_begin.drr_magic = DMU_BACKUP_MAGIC; + drr.drr_u.drr_begin.drr_version = DMU_BACKUP_HEADER_VERSION; + (void) snprintf(drr.drr_u.drr_begin.drr_toname, + sizeof (drr.drr_u.drr_begin.drr_toname), + "%s@%s", zhp->zfs_name, tosnap); + drr.drr_payloadlen = buflen; + fletcher_4_incremental_native(&drr, sizeof (drr), &zc); + err = write(outfd, &drr, sizeof (drr)); + + /* write header nvlist */ + if (err != -1) { + fletcher_4_incremental_native(packbuf, buflen, &zc); + err = write(outfd, packbuf, buflen); + } + free(packbuf); + if (err == -1) { + fsavl_destroy(fsavl); + nvlist_free(fss); + return (zfs_standard_error(zhp->zfs_hdl, + errno, errbuf)); + } + + /* write end record */ + if (err != -1) { + bzero(&drr, sizeof (drr)); + drr.drr_type = DRR_END; + drr.drr_u.drr_end.drr_checksum = zc; + err = write(outfd, &drr, sizeof (drr)); + if (err == -1) { + fsavl_destroy(fsavl); + nvlist_free(fss); + return (zfs_standard_error(zhp->zfs_hdl, + errno, errbuf)); + } + } + } + + /* dump each stream */ + sdd.fromsnap = fromsnap; + sdd.tosnap = tosnap; + sdd.outfd = outfd; + sdd.replicate = replicate; + sdd.doall = doall; + sdd.fromorigin = fromorigin; + sdd.fss = fss; + sdd.fsavl = fsavl; + sdd.verbose = verbose; + err = dump_filesystems(zhp, &sdd); + fsavl_destroy(fsavl); + nvlist_free(fss); + + if (replicate || doall) { + /* + * write final end record. NB: want to do this even if + * there was some error, because it might not be totally + * failed. + */ + dmu_replay_record_t drr = { 0 }; + drr.drr_type = DRR_END; + if (write(outfd, &drr, sizeof (drr)) == -1) { + return (zfs_standard_error(zhp->zfs_hdl, + errno, errbuf)); + } + } + + return (err || sdd.err); +} + +/* + * Routines specific to "zfs recv" + */ + +static int +recv_read(libzfs_handle_t *hdl, int fd, void *buf, int ilen, + boolean_t byteswap, zio_cksum_t *zc) +{ + char *cp = buf; + int rv; + int len = ilen; + + do { + rv = read(fd, cp, len); + cp += rv; + len -= rv; + } while (rv > 0); + + if (rv < 0 || len != 0) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "failed to read from stream")); + return (zfs_error(hdl, EZFS_BADSTREAM, dgettext(TEXT_DOMAIN, + "cannot receive"))); + } + + if (zc) { + if (byteswap) + fletcher_4_incremental_byteswap(buf, ilen, zc); + else + fletcher_4_incremental_native(buf, ilen, zc); + } + return (0); +} + +static int +recv_read_nvlist(libzfs_handle_t *hdl, int fd, int len, nvlist_t **nvp, + boolean_t byteswap, zio_cksum_t *zc) +{ + char *buf; + int err; + + buf = zfs_alloc(hdl, len); + if (buf == NULL) + return (ENOMEM); + + err = recv_read(hdl, fd, buf, len, byteswap, zc); + if (err != 0) { + free(buf); + return (err); + } + + err = nvlist_unpack(buf, len, nvp, 0); + free(buf); + if (err != 0) { + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "invalid " + "stream (malformed nvlist)")); + return (EINVAL); + } + return (0); +} + +static int +recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname, + int baselen, char *newname, recvflags_t flags) +{ + static int seq; + zfs_cmd_t zc = { 0 }; + int err; + prop_changelist_t *clp; + zfs_handle_t *zhp; + + zhp = zfs_open(hdl, name, ZFS_TYPE_DATASET); + if (zhp == NULL) + return (-1); + clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, + flags.force ? MS_FORCE : 0); + zfs_close(zhp); + if (clp == NULL) + return (-1); + err = changelist_prefix(clp); + if (err) + return (err); + + if (tryname) { + (void) strcpy(newname, tryname); + + zc.zc_objset_type = DMU_OST_ZFS; + (void) strlcpy(zc.zc_name, name, sizeof (zc.zc_name)); + (void) strlcpy(zc.zc_value, tryname, sizeof (zc.zc_value)); + + if (flags.verbose) { + (void) printf("attempting rename %s to %s\n", + zc.zc_name, zc.zc_value); + } + err = ioctl(hdl->libzfs_fd, ZFS_IOC_RENAME, &zc); + if (err == 0) + changelist_rename(clp, name, tryname); + } else { + err = ENOENT; + } + + if (err != 0 && strncmp(name+baselen, "recv-", 5) != 0) { + seq++; + + (void) strncpy(newname, name, baselen); + (void) snprintf(newname+baselen, ZFS_MAXNAMELEN-baselen, + "recv-%u-%u", getpid(), seq); + (void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value)); + + if (flags.verbose) { + (void) printf("failed - trying rename %s to %s\n", + zc.zc_name, zc.zc_value); + } + err = ioctl(hdl->libzfs_fd, ZFS_IOC_RENAME, &zc); + if (err == 0) + changelist_rename(clp, name, newname); + if (err && flags.verbose) { + (void) printf("failed (%u) - " + "will try again on next pass\n", errno); + } + err = EAGAIN; + } else if (flags.verbose) { + if (err == 0) + (void) printf("success\n"); + else + (void) printf("failed (%u)\n", errno); + } + + (void) changelist_postfix(clp); + changelist_free(clp); + + return (err); +} + +static int +recv_destroy(libzfs_handle_t *hdl, const char *name, int baselen, + char *newname, recvflags_t flags) +{ + zfs_cmd_t zc = { 0 }; + int err = 0; + prop_changelist_t *clp; + zfs_handle_t *zhp; + + zhp = zfs_open(hdl, name, ZFS_TYPE_DATASET); + if (zhp == NULL) + return (-1); + clp = changelist_gather(zhp, ZFS_PROP_NAME, 0, + flags.force ? MS_FORCE : 0); + zfs_close(zhp); + if (clp == NULL) + return (-1); + err = changelist_prefix(clp); + if (err) + return (err); + + zc.zc_objset_type = DMU_OST_ZFS; + (void) strlcpy(zc.zc_name, name, sizeof (zc.zc_name)); + + if (flags.verbose) + (void) printf("attempting destroy %s\n", zc.zc_name); + err = ioctl(hdl->libzfs_fd, ZFS_IOC_DESTROY, &zc); + + if (err == 0) { + if (flags.verbose) + (void) printf("success\n"); + changelist_remove(clp, zc.zc_name); + } + + (void) changelist_postfix(clp); + changelist_free(clp); + + if (err != 0) + err = recv_rename(hdl, name, NULL, baselen, newname, flags); + + return (err); +} + +typedef struct guid_to_name_data { + uint64_t guid; + char *name; +} guid_to_name_data_t; + +static int +guid_to_name_cb(zfs_handle_t *zhp, void *arg) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat May 16 02:49:05 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC0FF106564A; Sat, 16 May 2009 02:49:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9A3528FC0C; Sat, 16 May 2009 02:49:05 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G2n5dU042045; Sat, 16 May 2009 02:49:05 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G2n52p042044; Sat, 16 May 2009 02:49:05 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160249.n4G2n52p042044@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 02:49:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192180 - user/kmacy/ZFS_MFC/sys/amd64/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 02:49:05 -0000 Author: kmacy Date: Sat May 16 02:49:05 2009 New Revision: 192180 URL: http://svn.freebsd.org/changeset/base/192180 Log: add KDB, DDB, and opensolaris dependency Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Modified: user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sat May 16 02:45:38 2009 (r192179) +++ user/kmacy/ZFS_MFC/sys/amd64/conf/GENERIC_MINUS Sat May 16 02:49:05 2009 (r192180) @@ -25,7 +25,7 @@ ident GENERIC #hints "GENERIC.hints" # Default places to look for devices. makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols -makeoptions MODULES_OVERRIDE="zfs" +makeoptions MODULES_OVERRIDE="opensolaris zfs" options SCHED_ULE # ULE scheduler options PREEMPTION # Enable kernel thread preemption @@ -74,7 +74,8 @@ options INVARIANT_SUPPORT options WITNESS options WITNESS_SKIPSPIN options DEBUG - +options KDB +options DDB # Make an SMP-capable kernel by default options SMP # Symmetric MultiProcessor Kernel From owner-svn-src-user@FreeBSD.ORG Sat May 16 03:47:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44FA61065674; Sat, 16 May 2009 03:47:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2836E8FC17; Sat, 16 May 2009 03:47:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G3lm4n043421; Sat, 16 May 2009 03:47:48 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G3lmOY043420; Sat, 16 May 2009 03:47:48 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160347.n4G3lmOY043420@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 03:47:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192182 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 03:47:49 -0000 Author: kmacy Date: Sat May 16 03:47:48 2009 New Revision: 192182 URL: http://svn.freebsd.org/changeset/base/192182 Log: simplify osd interface Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 03:12:55 2009 (r192181) +++ user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 03:47:48 2009 (r192182) @@ -58,8 +58,8 @@ SYSCTL_INT(_debug, OID_AUTO, osd, CTLFLA } \ } while (0) -static void do_osd_del(u_int type, struct osd *osd, u_int slot, - int list_locked); +static void do_osd_del(u_int type, struct osd *osd, u_int slot); +static void do_osd_del_locked(u_int type, struct osd *osd, u_int slot); /* * Lists of objects with OSD. @@ -160,7 +160,7 @@ osd_deregister(u_int type, u_int slot) */ mtx_lock(&osd_list_lock[type]); LIST_FOREACH_SAFE(osd, &osd_list[type], osd_next, tosd) - do_osd_del(type, osd, slot, 1); + do_osd_del_locked(type, osd, slot); mtx_unlock(&osd_list_lock[type]); /* * Set destructor to NULL to free the slot. @@ -271,23 +271,15 @@ osd_get(u_int type, struct osd *osd, u_i return (value); } -void -osd_del(u_int type, struct osd *osd, u_int slot) -{ - - rw_rlock(&osd_object_lock[type]); - do_osd_del(type, osd, slot, 0); - rw_runlock(&osd_object_lock[type]); -} - static void -do_osd_del(u_int type, struct osd *osd, u_int slot, int list_locked) +do_osd_del_locked(u_int type, struct osd *osd, u_int slot) { int i; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); + mtx_assert(&osd_list_lock[type], MA_OWNED); OSD_DEBUG("Deleting slot (type=%u, slot=%u).", type, slot); @@ -309,11 +301,7 @@ do_osd_del(u_int type, struct osd *osd, if (i == -1) { /* No values left for this object. */ OSD_DEBUG("No more slots left (type=%u).", type); - if (!list_locked) - mtx_lock(&osd_list_lock[type]); LIST_REMOVE(osd, osd_next); - if (!list_locked) - mtx_unlock(&osd_list_lock[type]); free(osd->osd_slots, M_OSD); osd->osd_slots = NULL; osd->osd_nslots = 0; @@ -332,6 +320,25 @@ do_osd_del(u_int type, struct osd *osd, } } +static void +do_osd_del(u_int type, struct osd *osd, u_int slot) +{ + mtx_lock(&osd_list_lock[type]); + do_osd_del_locked(type, osd, slot); + mtx_unlock(&osd_list_lock[type]); +} + +void +osd_del(u_int type, struct osd *osd, u_int slot) +{ + + rw_rlock(&osd_object_lock[type]); + do_osd_del(type, osd, slot); + rw_runlock(&osd_object_lock[type]); +} + + + int osd_call(u_int type, u_int method, void *obj, void *data) { @@ -373,7 +380,7 @@ osd_exit(u_int type, struct osd *osd) rw_rlock(&osd_object_lock[type]); for (i = 1; i <= osd->osd_nslots; i++) { if (osd_destructors[type][i - 1] != NULL) - do_osd_del(type, osd, i, 0); + do_osd_del(type, osd, i); else OSD_DEBUG("Unused slot (type=%u, slot=%u).", type, i); } From owner-svn-src-user@FreeBSD.ORG Sat May 16 04:25:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3191D106566B; Sat, 16 May 2009 04:25:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 20A8A8FC27; Sat, 16 May 2009 04:25:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G4PDHn044193; Sat, 16 May 2009 04:25:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G4PDaL044192; Sat, 16 May 2009 04:25:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160425.n4G4PDaL044192@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 04:25:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192183 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 04:25:13 -0000 Author: kmacy Date: Sat May 16 04:25:12 2009 New Revision: 192183 URL: http://svn.freebsd.org/changeset/base/192183 Log: add dirty record to dbuf lock order Modified: user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Modified: user/kmacy/ZFS_MFC/sys/kern/subr_witness.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Sat May 16 03:47:48 2009 (r192182) +++ user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Sat May 16 04:25:12 2009 (r192183) @@ -397,6 +397,12 @@ static struct witness_order_list_entry o { "vnode interlock", &lock_class_mtx_sleep }, { NULL, NULL }, /* + * ZFS locking + */ + { "dr->dt.di.dr_mtx", &lock_class_sx }, + { "db->db_mtx", &lock_class_sx }, + { NULL, NULL }, + /* * spin locks */ #ifdef SMP From owner-svn-src-user@FreeBSD.ORG Sat May 16 04:33:00 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0FA481065670; Sat, 16 May 2009 04:33:00 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F307F8FC13; Sat, 16 May 2009 04:32:59 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G4Wxl0044366; Sat, 16 May 2009 04:32:59 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G4WxWI044365; Sat, 16 May 2009 04:32:59 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160432.n4G4WxWI044365@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 04:32:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192184 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 04:33:00 -0000 Author: kmacy Date: Sat May 16 04:32:59 2009 New Revision: 192184 URL: http://svn.freebsd.org/changeset/base/192184 Log: add dnode "mutex" to lock order Modified: user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Modified: user/kmacy/ZFS_MFC/sys/kern/subr_witness.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Sat May 16 04:25:12 2009 (r192183) +++ user/kmacy/ZFS_MFC/sys/kern/subr_witness.c Sat May 16 04:32:59 2009 (r192184) @@ -399,6 +399,7 @@ static struct witness_order_list_entry o /* * ZFS locking */ + { "dn->dn_mtx", &lock_class_sx }, { "dr->dt.di.dr_mtx", &lock_class_sx }, { "db->db_mtx", &lock_class_sx }, { NULL, NULL }, From owner-svn-src-user@FreeBSD.ORG Sat May 16 05:14:37 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24038106564A; Sat, 16 May 2009 05:14:37 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EC7AC8FC14; Sat, 16 May 2009 05:14:36 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G5EajU045278; Sat, 16 May 2009 05:14:36 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G5EasH045277; Sat, 16 May 2009 05:14:36 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160514.n4G5EasH045277@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 05:14:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192185 - user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 05:14:37 -0000 Author: kmacy Date: Sat May 16 05:14:36 2009 New Revision: 192185 URL: http://svn.freebsd.org/changeset/base/192185 Log: remove dead code and mount lock acquisition that was accidentally merged Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Sat May 16 04:32:59 2009 (r192184) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c Sat May 16 05:14:36 2009 (r192185) @@ -39,8 +39,6 @@ __FBSDID("$FreeBSD$"); MALLOC_DECLARE(M_MOUNT); - - void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg, int flags __unused) @@ -93,52 +91,6 @@ vfs_optionisset(const vfs_t *vfsp, const return (error != 0 ? 0 : 1); } -#if 0 -int -traverse(vnode_t **cvpp) -{ - kthread_t *td = curthread; - vnode_t *cvp; - vnode_t *tvp; - vfs_t *vfsp; - int error; - - cvp = *cvpp; - error = 0; - - /* - * If this vnode is mounted on, then we transparently indirect - * to the vnode which is the root of the mounted file system. - * Before we do this we must check that an unmount is not in - * progress on this vnode. - */ - - for (;;) { - /* - * Reached the end of the mount chain? - */ - vfsp = vn_mountedvfs(cvp); - if (vfsp == NULL) - break; - VN_RELE(cvp); - - /* - * The read lock must be held across the call to VFS_ROOT() to - * prevent a concurrent unmount from destroying the vfs. - */ - error = VFS_ROOT(vfsp, 0, &tvp, td); - if (error) - break; - VOP_UNLOCK(tvp, 0, td); - - cvp = tvp; - } - - *cvpp = cvp; - return (error); -} -#endif - extern struct mount *vfs_mount_alloc(struct vnode *vp, struct vfsconf *vfsp, const char *fspath, struct thread *td); @@ -188,10 +140,7 @@ domount(kthread_t *td, vnode_t *vp, cons /* * Set the mount level flags. - * crdup() can sleep, so do it before acquiring a mutex. */ - cr = crdup(kcred); - MNT_ILOCK(mp); if (fsflags & MNT_RDONLY) mp->mnt_flag |= MNT_RDONLY; mp->mnt_flag &=~ MNT_UPDATEMASK; From owner-svn-src-user@FreeBSD.ORG Sat May 16 06:05:56 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 31C70106566B; Sat, 16 May 2009 06:05:56 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 201658FC18; Sat, 16 May 2009 06:05:56 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G65uhA046383; Sat, 16 May 2009 06:05:56 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G65uHY046382; Sat, 16 May 2009 06:05:56 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160605.n4G65uHY046382@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 06:05:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192186 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 06:05:56 -0000 Author: kmacy Date: Sat May 16 06:05:55 2009 New Revision: 192186 URL: http://svn.freebsd.org/changeset/base/192186 Log: - pass flags through to vn_lock - ifdef out incorrect assert - only adjust vnodes once Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sat May 16 05:14:36 2009 (r192185) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sat May 16 06:05:55 2009 (r192186) @@ -860,7 +860,7 @@ zfs_root(vfs_t *vfsp, int flags, vnode_t error = zfs_zget(zfsvfs, zfsvfs->z_root, &rootzp); if (error == 0) { *vpp = ZTOV(rootzp); - error = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, td); + error = vn_lock(*vpp, flags, td); (*vpp)->v_vflag |= VV_ROOT; } @@ -1078,7 +1078,13 @@ zfs_umount(vfs_t *vfsp, int fflag, kthre if (zfsvfs->z_issnap) { vnode_t *svp = vfsp->mnt_vnodecovered; +#if 0 + /* + * I believe that this is incorrect for the + * case of manually mounted snapshots + */ ASSERT(svp->v_count == 2); +#endif VN_RELE(svp); } zfs_freevfs(vfsp); @@ -1103,7 +1109,7 @@ zfs_vget(vfs_t *vfsp, ino_t ino, int fla *vpp = NULL; else { *vpp = ZTOV(zp); - vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread); + vn_lock(*vpp, flags, curthread); } ZFS_EXIT(zfsvfs); return (err); @@ -1337,13 +1343,6 @@ zfs_init(void) * ZFS/i386. */ zfs_vnodes_adjust(); - - /* - * Reduce number of vnodes. Originally number of vnodes is calculated - * with UFS inode in mind. We reduce it here, because it's too big for - * ZFS/i386. - */ - zfs_vnodes_adjust(); } void From owner-svn-src-user@FreeBSD.ORG Sat May 16 06:22:13 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55D6C1065670; Sat, 16 May 2009 06:22:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4440F8FC1E; Sat, 16 May 2009 06:22:13 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G6MD4O046739; Sat, 16 May 2009 06:22:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G6MDxT046738; Sat, 16 May 2009 06:22:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160622.n4G6MDxT046738@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 06:22:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192187 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 06:22:13 -0000 Author: kmacy Date: Sat May 16 06:22:12 2009 New Revision: 192187 URL: http://svn.freebsd.org/changeset/base/192187 Log: nhdr needs to be zeroed Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 06:05:55 2009 (r192186) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 06:22:12 2009 (r192187) @@ -2965,7 +2965,7 @@ arc_release(arc_buf_t *buf, void *tag) mutex_exit(hash_lock); - nhdr = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE); + nhdr = kmem_cache_alloc(hdr_cache, KM_PUSHPAGE|M_ZERO); nhdr->b_size = blksz; nhdr->b_spa = spa; nhdr->b_type = type; From owner-svn-src-user@FreeBSD.ORG Sat May 16 06:39:22 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD71D106566C; Sat, 16 May 2009 06:39:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 81EAE8FC13; Sat, 16 May 2009 06:39:22 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G6dMLP047087; Sat, 16 May 2009 06:39:22 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G6dMY5047084; Sat, 16 May 2009 06:39:22 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160639.n4G6dMY5047084@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 06:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192188 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 06:39:22 -0000 Author: kmacy Date: Sat May 16 06:39:21 2009 New Revision: 192188 URL: http://svn.freebsd.org/changeset/base/192188 Log: make sure that td_osd always gets initialized Modified: user/kmacy/ZFS_MFC/sys/kern/kern_fork.c user/kmacy/ZFS_MFC/sys/kern/kern_kse.c user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Modified: user/kmacy/ZFS_MFC/sys/kern/kern_fork.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_fork.c Sat May 16 06:22:12 2009 (r192187) +++ user/kmacy/ZFS_MFC/sys/kern/kern_fork.c Sat May 16 06:39:21 2009 (r192188) @@ -505,9 +505,9 @@ again: bzero(&td2->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); - bzero(&td2->td_osd, sizeof(struct osd)); bcopy(&td->td_startcopy, &td2->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); + bzero(&td2->td_osd, sizeof(struct osd)); td2->td_sigstk = td->td_sigstk; td2->td_sigmask = td->td_sigmask; Modified: user/kmacy/ZFS_MFC/sys/kern/kern_kse.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_kse.c Sat May 16 06:22:12 2009 (r192187) +++ user/kmacy/ZFS_MFC/sys/kern/kern_kse.c Sat May 16 06:39:21 2009 (r192188) @@ -1014,6 +1014,7 @@ thread_alloc_spare(struct thread *td) td->td_standin = spare; bzero(&spare->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); + bzero(&td2->td_osd, sizeof(struct osd)); spare->td_proc = td->td_proc; spare->td_ucred = crhold(td->td_ucred); spare->td_flags = TDF_INMEM; Modified: user/kmacy/ZFS_MFC/sys/kern/kern_thr.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Sat May 16 06:22:12 2009 (r192187) +++ user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Sat May 16 06:39:21 2009 (r192188) @@ -199,6 +199,7 @@ create_thread(struct thread *td, mcontex __rangeof(struct thread, td_startzero, td_endzero)); bcopy(&td->td_startcopy, &newtd->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); + bzero(&td2->td_osd, sizeof(struct osd)); newtd->td_proc = td->td_proc; newtd->td_ucred = crhold(td->td_ucred); From owner-svn-src-user@FreeBSD.ORG Sat May 16 06:42:32 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0C56106564A; Sat, 16 May 2009 06:42:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9F9A98FC0A; Sat, 16 May 2009 06:42:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G6gWHC047191; Sat, 16 May 2009 06:42:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G6gWt9047189; Sat, 16 May 2009 06:42:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160642.n4G6gWt9047189@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 06:42:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192189 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 06:42:33 -0000 Author: kmacy Date: Sat May 16 06:42:32 2009 New Revision: 192189 URL: http://svn.freebsd.org/changeset/base/192189 Log: fix copy paste errors Modified: user/kmacy/ZFS_MFC/sys/kern/kern_kse.c user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Modified: user/kmacy/ZFS_MFC/sys/kern/kern_kse.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_kse.c Sat May 16 06:39:21 2009 (r192188) +++ user/kmacy/ZFS_MFC/sys/kern/kern_kse.c Sat May 16 06:42:32 2009 (r192189) @@ -1014,7 +1014,7 @@ thread_alloc_spare(struct thread *td) td->td_standin = spare; bzero(&spare->td_startzero, __rangeof(struct thread, td_startzero, td_endzero)); - bzero(&td2->td_osd, sizeof(struct osd)); + bzero(&spare->td_osd, sizeof(struct osd)); spare->td_proc = td->td_proc; spare->td_ucred = crhold(td->td_ucred); spare->td_flags = TDF_INMEM; Modified: user/kmacy/ZFS_MFC/sys/kern/kern_thr.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Sat May 16 06:39:21 2009 (r192188) +++ user/kmacy/ZFS_MFC/sys/kern/kern_thr.c Sat May 16 06:42:32 2009 (r192189) @@ -199,7 +199,7 @@ create_thread(struct thread *td, mcontex __rangeof(struct thread, td_startzero, td_endzero)); bcopy(&td->td_startcopy, &newtd->td_startcopy, __rangeof(struct thread, td_startcopy, td_endcopy)); - bzero(&td2->td_osd, sizeof(struct osd)); + bzero(&newtd->td_osd, sizeof(struct osd)); newtd->td_proc = td->td_proc; newtd->td_ucred = crhold(td->td_ucred); From owner-svn-src-user@FreeBSD.ORG Sat May 16 08:27:23 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B0B8E1065673; Sat, 16 May 2009 08:27:23 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9EDE88FC1A; Sat, 16 May 2009 08:27:23 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4G8RNMu049723; Sat, 16 May 2009 08:27:23 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4G8RNBP049722; Sat, 16 May 2009 08:27:23 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905160827.n4G8RNBP049722@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 08:27:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192192 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 08:27:23 -0000 Author: kmacy Date: Sat May 16 08:27:23 2009 New Revision: 192192 URL: http://svn.freebsd.org/changeset/base/192192 Log: don't assume snapshot is mounted on the control directory Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sat May 16 06:57:24 2009 (r192191) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Sat May 16 08:27:23 2009 (r192192) @@ -1078,14 +1078,11 @@ zfs_umount(vfs_t *vfsp, int fflag, kthre if (zfsvfs->z_issnap) { vnode_t *svp = vfsp->mnt_vnodecovered; -#if 0 /* - * I believe that this is incorrect for the - * case of manually mounted snapshots + * We don't need an extra vn_rele if this is a manual snapshot mount */ - ASSERT(svp->v_count == 2); -#endif - VN_RELE(svp); + if (svp->v_count == 2) + VN_RELE(svp); } zfs_freevfs(vfsp); From owner-svn-src-user@FreeBSD.ORG Sat May 16 10:55:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A9158106566B for ; Sat, 16 May 2009 10:55:14 +0000 (UTC) (envelope-from dfr@rabson.org) Received: from itchy.rabson.org (router.rabson.org [80.177.232.241]) by mx1.freebsd.org (Postfix) with ESMTP id 7DC388FC1A for ; Sat, 16 May 2009 10:55:13 +0000 (UTC) (envelope-from dfr@rabson.org) Received: from [IPv6:2001:470:909f:1:225:ff:feed:9426] (unknown [IPv6:2001:470:909f:1:225:ff:feed:9426]) by itchy.rabson.org (Postfix) with ESMTP id 727605D43; Sat, 16 May 2009 11:45:25 +0100 (BST) Message-Id: From: Doug Rabson To: Kip Macy In-Reply-To: <200905152311.n4FNBYcm037473@svn.freebsd.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.4) Date: Sat, 16 May 2009 11:44:33 +0100 References: <200905152311.n4FNBYcm037473@svn.freebsd.org> X-Mailer: Apple Mail (2.930.4) Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r192168 - in user/kmacy/ZFS_MFC/sys/cddl/boot: . zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 10:55:15 -0000 Somehow sys/cddl/boot/zfs/README has two copies of the text that appears in current. On 16 May 2009, at 00:11, Kip Macy wrote: > Author: kmacy > Date: Fri May 15 23:11:34 2009 > New Revision: 192168 > URL: http://svn.freebsd.org/changeset/base/192168 > > Log: > add ZFS boot support > > Added: > user/kmacy/ZFS_MFC/sys/cddl/boot/ > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/ > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c (contents, props > changed) > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c (contents, props > changed) > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c (contents, props > changed) > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h (contents, props > changed) > user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfssubr.c (contents, props > changed) > > Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README > = > = > = > = > = > = > = > = > ====================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README Fri May 15 23:11:34 > 2009 (r192168) > @@ -0,0 +1,28 @@ > +$FreeBSD$ > + > +This directory contains various files derived from CDDL sources that > +are used by the ZFS bootstrap: > + > + fletcher.c checksum support > + sha256.c checksum support > + lzjb.c compression support > + zfssubr.c mostly checksum and compression support > + zfsimpl.h mostly describing the physical layout > + > +The files fletcher.c, lzjb.c and sha256.c are largely identical to > the > +ZFS base code (with write support removed) and could be shared but > +that might complicate future imports from OpenSolaris. > +$FreeBSD$ > + > +This directory contains various files derived from CDDL sources that > +are used by the ZFS bootstrap: > + > + fletcher.c checksum support > + sha256.c checksum support > + lzjb.c compression support > + zfssubr.c mostly checksum and compression support > + zfsimpl.h mostly describing the physical layout > + > +The files fletcher.c, lzjb.c and sha256.c are largely identical to > the > +ZFS base code (with write support removed) and could be shared but > +that might complicate future imports from OpenSolaris. > > Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c > = > = > = > = > = > = > = > = > ====================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c Fri May 15 > 23:11:34 2009 (r192168) > @@ -0,0 +1,120 @@ > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License (the "License"). > + * You may not use this file except in compliance with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > +/* > + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +static void > +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + const uint64_t *ip = buf; > + const uint64_t *ipend = ip + (size / sizeof (uint64_t)); > + uint64_t a0, b0, a1, b1; > + > + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) { > + a0 += ip[0]; > + a1 += ip[1]; > + b0 += a0; > + b1 += a1; > + } > + > + ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); > +} > + > +static void > +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + const uint32_t *ip = buf; > + const uint32_t *ipend = ip + (size / sizeof (uint32_t)); > + uint64_t a, b, c, d; > + > + for (a = b = c = d = 0; ip < ipend; ip++) { > + a += ip[0]; > + b += a; > + c += b; > + d += c; > + } > + > + ZIO_SET_CHECKSUM(zcp, a, b, c, d); > +} > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License (the "License"). > + * You may not use this file except in compliance with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > +/* > + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +static void > +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + const uint64_t *ip = buf; > + const uint64_t *ipend = ip + (size / sizeof (uint64_t)); > + uint64_t a0, b0, a1, b1; > + > + for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) { > + a0 += ip[0]; > + a1 += ip[1]; > + b0 += a0; > + b1 += a1; > + } > + > + ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); > +} > + > +static void > +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + const uint32_t *ip = buf; > + const uint32_t *ipend = ip + (size / sizeof (uint32_t)); > + uint64_t a, b, c, d; > + > + for (a = b = c = d = 0; ip < ipend; ip++) { > + a += ip[0]; > + b += a; > + c += b; > + d += c; > + } > + > + ZIO_SET_CHECKSUM(zcp, a, b, c, d); > +} > > Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c > = > = > = > = > = > = > = > = > ====================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c Fri May 15 23:11:34 > 2009 (r192168) > @@ -0,0 +1,148 @@ > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License (the "License"). > + * You may not use this file except in compliance with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > + > +/* > + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +/* > + * We keep our own copy of this algorithm for 2 main reasons: > + * 1. If we didn't, anyone modifying common/os/compress.c would > + * directly break our on disk format > + * 2. Our version of lzjb does not have a number of checks that the > + * common/os version needs and uses > + * In particular, we are adding the "feature" that compress() can > + * take a destination buffer size and return -1 if the data will not > + * compress to d_len or less. > + */ > + > +#define MATCH_BITS 6 > +#define MATCH_MIN 3 > +#define MATCH_MAX ((1 << MATCH_BITS) + (MATCH_MIN - 1)) > +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) > +#define LEMPEL_SIZE 256 > + > +/*ARGSUSED*/ > +static int > +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t > d_len, int n) > +{ > + unsigned char *src = s_start; > + unsigned char *dst = d_start; > + unsigned char *d_end = (unsigned char *)d_start + d_len; > + unsigned char *cpy, copymap = 0; > + int copymask = 1 << (NBBY - 1); > + > + while (dst < d_end) { > + if ((copymask <<= 1) == (1 << NBBY)) { > + copymask = 1; > + copymap = *src++; > + } > + if (copymap & copymask) { > + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; > + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; > + src += 2; > + if ((cpy = dst - offset) < (unsigned char *)d_start) > + return (-1); > + while (--mlen >= 0 && dst < d_end) > + *dst++ = *cpy++; > + } else { > + *dst++ = *src++; > + } > + } > + return (0); > +} > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License (the "License"). > + * You may not use this file except in compliance with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > + > +/* > + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +/* > + * We keep our own copy of this algorithm for 2 main reasons: > + * 1. If we didn't, anyone modifying common/os/compress.c would > + * directly break our on disk format > + * 2. Our version of lzjb does not have a number of checks that the > + * common/os version needs and uses > + * In particular, we are adding the "feature" that compress() can > + * take a destination buffer size and return -1 if the data will not > + * compress to d_len or less. > + */ > + > +#define MATCH_BITS 6 > +#define MATCH_MIN 3 > +#define MATCH_MAX ((1 << MATCH_BITS) + (MATCH_MIN - 1)) > +#define OFFSET_MASK ((1 << (16 - MATCH_BITS)) - 1) > +#define LEMPEL_SIZE 256 > + > +/*ARGSUSED*/ > +static int > +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t > d_len, int n) > +{ > + unsigned char *src = s_start; > + unsigned char *dst = d_start; > + unsigned char *d_end = (unsigned char *)d_start + d_len; > + unsigned char *cpy, copymap = 0; > + int copymask = 1 << (NBBY - 1); > + > + while (dst < d_end) { > + if ((copymask <<= 1) == (1 << NBBY)) { > + copymask = 1; > + copymap = *src++; > + } > + if (copymap & copymask) { > + int mlen = (src[0] >> (NBBY - MATCH_BITS)) + MATCH_MIN; > + int offset = ((src[0] << NBBY) | src[1]) & OFFSET_MASK; > + src += 2; > + if ((cpy = dst - offset) < (unsigned char *)d_start) > + return (-1); > + while (--mlen >= 0 && dst < d_end) > + *dst++ = *cpy++; > + } else { > + *dst++ = *src++; > + } > + } > + return (0); > +} > > Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c > = > = > = > = > = > = > = > = > ====================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c Fri May 15 > 23:11:34 2009 (r192168) > @@ -0,0 +1,254 @@ > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License, Version 1.0 only > + * (the "License"). You may not use this file except in compliance > + * with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > +/* > + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +/* > + * SHA-256 checksum, as specified in FIPS 180-2, available at: > + * http://csrc.nist.gov/cryptval > + * > + * This is a very compact implementation of SHA-256. > + * It is designed to be simple and portable, not to be fast. > + */ > + > +/* > + * The literal definitions according to FIPS180-2 would be: > + * > + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) > + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) > + * > + * We use logical equivalents which require one less op. > + */ > +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) > +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) > +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) > +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) > +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) > +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) > +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) > + > +static const uint32_t SHA256_K[64] = { > + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, > + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, > + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, > + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, > + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, > + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, > + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, > + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, > + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, > + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, > + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, > + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, > + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, > + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, > + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, > + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 > +}; > + > +static void > +SHA256Transform(uint32_t *H, const uint8_t *cp) > +{ > + uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; > + > + for (t = 0; t < 16; t++, cp += 4) > + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; > + > + for (t = 16; t < 64; t++) > + W[t] = sigma1(W[t - 2]) + W[t - 7] + > + sigma0(W[t - 15]) + W[t - 16]; > + > + a = H[0]; b = H[1]; c = H[2]; d = H[3]; > + e = H[4]; f = H[5]; g = H[6]; h = H[7]; > + > + for (t = 0; t < 64; t++) { > + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; > + T2 = SIGMA0(a) + Maj(a, b, c); > + h = g; g = f; f = e; e = d + T1; > + d = c; c = b; b = a; a = T1 + T2; > + } > + > + H[0] += a; H[1] += b; H[2] += c; H[3] += d; > + H[4] += e; H[5] += f; H[6] += g; H[7] += h; > +} > + > +static void > +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, > + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; > + uint8_t pad[128]; > + int padsize = size & 63; > + int i; > + > + for (i = 0; i < size - padsize; i += 64) > + SHA256Transform(H, (uint8_t *)buf + i); > + > + for (i = 0; i < padsize; i++) > + pad[i] = ((uint8_t *)buf)[i]; > + > + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) > + pad[padsize] = 0; > + > + for (i = 0; i < 8; i++) > + pad[padsize++] = (size << 3) >> (56 - 8 * i); > + > + for (i = 0; i < padsize; i += 64) > + SHA256Transform(H, pad + i); > + > + ZIO_SET_CHECKSUM(zcp, > + (uint64_t)H[0] << 32 | H[1], > + (uint64_t)H[2] << 32 | H[3], > + (uint64_t)H[4] << 32 | H[5], > + (uint64_t)H[6] << 32 | H[7]); > +} > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License, Version 1.0 only > + * (the "License"). You may not use this file except in compliance > + * with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > +/* > + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/*#pragma ident "%Z%%M% %I% %E% SMI"*/ > + > +/* > + * SHA-256 checksum, as specified in FIPS 180-2, available at: > + * http://csrc.nist.gov/cryptval > + * > + * This is a very compact implementation of SHA-256. > + * It is designed to be simple and portable, not to be fast. > + */ > + > +/* > + * The literal definitions according to FIPS180-2 would be: > + * > + * Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) > + * Maj(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) > + * > + * We use logical equivalents which require one less op. > + */ > +#define Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) > +#define Maj(x, y, z) (((x) & (y)) ^ ((z) & ((x) ^ (y)))) > +#define Rot32(x, s) (((x) >> s) | ((x) << (32 - s))) > +#define SIGMA0(x) (Rot32(x, 2) ^ Rot32(x, 13) ^ Rot32(x, 22)) > +#define SIGMA1(x) (Rot32(x, 6) ^ Rot32(x, 11) ^ Rot32(x, 25)) > +#define sigma0(x) (Rot32(x, 7) ^ Rot32(x, 18) ^ ((x) >> 3)) > +#define sigma1(x) (Rot32(x, 17) ^ Rot32(x, 19) ^ ((x) >> 10)) > + > +static const uint32_t SHA256_K[64] = { > + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, > + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, > + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, > + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, > + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, > + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, > + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, > + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, > + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, > + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, > + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, > + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, > + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, > + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, > + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, > + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 > +}; > + > +static void > +SHA256Transform(uint32_t *H, const uint8_t *cp) > +{ > + uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; > + > + for (t = 0; t < 16; t++, cp += 4) > + W[t] = (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3]; > + > + for (t = 16; t < 64; t++) > + W[t] = sigma1(W[t - 2]) + W[t - 7] + > + sigma0(W[t - 15]) + W[t - 16]; > + > + a = H[0]; b = H[1]; c = H[2]; d = H[3]; > + e = H[4]; f = H[5]; g = H[6]; h = H[7]; > + > + for (t = 0; t < 64; t++) { > + T1 = h + SIGMA1(e) + Ch(e, f, g) + SHA256_K[t] + W[t]; > + T2 = SIGMA0(a) + Maj(a, b, c); > + h = g; g = f; f = e; e = d + T1; > + d = c; c = b; b = a; a = T1 + T2; > + } > + > + H[0] += a; H[1] += b; H[2] += c; H[3] += d; > + H[4] += e; H[5] += f; H[6] += g; H[7] += h; > +} > + > +static void > +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) > +{ > + uint32_t H[8] = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, > + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; > + uint8_t pad[128]; > + int padsize = size & 63; > + int i; > + > + for (i = 0; i < size - padsize; i += 64) > + SHA256Transform(H, (uint8_t *)buf + i); > + > + for (i = 0; i < padsize; i++) > + pad[i] = ((uint8_t *)buf)[i]; > + > + for (pad[padsize++] = 0x80; (padsize & 63) != 56; padsize++) > + pad[padsize] = 0; > + > + for (i = 0; i < 8; i++) > + pad[padsize++] = (size << 3) >> (56 - 8 * i); > + > + for (i = 0; i < padsize; i += 64) > + SHA256Transform(H, pad + i); > + > + ZIO_SET_CHECKSUM(zcp, > + (uint64_t)H[0] << 32 | H[1], > + (uint64_t)H[2] << 32 | H[3], > + (uint64_t)H[4] << 32 | H[5], > + (uint64_t)H[6] << 32 | H[7]); > +} > > Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h > = > = > = > = > = > = > = > = > ====================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h Fri May 15 > 23:11:34 2009 (r192168) > @@ -0,0 +1,2340 @@ > +/*- > + * Copyright (c) 2002 McAfee, Inc. > + * All rights reserved. > + * > + * This software was developed for the FreeBSD Project by Marshall > + * Kirk McKusick and McAfee Research,, the Security Research > Division of > + * McAfee, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 > ("CBOSS"), as > + * part of the DARPA CHATS research program > + * > + * 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. > + */ > +/* > + * CDDL HEADER START > + * > + * The contents of this file are subject to the terms of the > + * Common Development and Distribution License (the "License"). > + * You may not use this file except in compliance with the License. > + * > + * You can obtain a copy of the license at usr/src/ > OPENSOLARIS.LICENSE > + * or http://www.opensolaris.org/os/licensing. > + * See the License for the specific language governing permissions > + * and limitations under the License. > + * > + * When distributing Covered Code, include this CDDL HEADER in each > + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. > + * If applicable, add the following below this CDDL HEADER, with the > + * fields enclosed by brackets "[]" replaced with your own > identifying > + * information: Portions Copyright [yyyy] [name of copyright owner] > + * > + * CDDL HEADER END > + */ > +/* > + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. > + * Use is subject to license terms. > + */ > + > +/* CRC64 table */ > +#define ZFS_CRC64_POLY 0xC96C5795D7870F42ULL /* ECMA-182, reflected > form */ > + > +/* > + * Macros for various sorts of alignment and rounding when the > alignment > + * is known to be a power of 2. > + */ > +#define P2ALIGN(x, align) ((x) & -(align)) > +#define P2PHASE(x, align) ((x) & ((align) - 1)) > +#define P2NPHASE(x, align) (-(x) & ((align) - 1)) > +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) > +#define P2END(x, align) (-(~(x) & -(align))) > +#define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & - > (align))) > +#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) > + > +/* > + * General-purpose 32-bit and 64-bit bitfield encodings. > + */ > +#define BF32_DECODE(x, low, len) P2PHASE((x) >> (low), 1U << (len)) > +#define BF64_DECODE(x, low, len) P2PHASE((x) >> (low), 1ULL << (len)) > +#define BF32_ENCODE(x, low, len) (P2PHASE((x), 1U << (len)) << (low)) > +#define BF64_ENCODE(x, low, len) (P2PHASE((x), 1ULL << (len)) << > (low)) > + > +#define BF32_GET(x, low, len) BF32_DECODE(x, low, len) > +#define BF64_GET(x, low, len) BF64_DECODE(x, low, len) > + > +#define BF32_SET(x, low, len, val) \ > + ((x) ^= BF32_ENCODE((x >> low) ^ (val), low, len)) > +#define BF64_SET(x, low, len, val) \ > + ((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)) > + > +#define BF32_GET_SB(x, low, len, shift, bias) \ > + ((BF32_GET(x, low, len) + (bias)) << (shift)) > +#define BF64_GET_SB(x, low, len, shift, bias) \ > + ((BF64_GET(x, low, len) + (bias)) << (shift)) > + > +#define BF32_SET_SB(x, low, len, shift, bias, val) \ > + BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) > +#define BF64_SET_SB(x, low, len, shift, bias, val) \ > + BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) > + > +/* > + * We currently support nine block sizes, from 512 bytes to 128K. > + * We could go higher, but the benefits are near-zero and the cost > + * of COWing a giant block to modify one byte would become excessive. > + */ > +#define SPA_MINBLOCKSHIFT 9 > +#define SPA_MAXBLOCKSHIFT 17 > +#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) > +#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) > + > +#define SPA_BLOCKSIZES (SPA_MAXBLOCKSHIFT - SPA_MINBLOCKSHIFT + 1) > + > +/* > + * The DVA size encodings for LSIZE and PSIZE support blocks up to > 32MB. > + * The ASIZE encoding should be at least 64 times larger (6 more > bits) > + * to support up to 4-way RAID-Z mirror mode with worst-case gang > block > + * overhead, three DVAs per bp, plus one more bit in case we do > anything > + * else that expands the ASIZE. > + */ > +#define SPA_LSIZEBITS 16 /* LSIZE up to 32M (2^16 * 512) */ > +#define SPA_PSIZEBITS 16 /* PSIZE up to 32M (2^16 * 512) */ > +#define SPA_ASIZEBITS 24 /* ASIZE up to 64 times larger */ > + > +/* > + * All SPA data is represented by 128-bit data virtual addresses > (DVAs). > + * The members of the dva_t should be considered opaque outside the > SPA. > + */ > +typedef struct dva { > + uint64_t dva_word[2]; > +} dva_t; > + > +/* > + * Each block has a 256-bit checksum -- strong enough for > cryptographic hashes. > + */ > +typedef struct zio_cksum { > + uint64_t zc_word[4]; > +} zio_cksum_t; > + > +/* > + * Each block is described by its DVAs, time of birth, checksum, etc. > + * The word-by-word, bit-by-bit layout of the blkptr is as follows: > + * > + * 64 56 48 40 32 24 16 8 0 > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 0 | vdev1 | GRID | ASIZE | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 1 |G| offset1 | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 2 | vdev2 | GRID | ASIZE | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 3 |G| offset2 | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 4 | vdev3 | GRID | ASIZE | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 5 |G| offset3 | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 6 |E| lvl | type | cksum | comp | PSIZE | LSIZE | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 7 | padding | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 8 | padding | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * 9 | padding | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * a | birth txg | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * b | fill count | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * c | checksum[0] | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * d | checksum[1] | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * e | checksum[2] | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * f | checksum[3] | > + * +-------+-------+-------+-------+-------+-------+-------+-------+ > + * > + * Legend: > + * > + * vdev virtual device ID > + * offset offset into virtual device > + * LSIZE logical size > + * PSIZE physical size (after compression) > + * ASIZE allocated size (including RAID-Z parity and gang block > headers) > + * GRID RAID-Z layout information (reserved for future use) > + * cksum checksum function > + * comp compression function > + * G gang block indicator > + * E endianness > + * type DMU object type > + * lvl level of indirection > + * birth txg transaction group in which the block was born > + * fill count number of non-zero blocks under this bp > + * checksum[4] 256-bit checksum of the data this bp describes > + */ > +typedef struct blkptr { > + dva_t blk_dva[3]; /* 128-bit Data Virtual Address */ > + uint64_t blk_prop; /* size, compression, type, etc */ > + uint64_t blk_pad[3]; /* Extra space for the future */ > + uint64_t blk_birth; /* transaction group at birth */ > + uint64_t blk_fill; /* fill count */ > + zio_cksum_t blk_cksum; /* 256-bit checksum */ > +} blkptr_t; > + > +#define SPA_BLKPTRSHIFT 7 /* blkptr_t is 128 bytes */ > +#define SPA_DVAS_PER_BP 3 /* Number of DVAs in a bp */ > + > +/* > + * Macros to get and set fields in a bp or DVA. > + */ > +#define DVA_GET_ASIZE(dva) \ > + BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0) > +#define DVA_SET_ASIZE(dva, x) \ > + BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, 0, x) > + > +#define DVA_GET_GRID(dva) BF64_GET((dva)->dva_word[0], 24, 8) > +#define DVA_SET_GRID(dva, x) BF64_SET((dva)->dva_word[0], 24, 8, x) > + > +#define DVA_GET_VDEV(dva) BF64_GET((dva)->dva_word[0], 32, 32) > +#define DVA_SET_VDEV(dva, x) BF64_SET((dva)->dva_word[0], 32, 32, x) > + > +#define DVA_GET_OFFSET(dva) \ > + BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0) > +#define DVA_SET_OFFSET(dva, x) \ > + BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, 0, x) > + > +#define DVA_GET_GANG(dva) BF64_GET((dva)->dva_word[1], 63, 1) > +#define DVA_SET_GANG(dva, x) BF64_SET((dva)->dva_word[1], 63, 1, x) > + > +#define BP_GET_LSIZE(bp) \ > + (BP_IS_HOLE(bp) ? 0 : \ > + BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)) > +#define BP_SET_LSIZE(bp, x) \ > + BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) > + > +#define BP_GET_PSIZE(bp) \ > + BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1) > +#define BP_SET_PSIZE(bp, x) \ > + BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x) > + > +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) > +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) > + > +#define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) > +#define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) > + > +#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8) > +#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x) > + > +#define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) > +#define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) > + > +#define BP_GET_BYTEORDER(bp) (0 - BF64_GET((bp)->blk_prop, 63, 1)) > +#define BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop, 63, 1, x) > + > +#define BP_GET_ASIZE(bp) \ > + (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + DVA_GET_ASIZE(&(bp)- > >blk_dva[1]) + \ > + DVA_GET_ASIZE(&(bp)->blk_dva[2])) > + > +#define BP_GET_UCSIZE(bp) \ > + ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \ > + BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); > + > +#define BP_GET_NDVAS(bp) \ > + (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ > + !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ > + !!DVA_GET_ASIZE(&(bp)->blk_dva[2])) > + > +#define BP_COUNT_GANG(bp) \ > + (DVA_GET_GANG(&(bp)->blk_dva[0]) + \ > + DVA_GET_GANG(&(bp)->blk_dva[1]) + \ > + DVA_GET_GANG(&(bp)->blk_dva[2])) > + > +#define DVA_EQUAL(dva1, dva2) \ > + ((dva1)->dva_word[1] == (dva2)->dva_word[1] && \ > + (dva1)->dva_word[0] == (dva2)->dva_word[0]) > + > +#define ZIO_CHECKSUM_EQUAL(zc1, zc2) \ > + (0 == (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ > + ((zc1).zc_word[1] - (zc2).zc_word[1]) | \ > + ((zc1).zc_word[2] - (zc2).zc_word[2]) | \ > + ((zc1).zc_word[3] - (zc2).zc_word[3]))) > + > + > +#define DVA_IS_VALID(dva) (DVA_GET_ASIZE(dva) != 0) > + > +#define ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) \ > +{ \ > + (zcp)->zc_word[0] = w0; \ > + (zcp)->zc_word[1] = w1; \ > + (zcp)->zc_word[2] = w2; \ > + (zcp)->zc_word[3] = w3; \ > +} > + > +#define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) > +#define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) > +#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) > +#define BP_IS_OLDER(bp, txg) (!BP_IS_HOLE(bp) && (bp)->blk_birth < > (txg)) > + > +#define BP_ZERO(bp) \ > +{ \ > + (bp)->blk_dva[0].dva_word[0] = 0; \ > + (bp)->blk_dva[0].dva_word[1] = 0; \ > + (bp)->blk_dva[1].dva_word[0] = 0; \ > + (bp)->blk_dva[1].dva_word[1] = 0; \ > + (bp)->blk_dva[2].dva_word[0] = 0; \ > + (bp)->blk_dva[2].dva_word[1] = 0; \ > + (bp)->blk_prop = 0; \ > + (bp)->blk_pad[0] = 0; \ > + (bp)->blk_pad[1] = 0; \ > + (bp)->blk_pad[2] = 0; \ > + (bp)->blk_birth = 0; \ > + (bp)->blk_fill = 0; \ > + ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ > +} > + > +#define ZBT_MAGIC 0x210da7ab10c7a11ULL /* zio data bloc tail */ > + > +typedef struct zio_block_tail { > + uint64_t zbt_magic; /* for validation, endianness */ > + zio_cksum_t zbt_cksum; /* 256-bit checksum */ > +} zio_block_tail_t; > + > +#define VDEV_SKIP_SIZE (8 << 10) > +#define VDEV_BOOT_HEADER_SIZE (8 << 10) > +#define VDEV_PHYS_SIZE (112 << 10) > +#define VDEV_UBERBLOCK_RING (128 << 10) > + > +#define VDEV_UBERBLOCK_SHIFT(vd) \ > + MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT) > +#define VDEV_UBERBLOCK_COUNT(vd) \ > + (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd)) > +#define VDEV_UBERBLOCK_OFFSET(vd, n) \ > + offsetof(vdev_label_t, vl_uberblock[(n) << > VDEV_UBERBLOCK_SHIFT(vd)]) > +#define VDEV_UBERBLOCK_SIZE(vd) (1ULL << VDEV_UBERBLOCK_SHIFT(vd)) > + > +/* ZFS boot block */ > +#define VDEV_BOOT_MAGIC 0x2f5b007b10cULL > +#define VDEV_BOOT_VERSION 1 /* version number */ > + > +typedef struct vdev_boot_header { > + uint64_t vb_magic; /* VDEV_BOOT_MAGIC */ > + uint64_t vb_version; /* VDEV_BOOT_VERSION */ > + uint64_t vb_offset; /* start offset (bytes) */ > + uint64_t vb_size; /* size (bytes) */ > + char vb_pad[VDEV_BOOT_HEADER_SIZE - 4 * sizeof (uint64_t)]; > +} vdev_boot_header_t; > + > +typedef struct vdev_phys { > + char vp_nvlist[VDEV_PHYS_SIZE - sizeof (zio_block_tail_t)]; > + zio_block_tail_t vp_zbt; > +} vdev_phys_t; > + > +typedef struct vdev_label { > + char vl_pad[VDEV_SKIP_SIZE]; /* 8K */ > + vdev_boot_header_t vl_boot_header; /* 8K */ > + vdev_phys_t vl_vdev_phys; /* 112K */ > + char vl_uberblock[VDEV_UBERBLOCK_RING]; /* 128K */ > +} vdev_label_t; /* 256K total */ > + > +/* > + * vdev_dirty() flags > + */ > +#define VDD_METASLAB 0x01 > +#define VDD_DTL 0x02 > + > +/* > + * Size and offset of embedded boot loader region on each label. > + * The total size of the first two labels plus the boot area is 4MB. > + */ > +#define VDEV_BOOT_OFFSET (2 * sizeof (vdev_label_t)) > +#define VDEV_BOOT_SIZE (7ULL << 19) /* 3.5M */ > + > +/* > + * Size of label regions at the start and end of each leaf device. > + */ > +#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + > VDEV_BOOT_SIZE) > +#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t)) > +#define VDEV_LABELS 4 > + > +enum zio_checksum { > + ZIO_CHECKSUM_INHERIT = 0, > + ZIO_CHECKSUM_ON, > + ZIO_CHECKSUM_OFF, > + ZIO_CHECKSUM_LABEL, > + ZIO_CHECKSUM_GANG_HEADER, > + ZIO_CHECKSUM_ZILOG, > + ZIO_CHECKSUM_FLETCHER_2, > + ZIO_CHECKSUM_FLETCHER_4, > + ZIO_CHECKSUM_SHA256, > + ZIO_CHECKSUM_FUNCTIONS > +}; > + > +#define ZIO_CHECKSUM_ON_VALUE ZIO_CHECKSUM_FLETCHER_2 > +#define ZIO_CHECKSUM_DEFAULT ZIO_CHECKSUM_ON > + > +enum zio_compress { > + ZIO_COMPRESS_INHERIT = 0, > + ZIO_COMPRESS_ON, > + ZIO_COMPRESS_OFF, > + ZIO_COMPRESS_LZJB, > + ZIO_COMPRESS_EMPTY, > + ZIO_COMPRESS_GZIP_1, > + ZIO_COMPRESS_GZIP_2, > + ZIO_COMPRESS_GZIP_3, > + ZIO_COMPRESS_GZIP_4, > + ZIO_COMPRESS_GZIP_5, > + ZIO_COMPRESS_GZIP_6, > + ZIO_COMPRESS_GZIP_7, > + ZIO_COMPRESS_GZIP_8, > + ZIO_COMPRESS_GZIP_9, > + ZIO_COMPRESS_FUNCTIONS > +}; > + > +#define ZIO_COMPRESS_ON_VALUE ZIO_COMPRESS_LZJB > +#define ZIO_COMPRESS_DEFAULT ZIO_COMPRESS_OFF > + > +/* nvlist pack encoding */ > +#define NV_ENCODE_NATIVE 0 > +#define NV_ENCODE_XDR 1 > + > +typedef enum { > + DATA_TYPE_UNKNOWN = 0, > + DATA_TYPE_BOOLEAN, > + DATA_TYPE_BYTE, > + DATA_TYPE_INT16, > + DATA_TYPE_UINT16, > + DATA_TYPE_INT32, > + DATA_TYPE_UINT32, > + DATA_TYPE_INT64, > + DATA_TYPE_UINT64, > + DATA_TYPE_STRING, > + DATA_TYPE_BYTE_ARRAY, > + DATA_TYPE_INT16_ARRAY, > + DATA_TYPE_UINT16_ARRAY, > + DATA_TYPE_INT32_ARRAY, > + DATA_TYPE_UINT32_ARRAY, > + DATA_TYPE_INT64_ARRAY, > + DATA_TYPE_UINT64_ARRAY, > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat May 16 16:44:38 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 848BF106564A for ; Sat, 16 May 2009 16:44:38 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.249]) by mx1.freebsd.org (Postfix) with ESMTP id E603C8FC1E for ; Sat, 16 May 2009 16:44:34 +0000 (UTC) (envelope-from mat.macy@gmail.com) Received: by an-out-0708.google.com with SMTP id c3so1247228ana.13 for ; Sat, 16 May 2009 09:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type:content-transfer-encoding; bh=n33YR+WQbTxpaafSu5EnRMjsHcxKf7Qg3zI1/66G/mQ=; b=KLoN55IlDPfAeAdrY56S2ZsrnyAxtDVJ7q/Y1l0sxFuNYI4dFaGGdl5YFMRXKgbQxf UKoH3CF14QBkb8hYFU8U8DH6OTH3LmmEtwwBsBDB31Zo9NSqIfNVZMPCQg9Jm4dOH5jr rYoJCve+I2KHAkR/93DdxXB+MnxulGacvrUYE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=bxKCQPk2ttN/hCifR/StE3t3bq+WX5Ds8TaqMRFaq3sJ0OPLr2Uf0jU203U3jsfv7O 5KtCUEk2mf4U3oNw04GMhg0jhYWKvMWwb9+HCIT41ZYnfQf/xEjGqSR2raL/cRmBfYIv a4BxYKMvqAu9xwyq1QvHX2UaPFIPpCem8Bqdc= MIME-Version: 1.0 Sender: mat.macy@gmail.com Received: by 10.100.207.15 with SMTP id e15mr5784393ang.30.1242490583889; Sat, 16 May 2009 09:16:23 -0700 (PDT) In-Reply-To: References: <200905152311.n4FNBYcm037473@svn.freebsd.org> Date: Sat, 16 May 2009 09:16:23 -0700 X-Google-Sender-Auth: 8902d88f29ef06bc Message-ID: <3c1674c90905160916m71f75ea8tcd7aa8b9057e1c1b@mail.gmail.com> From: Kip Macy To: Doug Rabson Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r192168 - in user/kmacy/ZFS_MFC/sys/cddl/boot: . zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 16:44:38 -0000 Thanks. 'svn revert' doesn't delete files that haven't been added - I applied a patch from another tree multiple times which causes files to have the same content multiple times. Cheers, Kip On Sat, May 16, 2009 at 3:44 AM, Doug Rabson wrote: > Somehow sys/cddl/boot/zfs/README has two copies of the text that appears = in > current. > > On 16 May 2009, at 00:11, Kip Macy wrote: > >> Author: kmacy >> Date: Fri May 15 23:11:34 2009 >> New Revision: 192168 >> URL: http://svn.freebsd.org/changeset/base/192168 >> >> Log: >> =A0add ZFS boot support >> >> Added: >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/ >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/ >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c =A0 (contents, props >> changed) >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c =A0 (contents, props chan= ged) >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c =A0 (contents, props ch= anged) >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h =A0 (contents, props >> changed) >> =A0user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfssubr.c =A0 (contents, props >> changed) >> >> Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added) >> +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README Fri May 15 23:11:34 2009 >> =A0(r192168) >> @@ -0,0 +1,28 @@ >> +$FreeBSD$ >> + >> +This directory contains various files derived from CDDL sources that >> +are used by the ZFS bootstrap: >> + >> + =A0 =A0fletcher.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum support >> + =A0 =A0sha256.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum support >> + =A0 =A0lzjb.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compression supp= ort >> + =A0 =A0zfssubr.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mostly checksum an= d compression support >> + =A0 =A0zfsimpl.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mostly describing = the physical layout >> + >> +The files fletcher.c, lzjb.c and sha256.c are largely identical to the >> +ZFS base code (with write support removed) and could be shared but >> +that might complicate future imports from OpenSolaris. >> +$FreeBSD$ >> + >> +This directory contains various files derived from CDDL sources that >> +are used by the ZFS bootstrap: >> + >> + =A0 =A0fletcher.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum support >> + =A0 =A0sha256.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum support >> + =A0 =A0lzjb.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 compression supp= ort >> + =A0 =A0zfssubr.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mostly checksum an= d compression support >> + =A0 =A0zfsimpl.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0mostly describing = the physical layout >> + >> +The files fletcher.c, lzjb.c and sha256.c are largely identical to the >> +ZFS base code (with write support removed) and could be shared but >> +that might complicate future imports from OpenSolaris. >> >> Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added) >> +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c =A0 =A0 Fri May 15 >> 23:11:34 2009 =A0 (r192168) >> @@ -0,0 +1,120 @@ >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License (the "License"). >> + * You may not use this file except in compliance with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> +/* >> + * Copyright 2006 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +static void >> +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 const uint64_t *ip =3D buf; >> + =A0 =A0 =A0 const uint64_t *ipend =3D ip + (size / sizeof (uint64_t)); >> + =A0 =A0 =A0 uint64_t a0, b0, a1, b1; >> + >> + =A0 =A0 =A0 for (a0 =3D b0 =3D a1 =3D b1 =3D 0; ip < ipend; ip +=3D 2)= { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a0 +=3D ip[0]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a1 +=3D ip[1]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b0 +=3D a0; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b1 +=3D a1; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); >> +} >> + >> +static void >> +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 const uint32_t *ip =3D buf; >> + =A0 =A0 =A0 const uint32_t *ipend =3D ip + (size / sizeof (uint32_t)); >> + =A0 =A0 =A0 uint64_t a, b, c, d; >> + >> + =A0 =A0 =A0 for (a =3D b =3D c =3D d =3D 0; ip < ipend; ip++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a +=3D ip[0]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b +=3D a; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 c +=3D b; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 d +=3D c; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, a, b, c, d); >> +} >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License (the "License"). >> + * You may not use this file except in compliance with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> +/* >> + * Copyright 2006 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +static void >> +fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 const uint64_t *ip =3D buf; >> + =A0 =A0 =A0 const uint64_t *ipend =3D ip + (size / sizeof (uint64_t)); >> + =A0 =A0 =A0 uint64_t a0, b0, a1, b1; >> + >> + =A0 =A0 =A0 for (a0 =3D b0 =3D a1 =3D b1 =3D 0; ip < ipend; ip +=3D 2)= { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a0 +=3D ip[0]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a1 +=3D ip[1]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b0 +=3D a0; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b1 +=3D a1; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1); >> +} >> + >> +static void >> +fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 const uint32_t *ip =3D buf; >> + =A0 =A0 =A0 const uint32_t *ipend =3D ip + (size / sizeof (uint32_t)); >> + =A0 =A0 =A0 uint64_t a, b, c, d; >> + >> + =A0 =A0 =A0 for (a =3D b =3D c =3D d =3D 0; ip < ipend; ip++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 a +=3D ip[0]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 b +=3D a; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 c +=3D b; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 d +=3D c; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, a, b, c, d); >> +} >> >> Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added) >> +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c Fri May 15 23:11:34 2009 >> =A0(r192168) >> @@ -0,0 +1,148 @@ >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License (the "License"). >> + * You may not use this file except in compliance with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> + >> +/* >> + * Copyright 2007 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +/* >> + * We keep our own copy of this algorithm for 2 main reasons: >> + * =A0 =A0 1. If we didn't, anyone modifying common/os/compress.c would >> + * =A0 =A0 =A0 =A0 directly break our on disk format >> + * =A0 =A0 2. Our version of lzjb does not have a number of checks that= the >> + * =A0 =A0 =A0 =A0 common/os version needs and uses >> + * In particular, we are adding the "feature" that compress() can >> + * take a destination buffer size and return -1 if the data will not >> + * compress to d_len or less. >> + */ >> + >> +#define =A0 =A0 =A0 =A0MATCH_BITS =A0 =A0 =A06 >> +#define =A0 =A0 =A0 =A0MATCH_MIN =A0 =A0 =A0 3 >> +#define =A0 =A0 =A0 =A0MATCH_MAX =A0 =A0 =A0 ((1 << MATCH_BITS) + (MATC= H_MIN - 1)) >> +#define =A0 =A0 =A0 =A0OFFSET_MASK =A0 =A0 ((1 << (16 - MATCH_BITS)) - = 1) >> +#define =A0 =A0 =A0 =A0LEMPEL_SIZE =A0 =A0 256 >> + >> +/*ARGSUSED*/ >> +static int >> +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_le= n, >> int n) >> +{ >> + =A0 =A0 =A0 unsigned char *src =3D s_start; >> + =A0 =A0 =A0 unsigned char *dst =3D d_start; >> + =A0 =A0 =A0 unsigned char *d_end =3D (unsigned char *)d_start + d_len; >> + =A0 =A0 =A0 unsigned char *cpy, copymap =3D 0; >> + =A0 =A0 =A0 int copymask =3D 1 << (NBBY - 1); >> + >> + =A0 =A0 =A0 while (dst < d_end) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((copymask <<=3D 1) =3D=3D (1 << NBBY))= { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 copymask =3D 1; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 copymap =3D *src++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (copymap & copymask) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int mlen =3D (src[0] >> (N= BBY - MATCH_BITS)) + >> MATCH_MIN; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int offset =3D ((src[0] <<= NBBY) | src[1]) & >> OFFSET_MASK; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 src +=3D 2; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((cpy =3D dst - offset)= < (unsigned char >> *)d_start) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (-1= ); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (--mlen >=3D 0 && ds= t < d_end) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *dst++ =3D= *cpy++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *dst++ =3D *src++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 } >> + =A0 =A0 =A0 return (0); >> +} >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License (the "License"). >> + * You may not use this file except in compliance with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> + >> +/* >> + * Copyright 2007 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +/* >> + * We keep our own copy of this algorithm for 2 main reasons: >> + * =A0 =A0 1. If we didn't, anyone modifying common/os/compress.c would >> + * =A0 =A0 =A0 =A0 directly break our on disk format >> + * =A0 =A0 2. Our version of lzjb does not have a number of checks that= the >> + * =A0 =A0 =A0 =A0 common/os version needs and uses >> + * In particular, we are adding the "feature" that compress() can >> + * take a destination buffer size and return -1 if the data will not >> + * compress to d_len or less. >> + */ >> + >> +#define =A0 =A0 =A0 =A0MATCH_BITS =A0 =A0 =A06 >> +#define =A0 =A0 =A0 =A0MATCH_MIN =A0 =A0 =A0 3 >> +#define =A0 =A0 =A0 =A0MATCH_MAX =A0 =A0 =A0 ((1 << MATCH_BITS) + (MATC= H_MIN - 1)) >> +#define =A0 =A0 =A0 =A0OFFSET_MASK =A0 =A0 ((1 << (16 - MATCH_BITS)) - = 1) >> +#define =A0 =A0 =A0 =A0LEMPEL_SIZE =A0 =A0 256 >> + >> +/*ARGSUSED*/ >> +static int >> +lzjb_decompress(void *s_start, void *d_start, size_t s_len, size_t d_le= n, >> int n) >> +{ >> + =A0 =A0 =A0 unsigned char *src =3D s_start; >> + =A0 =A0 =A0 unsigned char *dst =3D d_start; >> + =A0 =A0 =A0 unsigned char *d_end =3D (unsigned char *)d_start + d_len; >> + =A0 =A0 =A0 unsigned char *cpy, copymap =3D 0; >> + =A0 =A0 =A0 int copymask =3D 1 << (NBBY - 1); >> + >> + =A0 =A0 =A0 while (dst < d_end) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((copymask <<=3D 1) =3D=3D (1 << NBBY))= { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 copymask =3D 1; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 copymap =3D *src++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (copymap & copymask) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int mlen =3D (src[0] >> (N= BBY - MATCH_BITS)) + >> MATCH_MIN; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 int offset =3D ((src[0] <<= NBBY) | src[1]) & >> OFFSET_MASK; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 src +=3D 2; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if ((cpy =3D dst - offset)= < (unsigned char >> *)d_start) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return (-1= ); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 while (--mlen >=3D 0 && ds= t < d_end) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *dst++ =3D= *cpy++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *dst++ =3D *src++; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 } >> + =A0 =A0 =A0 return (0); >> +} >> >> Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added) >> +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c =A0 =A0 =A0 Fri May 15 >> 23:11:34 2009 =A0 (r192168) >> @@ -0,0 +1,254 @@ >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License, Version 1.0 only >> + * (the "License"). =A0You may not use this file except in compliance >> + * with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> +/* >> + * Copyright 2005 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +/* >> + * SHA-256 checksum, as specified in FIPS 180-2, available at: >> + * http://csrc.nist.gov/cryptval >> + * >> + * This is a very compact implementation of SHA-256. >> + * It is designed to be simple and portable, not to be fast. >> + */ >> + >> +/* >> + * The literal definitions according to FIPS180-2 would be: >> + * >> + * =A0 =A0 Ch(x, y, z) =A0 =A0 (((x) & (y)) ^ ((~(x)) & (z))) >> + * =A0 =A0 Maj(x, y, z) =A0 =A0(((x) & (y)) | ((x) & (z)) | ((y) & (z))= ) >> + * >> + * We use logical equivalents which require one less op. >> + */ >> +#define =A0 =A0 =A0 =A0Ch(x, y, z) =A0 =A0 ((z) ^ ((x) & ((y) ^ (z)))) >> +#define =A0 =A0 =A0 =A0Maj(x, y, z) =A0 =A0(((x) & (y)) ^ ((z) & ((x) ^= (y)))) >> +#define =A0 =A0 =A0 =A0Rot32(x, s) =A0 =A0 (((x) >> s) | ((x) << (32 - = s))) >> +#define =A0 =A0 =A0 =A0SIGMA0(x) =A0 =A0 =A0 (Rot32(x, 2) ^ Rot32(x, 13= ) ^ Rot32(x, >> 22)) >> +#define =A0 =A0 =A0 =A0SIGMA1(x) =A0 =A0 =A0 (Rot32(x, 6) ^ Rot32(x, 11= ) ^ Rot32(x, >> 25)) >> +#define =A0 =A0 =A0 =A0sigma0(x) =A0 =A0 =A0 (Rot32(x, 7) ^ Rot32(x, 18= ) ^ ((x) >> 3)) >> +#define =A0 =A0 =A0 =A0sigma1(x) =A0 =A0 =A0 (Rot32(x, 17) ^ Rot32(x, 1= 9) ^ ((x) >> >> 10)) >> + >> +static const uint32_t SHA256_K[64] =3D { >> + =A0 =A0 =A0 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, >> + =A0 =A0 =A0 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, >> + =A0 =A0 =A0 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, >> + =A0 =A0 =A0 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, >> + =A0 =A0 =A0 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, >> + =A0 =A0 =A0 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, >> + =A0 =A0 =A0 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, >> + =A0 =A0 =A0 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, >> + =A0 =A0 =A0 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, >> + =A0 =A0 =A0 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, >> + =A0 =A0 =A0 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, >> + =A0 =A0 =A0 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, >> + =A0 =A0 =A0 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, >> + =A0 =A0 =A0 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, >> + =A0 =A0 =A0 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, >> + =A0 =A0 =A0 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 >> +}; >> + >> +static void >> +SHA256Transform(uint32_t *H, const uint8_t *cp) >> +{ >> + =A0 =A0 =A0 uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; >> + >> + =A0 =A0 =A0 for (t =3D 0; t < 16; t++, cp +=3D 4) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 W[t] =3D (cp[0] << 24) | (cp[1] << 16) | (= cp[2] << 8) | >> cp[3]; >> + >> + =A0 =A0 =A0 for (t =3D 16; t < 64; t++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 W[t] =3D sigma1(W[t - 2]) + W[t - 7] + >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sigma0(W[t - 15]) + W[t - 16]; >> + >> + =A0 =A0 =A0 a =3D H[0]; b =3D H[1]; c =3D H[2]; d =3D H[3]; >> + =A0 =A0 =A0 e =3D H[4]; f =3D H[5]; g =3D H[6]; h =3D H[7]; >> + >> + =A0 =A0 =A0 for (t =3D 0; t < 64; t++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 T1 =3D h + SIGMA1(e) + Ch(e, f, g) + SHA25= 6_K[t] + W[t]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 T2 =3D SIGMA0(a) + Maj(a, b, c); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 h =3D g; g =3D f; f =3D e; e =3D d + T1; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 d =3D c; c =3D b; b =3D a; a =3D T1 + T2; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 H[0] +=3D a; H[1] +=3D b; H[2] +=3D c; H[3] +=3D d; >> + =A0 =A0 =A0 H[4] +=3D e; H[5] +=3D f; H[6] +=3D g; H[7] +=3D h; >> +} >> + >> +static void >> +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 uint32_t H[8] =3D { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0x= a54ff53a, >> + =A0 =A0 =A0 =A0 =A0 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; >> + =A0 =A0 =A0 uint8_t pad[128]; >> + =A0 =A0 =A0 int padsize =3D size & 63; >> + =A0 =A0 =A0 int i; >> + >> + =A0 =A0 =A0 for (i =3D 0; i < size - padsize; i +=3D 64) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SHA256Transform(H, (uint8_t *)buf + i); >> + >> + =A0 =A0 =A0 for (i =3D 0; i < padsize; i++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[i] =3D ((uint8_t *)buf)[i]; >> + >> + =A0 =A0 =A0 for (pad[padsize++] =3D 0x80; (padsize & 63) !=3D 56; pads= ize++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[padsize] =3D 0; >> + >> + =A0 =A0 =A0 for (i =3D 0; i < 8; i++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[padsize++] =3D (size << 3) >> (56 - 8 = * i); >> + >> + =A0 =A0 =A0 for (i =3D 0; i < padsize; i +=3D 64) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SHA256Transform(H, pad + i); >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[0] << 32 | H[1], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[2] << 32 | H[3], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[4] << 32 | H[5], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[6] << 32 | H[7]); >> +} >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License, Version 1.0 only >> + * (the "License"). =A0You may not use this file except in compliance >> + * with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> +/* >> + * Copyright 2005 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/*#pragma ident =A0 =A0 =A0 =A0"%Z%%M% %I% =A0 =A0 %E% SMI"*/ >> + >> +/* >> + * SHA-256 checksum, as specified in FIPS 180-2, available at: >> + * http://csrc.nist.gov/cryptval >> + * >> + * This is a very compact implementation of SHA-256. >> + * It is designed to be simple and portable, not to be fast. >> + */ >> + >> +/* >> + * The literal definitions according to FIPS180-2 would be: >> + * >> + * =A0 =A0 Ch(x, y, z) =A0 =A0 (((x) & (y)) ^ ((~(x)) & (z))) >> + * =A0 =A0 Maj(x, y, z) =A0 =A0(((x) & (y)) | ((x) & (z)) | ((y) & (z))= ) >> + * >> + * We use logical equivalents which require one less op. >> + */ >> +#define =A0 =A0 =A0 =A0Ch(x, y, z) =A0 =A0 ((z) ^ ((x) & ((y) ^ (z)))) >> +#define =A0 =A0 =A0 =A0Maj(x, y, z) =A0 =A0(((x) & (y)) ^ ((z) & ((x) ^= (y)))) >> +#define =A0 =A0 =A0 =A0Rot32(x, s) =A0 =A0 (((x) >> s) | ((x) << (32 - = s))) >> +#define =A0 =A0 =A0 =A0SIGMA0(x) =A0 =A0 =A0 (Rot32(x, 2) ^ Rot32(x, 13= ) ^ Rot32(x, >> 22)) >> +#define =A0 =A0 =A0 =A0SIGMA1(x) =A0 =A0 =A0 (Rot32(x, 6) ^ Rot32(x, 11= ) ^ Rot32(x, >> 25)) >> +#define =A0 =A0 =A0 =A0sigma0(x) =A0 =A0 =A0 (Rot32(x, 7) ^ Rot32(x, 18= ) ^ ((x) >> 3)) >> +#define =A0 =A0 =A0 =A0sigma1(x) =A0 =A0 =A0 (Rot32(x, 17) ^ Rot32(x, 1= 9) ^ ((x) >> >> 10)) >> + >> +static const uint32_t SHA256_K[64] =3D { >> + =A0 =A0 =A0 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, >> + =A0 =A0 =A0 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, >> + =A0 =A0 =A0 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, >> + =A0 =A0 =A0 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, >> + =A0 =A0 =A0 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, >> + =A0 =A0 =A0 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, >> + =A0 =A0 =A0 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, >> + =A0 =A0 =A0 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, >> + =A0 =A0 =A0 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, >> + =A0 =A0 =A0 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, >> + =A0 =A0 =A0 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, >> + =A0 =A0 =A0 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, >> + =A0 =A0 =A0 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, >> + =A0 =A0 =A0 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, >> + =A0 =A0 =A0 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, >> + =A0 =A0 =A0 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 >> +}; >> + >> +static void >> +SHA256Transform(uint32_t *H, const uint8_t *cp) >> +{ >> + =A0 =A0 =A0 uint32_t a, b, c, d, e, f, g, h, t, T1, T2, W[64]; >> + >> + =A0 =A0 =A0 for (t =3D 0; t < 16; t++, cp +=3D 4) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 W[t] =3D (cp[0] << 24) | (cp[1] << 16) | (= cp[2] << 8) | >> cp[3]; >> + >> + =A0 =A0 =A0 for (t =3D 16; t < 64; t++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 W[t] =3D sigma1(W[t - 2]) + W[t - 7] + >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sigma0(W[t - 15]) + W[t - 16]; >> + >> + =A0 =A0 =A0 a =3D H[0]; b =3D H[1]; c =3D H[2]; d =3D H[3]; >> + =A0 =A0 =A0 e =3D H[4]; f =3D H[5]; g =3D H[6]; h =3D H[7]; >> + >> + =A0 =A0 =A0 for (t =3D 0; t < 64; t++) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 T1 =3D h + SIGMA1(e) + Ch(e, f, g) + SHA25= 6_K[t] + W[t]; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 T2 =3D SIGMA0(a) + Maj(a, b, c); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 h =3D g; g =3D f; f =3D e; e =3D d + T1; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 d =3D c; c =3D b; b =3D a; a =3D T1 + T2; >> + =A0 =A0 =A0 } >> + >> + =A0 =A0 =A0 H[0] +=3D a; H[1] +=3D b; H[2] +=3D c; H[3] +=3D d; >> + =A0 =A0 =A0 H[4] +=3D e; H[5] +=3D f; H[6] +=3D g; H[7] +=3D h; >> +} >> + >> +static void >> +zio_checksum_SHA256(const void *buf, uint64_t size, zio_cksum_t *zcp) >> +{ >> + =A0 =A0 =A0 uint32_t H[8] =3D { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0x= a54ff53a, >> + =A0 =A0 =A0 =A0 =A0 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; >> + =A0 =A0 =A0 uint8_t pad[128]; >> + =A0 =A0 =A0 int padsize =3D size & 63; >> + =A0 =A0 =A0 int i; >> + >> + =A0 =A0 =A0 for (i =3D 0; i < size - padsize; i +=3D 64) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SHA256Transform(H, (uint8_t *)buf + i); >> + >> + =A0 =A0 =A0 for (i =3D 0; i < padsize; i++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[i] =3D ((uint8_t *)buf)[i]; >> + >> + =A0 =A0 =A0 for (pad[padsize++] =3D 0x80; (padsize & 63) !=3D 56; pads= ize++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[padsize] =3D 0; >> + >> + =A0 =A0 =A0 for (i =3D 0; i < 8; i++) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pad[padsize++] =3D (size << 3) >> (56 - 8 = * i); >> + >> + =A0 =A0 =A0 for (i =3D 0; i < padsize; i +=3D 64) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 SHA256Transform(H, pad + i); >> + >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(zcp, >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[0] << 32 | H[1], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[2] << 32 | H[3], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[4] << 32 | H[5], >> + =A0 =A0 =A0 =A0 =A0 (uint64_t)H[6] << 32 | H[7]); >> +} >> >> Added: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- /dev/null =A0 00:00:00 1970 =A0 (empty, because file is newly added) >> +++ user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h =A0 =A0 =A0Fri May 15 >> 23:11:34 2009 =A0 (r192168) >> @@ -0,0 +1,2340 @@ >> +/*- >> + * Copyright (c) 2002 McAfee, Inc. >> + * All rights reserved. >> + * >> + * This software was developed for the FreeBSD Project by Marshall >> + * Kirk McKusick and McAfee Research,, the Security Research Division o= f >> + * McAfee, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), >> as >> + * part of the DARPA CHATS research program >> + * >> + * 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 >> + * =A0 =A0notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * =A0 =A0notice, this list of conditions and the following disclaimer = in the >> + * =A0 =A0documentation and/or other materials provided with the >> distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' A= ND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, TH= E >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> PURPOSE >> + * ARE DISCLAIMED. =A0IN 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 AN= Y >> WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY = OF >> + * SUCH DAMAGE. >> + */ >> +/* >> + * CDDL HEADER START >> + * >> + * The contents of this file are subject to the terms of the >> + * Common Development and Distribution License (the "License"). >> + * You may not use this file except in compliance with the License. >> + * >> + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE >> + * or http://www.opensolaris.org/os/licensing. >> + * See the License for the specific language governing permissions >> + * and limitations under the License. >> + * >> + * When distributing Covered Code, include this CDDL HEADER in each >> + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. >> + * If applicable, add the following below this CDDL HEADER, with the >> + * fields enclosed by brackets "[]" replaced with your own identifying >> + * information: Portions Copyright [yyyy] [name of copyright owner] >> + * >> + * CDDL HEADER END >> + */ >> +/* >> + * Copyright 2007 Sun Microsystems, Inc. =A0All rights reserved. >> + * Use is subject to license terms. >> + */ >> + >> +/* CRC64 table */ >> +#define =A0 =A0 =A0 =A0ZFS_CRC64_POLY =A00xC96C5795D7870F42ULL =A0 /* E= CMA-182, >> reflected form */ >> + >> +/* >> + * Macros for various sorts of alignment and rounding when the alignmen= t >> + * is known to be a power of 2. >> + */ >> +#define =A0 =A0 =A0 =A0P2ALIGN(x, align) =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((= x) & -(align)) >> +#define =A0 =A0 =A0 =A0P2PHASE(x, align) =A0 =A0 =A0 =A0 =A0 =A0 =A0 ((= x) & ((align) - 1)) >> +#define =A0 =A0 =A0 =A0P2NPHASE(x, align) =A0 =A0 =A0 =A0 =A0 =A0 =A0(-= (x) & ((align) - 1)) >> +#define =A0 =A0 =A0 =A0P2ROUNDUP(x, align) =A0 =A0 =A0 =A0 =A0 =A0 (-(-= (x) & -(align))) >> +#define =A0 =A0 =A0 =A0P2END(x, align) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = (-(~(x) & -(align))) >> +#define =A0 =A0 =A0 =A0P2PHASEUP(x, align, phase) =A0 =A0 =A0((phase) -= (((phase) - >> (x)) & -(align))) >> +#define =A0 =A0 =A0 =A0P2CROSS(x, y, align) =A0 =A0 =A0 =A0 =A0 =A0(((x= ) ^ (y)) > (align) - >> 1) >> + >> +/* >> + * General-purpose 32-bit and 64-bit bitfield encodings. >> + */ >> +#define =A0 =A0 =A0 =A0BF32_DECODE(x, low, len) =A0 =A0 =A0 =A0P2PHASE(= (x) >> (low), 1U >> << (len)) >> +#define =A0 =A0 =A0 =A0BF64_DECODE(x, low, len) =A0 =A0 =A0 =A0P2PHASE(= (x) >> (low), 1ULL >> << (len)) >> +#define =A0 =A0 =A0 =A0BF32_ENCODE(x, low, len) =A0 =A0 =A0 =A0(P2PHASE= ((x), 1U << (len)) >> << (low)) >> +#define =A0 =A0 =A0 =A0BF64_ENCODE(x, low, len) =A0 =A0 =A0 =A0(P2PHASE= ((x), 1ULL << >> (len)) << (low)) >> + >> +#define =A0 =A0 =A0 =A0BF32_GET(x, low, len) =A0 =A0 =A0 =A0 =A0 BF32_D= ECODE(x, low, len) >> +#define =A0 =A0 =A0 =A0BF64_GET(x, low, len) =A0 =A0 =A0 =A0 =A0 BF64_D= ECODE(x, low, len) >> + >> +#define =A0 =A0 =A0 =A0BF32_SET(x, low, len, val) =A0 =A0 =A0\ >> + =A0 =A0 =A0 ((x) ^=3D BF32_ENCODE((x >> low) ^ (val), low, len)) >> +#define =A0 =A0 =A0 =A0BF64_SET(x, low, len, val) =A0 =A0 =A0\ >> + =A0 =A0 =A0 ((x) ^=3D BF64_ENCODE((x >> low) ^ (val), low, len)) >> + >> +#define =A0 =A0 =A0 =A0BF32_GET_SB(x, low, len, shift, bias) =A0 \ >> + =A0 =A0 =A0 ((BF32_GET(x, low, len) + (bias)) << (shift)) >> +#define =A0 =A0 =A0 =A0BF64_GET_SB(x, low, len, shift, bias) =A0 \ >> + =A0 =A0 =A0 ((BF64_GET(x, low, len) + (bias)) << (shift)) >> + >> +#define =A0 =A0 =A0 =A0BF32_SET_SB(x, low, len, shift, bias, val) =A0 = =A0 =A0\ >> + =A0 =A0 =A0 BF32_SET(x, low, len, ((val) >> (shift)) - (bias)) >> +#define =A0 =A0 =A0 =A0BF64_SET_SB(x, low, len, shift, bias, val) =A0 = =A0 =A0\ >> + =A0 =A0 =A0 BF64_SET(x, low, len, ((val) >> (shift)) - (bias)) >> + >> +/* >> + * We currently support nine block sizes, from 512 bytes to 128K. >> + * We could go higher, but the benefits are near-zero and the cost >> + * of COWing a giant block to modify one byte would become excessive. >> + */ >> +#define =A0 =A0 =A0 =A0SPA_MINBLOCKSHIFT =A0 =A0 =A0 9 >> +#define =A0 =A0 =A0 =A0SPA_MAXBLOCKSHIFT =A0 =A0 =A0 17 >> +#define =A0 =A0 =A0 =A0SPA_MINBLOCKSIZE =A0 =A0 =A0 =A0(1ULL << SPA_MIN= BLOCKSHIFT) >> +#define =A0 =A0 =A0 =A0SPA_MAXBLOCKSIZE =A0 =A0 =A0 =A0(1ULL << SPA_MAX= BLOCKSHIFT) >> + >> +#define =A0 =A0 =A0 =A0SPA_BLOCKSIZES =A0 =A0 =A0 =A0 =A0(SPA_MAXBLOCKS= HIFT - >> SPA_MINBLOCKSHIFT + 1) >> + >> +/* >> + * The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB= . >> + * The ASIZE encoding should be at least 64 times larger (6 more bits) >> + * to support up to 4-way RAID-Z mirror mode with worst-case gang block >> + * overhead, three DVAs per bp, plus one more bit in case we do anythin= g >> + * else that expands the ASIZE. >> + */ >> +#define =A0 =A0 =A0 =A0SPA_LSIZEBITS =A0 =A0 =A0 =A0 =A0 16 =A0 =A0 =A0= /* LSIZE up to 32M (2^16 * >> 512) */ >> +#define =A0 =A0 =A0 =A0SPA_PSIZEBITS =A0 =A0 =A0 =A0 =A0 16 =A0 =A0 =A0= /* PSIZE up to 32M (2^16 * >> 512) */ >> +#define =A0 =A0 =A0 =A0SPA_ASIZEBITS =A0 =A0 =A0 =A0 =A0 24 =A0 =A0 =A0= /* ASIZE up to 64 times >> larger =A0*/ >> + >> +/* >> + * All SPA data is represented by 128-bit data virtual addresses (DVAs)= . >> + * The members of the dva_t should be considered opaque outside the SPA= . >> + */ >> +typedef struct dva { >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0dva_word[2]; >> +} dva_t; >> + >> +/* >> + * Each block has a 256-bit checksum -- strong enough for cryptographic >> hashes. >> + */ >> +typedef struct zio_cksum { >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0zc_word[4]; >> +} zio_cksum_t; >> + >> +/* >> + * Each block is described by its DVAs, time of birth, checksum, etc. >> + * The word-by-word, bit-by-bit layout of the blkptr is as follows: >> + * >> + * =A0 =A0 64 =A0 =A0 =A056 =A0 =A0 =A048 =A0 =A0 =A040 =A0 =A0 =A032 = =A0 =A0 =A024 =A0 =A0 =A016 =A0 =A0 =A08 =A0 =A0 =A0 0 >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 0 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 vdev1 =A0 =A0 =A0 =A0 =A0 | GRID= =A0| =A0 =A0 =A0 =A0 ASIZE =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 1 =A0 |G| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0offset1 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 2 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 vdev2 =A0 =A0 =A0 =A0 =A0 | GRID= =A0| =A0 =A0 =A0 =A0 ASIZE =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 3 =A0 |G| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0offset2 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 4 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 vdev3 =A0 =A0 =A0 =A0 =A0 | GRID= =A0| =A0 =A0 =A0 =A0 ASIZE =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 5 =A0 |G| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0offset3 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 6 =A0 |E| lvl | type =A0| cksum | comp =A0| =A0 =A0 PSIZE =A0 =A0 | = =A0 =A0 LSIZE =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 7 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 padding =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 8 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 padding =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * 9 =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 padding =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * a =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 birth txg =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * b =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fill count =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * c =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum[0] =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * d =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum[1] =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * e =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum[2] =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * f =A0 | =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 checksum[3] =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | >> + * =A0 =A0 +-------+-------+-------+-------+-------+-------+-------+---= ----+ >> + * >> + * Legend: >> + * >> + * vdev =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0virtual device ID >> + * offset =A0 =A0 =A0offset into virtual device >> + * LSIZE =A0 =A0 =A0 logical size >> + * PSIZE =A0 =A0 =A0 physical size (after compression) >> + * ASIZE =A0 =A0 =A0 allocated size (including RAID-Z parity and gang b= lock >> headers) >> + * GRID =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0RAID-Z layout information (reser= ved for future >> use) >> + * cksum =A0 =A0 =A0 checksum function >> + * comp =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0compression function >> + * G =A0 =A0 =A0 =A0 =A0 gang block indicator >> + * E =A0 =A0 =A0 =A0 =A0 endianness >> + * type =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0DMU object type >> + * lvl =A0 =A0 =A0 =A0 level of indirection >> + * birth txg =A0 transaction group in which the block was born >> + * fill count =A0number of non-zero blocks under this bp >> + * checksum[4] 256-bit checksum of the data this bp describes >> + */ >> +typedef struct blkptr { >> + =A0 =A0 =A0 dva_t =A0 =A0 =A0 =A0 =A0 blk_dva[3]; =A0 =A0 /* 128-bit D= ata Virtual Address */ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0blk_prop; =A0 =A0 =A0 /* size, com= pression, type, etc */ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0blk_pad[3]; =A0 =A0 /* Extra space= for the future =A0 */ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0blk_birth; =A0 =A0 =A0/* transacti= on group at birth =A0 */ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0blk_fill; =A0 =A0 =A0 /* fill coun= t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */ >> + =A0 =A0 =A0 zio_cksum_t =A0 =A0 blk_cksum; =A0 =A0 =A0/* 256-bit check= sum =A0 =A0 =A0 =A0 =A0 =A0 */ >> +} blkptr_t; >> + >> +#define =A0 =A0 =A0 =A0SPA_BLKPTRSHIFT 7 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*= blkptr_t is 128 bytes >> =A0 =A0 =A0*/ >> +#define =A0 =A0 =A0 =A0SPA_DVAS_PER_BP 3 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /*= Number of DVAs in a bp >> =A0 =A0 =A0 */ >> + >> +/* >> + * Macros to get and set fields in a bp or DVA. >> + */ >> +#define =A0 =A0 =A0 =A0DVA_GET_ASIZE(dva) =A0 =A0 =A0\ >> + =A0 =A0 =A0 BF64_GET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, = 0) >> +#define =A0 =A0 =A0 =A0DVA_SET_ASIZE(dva, x) =A0 \ >> + =A0 =A0 =A0 BF64_SET_SB((dva)->dva_word[0], 0, 24, SPA_MINBLOCKSHIFT, = 0, x) >> + >> +#define =A0 =A0 =A0 =A0DVA_GET_GRID(dva) =A0 =A0 =A0 BF64_GET((dva)->dv= a_word[0], 24, >> 8) >> +#define =A0 =A0 =A0 =A0DVA_SET_GRID(dva, x) =A0 =A0BF64_SET((dva)->dva_= word[0], 24, >> 8, x) >> + >> +#define =A0 =A0 =A0 =A0DVA_GET_VDEV(dva) =A0 =A0 =A0 BF64_GET((dva)->dv= a_word[0], 32, >> 32) >> +#define =A0 =A0 =A0 =A0DVA_SET_VDEV(dva, x) =A0 =A0BF64_SET((dva)->dva_= word[0], 32, >> 32, x) >> + >> +#define =A0 =A0 =A0 =A0DVA_GET_OFFSET(dva) =A0 =A0 \ >> + =A0 =A0 =A0 BF64_GET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, = 0) >> +#define =A0 =A0 =A0 =A0DVA_SET_OFFSET(dva, x) =A0\ >> + =A0 =A0 =A0 BF64_SET_SB((dva)->dva_word[1], 0, 63, SPA_MINBLOCKSHIFT, = 0, x) >> + >> +#define =A0 =A0 =A0 =A0DVA_GET_GANG(dva) =A0 =A0 =A0 BF64_GET((dva)->dv= a_word[1], 63, >> 1) >> +#define =A0 =A0 =A0 =A0DVA_SET_GANG(dva, x) =A0 =A0BF64_SET((dva)->dva_= word[1], 63, >> 1, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_LSIZE(bp) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (BP_IS_HOLE(bp) ? 0 : \ >> + =A0 =A0 =A0 BF64_GET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)) >> +#define =A0 =A0 =A0 =A0BP_SET_LSIZE(bp, x) =A0 =A0 \ >> + =A0 =A0 =A0 BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x= ) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_PSIZE(bp) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 BF64_GET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1) >> +#define =A0 =A0 =A0 =A0BP_SET_PSIZE(bp, x) =A0 =A0 \ >> + =A0 =A0 =A0 BF64_SET_SB((bp)->blk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, = x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_COMPRESS(bp) =A0 =A0 BF64_GET((bp)->blk_p= rop, 32, 8) >> +#define =A0 =A0 =A0 =A0BP_SET_COMPRESS(bp, x) =A0BF64_SET((bp)->blk_pro= p, 32, 8, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_CHECKSUM(bp) =A0 =A0 BF64_GET((bp)->blk_p= rop, 40, 8) >> +#define =A0 =A0 =A0 =A0BP_SET_CHECKSUM(bp, x) =A0BF64_SET((bp)->blk_pro= p, 40, 8, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_TYPE(bp) =A0 =A0 =A0 =A0 BF64_GET((bp)->b= lk_prop, 48, 8) >> +#define =A0 =A0 =A0 =A0BP_SET_TYPE(bp, x) =A0 =A0 =A0BF64_SET((bp)->blk= _prop, 48, 8, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_LEVEL(bp) =A0 =A0 =A0 =A0BF64_GET((bp)->b= lk_prop, 56, 5) >> +#define =A0 =A0 =A0 =A0BP_SET_LEVEL(bp, x) =A0 =A0 BF64_SET((bp)->blk_p= rop, 56, 5, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_BYTEORDER(bp) =A0 =A0(0 - BF64_GET((bp)->= blk_prop, 63, >> 1)) >> +#define =A0 =A0 =A0 =A0BP_SET_BYTEORDER(bp, x) BF64_SET((bp)->blk_prop,= 63, 1, x) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_ASIZE(bp) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (DVA_GET_ASIZE(&(bp)->blk_dva[0]) + >> DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DVA_GET_ASIZE(&(bp)->blk_dva[2])) >> + >> +#define =A0 =A0 =A0 =A0BP_GET_UCSIZE(bp) \ >> + =A0 =A0 =A0 ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metad= ata) ? \ >> + =A0 =A0 =A0 BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp)); >> + >> +#define =A0 =A0 =A0 =A0BP_GET_NDVAS(bp) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (!!DVA_GET_ASIZE(&(bp)->blk_dva[0]) + \ >> + =A0 =A0 =A0 !!DVA_GET_ASIZE(&(bp)->blk_dva[1]) + \ >> + =A0 =A0 =A0 !!DVA_GET_ASIZE(&(bp)->blk_dva[2])) >> + >> +#define =A0 =A0 =A0 =A0BP_COUNT_GANG(bp) =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (DVA_GET_GANG(&(bp)->blk_dva[0]) + \ >> + =A0 =A0 =A0 DVA_GET_GANG(&(bp)->blk_dva[1]) + \ >> + =A0 =A0 =A0 DVA_GET_GANG(&(bp)->blk_dva[2])) >> + >> +#define =A0 =A0 =A0 =A0DVA_EQUAL(dva1, dva2) =A0 \ >> + =A0 =A0 =A0 ((dva1)->dva_word[1] =3D=3D (dva2)->dva_word[1] && \ >> + =A0 =A0 =A0 (dva1)->dva_word[0] =3D=3D (dva2)->dva_word[0]) >> + >> +#define =A0 =A0 =A0 =A0ZIO_CHECKSUM_EQUAL(zc1, zc2) \ >> + =A0 =A0 =A0 (0 =3D=3D (((zc1).zc_word[0] - (zc2).zc_word[0]) | \ >> + =A0 =A0 =A0 ((zc1).zc_word[1] - (zc2).zc_word[1]) | \ >> + =A0 =A0 =A0 ((zc1).zc_word[2] - (zc2).zc_word[2]) | \ >> + =A0 =A0 =A0 ((zc1).zc_word[3] - (zc2).zc_word[3]))) >> + >> + >> +#define =A0 =A0 =A0 =A0DVA_IS_VALID(dva) =A0 =A0 =A0 (DVA_GET_ASIZE(dva= ) !=3D 0) >> + >> +#define =A0 =A0 =A0 =A0ZIO_SET_CHECKSUM(zcp, w0, w1, w2, w3) =A0 \ >> +{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (zcp)->zc_word[0] =3D w0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = \ >> + =A0 =A0 =A0 (zcp)->zc_word[1] =3D w1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = \ >> + =A0 =A0 =A0 (zcp)->zc_word[2] =3D w2; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = \ >> + =A0 =A0 =A0 (zcp)->zc_word[3] =3D w3; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = \ >> +} >> + >> +#define =A0 =A0 =A0 =A0BP_IDENTITY(bp) =A0 =A0 =A0 =A0 (&(bp)->blk_dva[= 0]) >> +#define =A0 =A0 =A0 =A0BP_IS_GANG(bp) =A0 =A0 =A0 =A0 =A0DVA_GET_GANG(B= P_IDENTITY(bp)) >> +#define =A0 =A0 =A0 =A0BP_IS_HOLE(bp) =A0 =A0 =A0 =A0 =A0((bp)->blk_bir= th =3D=3D 0) >> +#define =A0 =A0 =A0 =A0BP_IS_OLDER(bp, txg) =A0 =A0(!BP_IS_HOLE(bp) && >> (bp)->blk_birth < (txg)) >> + >> +#define =A0 =A0 =A0 =A0BP_ZERO(bp) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 \ >> +{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (bp)->blk_dva[0].dva_word[0] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_dva[0].dva_word[1] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_dva[1].dva_word[0] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_dva[1].dva_word[1] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_dva[2].dva_word[0] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_dva[2].dva_word[1] =3D 0; =A0 =A0 =A0 \ >> + =A0 =A0 =A0 (bp)->blk_prop =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 \ >> + =A0 =A0 =A0 (bp)->blk_pad[0] =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 \ >> + =A0 =A0 =A0 (bp)->blk_pad[1] =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 \ >> + =A0 =A0 =A0 (bp)->blk_pad[2] =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 \ >> + =A0 =A0 =A0 (bp)->blk_birth =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0\ >> + =A0 =A0 =A0 (bp)->blk_fill =3D 0; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 \ >> + =A0 =A0 =A0 ZIO_SET_CHECKSUM(&(bp)->blk_cksum, 0, 0, 0, 0); \ >> +} >> + >> +#define =A0 =A0 =A0 =A0ZBT_MAGIC =A0 =A0 =A0 0x210da7ab10c7a11ULL =A0 = =A0/* zio data bloc >> tail */ >> + >> +typedef struct zio_block_tail { >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0zbt_magic; =A0 =A0 =A0/* for valid= ation, endianness =A0 */ >> + =A0 =A0 =A0 zio_cksum_t =A0 =A0 zbt_cksum; =A0 =A0 =A0/* 256-bit check= sum =A0 =A0 =A0 =A0 =A0 =A0 */ >> +} zio_block_tail_t; >> + >> +#define =A0 =A0 =A0 =A0VDEV_SKIP_SIZE =A0 =A0 =A0 =A0 =A0(8 << 10) >> +#define =A0 =A0 =A0 =A0VDEV_BOOT_HEADER_SIZE =A0 (8 << 10) >> +#define =A0 =A0 =A0 =A0VDEV_PHYS_SIZE =A0 =A0 =A0 =A0 =A0(112 << 10) >> +#define =A0 =A0 =A0 =A0VDEV_UBERBLOCK_RING =A0 =A0 (128 << 10) >> + >> +#define =A0 =A0 =A0 =A0VDEV_UBERBLOCK_SHIFT(vd) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 MAX((vd)->vdev_top->vdev_ashift, UBERBLOCK_SHIFT) >> +#define =A0 =A0 =A0 =A0VDEV_UBERBLOCK_COUNT(vd) =A0 =A0 =A0 =A0\ >> + =A0 =A0 =A0 (VDEV_UBERBLOCK_RING >> VDEV_UBERBLOCK_SHIFT(vd)) >> +#define =A0 =A0 =A0 =A0VDEV_UBERBLOCK_OFFSET(vd, n) =A0 =A0\ >> + =A0 =A0 =A0 offsetof(vdev_label_t, vl_uberblock[(n) << >> VDEV_UBERBLOCK_SHIFT(vd)]) >> +#define =A0 =A0 =A0 =A0VDEV_UBERBLOCK_SIZE(vd) =A0 =A0 =A0 =A0 (1ULL << >> VDEV_UBERBLOCK_SHIFT(vd)) >> + >> +/* ZFS boot block */ >> +#define =A0 =A0 =A0 =A0VDEV_BOOT_MAGIC =A0 =A0 =A0 =A0 0x2f5b007b10cULL >> +#define =A0 =A0 =A0 =A0VDEV_BOOT_VERSION =A0 =A0 =A0 1 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 /* version number >> =A0 =A0 =A0 */ >> + >> +typedef struct vdev_boot_header { >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0vb_magic; =A0 =A0 =A0 =A0 =A0 =A0 = =A0 /* VDEV_BOOT_MAGIC =A0 =A0 =A0*/ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0vb_version; =A0 =A0 =A0 =A0 =A0 = =A0 /* VDEV_BOOT_VERSION =A0 =A0*/ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0vb_offset; =A0 =A0 =A0 =A0 =A0 =A0= =A0/* start offset (bytes) */ >> + =A0 =A0 =A0 uint64_t =A0 =A0 =A0 =A0vb_size; =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0/* size (bytes) =A0 =A0 =A0 =A0 */ >> + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0vb_pad[VDEV_BOOT_HEADER_SIZE -= 4 * sizeof >> (uint64_t)]; >> +} vdev_boot_header_t; >> + >> +typedef struct vdev_phys { >> + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0vp_nvlist[VDEV_PHYS_SIZE - siz= eof >> (zio_block_tail_t)]; >> + =A0 =A0 =A0 zio_block_tail_t vp_zbt; >> +} vdev_phys_t; >> + >> +typedef struct vdev_label { >> + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0vl_pad[VDEV_SKIP_SIZE]; =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* =A0 8K */ >> + =A0 =A0 =A0 vdev_boot_header_t vl_boot_header; =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0/* =A0 8K */ >> + =A0 =A0 =A0 vdev_phys_t =A0 =A0 vl_vdev_phys; =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* 112K */ >> + =A0 =A0 =A0 char =A0 =A0 =A0 =A0 =A0 =A0vl_uberblock[VDEV_UBERBLOCK_RI= NG]; =A0 =A0 =A0/* 128K */ >> +} vdev_label_t; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* >> 256K total */ >> + >> +/* >> + * vdev_dirty() flags >> + */ >> +#define =A0 =A0 =A0 =A0VDD_METASLAB =A0 =A00x01 >> +#define =A0 =A0 =A0 =A0VDD_DTL =A0 =A0 =A0 =A0 0x02 >> + >> +/* >> + * Size and offset of embedded boot loader region on each label. >> + * The total size of the first two labels plus the boot area is 4MB. >> + */ >> +#define =A0 =A0 =A0 =A0VDEV_BOOT_OFFSET =A0 =A0 =A0 =A0(2 * sizeof (vde= v_label_t)) >> +#define =A0 =A0 =A0 =A0VDEV_BOOT_SIZE =A0 =A0 =A0 =A0 =A0(7ULL << 19) = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* >> 3.5M */ >> + >> +/* >> + * Size of label regions at the start and end of each leaf device. >> + */ >> +#define =A0 =A0 =A0 =A0VDEV_LABEL_START_SIZE =A0 (2 * sizeof (vdev_labe= l_t) + >> VDEV_BOOT_SIZE) >> +#define =A0 =A0 =A0 =A0VDEV_LABEL_END_SIZE =A0 =A0 (2 * sizeof (vdev_la= bel_t)) >> +#define =A0 =A0 =A0 =A0VDEV_LABELS =A0 =A0 =A0 =A0 =A0 =A0 4 >> + >> +enum zio_checksum { >> + =A0 =A0 =A0 ZIO_CHECKSUM_INHERIT =3D 0, >> + =A0 =A0 =A0 ZIO_CHECKSUM_ON, >> + =A0 =A0 =A0 ZIO_CHECKSUM_OFF, >> + =A0 =A0 =A0 ZIO_CHECKSUM_LABEL, >> + =A0 =A0 =A0 ZIO_CHECKSUM_GANG_HEADER, >> + =A0 =A0 =A0 ZIO_CHECKSUM_ZILOG, >> + =A0 =A0 =A0 ZIO_CHECKSUM_FLETCHER_2, >> + =A0 =A0 =A0 ZIO_CHECKSUM_FLETCHER_4, >> + =A0 =A0 =A0 ZIO_CHECKSUM_SHA256, >> + =A0 =A0 =A0 ZIO_CHECKSUM_FUNCTIONS >> +}; >> + >> +#define =A0 =A0 =A0 =A0ZIO_CHECKSUM_ON_VALUE =A0 ZIO_CHECKSUM_FLETCHER_= 2 >> +#define =A0 =A0 =A0 =A0ZIO_CHECKSUM_DEFAULT =A0 =A0ZIO_CHECKSUM_ON >> + >> +enum zio_compress { >> + =A0 =A0 =A0 ZIO_COMPRESS_INHERIT =3D 0, >> + =A0 =A0 =A0 ZIO_COMPRESS_ON, >> + =A0 =A0 =A0 ZIO_COMPRESS_OFF, >> + =A0 =A0 =A0 ZIO_COMPRESS_LZJB, >> + =A0 =A0 =A0 ZIO_COMPRESS_EMPTY, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_1, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_2, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_3, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_4, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_5, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_6, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_7, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_8, >> + =A0 =A0 =A0 ZIO_COMPRESS_GZIP_9, >> + =A0 =A0 =A0 ZIO_COMPRESS_FUNCTIONS >> +}; >> + >> +#define =A0 =A0 =A0 =A0ZIO_COMPRESS_ON_VALUE =A0 ZIO_COMPRESS_LZJB >> +#define =A0 =A0 =A0 =A0ZIO_COMPRESS_DEFAULT =A0 =A0ZIO_COMPRESS_OFF >> + >> +/* nvlist pack encoding */ >> +#define =A0 =A0 =A0 =A0NV_ENCODE_NATIVE =A0 =A0 =A0 =A00 >> +#define =A0 =A0 =A0 =A0NV_ENCODE_XDR =A0 =A0 =A0 =A0 =A0 1 >> + >> +typedef enum { >> + =A0 =A0 =A0 DATA_TYPE_UNKNOWN =3D 0, >> + =A0 =A0 =A0 DATA_TYPE_BOOLEAN, >> + =A0 =A0 =A0 DATA_TYPE_BYTE, >> + =A0 =A0 =A0 DATA_TYPE_INT16, >> + =A0 =A0 =A0 DATA_TYPE_UINT16, >> + =A0 =A0 =A0 DATA_TYPE_INT32, >> + =A0 =A0 =A0 DATA_TYPE_UINT32, >> + =A0 =A0 =A0 DATA_TYPE_INT64, >> + =A0 =A0 =A0 DATA_TYPE_UINT64, >> + =A0 =A0 =A0 DATA_TYPE_STRING, >> + =A0 =A0 =A0 DATA_TYPE_BYTE_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_INT16_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_UINT16_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_INT32_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_UINT32_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_INT64_ARRAY, >> + =A0 =A0 =A0 DATA_TYPE_UINT64_ARRAY, >> >> *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > > --=20 When bad men combine, the good must associate; else they will fall one by one, an unpitied sacrifice in a contemptible struggle. Edmund Burke From owner-svn-src-user@FreeBSD.ORG Sat May 16 18:08:28 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9175F1065677; Sat, 16 May 2009 18:08:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D9DD8FC13; Sat, 16 May 2009 18:08:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GI8S3B065918; Sat, 16 May 2009 18:08:28 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GI8S2Y065916; Sat, 16 May 2009 18:08:28 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905161808.n4GI8S2Y065916@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 18:08:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192202 - in user/kmacy/ZFS_MFC/sys: boot/i386/zfsboot boot/zfs cddl/boot/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 18:08:30 -0000 Author: kmacy Date: Sat May 16 18:08:28 2009 New Revision: 192202 URL: http://svn.freebsd.org/changeset/base/192202 Log: remove duplicated file contents and merge raidz boot support Added: user/kmacy/ZFS_MFC/sys/boot/i386/zfsboot/ user/kmacy/ZFS_MFC/sys/boot/i386/zfsboot/zfsboot.c (contents, props changed) user/kmacy/ZFS_MFC/sys/boot/zfs/ user/kmacy/ZFS_MFC/sys/boot/zfs/zfsimpl.c (contents, props changed) Modified: user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/README user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/fletcher.c user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/lzjb.c user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/sha256.c user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfsimpl.h user/kmacy/ZFS_MFC/sys/cddl/boot/zfs/zfssubr.c Added: user/kmacy/ZFS_MFC/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/boot/i386/zfsboot/zfsboot.c Sat May 16 18:08:28 2009 (r192202) @@ -0,0 +1,1057 @@ +/*- + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#ifdef GPT +#include +#endif +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#ifndef GPT +#include "zfsboot.h" +#endif +#include "lib.h" + +#define IO_KEYBOARD 1 +#define IO_SERIAL 2 + +#define SECOND 18 /* Circa that many ticks in a second. */ + +#define RBX_ASKNAME 0x0 /* -a */ +#define RBX_SINGLE 0x1 /* -s */ +/* 0x2 is reserved for log2(RB_NOSYNC). */ +/* 0x3 is reserved for log2(RB_HALT). */ +/* 0x4 is reserved for log2(RB_INITNAME). */ +#define RBX_DFLTROOT 0x5 /* -r */ +#define RBX_KDB 0x6 /* -d */ +/* 0x7 is reserved for log2(RB_RDONLY). */ +/* 0x8 is reserved for log2(RB_DUMP). */ +/* 0x9 is reserved for log2(RB_MINIROOT). */ +#define RBX_CONFIG 0xa /* -c */ +#define RBX_VERBOSE 0xb /* -v */ +#define RBX_SERIAL 0xc /* -h */ +#define RBX_CDROM 0xd /* -C */ +/* 0xe is reserved for log2(RB_POWEROFF). */ +#define RBX_GDB 0xf /* -g */ +#define RBX_MUTE 0x10 /* -m */ +/* 0x11 is reserved for log2(RB_SELFTEST). */ +/* 0x12 is reserved for boot programs. */ +/* 0x13 is reserved for boot programs. */ +#define RBX_PAUSE 0x14 /* -p */ +#define RBX_QUIET 0x15 /* -q */ +#define RBX_NOINTR 0x1c /* -n */ +/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */ +#define RBX_DUAL 0x1d /* -D */ +/* 0x1f is reserved for log2(RB_BOOTINFO). */ + +/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */ +#define RBX_MASK (OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \ + OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \ + OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \ + OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \ + OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \ + OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL)) + +/* Hint to loader that we came from ZFS */ +#define KARGS_FLAGS_ZFS 0x4 + +#define PATH_CONFIG "/boot.config" +#define PATH_BOOT3 "/boot/loader" +#define PATH_KERNEL "/boot/kernel/kernel" + +#define ARGS 0x900 +#define NOPT 14 +#define NDEV 3 +#define MEM_BASE 0x12 +#define MEM_EXT 0x15 +#define V86_CY(x) ((x) & 1) +#define V86_ZR(x) ((x) & 0x40) + +#define DRV_HARD 0x80 +#define DRV_MASK 0x7f + +#define TYPE_AD 0 +#define TYPE_DA 1 +#define TYPE_MAXHARD TYPE_DA +#define TYPE_FD 2 + +#define OPT_SET(opt) (1 << (opt)) +#define OPT_CHECK(opt) ((opts) & OPT_SET(opt)) + +extern uint32_t _end; + +#ifdef GPT +static const uuid_t freebsd_zfs_uuid = GPT_ENT_TYPE_FREEBSD_ZFS; +#endif +static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */ +static const unsigned char flags[NOPT] = { + RBX_DUAL, + RBX_SERIAL, + RBX_ASKNAME, + RBX_CDROM, + RBX_CONFIG, + RBX_KDB, + RBX_GDB, + RBX_MUTE, + RBX_NOINTR, + RBX_PAUSE, + RBX_QUIET, + RBX_DFLTROOT, + RBX_SINGLE, + RBX_VERBOSE +}; + +static const char *const dev_nm[NDEV] = {"ad", "da", "fd"}; +static const unsigned char dev_maj[NDEV] = {30, 4, 2}; + +struct dsk { + unsigned drive; + unsigned type; + unsigned unit; + unsigned slice; + unsigned part; + unsigned start; + int init; +}; +static char cmd[512]; +static char kname[1024]; +static uint32_t opts; +static int comspeed = SIOSPD; +static struct bootinfo bootinfo; +static uint32_t bootdev; +static uint8_t ioctrl = IO_KEYBOARD; + +/* Buffers that must not span a 64k boundary. */ +#define READ_BUF_SIZE 8192 +struct dmadat { + char rdbuf[READ_BUF_SIZE]; /* for reading large things */ + char secbuf[READ_BUF_SIZE]; /* for MBR/disklabel */ +}; +static struct dmadat *dmadat; + +void exit(int); +static void load(void); +static int parse(void); +static void printf(const char *,...); +static void putchar(int); +static uint32_t memsize(void); +static int drvread(struct dsk *, void *, unsigned, unsigned); +static int keyhit(unsigned); +static int xputc(int); +static int xgetc(int); +static int getc(int); + +static void memcpy(void *, const void *, int); +static void +memcpy(void *dst, const void *src, int len) +{ + const char *s = src; + char *d = dst; + + while (len--) + *d++ = *s++; +} + +static void +strcpy(char *dst, const char *src) +{ + while (*src) + *dst++ = *src++; + *dst++ = 0; +} + +static void +strcat(char *dst, const char *src) +{ + while (*dst) + dst++; + while (*src) + *dst++ = *src++; + *dst++ = 0; +} + +static int +strcmp(const char *s1, const char *s2) +{ + for (; *s1 == *s2 && *s1; s1++, s2++); + return (unsigned char)*s1 - (unsigned char)*s2; +} + +static const char * +strchr(const char *s, char ch) +{ + for (; *s; s++) + if (*s == ch) + return s; + return 0; +} + +static int +memcmp(const void *p1, const void *p2, size_t n) +{ + const char *s1 = (const char *) p1; + const char *s2 = (const char *) p2; + for (; n > 0 && *s1 == *s2; s1++, s2++, n--); + if (n) + return (unsigned char)*s1 - (unsigned char)*s2; + else + return 0; +} + +static void +memset(void *p, char val, size_t n) +{ + char *s = (char *) p; + while (n--) + *s++ = val; +} + +static void * +malloc(size_t n) +{ + static char *heap_next; + static char *heap_end; + + if (!heap_next) { + heap_next = (char *) dmadat + sizeof(*dmadat); + heap_end = (char *) (640*1024); + } + + char *p = heap_next; + if (p + n > heap_end) { + printf("malloc failure\n"); + for (;;) + ; + return 0; + } + heap_next += n; + return p; +} + +static size_t +strlen(const char *s) +{ + size_t len = 0; + while (*s++) + len++; + return len; +} + +static char * +strdup(const char *s) +{ + char *p = malloc(strlen(s) + 1); + strcpy(p, s); + return p; +} + +#include "zfsimpl.c" + +/* + * Read from a dnode (which must be from a ZPL filesystem). + */ +static int +zfs_read(spa_t *spa, const dnode_phys_t *dnode, off_t *offp, void *start, size_t size) +{ + const znode_phys_t *zp = (const znode_phys_t *) dnode->dn_bonus; + size_t n; + int rc; + + n = size; + if (*offp + n > zp->zp_size) + n = zp->zp_size - *offp; + + rc = dnode_read(spa, dnode, *offp, start, n); + if (rc) + return (-1); + *offp += n; + + return (n); +} + +/* + * Current ZFS pool + */ +spa_t *spa; + +/* + * A wrapper for dskread that doesn't have to worry about whether the + * buffer pointer crosses a 64k boundary. + */ +static int +vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) +{ + char *p; + unsigned int lba, nb; + struct dsk *dsk = (struct dsk *) priv; + + if ((off & (DEV_BSIZE - 1)) || (bytes & (DEV_BSIZE - 1))) + return -1; + + p = buf; + lba = off / DEV_BSIZE; + while (bytes > 0) { + nb = bytes / DEV_BSIZE; + if (nb > READ_BUF_SIZE / DEV_BSIZE) + nb = READ_BUF_SIZE / DEV_BSIZE; + if (drvread(dsk, dmadat->rdbuf, lba, nb)) + return -1; + memcpy(p, dmadat->rdbuf, nb * DEV_BSIZE); + p += nb * DEV_BSIZE; + lba += nb; + bytes -= nb * DEV_BSIZE; + } + + return 0; +} + +static int +xfsread(const dnode_phys_t *dnode, off_t *offp, void *buf, size_t nbyte) +{ + if ((size_t)zfs_read(spa, dnode, offp, buf, nbyte) != nbyte) { + printf("Invalid %s\n", "format"); + return -1; + } + return 0; +} + +static inline uint32_t +memsize(void) +{ + v86.addr = MEM_EXT; + v86.eax = 0x8800; + v86int(); + return v86.eax; +} + +static inline void +getstr(void) +{ + char *s; + int c; + + s = cmd; + for (;;) { + switch (c = xgetc(0)) { + case 0: + break; + case '\177': + case '\b': + if (s > cmd) { + s--; + printf("\b \b"); + } + break; + case '\n': + case '\r': + *s = 0; + return; + default: + if (s - cmd < sizeof(cmd) - 1) + *s++ = c; + putchar(c); + } + } +} + +static inline void +putc(int c) +{ + v86.addr = 0x10; + v86.eax = 0xe00 | (c & 0xff); + v86.ebx = 0x7; + v86int(); +} + +/* + * Try to detect a device supported by the legacy int13 BIOS + */ +static int +int13probe(int drive) +{ + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x800; + v86.edx = drive; + v86int(); + + if (!(v86.efl & 0x1) && /* carry clear */ + ((v86.edx & 0xff) != (drive & DRV_MASK))) { /* unit # OK */ + if ((v86.ecx & 0x3f) == 0) { /* absurd sector size */ + return(0); /* skip device */ + } + return (1); + } + return(0); +} + +/* + * We call this when we find a ZFS vdev - ZFS consumes the dsk + * structure so we must make a new one. + */ +static struct dsk * +copy_dsk(struct dsk *dsk) +{ + struct dsk *newdsk; + + newdsk = malloc(sizeof(struct dsk)); + *newdsk = *dsk; + return (newdsk); +} + +static void +probe_drive(struct dsk *dsk, spa_t **spap) +{ +#ifdef GPT + struct gpt_hdr hdr; + struct gpt_ent *ent; + daddr_t slba, elba; + unsigned part, entries_per_sec; +#endif + struct dos_partition *dp; + char *sec; + unsigned i; + + /* + * If we find a vdev on the whole disk, stop here. Otherwise dig + * out the MBR and probe each slice in turn for a vdev. + */ + if (vdev_probe(vdev_read, dsk, spap) == 0) + return; + + sec = dmadat->secbuf; + dsk->start = 0; + +#ifdef GPT + /* + * First check for GPT. + */ + if (drvread(dsk, sec, 1, 1)) { + return; + } + memcpy(&hdr, sec, sizeof(hdr)); + if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 || + hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 || + hdr.hdr_entsz < sizeof(*ent) || DEV_BSIZE % hdr.hdr_entsz != 0) { + goto trymbr; + } + + /* + * Probe all GPT partitions for the presense of ZFS pools. We + * return the spa_t for the first we find (if requested). This + * will have the effect of booting from the first pool on the + * disk. + */ + entries_per_sec = DEV_BSIZE / hdr.hdr_entsz; + slba = hdr.hdr_lba_table; + elba = slba + hdr.hdr_entries / entries_per_sec; + while (slba < elba) { + if (drvread(dsk, sec, slba, 1)) + return; + for (part = 0; part < entries_per_sec; part++) { + ent = (struct gpt_ent *)(sec + part * hdr.hdr_entsz); + if (memcmp(&ent->ent_type, &freebsd_zfs_uuid, + sizeof(uuid_t)) == 0) { + dsk->start = ent->ent_lba_start; + if (vdev_probe(vdev_read, dsk, spap) == 0) { + /* + * We record the first pool we find (we will try + * to boot from that one). + */ + spap = 0; + + /* + * This slice had a vdev. We need a new dsk + * structure now since the vdev now owns this one. + */ + dsk = copy_dsk(dsk); + } + break; + } + } + slba++; + } + return; +trymbr: +#endif + + if (drvread(dsk, sec, DOSBBSECTOR, 1)) + return; + dp = (void *)(sec + DOSPARTOFF); + + for (i = 0; i < NDOSPART; i++) { + if (!dp[i].dp_typ) + continue; + dsk->start = dp[i].dp_start; + if (vdev_probe(vdev_read, dsk, spap) == 0) { + /* + * We record the first pool we find (we will try to boot + * from that one. + */ + spap = 0; + + /* + * This slice had a vdev. We need a new dsk structure now + * since the vdev now owns this one. + */ + dsk = copy_dsk(dsk); + } + } +} + +int +main(void) +{ + int autoboot, i; + dnode_phys_t dn; + off_t off; + struct dsk *dsk; + + dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); + v86.ctl = V86_FLAGS; + + dsk = malloc(sizeof(struct dsk)); + dsk->drive = *(uint8_t *)PTOV(ARGS); + dsk->type = dsk->drive & DRV_HARD ? TYPE_AD : TYPE_FD; + dsk->unit = dsk->drive & DRV_MASK; + dsk->slice = *(uint8_t *)PTOV(ARGS + 1) + 1; + dsk->part = 0; + dsk->start = 0; + dsk->init = 0; + + bootinfo.bi_version = BOOTINFO_VERSION; + bootinfo.bi_size = sizeof(bootinfo); + bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */ + bootinfo.bi_extmem = memsize(); + bootinfo.bi_memsizes_valid++; + bootinfo.bi_bios_dev = dsk->drive; + + bootdev = MAKEBOOTDEV(dev_maj[dsk->type], + dsk->slice, dsk->unit, dsk->part), + + /* Process configuration file */ + + autoboot = 1; + + zfs_init(); + + /* + * Probe the boot drive first - we will try to boot from whatever + * pool we find on that drive. + */ + probe_drive(dsk, &spa); + + /* + * Probe the rest of the drives that the bios knows about. This + * will find any other available pools and it may fill in missing + * vdevs for the boot pool. + */ + for (i = 0; i < 128; i++) { + if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS)) + continue; + + if (!int13probe(i | DRV_HARD)) + break; + + dsk = malloc(sizeof(struct dsk)); + dsk->drive = i | DRV_HARD; + dsk->type = dsk->drive & TYPE_AD; + dsk->unit = i; + dsk->slice = 0; + dsk->part = 0; + dsk->start = 0; + dsk->init = 0; + probe_drive(dsk, 0); + } + + /* + * If we didn't find a pool on the boot drive, default to the + * first pool we found, if any. + */ + if (!spa) { + spa = STAILQ_FIRST(&zfs_pools); + if (!spa) { + printf("No ZFS pools located, can't boot\n"); + for (;;) + ; + } + } + + zfs_mount_pool(spa); + + if (zfs_lookup(spa, PATH_CONFIG, &dn) == 0) { + off = 0; + xfsread(&dn, &off, cmd, sizeof(cmd)); + } + + if (*cmd) { + if (parse()) + autoboot = 0; + if (!OPT_CHECK(RBX_QUIET)) + printf("%s: %s", PATH_CONFIG, cmd); + /* Do not process this command twice */ + *cmd = 0; + } + + /* + * Try to exec stage 3 boot loader. If interrupted by a keypress, + * or in case of failure, try to load a kernel directly instead. + */ + + if (autoboot && !*kname) { + memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3)); + if (!keyhit(3*SECOND)) { + load(); + memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); + } + } + + /* Present the user with the boot2 prompt. */ + + for (;;) { + if (!autoboot || !OPT_CHECK(RBX_QUIET)) + printf("\nFreeBSD/i386 boot\n" + "Default: %s:%s\n" + "boot: ", + spa->spa_name, kname); + if (ioctrl & IO_SERIAL) + sio_flush(); + if (!autoboot || keyhit(5*SECOND)) + getstr(); + else if (!autoboot || !OPT_CHECK(RBX_QUIET)) + putchar('\n'); + autoboot = 0; + if (parse()) + putchar('\a'); + else + load(); + } +} + +/* XXX - Needed for btxld to link the boot2 binary; do not remove. */ +void +exit(int x) +{ +} + +static void +load(void) +{ + union { + struct exec ex; + Elf32_Ehdr eh; + } hdr; + static Elf32_Phdr ep[2]; + static Elf32_Shdr es[2]; + caddr_t p; + dnode_phys_t dn; + off_t off; + uint32_t addr, x; + int fmt, i, j; + + if (zfs_lookup(spa, kname, &dn)) { + return; + } + off = 0; + if (xfsread(&dn, &off, &hdr, sizeof(hdr))) + return; + if (N_GETMAGIC(hdr.ex) == ZMAGIC) + fmt = 0; + else if (IS_ELF(hdr.eh)) + fmt = 1; + else { + printf("Invalid %s\n", "format"); + return; + } + if (fmt == 0) { + addr = hdr.ex.a_entry & 0xffffff; + p = PTOV(addr); + off = PAGE_SIZE; + if (xfsread(&dn, &off, p, hdr.ex.a_text)) + return; + p += roundup2(hdr.ex.a_text, PAGE_SIZE); + if (xfsread(&dn, &off, p, hdr.ex.a_data)) + return; + p += hdr.ex.a_data + roundup2(hdr.ex.a_bss, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + memcpy(p, &hdr.ex.a_syms, sizeof(hdr.ex.a_syms)); + p += sizeof(hdr.ex.a_syms); + if (hdr.ex.a_syms) { + if (xfsread(&dn, &off, p, hdr.ex.a_syms)) + return; + p += hdr.ex.a_syms; + if (xfsread(&dn, &off, p, sizeof(int))) + return; + x = *(uint32_t *)p; + p += sizeof(int); + x -= sizeof(int); + if (xfsread(&dn, &off, p, x)) + return; + p += x; + } + } else { + off = hdr.eh.e_phoff; + for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + if (xfsread(&dn, &off, ep + j, sizeof(ep[0]))) + return; + if (ep[j].p_type == PT_LOAD) + j++; + } + for (i = 0; i < 2; i++) { + p = PTOV(ep[i].p_paddr & 0xffffff); + off = ep[i].p_offset; + if (xfsread(&dn, &off, p, ep[i].p_filesz)) + return; + } + p += roundup2(ep[1].p_memsz, PAGE_SIZE); + bootinfo.bi_symtab = VTOP(p); + if (hdr.eh.e_shnum == hdr.eh.e_shstrndx + 3) { + off = hdr.eh.e_shoff + sizeof(es[0]) * + (hdr.eh.e_shstrndx + 1); + if (xfsread(&dn, &off, &es, sizeof(es))) + return; + for (i = 0; i < 2; i++) { + memcpy(p, &es[i].sh_size, sizeof(es[i].sh_size)); + p += sizeof(es[i].sh_size); + off = es[i].sh_offset; + if (xfsread(&dn, &off, p, es[i].sh_size)) + return; + p += es[i].sh_size; + } + } + addr = hdr.eh.e_entry & 0xffffff; + } + bootinfo.bi_esymtab = VTOP(p); + bootinfo.bi_kernelname = VTOP(kname); + __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), + bootdev, + KARGS_FLAGS_ZFS, + (uint32_t) spa->spa_guid, + (uint32_t) (spa->spa_guid >> 32), + VTOP(&bootinfo)); +} + +static int +parse() +{ + char *arg = cmd; + char *ep, *p, *q; + const char *cp; + //unsigned int drv; + int c, i, j; + + while ((c = *arg++)) { + if (c == ' ' || c == '\t' || c == '\n') + continue; + for (p = arg; *p && *p != '\n' && *p != ' ' && *p != '\t'; p++); + ep = p; + if (*p) + *p++ = 0; + if (c == '-') { + while ((c = *arg++)) { + if (c == 'P') { + if (*(uint8_t *)PTOV(0x496) & 0x10) { + cp = "yes"; + } else { + opts |= OPT_SET(RBX_DUAL) | OPT_SET(RBX_SERIAL); + cp = "no"; + } + printf("Keyboard: %s\n", cp); + continue; + } else if (c == 'S') { + j = 0; + while ((unsigned int)(i = *arg++ - '0') <= 9) + j = j * 10 + i; + if (j > 0 && i == -'0') { + comspeed = j; + break; + } + /* Fall through to error below ('S' not in optstr[]). */ + } + for (i = 0; c != optstr[i]; i++) + if (i == NOPT - 1) + return -1; + opts ^= OPT_SET(flags[i]); + } + ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) : + OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD; + if (ioctrl & IO_SERIAL) + sio_init(115200 / comspeed); + } if (c == '?') { + dnode_phys_t dn; + + if (zfs_lookup(spa, arg, &dn) == 0) { + zap_list(spa, &dn); + } + return -1; + } else { + arg--; + + /* + * Report pool status if the comment is 'status'. Lets + * hope no-one wants to load /status as a kernel. + */ + if (!strcmp(arg, "status")) { + spa_all_status(); + return -1; + } + + /* + * If there is a colon, switch pools. + */ + q = (char *) strchr(arg, ':'); + if (q) { + spa_t *newspa; + + *q++ = 0; + newspa = spa_find_by_name(arg); + if (newspa) { + spa = newspa; + zfs_mount_pool(spa); + } else { + printf("\nCan't find ZFS pool %s\n", arg); + return -1; + } + arg = q; + } + if ((i = ep - arg)) { + if ((size_t)i >= sizeof(kname)) + return -1; + memcpy(kname, arg, i + 1); + } + } + arg = p; + } + return 0; +} + +static void +printf(const char *fmt,...) +{ + va_list ap; + char buf[10]; + char *s; + unsigned u; + int c; + int minus; + int prec; + int len; + int pad; + + va_start(ap, fmt); + while ((c = *fmt++)) { + if (c == '%') { + minus = 0; + prec = 0; + nextfmt: + c = *fmt++; + switch (c) { + case '-': + minus = 1; + goto nextfmt; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + prec = 10 * prec + (c - '0'); + goto nextfmt; + case 'c': + putchar(va_arg(ap, int)); + continue; + case 's': + s = va_arg(ap, char *); + if (prec) { + len = strlen(s); + if (len < prec) + pad = prec - len; + else + pad = 0; + if (minus) + while (pad--) + putchar(' '); + for (; *s; s++) + putchar(*s); + if (!minus) + while (pad--) + putchar(' '); + } else { + for (; *s; s++) + putchar(*s); + } + continue; + case 'u': + u = va_arg(ap, unsigned); + s = buf; + do + *s++ = '0' + u % 10U; + while (u /= 10U); + while (--s >= buf) + putchar(*s); + continue; + } + } + putchar(c); + } + va_end(ap); + return; +} + +static void +putchar(int c) +{ + if (c == '\n') + xputc('\r'); + xputc(c); +} + +#ifdef GPT +static struct { + uint16_t len; + uint16_t count; + uint16_t seg; + uint16_t off; + uint64_t lba; +} packet; +#endif + +static int +drvread(struct dsk *dsk, void *buf, unsigned lba, unsigned nblk) +{ +#ifdef GPT + static unsigned c = 0x2d5c7c2f; + + if (!OPT_CHECK(RBX_QUIET)) + printf("%c\b", c = c << 8 | c >> 24); + packet.len = 0x10; + packet.count = nblk; + packet.seg = VTOPOFF(buf); + packet.off = VTOPSEG(buf); + packet.lba = lba + dsk->start; + v86.ctl = V86_FLAGS; + v86.addr = 0x13; + v86.eax = 0x4200; + v86.edx = dsk->drive; + v86.ds = VTOPSEG(&packet); + v86.esi = VTOPOFF(&packet); + v86int(); + if (V86_CY(v86.efl)) { + printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba); + return -1; + } + return 0; +#else + static unsigned c = 0x2d5c7c2f; + + lba += dsk->start; + if (!OPT_CHECK(RBX_QUIET)) + printf("%c\b", c = c << 8 | c >> 24); + v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; + v86.addr = XREADORG; /* call to xread in boot1 */ + v86.es = VTOPSEG(buf); + v86.eax = lba; + v86.ebx = VTOPOFF(buf); + v86.ecx = lba >> 16; + v86.edx = nblk << 8 | dsk->drive; + v86int(); + v86.ctl = V86_FLAGS; + if (V86_CY(v86.efl)) { + printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba); + return -1; + } + return 0; +#endif +} *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat May 16 19:18:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 259161065675; Sat, 16 May 2009 19:18:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 09FFA8FC22; Sat, 16 May 2009 19:18:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GJIDpM067500; Sat, 16 May 2009 19:18:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GJIDEZ067497; Sat, 16 May 2009 19:18:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905161918.n4GJIDEZ067497@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 19:18:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192208 - in user/kmacy/ZFS_MFC/sys: cddl/contrib/opensolaris/uts/common/fs/zfs vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 19:18:14 -0000 Author: kmacy Date: Sat May 16 19:18:13 2009 New Revision: 192208 URL: http://svn.freebsd.org/changeset/base/192208 Log: merge large memory workaround Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 19:17:15 2009 (r192207) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 19:18:13 2009 (r192208) @@ -172,6 +172,7 @@ uint64_t zfs_arc_max; uint64_t zfs_arc_min; uint64_t zfs_arc_meta_limit = 0; int zfs_mdcomp_disable = 0; +int arc_large_memory_enabled = 0; TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); @@ -3431,17 +3432,13 @@ arc_init(void) arc_min_prefetch_lifespan = 1 * hz; /* Start out with 1/8 of all memory */ +#if defined(_KERNEL) && (__amd64__) + arc_c = physmem*PAGE_SIZE / 8; + if (physmem*PAGE_SIZE > kmem_size()) + arc_large_memory_enabled = 1; +#else arc_c = kmem_size() / 8; -#if 0 -#ifdef _KERNEL - /* - * On architectures where the physical memory can be larger - * than the addressable space (intel in 32-bit mode), we may - * need to limit the cache to 1/8 of VM size. - */ - arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8); -#endif -#endif +#endif /* set min cache to 1/32 of all memory, or 16MB, whichever is more */ arc_c_min = MAX(arc_c / 4, 64<<18); /* set max to 1/2 of all memory, or all but 1GB, whichever is more */ @@ -3456,8 +3453,13 @@ arc_init(void) * Allow the tunables to override our calculations if they are * reasonable (ie. over 16MB) */ +#if defined(_KERNEL) && defined(__amd64__) + if (zfs_arc_max >= 64<<18) + arc_c_max = zfs_arc_max; +#else if (zfs_arc_max >= 64<<18 && zfs_arc_max < kmem_size()) arc_c_max = zfs_arc_max; +#endif if (zfs_arc_min >= 64<<18 && zfs_arc_min <= arc_c_max) arc_c_min = zfs_arc_min; #endif Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Sat May 16 19:17:15 2009 (r192207) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Sat May 16 19:18:13 2009 (r192208) @@ -33,6 +33,9 @@ #include #include +#if defined(_KERNEL) && defined(__amd64__) +#include +#endif /* * ========================================================================== * I/O priority table @@ -85,6 +88,8 @@ extern vmem_t *zio_alloc_arena; #define IO_IS_ALLOCATING(zio) \ ((zio)->io_orig_pipeline & (1U << ZIO_STAGE_DVA_ALLOCATE)) +extern int arc_large_memory_enabled; + void zio_init(void) { @@ -208,6 +213,80 @@ zio_buf_alloc(size_t size) #endif } +#if defined(_KERNEL) && defined(__amd64__) +extern int vm_contig_launder(int queue); + +static void * +zio_large_malloc(size_t size) +{ + void *ret; + vm_page_t pages; + unsigned long npgs; + int actl, actmax, inactl, inactmax, tries; + int flags = M_WAITOK; + vm_paddr_t low = (1UL<<29); /* leave lower 512MB untouched */ + vm_paddr_t high = ~(vm_paddr_t)0; + unsigned long alignment = 1; + unsigned long boundary = 0; + + npgs = round_page(size) >> PAGE_SHIFT; + tries = 0; +retry: + pages = vm_phys_alloc_contig(npgs, low, high, alignment, boundary); + if (pages == NULL) { + if (tries < ((flags & M_NOWAIT) != 0 ? 1 : 3)) { + vm_page_lock_queues(); + inactl = 0; + inactmax = tries < 1 ? 0 : cnt.v_inactive_count; + actl = 0; + actmax = tries < 2 ? 0 : cnt.v_active_count; +again: + if (inactl < inactmax && + vm_contig_launder(PQ_INACTIVE)) { + inactl++; + goto again; + } + if (actl < actmax && + vm_contig_launder(PQ_ACTIVE)) { + actl++; + goto again; + } + vm_page_unlock_queues(); + tries++; + goto retry; + } + + ret = NULL; + } else { + int i; + + vm_page_lock_queues(); + for (i = 0; i < npgs; i++) + vm_page_wire(&pages[i]); + vm_page_unlock_queues(); + + return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(pages)); + } + return (ret); +} + +static void +zio_large_free(void *buf, size_t size) +{ + int npgs = round_page(size) >> PAGE_SHIFT; + int i; + vm_page_t m; + + m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)buf)); + vm_page_lock_queues(); + for (i = 0; i < npgs; i++, m++) { + vm_page_unwire(m, 0); + vm_page_free(m); + } + vm_page_unlock_queues(); +} +#endif + /* * Use zio_data_buf_alloc to allocate data. The data will not appear in a * crashdump if the kernel panics. This exists so that we will limit the amount @@ -224,7 +303,12 @@ zio_data_buf_alloc(size_t size) return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE)); #else - return (kmem_alloc(size, KM_SLEEP)); +#if defined(_KERNEL) && defined(__amd64__) + if (arc_large_memory_enabled && (size > PAGE_SIZE)) + return (zio_large_malloc(size)); + else +#endif + return (kmem_alloc(size, KM_SLEEP)); #endif } @@ -252,7 +336,12 @@ zio_data_buf_free(void *buf, size_t size kmem_cache_free(zio_data_buf_cache[c], buf); #else - kmem_free(buf, size); +#if defined (_KERNEL) && defined(__amd64__) + if (arc_large_memory_enabled && (size > PAGE_SIZE)) + zio_large_free(buf, size); + else +#endif + kmem_free(buf, size); #endif } Modified: user/kmacy/ZFS_MFC/sys/vm/vm_contig.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Sat May 16 19:17:15 2009 (r192207) +++ user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Sat May 16 19:18:13 2009 (r192208) @@ -87,6 +87,11 @@ __FBSDID("$FreeBSD$"); #include #include +/* + * Only available as a band-aid to ZFS + */ +int vm_contig_launder(int queue); + static int vm_contig_launder_page(vm_page_t m, vm_page_t *next) { @@ -146,7 +151,7 @@ vm_contig_launder_page(vm_page_t m, vm_p return (0); } -static int +int vm_contig_launder(int queue) { vm_page_t m, next; From owner-svn-src-user@FreeBSD.ORG Sat May 16 19:54:06 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CE9221065677; Sat, 16 May 2009 19:54:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A41348FC18; Sat, 16 May 2009 19:54:06 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GJs6wN068168; Sat, 16 May 2009 19:54:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GJs6kk068165; Sat, 16 May 2009 19:54:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905161954.n4GJs6kk068165@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 19:54:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192209 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 19:54:07 -0000 Author: kmacy Date: Sat May 16 19:54:06 2009 New Revision: 192209 URL: http://svn.freebsd.org/changeset/base/192209 Log: restore call to tsd_get in rrwlock.c eliminate white space differences with HEAD in other consumers Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:54:06 2009 (r192209) @@ -85,12 +85,11 @@ rrn_find(rrwlock_t *rrl) if (refcount_count(&rrl->rr_linked_rcount) == 0) return (NULL); -#if 0 + for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) return (rn); } -#endif return (NULL); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:54:06 2009 (r192209) @@ -451,7 +451,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * { itx_wr_state_t write_state; boolean_t slogging; - uintptr_t fsync_cnt = 0; + uintptr_t fsync_cnt; if (zilog == NULL || zp->z_unlinked) return; @@ -486,6 +486,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * write_state = WR_COPIED; else write_state = WR_NEED_COPY; + if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) { (void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1)); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:54:06 2009 (r192209) @@ -2299,6 +2299,7 @@ zfs_fsync(vnode_t *vp, int syncflag, cre zfsvfs_t *zfsvfs = zp->z_zfsvfs; (void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt); + ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); zil_commit(zfsvfs->z_log, zp->z_last_itx, zp->z_id); From owner-svn-src-user@FreeBSD.ORG Sat May 16 20:01:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 64CA81065670; Sat, 16 May 2009 20:01:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 396408FC08; Sat, 16 May 2009 20:01:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GJs6wN068168; Sat, 16 May 2009 19:54:06 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GJs6kk068165; Sat, 16 May 2009 19:54:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905161954.n4GJs6kk068165@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 19:54:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192209 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:01:10 -0000 Author: kmacy Date: Sat May 16 19:54:06 2009 New Revision: 192209 URL: http://svn.freebsd.org/changeset/base/192209 Log: restore call to tsd_get in rrwlock.c eliminate white space differences with HEAD in other consumers Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:54:06 2009 (r192209) @@ -85,12 +85,11 @@ rrn_find(rrwlock_t *rrl) if (refcount_count(&rrl->rr_linked_rcount) == 0) return (NULL); -#if 0 + for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) return (rn); } -#endif return (NULL); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:54:06 2009 (r192209) @@ -451,7 +451,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * { itx_wr_state_t write_state; boolean_t slogging; - uintptr_t fsync_cnt = 0; + uintptr_t fsync_cnt; if (zilog == NULL || zp->z_unlinked) return; @@ -486,6 +486,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * write_state = WR_COPIED; else write_state = WR_NEED_COPY; + if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) { (void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1)); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:54:06 2009 (r192209) @@ -2299,6 +2299,7 @@ zfs_fsync(vnode_t *vp, int syncflag, cre zfsvfs_t *zfsvfs = zp->z_zfsvfs; (void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt); + ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); zil_commit(zfsvfs->z_log, zp->z_last_itx, zp->z_id); From owner-svn-src-user@FreeBSD.ORG Sat May 16 20:01:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E365E106567B; Sat, 16 May 2009 20:01:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B8FA48FC15; Sat, 16 May 2009 20:01:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GK1ATt000785; Sat, 16 May 2009 20:01:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GJs6kk068165; Sat, 16 May 2009 19:54:06 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905161954.n4GJs6kk068165@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 19:54:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192209 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:01:11 -0000 Author: kmacy Date: Sat May 16 19:54:06 2009 New Revision: 192209 URL: http://svn.freebsd.org/changeset/base/192209 Log: restore call to tsd_get in rrwlock.c eliminate white space differences with HEAD in other consumers Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 19:54:06 2009 (r192209) @@ -85,12 +85,11 @@ rrn_find(rrwlock_t *rrl) if (refcount_count(&rrl->rr_linked_rcount) == 0) return (NULL); -#if 0 + for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) return (rn); } -#endif return (NULL); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_log.c Sat May 16 19:54:06 2009 (r192209) @@ -451,7 +451,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * { itx_wr_state_t write_state; boolean_t slogging; - uintptr_t fsync_cnt = 0; + uintptr_t fsync_cnt; if (zilog == NULL || zp->z_unlinked) return; @@ -486,6 +486,7 @@ zfs_log_write(zilog_t *zilog, dmu_tx_t * write_state = WR_COPIED; else write_state = WR_NEED_COPY; + if ((fsync_cnt = (uintptr_t)tsd_get(zfs_fsyncer_key)) != 0) { (void) tsd_set(zfs_fsyncer_key, (void *)(fsync_cnt - 1)); } Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:18:13 2009 (r192208) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Sat May 16 19:54:06 2009 (r192209) @@ -2299,6 +2299,7 @@ zfs_fsync(vnode_t *vp, int syncflag, cre zfsvfs_t *zfsvfs = zp->z_zfsvfs; (void) tsd_set(zfs_fsyncer_key, (void *)zfs_fsync_sync_cnt); + ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zp); zil_commit(zfsvfs->z_log, zp->z_last_itx, zp->z_id); From owner-svn-src-user@FreeBSD.ORG Sat May 16 20:34:58 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4DAEB106566C; Sat, 16 May 2009 20:34:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3E3F28FC2C; Sat, 16 May 2009 20:34:58 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GKYw2P001767; Sat, 16 May 2009 20:34:58 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GKYwI0001766; Sat, 16 May 2009 20:34:58 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162034.n4GKYwI0001766@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 20:34:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192212 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:34:58 -0000 Author: kmacy Date: Sat May 16 20:34:57 2009 New Revision: 192212 URL: http://svn.freebsd.org/changeset/base/192212 Log: only use direct map if we have more than 2GB Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 20:33:13 2009 (r192211) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 20:34:57 2009 (r192212) @@ -3434,7 +3434,7 @@ arc_init(void) /* Start out with 1/8 of all memory */ #if defined(_KERNEL) && (__amd64__) arc_c = physmem*PAGE_SIZE / 8; - if (physmem*PAGE_SIZE > kmem_size()) + if (physmem*PAGE_SIZE > kmem_size() && (1UL<<31)) arc_large_memory_enabled = 1; #else arc_c = kmem_size() / 8; From owner-svn-src-user@FreeBSD.ORG Sat May 16 20:35:57 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 590631065673; Sat, 16 May 2009 20:35:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 49A5B8FC08; Sat, 16 May 2009 20:35:57 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GKZvkj001828; Sat, 16 May 2009 20:35:57 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GKZvpk001827; Sat, 16 May 2009 20:35:57 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162035.n4GKZvpk001827@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 20:35:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192213 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:35:57 -0000 Author: kmacy Date: Sat May 16 20:35:57 2009 New Revision: 192213 URL: http://svn.freebsd.org/changeset/base/192213 Log: do check this time Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 20:34:57 2009 (r192212) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 20:35:57 2009 (r192213) @@ -3434,7 +3434,7 @@ arc_init(void) /* Start out with 1/8 of all memory */ #if defined(_KERNEL) && (__amd64__) arc_c = physmem*PAGE_SIZE / 8; - if (physmem*PAGE_SIZE > kmem_size() && (1UL<<31)) + if (physmem*PAGE_SIZE > kmem_size() && (physmem*PAGE_SIZE > (1UL<<31))) arc_large_memory_enabled = 1; #else arc_c = kmem_size() / 8; From owner-svn-src-user@FreeBSD.ORG Sat May 16 20:51:28 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB1801065670; Sat, 16 May 2009 20:51:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id ABB698FC18; Sat, 16 May 2009 20:51:28 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GKpSaa002193; Sat, 16 May 2009 20:51:28 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GKpS3C002192; Sat, 16 May 2009 20:51:28 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162051.n4GKpS3C002192@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 20:51:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192214 - user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 20:51:29 -0000 Author: kmacy Date: Sat May 16 20:51:28 2009 New Revision: 192214 URL: http://svn.freebsd.org/changeset/base/192214 Log: restore tsd_get call Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 20:35:57 2009 (r192213) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/rrwlock.c Sat May 16 20:51:28 2009 (r192214) @@ -85,12 +85,10 @@ rrn_find(rrwlock_t *rrl) if (refcount_count(&rrl->rr_linked_rcount) == 0) return (NULL); -#if 0 for (rn = tsd_get(rrw_tsd_key); rn != NULL; rn = rn->rn_next) { if (rn->rn_rrl == rrl) return (rn); } -#endif return (NULL); } From owner-svn-src-user@FreeBSD.ORG Sat May 16 21:06:48 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C9D92106566C; Sat, 16 May 2009 21:06:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BA7298FC08; Sat, 16 May 2009 21:06:48 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GL6mFX002647; Sat, 16 May 2009 21:06:48 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GL6mH7002644; Sat, 16 May 2009 21:06:48 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162106.n4GL6mH7002644@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 21:06:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192217 - in user/kmacy/ZFS_MFC/sys: amd64/include kern vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:06:49 -0000 Author: kmacy Date: Sat May 16 21:06:48 2009 New Revision: 192217 URL: http://svn.freebsd.org/changeset/base/192217 Log: bump kmem to 512GB Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h user/kmacy/ZFS_MFC/sys/kern/kern_malloc.c user/kmacy/ZFS_MFC/sys/vm/vm_kern.h Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 20:57:08 2009 (r192216) +++ user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 21:06:48 2009 (r192217) @@ -154,8 +154,8 @@ * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) * 0xffff804020101000 - 0xfffffeffffffffff unused * 0xffffff0000000000 - 0xffffff7fffffffff 512GB direct map mappings - * 0xffffff8000000000 - 0xfffffffe7fffffff unused (506GB) - * 0xfffffffe80000000 - 0xffffffffffffffff 6GB kernel map + * 0xffffff8000000000 - 0xfffffffe3fffffff unused (505GB) + * 0xfffffffe40000000 - 0xffffffffffffffff 512GB kernel map * * Within the kernel map: * @@ -163,7 +163,7 @@ */ #define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-1, NPDEPG-1, NPTEPG-1) -#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-6, 0, 0) +#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-512, 0, 0) #define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0) #define DMAP_MAX_ADDRESS KVADDR(DMPML4I+1, 0, 0, 0) Modified: user/kmacy/ZFS_MFC/sys/kern/kern_malloc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_malloc.c Sat May 16 20:57:08 2009 (r192216) +++ user/kmacy/ZFS_MFC/sys/kern/kern_malloc.c Sat May 16 21:06:48 2009 (r192217) @@ -181,20 +181,20 @@ struct { */ static uma_zone_t mt_zone; -u_int vm_kmem_size; -SYSCTL_UINT(_vm, OID_AUTO, kmem_size, CTLFLAG_RD, &vm_kmem_size, 0, +u_long vm_kmem_size; +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size, CTLFLAG_RD, &vm_kmem_size, 0, "Size of kernel memory"); -u_int vm_kmem_size_min; -SYSCTL_UINT(_vm, OID_AUTO, kmem_size_min, CTLFLAG_RD, &vm_kmem_size_min, 0, +u_long vm_kmem_size_min; +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_min, CTLFLAG_RD, &vm_kmem_size_min, 0, "Minimum size of kernel memory"); -u_int vm_kmem_size_max; -SYSCTL_UINT(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RD, &vm_kmem_size_max, 0, +u_long vm_kmem_size_max; +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_max, CTLFLAG_RD, &vm_kmem_size_max, 0, "Maximum size of kernel memory"); u_int vm_kmem_size_scale; -SYSCTL_UINT(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RD, &vm_kmem_size_scale, 0, +SYSCTL_ULONG(_vm, OID_AUTO, kmem_size_scale, CTLFLAG_RD, &vm_kmem_size_scale, 0, "Scale factor for kernel memory size"); /* @@ -589,7 +589,7 @@ kmeminit(void *dummy) #if defined(VM_KMEM_SIZE_MIN) vm_kmem_size_min = VM_KMEM_SIZE_MIN; #endif - TUNABLE_INT_FETCH("vm.kmem_size_min", &vm_kmem_size_min); + TUNABLE_LONG_FETCH("vm.kmem_size_min", &vm_kmem_size_min); if (vm_kmem_size_min > 0 && vm_kmem_size < vm_kmem_size_min) { vm_kmem_size = vm_kmem_size_min; } @@ -597,16 +597,16 @@ kmeminit(void *dummy) #if defined(VM_KMEM_SIZE_MAX) vm_kmem_size_max = VM_KMEM_SIZE_MAX; #endif - TUNABLE_INT_FETCH("vm.kmem_size_max", &vm_kmem_size_max); + TUNABLE_LONG_FETCH("vm.kmem_size_max", &vm_kmem_size_max); if (vm_kmem_size_max > 0 && vm_kmem_size >= vm_kmem_size_max) vm_kmem_size = vm_kmem_size_max; /* Allow final override from the kernel environment */ #ifndef BURN_BRIDGES - if (TUNABLE_INT_FETCH("kern.vm.kmem.size", &vm_kmem_size) != 0) + if (TUNABLE_LONG_FETCH("kern.vm.kmem.size", &vm_kmem_size) != 0) printf("kern.vm.kmem.size is now called vm.kmem_size!\n"); #endif - TUNABLE_INT_FETCH("vm.kmem_size", &vm_kmem_size); + TUNABLE_LONG_FETCH("vm.kmem_size", &vm_kmem_size); /* * Limit kmem virtual size to twice the physical memory. Modified: user/kmacy/ZFS_MFC/sys/vm/vm_kern.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/vm/vm_kern.h Sat May 16 20:57:08 2009 (r192216) +++ user/kmacy/ZFS_MFC/sys/vm/vm_kern.h Sat May 16 21:06:48 2009 (r192217) @@ -69,6 +69,6 @@ extern vm_map_t kernel_map; extern vm_map_t kmem_map; extern vm_map_t exec_map; extern vm_map_t pipe_map; -extern u_int vm_kmem_size; +extern u_long vm_kmem_size; #endif /* _VM_VM_KERN_H_ */ From owner-svn-src-user@FreeBSD.ORG Sat May 16 21:08:32 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B9AB2106566B; Sat, 16 May 2009 21:08:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A945F8FC08; Sat, 16 May 2009 21:08:32 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GL8Wnq002744; Sat, 16 May 2009 21:08:32 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GL8WZn002741; Sat, 16 May 2009 21:08:32 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162108.n4GL8WZn002741@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 21:08:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192218 - in user/kmacy/ZFS_MFC/sys: cddl/contrib/opensolaris/uts/common/fs/zfs vm X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:08:33 -0000 Author: kmacy Date: Sat May 16 21:08:32 2009 New Revision: 192218 URL: http://svn.freebsd.org/changeset/base/192218 Log: back out direct map hack Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 21:06:48 2009 (r192217) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Sat May 16 21:08:32 2009 (r192218) @@ -172,7 +172,6 @@ uint64_t zfs_arc_max; uint64_t zfs_arc_min; uint64_t zfs_arc_meta_limit = 0; int zfs_mdcomp_disable = 0; -int arc_large_memory_enabled = 0; TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); @@ -3432,13 +3431,17 @@ arc_init(void) arc_min_prefetch_lifespan = 1 * hz; /* Start out with 1/8 of all memory */ -#if defined(_KERNEL) && (__amd64__) - arc_c = physmem*PAGE_SIZE / 8; - if (physmem*PAGE_SIZE > kmem_size() && (physmem*PAGE_SIZE > (1UL<<31))) - arc_large_memory_enabled = 1; -#else arc_c = kmem_size() / 8; -#endif +#if 0 +#ifdef _KERNEL + /* + * On architectures where the physical memory can be larger + * than the addressable space (intel in 32-bit mode), we may + * need to limit the cache to 1/8 of VM size. + */ + arc_c = MIN(arc_c, vmem_size(heap_arena, VMEM_ALLOC | VMEM_FREE) / 8); +#endif +#endif /* set min cache to 1/32 of all memory, or 16MB, whichever is more */ arc_c_min = MAX(arc_c / 4, 64<<18); /* set max to 1/2 of all memory, or all but 1GB, whichever is more */ @@ -3453,13 +3456,8 @@ arc_init(void) * Allow the tunables to override our calculations if they are * reasonable (ie. over 16MB) */ -#if defined(_KERNEL) && defined(__amd64__) - if (zfs_arc_max >= 64<<18) - arc_c_max = zfs_arc_max; -#else if (zfs_arc_max >= 64<<18 && zfs_arc_max < kmem_size()) arc_c_max = zfs_arc_max; -#endif if (zfs_arc_min >= 64<<18 && zfs_arc_min <= arc_c_max) arc_c_min = zfs_arc_min; #endif Modified: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Sat May 16 21:06:48 2009 (r192217) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Sat May 16 21:08:32 2009 (r192218) @@ -33,9 +33,6 @@ #include #include -#if defined(_KERNEL) && defined(__amd64__) -#include -#endif /* * ========================================================================== * I/O priority table @@ -88,8 +85,6 @@ extern vmem_t *zio_alloc_arena; #define IO_IS_ALLOCATING(zio) \ ((zio)->io_orig_pipeline & (1U << ZIO_STAGE_DVA_ALLOCATE)) -extern int arc_large_memory_enabled; - void zio_init(void) { @@ -213,80 +208,6 @@ zio_buf_alloc(size_t size) #endif } -#if defined(_KERNEL) && defined(__amd64__) -extern int vm_contig_launder(int queue); - -static void * -zio_large_malloc(size_t size) -{ - void *ret; - vm_page_t pages; - unsigned long npgs; - int actl, actmax, inactl, inactmax, tries; - int flags = M_WAITOK; - vm_paddr_t low = (1UL<<29); /* leave lower 512MB untouched */ - vm_paddr_t high = ~(vm_paddr_t)0; - unsigned long alignment = 1; - unsigned long boundary = 0; - - npgs = round_page(size) >> PAGE_SHIFT; - tries = 0; -retry: - pages = vm_phys_alloc_contig(npgs, low, high, alignment, boundary); - if (pages == NULL) { - if (tries < ((flags & M_NOWAIT) != 0 ? 1 : 3)) { - vm_page_lock_queues(); - inactl = 0; - inactmax = tries < 1 ? 0 : cnt.v_inactive_count; - actl = 0; - actmax = tries < 2 ? 0 : cnt.v_active_count; -again: - if (inactl < inactmax && - vm_contig_launder(PQ_INACTIVE)) { - inactl++; - goto again; - } - if (actl < actmax && - vm_contig_launder(PQ_ACTIVE)) { - actl++; - goto again; - } - vm_page_unlock_queues(); - tries++; - goto retry; - } - - ret = NULL; - } else { - int i; - - vm_page_lock_queues(); - for (i = 0; i < npgs; i++) - vm_page_wire(&pages[i]); - vm_page_unlock_queues(); - - return (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(pages)); - } - return (ret); -} - -static void -zio_large_free(void *buf, size_t size) -{ - int npgs = round_page(size) >> PAGE_SHIFT; - int i; - vm_page_t m; - - m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)buf)); - vm_page_lock_queues(); - for (i = 0; i < npgs; i++, m++) { - vm_page_unwire(m, 0); - vm_page_free(m); - } - vm_page_unlock_queues(); -} -#endif - /* * Use zio_data_buf_alloc to allocate data. The data will not appear in a * crashdump if the kernel panics. This exists so that we will limit the amount @@ -303,12 +224,7 @@ zio_data_buf_alloc(size_t size) return (kmem_cache_alloc(zio_data_buf_cache[c], KM_PUSHPAGE)); #else -#if defined(_KERNEL) && defined(__amd64__) - if (arc_large_memory_enabled && (size > PAGE_SIZE)) - return (zio_large_malloc(size)); - else -#endif - return (kmem_alloc(size, KM_SLEEP)); + return (kmem_alloc(size, KM_SLEEP)); #endif } @@ -336,12 +252,7 @@ zio_data_buf_free(void *buf, size_t size kmem_cache_free(zio_data_buf_cache[c], buf); #else -#if defined (_KERNEL) && defined(__amd64__) - if (arc_large_memory_enabled && (size > PAGE_SIZE)) - zio_large_free(buf, size); - else -#endif - kmem_free(buf, size); + kmem_free(buf, size); #endif } Modified: user/kmacy/ZFS_MFC/sys/vm/vm_contig.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Sat May 16 21:06:48 2009 (r192217) +++ user/kmacy/ZFS_MFC/sys/vm/vm_contig.c Sat May 16 21:08:32 2009 (r192218) @@ -87,11 +87,6 @@ __FBSDID("$FreeBSD$"); #include #include -/* - * Only available as a band-aid to ZFS - */ -int vm_contig_launder(int queue); - static int vm_contig_launder_page(vm_page_t m, vm_page_t *next) { @@ -151,7 +146,7 @@ vm_contig_launder_page(vm_page_t m, vm_p return (0); } -int +static int vm_contig_launder(int queue) { vm_page_t m, next; From owner-svn-src-user@FreeBSD.ORG Sat May 16 21:48:10 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B3BFD1065672; Sat, 16 May 2009 21:48:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A31A08FC13; Sat, 16 May 2009 21:48:10 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GLmA8l004947; Sat, 16 May 2009 21:48:10 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GLmAup004941; Sat, 16 May 2009 21:48:10 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162148.n4GLmAup004941@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 21:48:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192221 - in user/kmacy/ZFS_MFC/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:48:10 -0000 Author: kmacy Date: Sat May 16 21:48:10 2009 New Revision: 192221 URL: http://svn.freebsd.org/changeset/base/192221 Log: integrate rmlock support and bring kern_osd.c in line with HEAD Added: user/kmacy/ZFS_MFC/sys/kern/kern_rmlock.c (contents, props changed) user/kmacy/ZFS_MFC/sys/sys/_rmlock.h (contents, props changed) user/kmacy/ZFS_MFC/sys/sys/rmlock.h (contents, props changed) Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c user/kmacy/ZFS_MFC/sys/sys/pcpu.h Modified: user/kmacy/ZFS_MFC/sys/kern/kern_osd.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 21:38:55 2009 (r192220) +++ user/kmacy/ZFS_MFC/sys/kern/kern_osd.c Sat May 16 21:48:10 2009 (r192221) @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #include #include #include @@ -78,7 +78,7 @@ static const u_int osd_nmethods[OSD_LAST }; static struct sx osd_module_lock[OSD_LAST + 1]; -static struct rwlock osd_object_lock[OSD_LAST + 1]; +static struct rmlock osd_object_lock[OSD_LAST + 1]; static struct mtx osd_list_lock[OSD_LAST + 1]; static void @@ -124,12 +124,12 @@ osd_register(u_int type, osd_destructor_ osd_nmethods[type], M_OSD, M_WAITOK); newptr = malloc(sizeof(osd_destructor_t) * osd_nslots[type], M_OSD, M_WAITOK); - rw_wlock(&osd_object_lock[type]); + rm_wlock(&osd_object_lock[type]); bcopy(osd_destructors[type], newptr, sizeof(osd_destructor_t) * i); free(osd_destructors[type], M_OSD); osd_destructors[type] = newptr; - rw_wunlock(&osd_object_lock[type]); + rm_wunlock(&osd_object_lock[type]); OSD_DEBUG("New slot allocated (type=%u, slot=%u).", type, i + 1); } @@ -154,7 +154,7 @@ osd_deregister(u_int type, u_int slot) KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); sx_xlock(&osd_module_lock[type]); - rw_wlock(&osd_object_lock[type]); + rm_wlock(&osd_object_lock[type]); /* * Free all OSD for the given slot. */ @@ -188,25 +188,26 @@ osd_deregister(u_int type, u_int slot) OSD_DEBUG("Slot deregistration (type=%u, slot=%u).", type, slot); } - rw_wunlock(&osd_object_lock[type]); + rm_wunlock(&osd_object_lock[type]); sx_xunlock(&osd_module_lock[type]); } int osd_set(u_int type, struct osd *osd, u_int slot, void *value) { + struct rm_priotracker tracker; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); - rw_rlock(&osd_object_lock[type]); + rm_rlock(&osd_object_lock[type], &tracker); if (slot > osd->osd_nslots) { if (value == NULL) { OSD_DEBUG( "Not allocating null slot (type=%u, slot=%u).", type, slot); - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); return (0); } else if (osd->osd_nslots == 0) { /* @@ -216,7 +217,7 @@ osd_set(u_int type, struct osd *osd, u_i osd->osd_slots = malloc(sizeof(void *) * slot, M_OSD, M_NOWAIT | M_ZERO); if (osd->osd_slots == NULL) { - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); return (ENOMEM); } osd->osd_nslots = slot; @@ -234,7 +235,7 @@ osd_set(u_int type, struct osd *osd, u_i newptr = realloc(osd->osd_slots, sizeof(void *) * slot, M_OSD, M_NOWAIT | M_ZERO); if (newptr == NULL) { - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); return (ENOMEM); } osd->osd_slots = newptr; @@ -245,20 +246,21 @@ osd_set(u_int type, struct osd *osd, u_i OSD_DEBUG("Setting slot value (type=%u, slot=%u, value=%p).", type, slot, value); osd->osd_slots[slot - 1] = value; - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); return (0); } void * osd_get(u_int type, struct osd *osd, u_int slot) { + struct rm_priotracker tracker; void *value; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); - rw_rlock(&osd_object_lock[type]); + rm_rlock(&osd_object_lock[type], &tracker); if (slot > osd->osd_nslots) { value = NULL; OSD_DEBUG("Slot doesn't exist (type=%u, slot=%u).", type, slot); @@ -267,7 +269,7 @@ osd_get(u_int type, struct osd *osd, u_i OSD_DEBUG("Returning slot value (type=%u, slot=%u, value=%p).", type, slot, value); } - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); return (value); } @@ -280,7 +282,7 @@ do_osd_del_locked(u_int type, struct osd KASSERT(slot > 0, ("Invalid slot.")); KASSERT(osd_destructors[type][slot - 1] != NULL, ("Unused slot.")); mtx_assert(&osd_list_lock[type], MA_OWNED); - + OSD_DEBUG("Deleting slot (type=%u, slot=%u).", type, slot); if (slot > osd->osd_nslots) { @@ -331,10 +333,11 @@ do_osd_del(u_int type, struct osd *osd, void osd_del(u_int type, struct osd *osd, u_int slot) { + struct rm_priotracker tracker; - rw_rlock(&osd_object_lock[type]); + rm_rlock(&osd_object_lock[type], &tracker); do_osd_del(type, osd, slot); - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); } @@ -367,6 +370,7 @@ osd_call(u_int type, u_int method, void void osd_exit(u_int type, struct osd *osd) { + struct rm_priotracker tracker; u_int i; KASSERT(type >= OSD_FIRST && type <= OSD_LAST, ("Invalid type.")); @@ -377,14 +381,14 @@ osd_exit(u_int type, struct osd *osd) return; } - rw_rlock(&osd_object_lock[type]); + rm_rlock(&osd_object_lock[type], &tracker); for (i = 1; i <= osd->osd_nslots; i++) { if (osd_destructors[type][i - 1] != NULL) do_osd_del(type, osd, i); else OSD_DEBUG("Unused slot (type=%u, slot=%u).", type, i); } - rw_runlock(&osd_object_lock[type]); + rm_runlock(&osd_object_lock[type], &tracker); OSD_DEBUG("Object exit (type=%u).", type); } @@ -397,7 +401,7 @@ osd_init(void *arg __unused) osd_nslots[i] = 0; LIST_INIT(&osd_list[i]); sx_init(&osd_module_lock[i], "osd_module"); - rw_init(&osd_object_lock[i], "osd_object"); + rm_init(&osd_object_lock[i], "osd_object", 0); mtx_init(&osd_list_lock[i], "osd_list", NULL, MTX_DEF); osd_destructors[i] = NULL; osd_methods[i] = NULL; Added: user/kmacy/ZFS_MFC/sys/kern/kern_rmlock.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/kern/kern_rmlock.c Sat May 16 21:48:10 2009 (r192221) @@ -0,0 +1,490 @@ +/*- + * Copyright (c) 2007 Stephan Uphoff + * 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. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + */ + +/* + * Machine independent bits of reader/writer lock implementation. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_ddb.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DDB +#include +#endif + +#define RMPF_ONQUEUE 1 +#define RMPF_SIGNAL 2 + +/* + * To support usage of rmlock in CVs and msleep yet another list for the + * priority tracker would be needed. Using this lock for cv and msleep also + * does not seem very useful + */ + +static __inline void compiler_memory_barrier(void) { + __asm __volatile("":::"memory"); +} + +static void lock_rm(struct lock_object *lock, int how); +static int unlock_rm(struct lock_object *lock); + +struct lock_class lock_class_rm = { + .lc_name = "rm", + .lc_flags = LC_SLEEPLOCK | LC_RECURSABLE, +#if 0 +#ifdef DDB + .lc_ddb_show = db_show_rwlock, +#endif +#endif + .lc_lock = lock_rm, + .lc_unlock = unlock_rm, +}; + +static void +lock_rm(struct lock_object *lock, int how) +{ + + panic("lock_rm called"); +} + +static int +unlock_rm(struct lock_object *lock) +{ + + panic("unlock_rm called"); +} + +static struct mtx rm_spinlock; + +MTX_SYSINIT(rm_spinlock, &rm_spinlock, "rm_spinlock", MTX_SPIN); + +/* + * Add or remove tracker from per cpu list. + * + * The per cpu list can be traversed at any time in forward direction from an + * interrupt on the *local* cpu. + */ +static void inline +rm_tracker_add(struct pcpu *pc, struct rm_priotracker *tracker) +{ + struct rm_queue *next; + + /* Initialize all tracker pointers */ + tracker->rmp_cpuQueue.rmq_prev = &pc->pc_rm_queue; + next = pc->pc_rm_queue.rmq_next; + tracker->rmp_cpuQueue.rmq_next = next; + + /* rmq_prev is not used during froward traversal. */ + next->rmq_prev = &tracker->rmp_cpuQueue; + + /* Update pointer to first element. */ + pc->pc_rm_queue.rmq_next = &tracker->rmp_cpuQueue; +} + +static void inline +rm_tracker_remove(struct pcpu *pc, struct rm_priotracker *tracker) +{ + struct rm_queue *next, *prev; + + next = tracker->rmp_cpuQueue.rmq_next; + prev = tracker->rmp_cpuQueue.rmq_prev; + + /* Not used during forward traversal. */ + next->rmq_prev = prev; + + /* Remove from list. */ + prev->rmq_next = next; +} + +static void +rm_cleanIPI(void *arg) +{ + struct pcpu *pc; + struct rmlock *rm = arg; + struct rm_priotracker *tracker; + struct rm_queue *queue; + pc = pcpu_find(curcpu); + + for (queue = pc->pc_rm_queue.rmq_next; queue != &pc->pc_rm_queue; + queue = queue->rmq_next) { + tracker = (struct rm_priotracker *)queue; + if (tracker->rmp_rmlock == rm && tracker->rmp_flags == 0) { + tracker->rmp_flags = RMPF_ONQUEUE; + mtx_lock_spin(&rm_spinlock); + LIST_INSERT_HEAD(&rm->rm_activeReaders, tracker, + rmp_qentry); + mtx_unlock_spin(&rm_spinlock); + } + } +} + +void +rm_init(struct rmlock *rm, const char *name, int opts) +{ + + rm->rm_noreadtoken = 1; + LIST_INIT(&rm->rm_activeReaders); + mtx_init(&rm->rm_lock, name, "RM_MTX",MTX_NOWITNESS); + lock_init(&rm->lock_object, &lock_class_rm, name, NULL, + (opts & LO_RECURSABLE)| LO_WITNESS); +} + +void +rm_destroy(struct rmlock *rm) +{ + + mtx_destroy(&rm->rm_lock); + lock_destroy(&rm->lock_object); +} + +int +rm_wowned(struct rmlock *rm) +{ + + return (mtx_owned(&rm->rm_lock)); +} + +void +rm_sysinit(void *arg) +{ + + struct rm_args *args = arg; + rm_init(args->ra_rm, args->ra_desc, args->ra_opts); +} + +static void +_rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker) +{ + struct pcpu *pc; + struct rm_queue *queue; + struct rm_priotracker *atracker; + + critical_enter(); + pc = pcpu_find(curcpu); + + /* Check if we just need to do a proper critical_exit. */ + if (0 == rm->rm_noreadtoken) { + critical_exit(); + return; + } + + /* Remove our tracker from the per cpu list. */ + rm_tracker_remove(pc, tracker); + + /* Check to see if the IPI granted us the lock after all. */ + if (tracker->rmp_flags) { + /* Just add back tracker - we hold the lock. */ + rm_tracker_add(pc, tracker); + critical_exit(); + return; + } + + /* + * We allow readers to aquire a lock even if a writer is blocked if + * the lock is recursive and the reader already holds the lock. + */ + if ((rm->lock_object.lo_flags & LO_RECURSABLE) != 0) { + /* + * Just grand the lock if this thread already have a tracker + * for this lock on the per cpu queue. + */ + for (queue = pc->pc_rm_queue.rmq_next; + queue != &pc->pc_rm_queue; queue = queue->rmq_next) { + atracker = (struct rm_priotracker *)queue; + if ((atracker->rmp_rmlock == rm) && + (atracker->rmp_thread == tracker->rmp_thread)) { + mtx_lock_spin(&rm_spinlock); + LIST_INSERT_HEAD(&rm->rm_activeReaders, + tracker, rmp_qentry); + tracker->rmp_flags = RMPF_ONQUEUE; + mtx_unlock_spin(&rm_spinlock); + rm_tracker_add(pc, tracker); + critical_exit(); + return; + } + } + } + + sched_unpin(); + critical_exit(); + + mtx_lock(&rm->rm_lock); + rm->rm_noreadtoken = 0; + critical_enter(); + + pc = pcpu_find(curcpu); + rm_tracker_add(pc, tracker); + sched_pin(); + critical_exit(); + + mtx_unlock(&rm->rm_lock); +} + +void +_rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker) +{ + struct thread *td = curthread; + struct pcpu *pc; + + tracker->rmp_flags = 0; + tracker->rmp_thread = td; + tracker->rmp_rmlock = rm; + + td->td_critnest++; /* critical_enter(); */ + + compiler_memory_barrier(); + + pc = cpuid_to_pcpu[td->td_oncpu]; /* pcpu_find(td->td_oncpu); */ + + rm_tracker_add(pc, tracker); + + td->td_pinned++; /* sched_pin(); */ + + compiler_memory_barrier(); + + td->td_critnest--; + + /* + * Fast path to combine two common conditions into a single + * conditional jump. + */ + if (0 == (td->td_owepreempt | rm->rm_noreadtoken)) + return; + + /* We do not have a read token and need to acquire one. */ + _rm_rlock_hard(rm, tracker); +} + +static void +_rm_unlock_hard(struct thread *td,struct rm_priotracker *tracker) +{ + + if (td->td_owepreempt) { + td->td_critnest++; + critical_exit(); + } + + if (!tracker->rmp_flags) + return; + + mtx_lock_spin(&rm_spinlock); + LIST_REMOVE(tracker, rmp_qentry); + + if (tracker->rmp_flags & RMPF_SIGNAL) { + struct rmlock *rm; + struct turnstile *ts; + + rm = tracker->rmp_rmlock; + + turnstile_chain_lock(&rm->lock_object); + mtx_unlock_spin(&rm_spinlock); + + ts = turnstile_lookup(&rm->lock_object); + + turnstile_signal(ts, TS_EXCLUSIVE_QUEUE); + turnstile_unpend(ts, TS_EXCLUSIVE_LOCK); + turnstile_chain_unlock(&rm->lock_object); + } else + mtx_unlock_spin(&rm_spinlock); +} + +void +_rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker) +{ + struct pcpu *pc; + struct thread *td = tracker->rmp_thread; + + td->td_critnest++; /* critical_enter(); */ + pc = cpuid_to_pcpu[td->td_oncpu]; /* pcpu_find(td->td_oncpu); */ + rm_tracker_remove(pc, tracker); + td->td_critnest--; + td->td_pinned--; /* sched_unpin(); */ + + if (0 == (td->td_owepreempt | tracker->rmp_flags)) + return; + + _rm_unlock_hard(td, tracker); +} + +void +_rm_wlock(struct rmlock *rm) +{ + struct rm_priotracker *prio; + struct turnstile *ts; + + mtx_lock(&rm->rm_lock); + + if (rm->rm_noreadtoken == 0) { + /* Get all read tokens back */ + + rm->rm_noreadtoken = 1; + + /* + * Assumes rm->rm_noreadtoken update is visible on other CPUs + * before rm_cleanIPI is called. + */ +#ifdef SMP + smp_rendezvous(smp_no_rendevous_barrier, + rm_cleanIPI, + smp_no_rendevous_barrier, + rm); + +#else + rm_cleanIPI(rm); +#endif + + mtx_lock_spin(&rm_spinlock); + while ((prio = LIST_FIRST(&rm->rm_activeReaders)) != NULL) { + ts = turnstile_trywait(&rm->lock_object); + prio->rmp_flags = RMPF_ONQUEUE | RMPF_SIGNAL; + mtx_unlock_spin(&rm_spinlock); + turnstile_wait(ts, prio->rmp_thread, + TS_EXCLUSIVE_QUEUE); + mtx_lock_spin(&rm_spinlock); + } + mtx_unlock_spin(&rm_spinlock); + } +} + +void +_rm_wunlock(struct rmlock *rm) +{ + + mtx_unlock(&rm->rm_lock); +} + +#ifdef LOCK_DEBUG + +void _rm_wlock_debug(struct rmlock *rm, const char *file, int line) +{ + + WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER | LOP_EXCLUSIVE, + file, line); + + _rm_wlock(rm); + + LOCK_LOG_LOCK("RMWLOCK", &rm->lock_object, 0, 0, file, line); + + WITNESS_LOCK(&rm->lock_object, LOP_EXCLUSIVE, file, line); + + curthread->td_locks++; + +} + +void +_rm_wunlock_debug(struct rmlock *rm, const char *file, int line) +{ + + curthread->td_locks--; + WITNESS_UNLOCK(&rm->lock_object, LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("RMWUNLOCK", &rm->lock_object, 0, 0, file, line); + _rm_wunlock(rm); +} + +void +_rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line) +{ + + WITNESS_CHECKORDER(&rm->lock_object, LOP_NEWORDER, file, line); + + _rm_rlock(rm, tracker); + + LOCK_LOG_LOCK("RMRLOCK", &rm->lock_object, 0, 0, file, line); + + WITNESS_LOCK(&rm->lock_object, 0, file, line); + + curthread->td_locks++; +} + +void +_rm_runlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line) +{ + + curthread->td_locks--; + WITNESS_UNLOCK(&rm->lock_object, 0, file, line); + LOCK_LOG_LOCK("RMRUNLOCK", &rm->lock_object, 0, 0, file, line); + _rm_runlock(rm, tracker); +} + +#else + +/* + * Just strip out file and line arguments if no lock debugging is enabled in + * the kernel - we are called from a kernel module. + */ +void +_rm_wlock_debug(struct rmlock *rm, const char *file, int line) +{ + + _rm_wlock(rm); +} + +void +_rm_wunlock_debug(struct rmlock *rm, const char *file, int line) +{ + + _rm_wunlock(rm); +} + +void +_rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line) +{ + + _rm_rlock(rm, tracker); +} + +void +_rm_runlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line) { + + _rm_runlock(rm, tracker); +} + +#endif Modified: user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c Sat May 16 21:38:55 2009 (r192220) +++ user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c Sat May 16 21:48:10 2009 (r192221) @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); #include #include -static struct pcpu *cpuid_to_pcpu[MAXCPU]; +struct pcpu *cpuid_to_pcpu[MAXCPU]; struct cpuhead cpuhead = SLIST_HEAD_INITIALIZER(cpuhead); /* Added: user/kmacy/ZFS_MFC/sys/sys/_rmlock.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/sys/_rmlock.h Sat May 16 21:48:10 2009 (r192221) @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2007 Stephan Uphoff + * 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. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS__RMLOCK_H_ +#define _SYS__RMLOCK_H_ + +/* + * XXXUPS remove as soon as we have per cpu variable + * linker sets and can define rm_queue in _rm_lock.h +*/ +#include +/* + * Mostly reader/occasional writer lock. + */ + +LIST_HEAD(rmpriolist,rm_priotracker); + +struct rmlock { + struct lock_object lock_object; + volatile int rm_noreadtoken; + LIST_HEAD(,rm_priotracker) rm_activeReaders; + struct mtx rm_lock; + +}; + +struct rm_priotracker { + struct rm_queue rmp_cpuQueue; /* Must be first */ + struct rmlock *rmp_rmlock; + struct thread *rmp_thread; + int rmp_flags; + LIST_ENTRY(rm_priotracker) rmp_qentry; +}; + +#endif /* !_SYS__RMLOCK_H_ */ Modified: user/kmacy/ZFS_MFC/sys/sys/pcpu.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/pcpu.h Sat May 16 21:38:55 2009 (r192220) +++ user/kmacy/ZFS_MFC/sys/sys/pcpu.h Sat May 16 21:48:10 2009 (r192221) @@ -45,6 +45,15 @@ struct pcb; struct thread; +/* + * XXXUPS remove as soon as we have per cpu variable + * linker sets and can define rm_queue in _rm_lock.h +*/ +struct rm_queue { + struct rm_queue* volatile rmq_next; + struct rm_queue* volatile rmq_prev; +}; + /* * This structure maps out the global data that needs to be kept on a * per-cpu basis. The members are accessed via the PCPU_GET/SET/PTR @@ -72,6 +81,13 @@ struct pcpu { struct vmmeter pc_cnt; /* VM stats counters */ long pc_cp_time[CPUSTATES]; /* statclock ticks */ struct device *pc_device; + /* + * Stuff for read mostly lock + * + * XXXUPS remove as soon as we have per cpu variable + * linker sets. + */ + struct rm_queue pc_rm_queue; }; #ifdef _KERNEL @@ -92,6 +108,10 @@ extern struct cpuhead cpuhead; * db_show_mdpcpu() is responsible for handling machine dependent * fields for the DDB 'show pcpu' command. */ + +extern struct pcpu *cpuid_to_pcpu[MAXCPU]; + + void cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size); void db_show_mdpcpu(struct pcpu *pcpu); Added: user/kmacy/ZFS_MFC/sys/sys/rmlock.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/sys/rmlock.h Sat May 16 21:48:10 2009 (r192221) @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2007 Stephan Uphoff + * 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. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * 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. + * + * $FreeBSD$ + */ + +#ifndef _SYS_RMLOCK_H_ +#define _SYS_RMLOCK_H_ + +#include + +#include +#include + +#ifdef _KERNEL + + +void rm_init(struct rmlock *rm, const char *name, int opts); +void rm_destroy(struct rmlock *rm); +int rm_wowned(struct rmlock *rm); +void rm_sysinit(void *arg); + + +void _rm_wlock_debug(struct rmlock *rm, const char *file, int line); +void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line); +void _rm_rlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line); +void _rm_runlock_debug(struct rmlock *rm, struct rm_priotracker *tracker, + const char *file, int line); + + +void _rm_wlock(struct rmlock *rm); +void _rm_wunlock(struct rmlock *rm); +void _rm_rlock(struct rmlock *rm, struct rm_priotracker *tracker); +void _rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker); + +/* + * Public interface for lock operations. + * + */ + +#ifndef LOCK_DEBUG +#error LOCK_DEBUG not defined, include before +#endif + +#if LOCK_DEBUG > 0 + +#define rm_wlock(rm) _rm_wlock_debug((rm), LOCK_FILE, LOCK_LINE) +#define rm_wunlock(rm) _rm_wunlock_debug((rm), LOCK_FILE, LOCK_LINE) +#define rm_rlock(rm,tracker) \ + _rm_rlock_debug((rm),(tracker), LOCK_FILE, LOCK_LINE ) +#define rm_runlock(rm,tracker) \ + _rm_runlock_debug((rm), (tracker), LOCK_FILE, LOCK_LINE ) + +#else + +#define rm_wlock(rm) _rm_wlock((rm)) +#define rm_wunlock(rm) _rm_wunlock((rm)) +#define rm_rlock(rm,tracker) _rm_rlock((rm),(tracker)) +#define rm_runlock(rm,tracker) _rm_runlock((rm), (tracker)) + +#endif + +#define rm_initialized(rm) lock_initalized(&(rm)->lock_object) + +struct rm_args { + struct rmlock *ra_rm; + const char *ra_desc; + int ra_opts; +}; + +#define RM_SYSINIT(name, rm, desc, opts) \ + static struct rm_args name##_args = { \ + (rm), \ + (desc), \ + (opts), \ + }; \ + SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ + rm_sysinit, &name##_args); \ + SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ + rm_destroy, (rm)) + + +#endif /* _KERNEL */ +#endif /* !_SYS_RMLOCK_H_ */ From owner-svn-src-user@FreeBSD.ORG Sat May 16 21:48:33 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2B422106564A; Sat, 16 May 2009 21:48:33 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1CD108FC08; Sat, 16 May 2009 21:48:33 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GLmXU0004988; Sat, 16 May 2009 21:48:33 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GLmWw7004987; Sat, 16 May 2009 21:48:33 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162148.n4GLmWw7004987@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 21:48:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192222 - user/kmacy/ZFS_MFC/sys/conf X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:48:33 -0000 Author: kmacy Date: Sat May 16 21:48:32 2009 New Revision: 192222 URL: http://svn.freebsd.org/changeset/base/192222 Log: add rmlock to compile Modified: user/kmacy/ZFS_MFC/sys/conf/files Modified: user/kmacy/ZFS_MFC/sys/conf/files ============================================================================== --- user/kmacy/ZFS_MFC/sys/conf/files Sat May 16 21:48:10 2009 (r192221) +++ user/kmacy/ZFS_MFC/sys/conf/files Sat May 16 21:48:32 2009 (r192222) @@ -1628,6 +1628,7 @@ kern/kern_priv.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_resource.c standard +kern/kern_rmlock.c standard kern/kern_rwlock.c standard kern/kern_sema.c standard kern/kern_shutdown.c standard From owner-svn-src-user@FreeBSD.ORG Sat May 16 21:59:31 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD91D1065674; Sat, 16 May 2009 21:59:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEE1C8FC1C; Sat, 16 May 2009 21:59:31 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GLxVEI005220; Sat, 16 May 2009 21:59:31 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GLxV8Q005219; Sat, 16 May 2009 21:59:31 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162159.n4GLxV8Q005219@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 21:59:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192223 - user/kmacy/ZFS_MFC/sys/amd64/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 21:59:32 -0000 Author: kmacy Date: Sat May 16 21:59:31 2009 New Revision: 192223 URL: http://svn.freebsd.org/changeset/base/192223 Log: update vm map comment Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 21:48:32 2009 (r192222) +++ user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 21:59:31 2009 (r192223) @@ -154,7 +154,6 @@ * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) * 0xffff804020101000 - 0xfffffeffffffffff unused * 0xffffff0000000000 - 0xffffff7fffffffff 512GB direct map mappings - * 0xffffff8000000000 - 0xfffffffe3fffffff unused (505GB) * 0xfffffffe40000000 - 0xffffffffffffffff 512GB kernel map * * Within the kernel map: From owner-svn-src-user@FreeBSD.ORG Sat May 16 22:05:14 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 19ABD106566B; Sat, 16 May 2009 22:05:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC5B8FC0C; Sat, 16 May 2009 22:05:14 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GM5DvH005439; Sat, 16 May 2009 22:05:13 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GM5DZ0005437; Sat, 16 May 2009 22:05:13 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162205.n4GM5DZ0005437@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 22:05:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192225 - in user/kmacy/ZFS_MFC/sys: kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 22:05:14 -0000 Author: kmacy Date: Sat May 16 22:05:13 2009 New Revision: 192225 URL: http://svn.freebsd.org/changeset/base/192225 Log: register lock_class_rm Modified: user/kmacy/ZFS_MFC/sys/kern/subr_lock.c user/kmacy/ZFS_MFC/sys/sys/lock.h Modified: user/kmacy/ZFS_MFC/sys/kern/subr_lock.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/subr_lock.c Sat May 16 22:00:13 2009 (r192224) +++ user/kmacy/ZFS_MFC/sys/kern/subr_lock.c Sat May 16 22:05:13 2009 (r192225) @@ -57,6 +57,7 @@ struct lock_class *lock_classes[LOCK_CLA &lock_class_mtx_spin, &lock_class_mtx_sleep, &lock_class_sx, + &lock_class_rm, &lock_class_rw, &lock_class_lockmgr, }; Modified: user/kmacy/ZFS_MFC/sys/sys/lock.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/lock.h Sat May 16 22:00:13 2009 (r192224) +++ user/kmacy/ZFS_MFC/sys/sys/lock.h Sat May 16 22:05:13 2009 (r192225) @@ -221,6 +221,7 @@ struct lock_list_entry { extern struct lock_class lock_class_mtx_sleep; extern struct lock_class lock_class_mtx_spin; extern struct lock_class lock_class_sx; +extern struct lock_class lock_class_rm; extern struct lock_class lock_class_rw; extern struct lock_class lock_class_lockmgr; From owner-svn-src-user@FreeBSD.ORG Sat May 16 22:07:41 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C5247106564A; Sat, 16 May 2009 22:07:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B64C88FC18; Sat, 16 May 2009 22:07:41 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GM7fTO005519; Sat, 16 May 2009 22:07:41 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GM7f6s005518; Sat, 16 May 2009 22:07:41 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162207.n4GM7f6s005518@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 22:07:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192226 - user/kmacy/ZFS_MFC/sys/amd64/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 22:07:42 -0000 Author: kmacy Date: Sat May 16 22:07:41 2009 New Revision: 192226 URL: http://svn.freebsd.org/changeset/base/192226 Log: correct range in comment pointed out by alc Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 22:05:13 2009 (r192225) +++ user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 22:07:41 2009 (r192226) @@ -154,7 +154,7 @@ * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) * 0xffff804020101000 - 0xfffffeffffffffff unused * 0xffffff0000000000 - 0xffffff7fffffffff 512GB direct map mappings - * 0xfffffffe40000000 - 0xffffffffffffffff 512GB kernel map + * 0xffffff8000000000 - 0xffffffffffffffff 512GB kernel map * * Within the kernel map: * From owner-svn-src-user@FreeBSD.ORG Sat May 16 22:20:42 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EF0BE10656B8; Sat, 16 May 2009 22:20:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DF8118FC17; Sat, 16 May 2009 22:20:42 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GMKgML005870; Sat, 16 May 2009 22:20:42 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GMKgDA005869; Sat, 16 May 2009 22:20:42 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162220.n4GMKgDA005869@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 22:20:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192229 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 22:20:43 -0000 Author: kmacy Date: Sat May 16 22:20:42 2009 New Revision: 192229 URL: http://svn.freebsd.org/changeset/base/192229 Log: initialize pcpu rm queues Modified: user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c Modified: user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c Sat May 16 22:18:58 2009 (r192228) +++ user/kmacy/ZFS_MFC/sys/kern/subr_pcpu.c Sat May 16 22:20:42 2009 (r192229) @@ -74,6 +74,8 @@ pcpu_init(struct pcpu *pcpu, int cpuid, cpuid_to_pcpu[cpuid] = pcpu; SLIST_INSERT_HEAD(&cpuhead, pcpu, pc_allcpu); cpu_pcpu_init(pcpu, cpuid, size); + pcpu->pc_rm_queue.rmq_next = &pcpu->pc_rm_queue; + pcpu->pc_rm_queue.rmq_prev = &pcpu->pc_rm_queue; } /* From owner-svn-src-user@FreeBSD.ORG Sat May 16 22:21:12 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17C1A10656C0 for ; Sat, 16 May 2009 22:21:12 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (mail.cs.rice.edu [128.42.1.31]) by mx1.freebsd.org (Postfix) with ESMTP id E7DE58FC20 for ; Sat, 16 May 2009 22:21:11 +0000 (UTC) (envelope-from alc@cs.rice.edu) Received: from mail.cs.rice.edu (localhost.localdomain [127.0.0.1]) by mail.cs.rice.edu (Postfix) with ESMTP id 260E22C2A8E; Sat, 16 May 2009 17:02:04 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.0 at mail.cs.rice.edu Received: from mail.cs.rice.edu ([127.0.0.1]) by mail.cs.rice.edu (mail.cs.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id w-feu6eCREls; Sat, 16 May 2009 17:01:56 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.cs.rice.edu (Postfix) with ESMTP id 538982C2A7E; Sat, 16 May 2009 17:01:56 -0500 (CDT) Message-ID: <4A0F37D3.6070300@cs.rice.edu> Date: Sat, 16 May 2009 17:01:55 -0500 From: Alan Cox User-Agent: Thunderbird 2.0.0.21 (X11/20090404) MIME-Version: 1.0 To: Kip Macy References: <200905162159.n4GLxV8Q005219@svn.freebsd.org> In-Reply-To: <200905162159.n4GLxV8Q005219@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: Re: svn commit: r192223 - user/kmacy/ZFS_MFC/sys/amd64/include X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 22:21:12 -0000 Kip Macy wrote: > Author: kmacy > Date: Sat May 16 21:59:31 2009 > New Revision: 192223 > URL: http://svn.freebsd.org/changeset/base/192223 > > Log: > update vm map comment > > Modified: > user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h > > Modified: user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h > ============================================================================== > --- user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 21:48:32 2009 (r192222) > +++ user/kmacy/ZFS_MFC/sys/amd64/include/vmparam.h Sat May 16 21:59:31 2009 (r192223) > @@ -154,7 +154,6 @@ > * 0xffff800000000000 - 0xffff804020100fff recursive page table (512GB slot) > * 0xffff804020101000 - 0xfffffeffffffffff unused > * 0xffffff0000000000 - 0xffffff7fffffffff 512GB direct map mappings > - * 0xffffff8000000000 - 0xfffffffe3fffffff unused (505GB) > * 0xfffffffe40000000 - 0xffffffffffffffff 512GB kernel map > * > * Within the kernel map: > The last line should now be: 0xffffff8000000000 - 0xffffffffffffffff 512GB kernel map From owner-svn-src-user@FreeBSD.ORG Sat May 16 22:54:16 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2256106566B; Sat, 16 May 2009 22:54:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7A508FC18; Sat, 16 May 2009 22:54:16 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GMsGJO006620; Sat, 16 May 2009 22:54:16 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GMsGhE006618; Sat, 16 May 2009 22:54:16 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162254.n4GMsGhE006618@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 22:54:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192232 - in user/kmacy/ZFS_MFC/sys: cddl/compat/opensolaris/kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 22:54:17 -0000 Author: kmacy Date: Sat May 16 22:54:16 2009 New Revision: 192232 URL: http://svn.freebsd.org/changeset/base/192232 Log: restore osd support to prisons Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c user/kmacy/ZFS_MFC/sys/sys/jail.h Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c Sat May 16 22:31:38 2009 (r192231) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c Sat May 16 22:54:16 2009 (r192232) @@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include #include +#include #include #include @@ -76,11 +76,8 @@ zone_dataset_attach(struct ucred *cred, free(zd, M_ZONES); return (ENOENT); } -#if 0 + head = osd_jail_get(pr, zone_slot); -#else - head = NULL; -#endif if (head != NULL) { dofree = 0; LIST_FOREACH(zd2, head, zd_next) { @@ -97,6 +94,8 @@ zone_dataset_attach(struct ucred *cred, head = malloc(sizeof(*head), M_ZONES, M_WAITOK); LIST_INIT(head); mtx_lock(&pr->pr_mtx); + error = osd_jail_set(pr, zone_slot, head); + KASSERT(error == 0, ("osd_jail_set() failed (error=%d)", error)); } strcpy(zd->zd_dataset, dataset); LIST_INSERT_HEAD(head, zd, zd_next); @@ -124,6 +123,11 @@ zone_dataset_detach(struct ucred *cred, sx_sunlock(&allprison_lock); if (pr == NULL) return (ENOENT); + head = osd_jail_get(pr, zone_slot); + if (head == NULL) { + error = ENOENT; + goto end; + } LIST_FOREACH(zd, head, zd_next) { if (strcmp(dataset, zd->zd_dataset) == 0) break; @@ -133,6 +137,8 @@ zone_dataset_detach(struct ucred *cred, else { LIST_REMOVE(zd, zd_next); free(zd, M_ZONES); + if (LIST_EMPTY(head)) + osd_jail_del(pr, zone_slot); error = 0; } end: @@ -162,7 +168,7 @@ zone_dataset_visible(const char *dataset } pr = curthread->td_ucred->cr_prison; mtx_lock(&pr->pr_mtx); - head = NULL; + head = osd_jail_get(pr, zone_slot); if (head == NULL) goto end; @@ -227,12 +233,14 @@ static void zone_sysinit(void *arg __unused) { + zone_slot = osd_jail_register(zone_destroy, NULL); } static void zone_sysuninit(void *arg __unused) { + osd_jail_deregister(zone_slot); } SYSINIT(zone_sysinit, SI_SUB_DRIVERS, SI_ORDER_ANY, zone_sysinit, NULL); Modified: user/kmacy/ZFS_MFC/sys/sys/jail.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/sys/jail.h Sat May 16 22:31:38 2009 (r192231) +++ user/kmacy/ZFS_MFC/sys/sys/jail.h Sat May 16 22:54:16 2009 (r192232) @@ -14,6 +14,8 @@ #define _SYS_JAIL_H_ #ifdef _KERNEL +#include + struct jail_v0 { u_int32_t version; char *path; @@ -137,6 +139,7 @@ struct prison { struct in_addr *pr_ip4; /* (c) v4 IPs of jail */ int pr_ip6s; /* (c) number of v6 IPs */ struct in6_addr *pr_ip6; /* (c) v6 IPs of jail */ + struct osd pr_osd; }; #endif /* _KERNEL || _WANT_PRISON */ From owner-svn-src-user@FreeBSD.ORG Sat May 16 23:33:07 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E1215106566C; Sat, 16 May 2009 23:33:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D13888FC13; Sat, 16 May 2009 23:33:07 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GNX7vS007487; Sat, 16 May 2009 23:33:07 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GNX7cU007485; Sat, 16 May 2009 23:33:07 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162333.n4GNX7cU007485@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 23:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192233 - user/kmacy/ZFS_MFC/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 23:33:08 -0000 Author: kmacy Date: Sat May 16 23:33:07 2009 New Revision: 192233 URL: http://svn.freebsd.org/changeset/base/192233 Log: deregister osd on thread exit Modified: user/kmacy/ZFS_MFC/sys/kern/kern_proc.c user/kmacy/ZFS_MFC/sys/kern/kern_thread.c Modified: user/kmacy/ZFS_MFC/sys/kern/kern_proc.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_proc.c Sat May 16 22:54:16 2009 (r192232) +++ user/kmacy/ZFS_MFC/sys/kern/kern_proc.c Sat May 16 23:33:07 2009 (r192233) @@ -200,6 +200,8 @@ proc_dtor(void *mem, int size, void *arg ("bad number of threads in exiting process")); KASSERT(STAILQ_EMPTY(&p->p_ktr), ("proc_dtor: non-empty p_ktr")); #endif + /* Free all OSD associated to this thread. */ + osd_thread_exit(td); /* Dispose of an alternate kstack, if it exists. * XXX What if there are more than one thread in the proc? Modified: user/kmacy/ZFS_MFC/sys/kern/kern_thread.c ============================================================================== --- user/kmacy/ZFS_MFC/sys/kern/kern_thread.c Sat May 16 22:54:16 2009 (r192232) +++ user/kmacy/ZFS_MFC/sys/kern/kern_thread.c Sat May 16 23:33:07 2009 (r192233) @@ -133,6 +133,9 @@ thread_ctor(void *mem, int size, void *a #ifdef AUDIT audit_thread_alloc(td); #endif + /* Free all OSD associated to this thread. */ + osd_thread_exit(td); + umtx_thread_alloc(td); return (0); } From owner-svn-src-user@FreeBSD.ORG Sat May 16 23:57:47 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE852106564A; Sat, 16 May 2009 23:57:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DDFC98FC19; Sat, 16 May 2009 23:57:47 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4GNvlmZ008027; Sat, 16 May 2009 23:57:47 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4GNvlGd008025; Sat, 16 May 2009 23:57:47 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905162357.n4GNvlGd008025@svn.freebsd.org> From: Kip Macy Date: Sat, 16 May 2009 23:57:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192235 - user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 May 2009 23:57:48 -0000 Author: kmacy Date: Sat May 16 23:57:47 2009 New Revision: 192235 URL: http://svn.freebsd.org/changeset/base/192235 Log: MFC adaptive spinning change Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/mutex.h user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/rwlock.h Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/mutex.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/mutex.h Sat May 16 23:56:45 2009 (r192234) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/mutex.h Sat May 16 23:57:47 2009 (r192235) @@ -47,9 +47,9 @@ typedef enum { typedef struct sx kmutex_t; #ifndef DEBUG -#define MUTEX_FLAGS (SX_DUPOK | SX_NOWITNESS) +#define MUTEX_FLAGS (SX_DUPOK | SX_NOWITNESS | SX_ADAPTIVESPIN) #else -#define MUTEX_FLAGS (SX_DUPOK) +#define MUTEX_FLAGS (SX_DUPOK | SX_ADAPTIVESPIN) #endif #define mutex_init(lock, desc, type, arg) do { \ Modified: user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/rwlock.h ============================================================================== --- user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/rwlock.h Sat May 16 23:56:45 2009 (r192234) +++ user/kmacy/ZFS_MFC/sys/cddl/compat/opensolaris/sys/rwlock.h Sat May 16 23:57:47 2009 (r192235) @@ -49,9 +49,9 @@ typedef enum { typedef struct sx krwlock_t; #ifndef DEBUG -#define RW_FLAGS (SX_DUPOK | SX_NOWITNESS) +#define RW_FLAGS (SX_DUPOK | SX_NOWITNESS | SX_ADAPTIVESPIN) #else -#define RW_FLAGS (SX_DUPOK) +#define RW_FLAGS (SX_DUPOK | SX_ADAPTIVESPIN) #endif #define RW_READ_HELD(x) (rw_read_held((x)))