From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:48:09 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D30599C0; Mon, 3 Jun 2013 04:48:09 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id AA71917A1; Mon, 3 Jun 2013 04:48:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534m9Rx012365; Mon, 3 Jun 2013 04:48:09 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534m9pf012363; Mon, 3 Jun 2013 04:48:09 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030448.r534m9pf012363@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:48:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251286 - in stable/9/sys: amd64/amd64 i386/i386 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:48:09 -0000 Author: kib Date: Mon Jun 3 04:48:09 2013 New Revision: 251286 URL: http://svnweb.freebsd.org/changeset/base/251286 Log: MFC r251033: When handling an exception from the attempt from loading the faulting context on return from the trap handler, re-enable the interrupts on i386 and amd64. Modified: stable/9/sys/amd64/amd64/exception.S stable/9/sys/i386/i386/exception.s Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/exception.S ============================================================================== --- stable/9/sys/amd64/amd64/exception.S Mon Jun 3 04:32:53 2013 (r251285) +++ stable/9/sys/amd64/amd64/exception.S Mon Jun 3 04:48:09 2013 (r251286) @@ -818,6 +818,10 @@ doreti_iret_fault: .globl ds_load_fault ds_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movq %rsp,%rdi call trap movw $KUDSEL,TF_DS(%rsp) @@ -827,6 +831,10 @@ ds_load_fault: .globl es_load_fault es_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movq %rsp,%rdi call trap movw $KUDSEL,TF_ES(%rsp) @@ -835,6 +843,10 @@ es_load_fault: ALIGN_TEXT .globl fs_load_fault fs_load_fault: + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movl $T_PROTFLT,TF_TRAPNO(%rsp) movq %rsp,%rdi call trap @@ -846,6 +858,10 @@ fs_load_fault: gs_load_fault: popfq movl $T_PROTFLT,TF_TRAPNO(%rsp) + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movq %rsp,%rdi call trap movw $KUG32SEL,TF_GS(%rsp) @@ -855,6 +871,10 @@ gs_load_fault: .globl fsbase_load_fault fsbase_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movq %rsp,%rdi call trap movq PCPU(CURTHREAD),%r8 @@ -866,6 +886,10 @@ fsbase_load_fault: .globl gsbase_load_fault gsbase_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) + testl $PSL_I,TF_RFLAGS(%rsp) + jz 1f + sti +1: movq %rsp,%rdi call trap movq PCPU(CURTHREAD),%r8 Modified: stable/9/sys/i386/i386/exception.s ============================================================================== --- stable/9/sys/i386/i386/exception.s Mon Jun 3 04:32:53 2013 (r251285) +++ stable/9/sys/i386/i386/exception.s Mon Jun 3 04:48:09 2013 (r251286) @@ -422,6 +422,7 @@ doreti_popl_es_fault: pushl %fs .globl doreti_popl_fs_fault doreti_popl_fs_fault: + sti movl $0,TF_ERR(%esp) /* XXX should be the error code */ movl $T_PROTFLT,TF_TRAPNO(%esp) jmp alltraps_with_regs_pushed From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:50:22 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 708DBB3A; Mon, 3 Jun 2013 04:50:22 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6194517B0; Mon, 3 Jun 2013 04:50:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534oMbM014374; Mon, 3 Jun 2013 04:50:22 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534oMQl014373; Mon, 3 Jun 2013 04:50:22 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030450.r534oMQl014373@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:50:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251287 - stable/9/sys/amd64/amd64 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:50:22 -0000 Author: kib Date: Mon Jun 3 04:50:21 2013 New Revision: 251287 URL: http://svnweb.freebsd.org/changeset/base/251287 Log: MFC r251035: When reporting the fault details, also print %rsp.r251035: When reporting the fault details, also print %rsp. Modified: stable/9/sys/amd64/amd64/trap.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/trap.c ============================================================================== --- stable/9/sys/amd64/amd64/trap.c Mon Jun 3 04:48:09 2013 (r251286) +++ stable/9/sys/amd64/amd64/trap.c Mon Jun 3 04:50:21 2013 (r251287) @@ -617,10 +617,10 @@ trap(struct trapframe *frame) ksi.ksi_addr = (void *)addr; if (uprintf_signal) { uprintf("pid %d comm %s: signal %d err %lx code %d type %d " - "addr 0x%lx rip 0x%lx " + "addr 0x%lx rsp 0x%lx rip 0x%lx " "<%02x %02x %02x %02x %02x %02x %02x %02x>\n", p->p_pid, p->p_comm, i, frame->tf_err, ucode, type, addr, - frame->tf_rip, + frame->tf_rsp, frame->tf_rip, fubyte((void *)(frame->tf_rip + 0)), fubyte((void *)(frame->tf_rip + 1)), fubyte((void *)(frame->tf_rip + 2)), From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:52:32 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0B58ECBD; Mon, 3 Jun 2013 04:52:32 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F186E17BE; Mon, 3 Jun 2013 04:52:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534qVvH014964; Mon, 3 Jun 2013 04:52:31 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534qVXs014963; Mon, 3 Jun 2013 04:52:31 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030452.r534qVXs014963@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:52:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251288 - stable/9/sys/amd64/ia32 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:52:32 -0000 Author: kib Date: Mon Jun 3 04:52:31 2013 New Revision: 251288 URL: http://svnweb.freebsd.org/changeset/base/251288 Log: MFC r251037: The ia32_get_mcontext() does not need to set PCB_FULL_IRET. Modified: stable/9/sys/amd64/ia32/ia32_signal.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/ia32/ia32_signal.c ============================================================================== --- stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:50:21 2013 (r251287) +++ stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:52:31 2013 (r251288) @@ -187,7 +187,6 @@ ia32_get_mcontext(struct thread *td, str mcp->mc_xfpustate = 0; mcp->mc_xfpustate_len = 0; bzero(mcp->mc_spare2, sizeof(mcp->mc_spare2)); - set_pcb_flags(pcb, PCB_FULL_IRET); return (0); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:55:04 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2027CE3F; Mon, 3 Jun 2013 04:55:04 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 117FB17D4; Mon, 3 Jun 2013 04:55:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534t3it015540; Mon, 3 Jun 2013 04:55:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534t3hV015539; Mon, 3 Jun 2013 04:55:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030455.r534t3hV015539@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:55:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251289 - stable/9/sys/amd64/ia32 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:55:04 -0000 Author: kib Date: Mon Jun 3 04:55:03 2013 New Revision: 251289 URL: http://svnweb.freebsd.org/changeset/base/251289 Log: MFC r251038: Use _MC_IA32_HASFPXSTATE name instead of _MC_HASFPXSTATE. Modified: stable/9/sys/amd64/ia32/ia32_signal.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/ia32/ia32_signal.c ============================================================================== --- stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:52:31 2013 (r251288) +++ stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:55:03 2013 (r251289) @@ -112,7 +112,7 @@ ia32_get_fpcontext(struct thread *td, st len = max_len; bzero(xfpusave + max_len, len - max_len); } - mcp->mc_flags |= _MC_HASFPXSTATE; + mcp->mc_flags |= _MC_IA32_HASFPXSTATE; mcp->mc_xfpustate_len = len; bcopy(get_pcb_user_save_td(td) + 1, xfpusave, len); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:57:16 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4A97EFBE; Mon, 3 Jun 2013 04:57:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2050117E4; Mon, 3 Jun 2013 04:57:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534vG24015986; Mon, 3 Jun 2013 04:57:16 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534vFPX015982; Mon, 3 Jun 2013 04:57:15 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030457.r534vFPX015982@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:57:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251290 - in stable/9/sys: amd64/amd64 amd64/ia32 i386/i386 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:57:16 -0000 Author: kib Date: Mon Jun 3 04:57:15 2013 New Revision: 251290 URL: http://svnweb.freebsd.org/changeset/base/251290 Log: MFC r251039: Use slightly more idiomatic expression to get the address of array. Modified: stable/9/sys/amd64/amd64/machdep.c stable/9/sys/amd64/ia32/ia32_signal.c stable/9/sys/i386/i386/machdep.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/amd64/machdep.c ============================================================================== --- stable/9/sys/amd64/amd64/machdep.c Mon Jun 3 04:55:03 2013 (r251289) +++ stable/9/sys/amd64/amd64/machdep.c Mon Jun 3 04:57:15 2013 (r251290) @@ -2244,7 +2244,7 @@ get_fpcontext(struct thread *td, mcontex size_t max_len, len; mcp->mc_ownedfp = fpugetregs(td); - bcopy(get_pcb_user_save_td(td), &mcp->mc_fpstate, + bcopy(get_pcb_user_save_td(td), &mcp->mc_fpstate[0], sizeof(mcp->mc_fpstate)); mcp->mc_fpformat = fpuformat(); if (!use_xsave || xfpusave_len == 0) Modified: stable/9/sys/amd64/ia32/ia32_signal.c ============================================================================== --- stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:55:03 2013 (r251289) +++ stable/9/sys/amd64/ia32/ia32_signal.c Mon Jun 3 04:57:15 2013 (r251290) @@ -101,7 +101,7 @@ ia32_get_fpcontext(struct thread *td, st * for now, it should be irrelevant for most applications. */ mcp->mc_ownedfp = fpugetregs(td); - bcopy(get_pcb_user_save_td(td), &mcp->mc_fpstate, + bcopy(get_pcb_user_save_td(td), &mcp->mc_fpstate[0], sizeof(mcp->mc_fpstate)); mcp->mc_fpformat = fpuformat(); if (!use_xsave || xfpusave_len == 0) Modified: stable/9/sys/i386/i386/machdep.c ============================================================================== --- stable/9/sys/i386/i386/machdep.c Mon Jun 3 04:55:03 2013 (r251289) +++ stable/9/sys/i386/i386/machdep.c Mon Jun 3 04:57:15 2013 (r251290) @@ -3453,7 +3453,7 @@ get_fpcontext(struct thread *td, mcontex bzero(mcp->mc_fpstate, sizeof(mcp->mc_fpstate)); #else mcp->mc_ownedfp = npxgetregs(td); - bcopy(&td->td_pcb->pcb_user_save, &mcp->mc_fpstate, + bcopy(&td->td_pcb->pcb_user_save, &mcp->mc_fpstate[0], sizeof(mcp->mc_fpstate)); mcp->mc_fpformat = npxformat(); #endif From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 04:58:13 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 862B11BE; Mon, 3 Jun 2013 04:58:13 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 764CF17EE; Mon, 3 Jun 2013 04:58:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r534wDLa016208; Mon, 3 Jun 2013 04:58:13 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r534wDrd016207; Mon, 3 Jun 2013 04:58:13 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306030458.r534wDrd016207@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 3 Jun 2013 04:58:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251291 - stable/9/lib/libthr/thread X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 04:58:13 -0000 Author: kib Date: Mon Jun 3 04:58:12 2013 New Revision: 251291 URL: http://svnweb.freebsd.org/changeset/base/251291 Log: MFC r251040: Partially apply the capitalization of the heading word of the sequence and fix typo. Modified: stable/9/lib/libthr/thread/thr_sig.c Directory Properties: stable/9/lib/libthr/ (props changed) Modified: stable/9/lib/libthr/thread/thr_sig.c ============================================================================== --- stable/9/lib/libthr/thread/thr_sig.c Mon Jun 3 04:57:15 2013 (r251290) +++ stable/9/lib/libthr/thread/thr_sig.c Mon Jun 3 04:58:12 2013 (r251291) @@ -205,9 +205,9 @@ handle_signal(struct sigaction *actp, in curthread->in_sigsuspend = 0; /* - * if thread is in deferred cancellation mode, disable cancellation + * If thread is in deferred cancellation mode, disable cancellation * in signal handler. - * if user signal handler calls a cancellation point function, e.g, + * If user signal handler calls a cancellation point function, e.g, * it calls write() to write data to file, because write() is a * cancellation point, the thread is immediately cancelled if * cancellation is pending, to avoid this problem while thread is in @@ -229,7 +229,7 @@ handle_signal(struct sigaction *actp, in * We have already reset cancellation point flags, so if user's code * longjmp()s out of its signal handler, wish its jmpbuf was set * outside of a cancellation point, in most cases, this would be - * true. however, ther is no way to save cancel_enable in jmpbuf, + * true. However, there is no way to save cancel_enable in jmpbuf, * so after setjmps() returns once more, the user code may need to * re-set cancel_enable flag by calling pthread_setcancelstate(). */ From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 14:33:10 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EC54EEFA; Mon, 3 Jun 2013 14:33:10 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DD1471070; Mon, 3 Jun 2013 14:33:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53EXAbs025894; Mon, 3 Jun 2013 14:33:10 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53EXARJ025893; Mon, 3 Jun 2013 14:33:10 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031433.r53EXARJ025893@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 14:33:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251299 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 14:33:11 -0000 Author: smh Date: Mon Jun 3 14:33:10 2013 New Revision: 251299 URL: http://svnweb.freebsd.org/changeset/base/251299 Log: MFC r246146: Format CDB output as 2 digit hex correcting the length Modified: stable/9/sys/cam/scsi/scsi_all.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 13:11:48 2013 (r251298) +++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 14:33:10 2013 (r251299) @@ -3136,7 +3136,7 @@ scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string = '\0'; for (i = 0; i < cdb_len; i++) snprintf(cdb_string + strlen(cdb_string), - len - strlen(cdb_string), "%x ", cdb_ptr[i]); + len - strlen(cdb_string), "%02hhx ", cdb_ptr[i]); return(cdb_string); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 15:48:26 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CFCB7FA; Mon, 3 Jun 2013 15:48:26 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C167816BD; Mon, 3 Jun 2013 15:48:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53FmQSV051199; Mon, 3 Jun 2013 15:48:26 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53FmQce051193; Mon, 3 Jun 2013 15:48:26 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031548.r53FmQce051193@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 15:48:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251301 - in stable/9/sys/cam: . ata scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 15:48:26 -0000 Author: smh Date: Mon Jun 3 15:48:25 2013 New Revision: 251301 URL: http://svnweb.freebsd.org/changeset/base/251301 Log: MFC r248922: Add the ability to enable / disable sorting of BIO requests Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/cam.c stable/9/sys/cam/cam.h stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Mon Jun 3 14:36:28 2013 (r251300) +++ stable/9/sys/cam/ata/ata_da.c Mon Jun 3 15:48:25 2013 (r251301) @@ -131,6 +131,7 @@ struct ada_softc { ada_state state; ada_flags flags; ada_quirks quirks; + int sort_io_queue; int ordered_tag_count; int outstanding_cmds; int trim_max_ranges; @@ -450,6 +451,8 @@ static void adaresume(void *arg); softc->read_ahead : ada_read_ahead) #define ADA_WC (softc->write_cache >= 0 ? \ softc->write_cache : ada_write_cache) +#define ADA_SIO (softc->sort_io_queue >= 0 ? \ + softc->sort_io_queue : cam_sort_io_queues) /* * Most platforms map firmware geometry to actual, but some don't. If @@ -660,10 +663,17 @@ adastrategy(struct bio *bp) * Place it in the queue of disk activities for this disk */ if (bp->bio_cmd == BIO_DELETE && - (softc->flags & ADA_FLAG_CAN_TRIM)) - bioq_disksort(&softc->trim_queue, bp); - else - bioq_disksort(&softc->bio_queue, bp); + (softc->flags & ADA_FLAG_CAN_TRIM)) { + if (ADA_SIO) + bioq_disksort(&softc->trim_queue, bp); + else + bioq_insert_tail(&softc->trim_queue, bp); + } else { + if (ADA_SIO) + bioq_disksort(&softc->bio_queue, bp); + else + bioq_insert_tail(&softc->bio_queue, bp); + } /* * Schedule ourselves for performing the work. @@ -1010,6 +1020,10 @@ adasysctlinit(void *context, int pending SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "write_cache", CTLFLAG_RW | CTLFLAG_MPSAFE, &softc->write_cache, 0, "Enable disk write cache."); + SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, "sort_io_queue", CTLFLAG_RW | CTLFLAG_MPSAFE, + &softc->sort_io_queue, 0, + "Sort IO queue to try and optimise disk access patterns"); #ifdef ADA_TEST_FAILURE /* * Add a 'door bell' sysctl which allows one to set it from userland @@ -1145,6 +1159,7 @@ adaregister(struct cam_periph *periph, v snprintf(announce_buf, sizeof(announce_buf), "kern.cam.ada.%d.write_cache", periph->unit_number); TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); + softc->sort_io_queue = -1; adagetparams(periph, cgd); softc->disk = disk_alloc(); softc->disk->d_devstat = devstat_new_entry(periph->periph_name, Modified: stable/9/sys/cam/cam.c ============================================================================== --- stable/9/sys/cam/cam.c Mon Jun 3 14:36:28 2013 (r251300) +++ stable/9/sys/cam/cam.c Mon Jun 3 15:48:25 2013 (r251301) @@ -110,6 +110,15 @@ const int num_cam_status_entries = #ifdef _KERNEL SYSCTL_NODE(_kern, OID_AUTO, cam, CTLFLAG_RD, 0, "CAM Subsystem"); + +#ifndef CAM_DEFAULT_SORT_IO_QUEUES +#define CAM_DEFAULT_SORT_IO_QUEUES 1 +#endif + +int cam_sort_io_queues = CAM_DEFAULT_SORT_IO_QUEUES; +TUNABLE_INT("kern.cam.sort_io_queues", &cam_sort_io_queues); +SYSCTL_INT(_kern_cam, OID_AUTO, sort_io_queues, CTLFLAG_RWTUN, + &cam_sort_io_queues, 0, "Sort IO queues to try and optimise disk access patterns"); #endif void Modified: stable/9/sys/cam/cam.h ============================================================================== --- stable/9/sys/cam/cam.h Mon Jun 3 14:36:28 2013 (r251300) +++ stable/9/sys/cam/cam.h Mon Jun 3 15:48:25 2013 (r251301) @@ -228,6 +228,9 @@ struct cam_status_entry extern const struct cam_status_entry cam_status_table[]; extern const int num_cam_status_entries; +#ifdef _KERNEL +extern int cam_sort_io_queues; +#endif union ccb; #ifdef SYSCTL_DECL /* from sysctl.h */ Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Mon Jun 3 14:36:28 2013 (r251300) +++ stable/9/sys/cam/scsi/scsi_da.c Mon Jun 3 15:48:25 2013 (r251301) @@ -145,6 +145,7 @@ struct da_softc { da_state state; da_flags flags; da_quirks quirks; + int sort_io_queue; int minimum_cmd_size; int error_inject; int ordered_tag_count; @@ -903,6 +904,8 @@ static timeout_t damediapoll; #define DA_DEFAULT_SEND_ORDERED 1 #endif +#define DA_SIO (softc->sort_io_queue >= 0 ? \ + softc->sort_io_queue : cam_sort_io_queues) static int da_poll_period = DA_DEFAULT_POLL_PERIOD; static int da_retry_count = DA_DEFAULT_RETRY; @@ -1129,10 +1132,15 @@ dastrategy(struct bio *bp) if (bp->bio_cmd == BIO_DELETE) { if (bp->bio_bcount == 0) biodone(bp); - else + else if (DA_SIO) bioq_disksort(&softc->delete_queue, bp); - } else + else + bioq_insert_tail(&softc->delete_queue, bp); + } else if (DA_SIO) { bioq_disksort(&softc->bio_queue, bp); + } else { + bioq_insert_tail(&softc->bio_queue, bp); + } /* * Schedule ourselves for performing the work. @@ -1487,6 +1495,9 @@ dasysctlinit(void *context, int pending) OID_AUTO, "minimum_cmd_size", CTLTYPE_INT | CTLFLAG_RW, &softc->minimum_cmd_size, 0, dacmdsizesysctl, "I", "Minimum CDB size"); + SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), + OID_AUTO, "sort_io_queue", CTLFLAG_RW, &softc->sort_io_queue, 0, + "Sort IO queue to try and optimise disk access patterns"); SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), @@ -1634,6 +1645,7 @@ daregister(struct cam_periph *periph, vo softc->flags |= DA_FLAG_PACK_REMOVABLE; softc->unmap_max_ranges = UNMAP_MAX_RANGES; softc->unmap_max_lba = 1024*1024*2; + softc->sort_io_queue = -1; periph->softc = softc; @@ -2109,9 +2121,16 @@ cmd6workaround(union ccb *ccb) dadeletemethodset(softc, DA_DELETE_DISABLE); } else dadeletemethodset(softc, DA_DELETE_DISABLE); - while ((bp = bioq_takefirst(&softc->delete_run_queue)) - != NULL) - bioq_disksort(&softc->delete_queue, bp); + + if (DA_SIO) { + while ((bp = bioq_takefirst(&softc->delete_run_queue)) + != NULL) + bioq_disksort(&softc->delete_queue, bp); + } else { + while ((bp = bioq_takefirst(&softc->delete_run_queue)) + != NULL) + bioq_insert_tail(&softc->delete_queue, bp); + } bioq_insert_tail(&softc->delete_queue, (struct bio *)ccb->ccb_h.ccb_bp); ccb->ccb_h.ccb_bp = NULL; From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:05:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6DE76522; Mon, 3 Jun 2013 16:05:35 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 500C3176F; Mon, 3 Jun 2013 16:05:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53G5Zhj058088; Mon, 3 Jun 2013 16:05:35 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53G5YWZ058086; Mon, 3 Jun 2013 16:05:34 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031605.r53G5YWZ058086@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 16:05:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251302 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:05:35 -0000 Author: smh Date: Mon Jun 3 16:05:34 2013 New Revision: 251302 URL: http://svnweb.freebsd.org/changeset/base/251302 Log: MFC r248992: Added ATA Pass-Through support to CAM Modified: stable/9/sys/cam/scsi/scsi_all.c stable/9/sys/cam/scsi/scsi_all.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 15:48:25 2013 (r251301) +++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 16:05:34 2013 (r251302) @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #ifndef _KERNEL #include @@ -5847,6 +5848,50 @@ scsi_write_same(struct ccb_scsiio *csio, } void +scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int32_t flags, u_int8_t tag_action, + u_int8_t protocol, u_int8_t ata_flags, u_int16_t features, + u_int16_t sector_count, uint64_t lba, u_int8_t command, + u_int8_t control, u_int8_t *data_ptr, u_int16_t dxfer_len, + u_int8_t sense_len, u_int32_t timeout) +{ + struct ata_pass_16 *ata_cmd; + + ata_cmd = (struct ata_pass_16 *)&csio->cdb_io.cdb_bytes; + ata_cmd->opcode = ATA_PASS_16; + ata_cmd->protocol = protocol; + ata_cmd->flags = ata_flags; + ata_cmd->features_ext = features >> 8; + ata_cmd->features = features; + ata_cmd->sector_count_ext = sector_count >> 8; + ata_cmd->sector_count = sector_count; + ata_cmd->lba_low = lba; + ata_cmd->lba_mid = lba >> 8; + ata_cmd->lba_high = lba >> 16; + ata_cmd->device = ATA_DEV_LBA; + if (protocol & AP_EXTEND) { + ata_cmd->lba_low_ext = lba >> 24; + ata_cmd->lba_mid_ext = lba >> 32; + ata_cmd->lba_high_ext = lba >> 40; + } else + ata_cmd->device |= (lba >> 24) & 0x0f; + ata_cmd->command = command; + ata_cmd->control = control; + + cam_fill_csio(csio, + retries, + cbfcnp, + flags, + tag_action, + data_ptr, + dxfer_len, + sense_len, + sizeof(*ata_cmd), + timeout); +} + +void scsi_unmap(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int8_t byte2, Modified: stable/9/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 15:48:25 2013 (r251301) +++ stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 16:05:34 2013 (r251302) @@ -908,6 +908,19 @@ struct scsi_start_stop_unit struct ata_pass_12 { u_int8_t opcode; u_int8_t protocol; +#define AP_PROTO_HARD_RESET (0x00 << 1) +#define AP_PROTO_SRST (0x01 << 1) +#define AP_PROTO_NON_DATA (0x03 << 1) +#define AP_PROTO_PIO_IN (0x04 << 1) +#define AP_PROTO_PIO_OUT (0x05 << 1) +#define AP_PROTO_DMA (0x06 << 1) +#define AP_PROTO_DMA_QUEUED (0x07 << 1) +#define AP_PROTO_DEVICE_DIAG (0x08 << 1) +#define AP_PROTO_DEVICE_RESET (0x09 << 1) +#define AP_PROTO_UDMA_IN (0x10 << 1) +#define AP_PROTO_UDMA_OUT (0x11 << 1) +#define AP_PROTO_FPDMA (0x12 << 1) +#define AP_PROTO_RESP_INFO (0x15 << 1) #define AP_MULTI 0xe0 u_int8_t flags; #define AP_T_LEN 0x03 @@ -943,6 +956,15 @@ struct ata_pass_16 { u_int8_t protocol; #define AP_EXTEND 0x01 u_int8_t flags; +#define AP_FLAG_TLEN_NO_DATA (0 << 0) +#define AP_FLAG_TLEN_FEAT (1 << 0) +#define AP_FLAG_TLEN_SECT_CNT (2 << 0) +#define AP_FLAG_TLEN_STPSIU (3 << 0) +#define AP_FLAG_BYT_BLOK_BYTES (0 << 2) +#define AP_FLAG_BYT_BLOK_BLOCKS (1 << 2) +#define AP_FLAG_TDIR_TO_DEV (0 << 3) +#define AP_FLAG_TDIR_FROM_DEV (1 << 3) +#define AP_FLAG_CHK_COND (1 << 5) u_int8_t features_ext; u_int8_t features; u_int8_t sector_count_ext; @@ -1064,7 +1086,7 @@ struct ata_pass_16 { /* * This length is the initial inquiry length used by the probe code, as - * well as the legnth necessary for scsi_print_inquiry() to function + * well as the length necessary for scsi_print_inquiry() to function * correctly. If either use requires a different length in the future, * the two values should be de-coupled. */ @@ -2370,6 +2392,14 @@ void scsi_write_same(struct ccb_scsiio * u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout); +void scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int32_t flags, u_int8_t tag_action, + u_int8_t protocol, u_int8_t ata_flags, u_int16_t features, + u_int16_t sector_count, uint64_t lba, u_int8_t command, + u_int8_t control, u_int8_t *data_ptr, u_int16_t dxfer_len, + u_int8_t sense_len, u_int32_t timeout); + void scsi_unmap(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, u_int8_t byte2, From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:09:24 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2719D832; Mon, 3 Jun 2013 16:09:24 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 18F5317B0; Mon, 3 Jun 2013 16:09:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53G9NTi058993; Mon, 3 Jun 2013 16:09:23 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53G9NNO058992; Mon, 3 Jun 2013 16:09:23 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201306031609.r53G9NNO058992@svn.freebsd.org> From: Jaakko Heinonen Date: Mon, 3 Jun 2013 16:09:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251303 - stable/9/sys/geom X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:09:24 -0000 Author: jh Date: Mon Jun 3 16:09:23 2013 New Revision: 251303 URL: http://svnweb.freebsd.org/changeset/base/251303 Log: MFC r250868: Remove an extra semicolon from the DOT language output. PR: kern/178540 Modified: stable/9/sys/geom/geom_dump.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/geom_dump.c ============================================================================== --- stable/9/sys/geom/geom_dump.c Mon Jun 3 16:05:34 2013 (r251302) +++ stable/9/sys/geom/geom_dump.c Mon Jun 3 16:09:23 2013 (r251303) @@ -104,7 +104,7 @@ g_confdot(void *p, int flag ) sbuf_printf(sb, "digraph geom {\n"); LIST_FOREACH(mp, &g_classes, class) g_confdot_class(sb, mp); - sbuf_printf(sb, "};\n"); + sbuf_printf(sb, "}\n"); sbuf_finish(sb); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:14:25 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 2C7EDC9C; Mon, 3 Jun 2013 16:14:25 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1DED017F4; Mon, 3 Jun 2013 16:14:25 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53GEO2V061912; Mon, 3 Jun 2013 16:14:25 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53GEORQ061911; Mon, 3 Jun 2013 16:14:24 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031614.r53GEORQ061911@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 16:14:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251305 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:14:25 -0000 Author: smh Date: Mon Jun 3 16:14:24 2013 New Revision: 251305 URL: http://svnweb.freebsd.org/changeset/base/251305 Log: MFC r249929: Removed unneeded tests in dadeletemethodset Modified: stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Mon Jun 3 16:10:30 2013 (r251304) +++ stable/9/sys/cam/scsi/scsi_da.c Mon Jun 3 16:14:24 2013 (r251305) @@ -868,7 +868,7 @@ static void daasync(void *callback_arg, static void dasysctlinit(void *context, int pending); static int dacmdsizesysctl(SYSCTL_HANDLER_ARGS); static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS); -static int dadeletemethodset(struct da_softc *softc, +static void dadeletemethodset(struct da_softc *softc, da_delete_methods delete_method); static periph_ctor_t daregister; static periph_dtor_t dacleanup; @@ -1568,12 +1568,10 @@ dacmdsizesysctl(SYSCTL_HANDLER_ARGS) return (0); } -static int +static void dadeletemethodset(struct da_softc *softc, da_delete_methods delete_method) { - if (delete_method < 0 || delete_method > DA_DELETE_MAX) - return (EINVAL); softc->delete_method = delete_method; @@ -1581,8 +1579,6 @@ dadeletemethodset(struct da_softc *softc softc->disk->d_flags |= DISKFLAG_CANDELETE; else softc->disk->d_flags &= ~DISKFLAG_CANDELETE; - - return (0); } static int @@ -1607,7 +1603,8 @@ dadeletemethodsysctl(SYSCTL_HANDLER_ARGS for (i = 0; i <= DA_DELETE_MAX; i++) { if (strcmp(buf, da_delete_method_names[i]) != 0) continue; - return dadeletemethodset(softc, i); + dadeletemethodset(softc, i); + return (0); } return (EINVAL); } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:22:20 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 69DCFEB2; Mon, 3 Jun 2013 16:22:20 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 424741845; Mon, 3 Jun 2013 16:22:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53GMJwu065393; Mon, 3 Jun 2013 16:22:19 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53GMJQt065392; Mon, 3 Jun 2013 16:22:19 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031622.r53GMJQt065392@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 16:22:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251306 - stable/9/sys/geom X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:22:20 -0000 Author: smh Date: Mon Jun 3 16:22:19 2013 New Revision: 251306 URL: http://svnweb.freebsd.org/changeset/base/251306 Log: MFC r249930: Added a sysctl to control the maximum size of a delete request Modified: stable/9/sys/geom/geom_dev.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/geom/geom_dev.c ============================================================================== --- stable/9/sys/geom/geom_dev.c Mon Jun 3 16:14:24 2013 (r251305) +++ stable/9/sys/geom/geom_dev.c Mon Jun 3 16:22:19 2013 (r251306) @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -93,6 +94,19 @@ static struct g_class g_dev_class = { .attrchanged = g_dev_attrchanged }; +/* + * We target 262144 (8 x 32768) sectors by default as this significantly + * increases the throughput on commonly used SSD's with a marginal + * increase in non-interruptible request latency. + */ +static uint64_t g_dev_del_max_sectors = 262144; +SYSCTL_DECL(_kern_geom); +SYSCTL_NODE(_kern_geom, OID_AUTO, dev, CTLFLAG_RW, 0, "GEOM_DEV stuff"); +SYSCTL_QUAD(_kern_geom_dev, OID_AUTO, delete_max_sectors, CTLFLAG_RW, + &g_dev_del_max_sectors, 0, "Maximum number of sectors in a single " + "delete request sent to the provider. Larger requests are chunked " + "so they can be interrupted. (0 = disable chunking)"); + static void g_dev_destroy(void *arg, int flags __unused) { @@ -412,17 +426,20 @@ g_dev_ioctl(struct cdev *dev, u_long cmd } while (length > 0) { chunk = length; - if (chunk > 65536 * cp->provider->sectorsize) - chunk = 65536 * cp->provider->sectorsize; + if (g_dev_del_max_sectors != 0 && chunk > + g_dev_del_max_sectors * cp->provider->sectorsize) { + chunk = g_dev_del_max_sectors * + cp->provider->sectorsize; + } error = g_delete_data(cp, offset, chunk); length -= chunk; offset += chunk; if (error) break; /* - * Since the request size is unbounded, the service - * time is likewise. We make this ioctl interruptible - * by checking for signals for each bio. + * Since the request size can be large, the service + * time can be is likewise. We make this ioctl + * interruptible by checking for signals for each bio. */ if (SIGPENDING(td)) break; From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:46:38 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 249286F5; Mon, 3 Jun 2013 16:46:38 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 16D8C19BF; Mon, 3 Jun 2013 16:46:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53GkbD3074212; Mon, 3 Jun 2013 16:46:37 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53GkbA0074211; Mon, 3 Jun 2013 16:46:37 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201306031646.r53GkbA0074211@svn.freebsd.org> From: Jung-uk Kim Date: Mon, 3 Jun 2013 16:46:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251307 - stable/9/usr.sbin/acpi/acpidump X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:46:38 -0000 Author: jkim Date: Mon Jun 3 16:46:37 2013 New Revision: 251307 URL: http://svnweb.freebsd.org/changeset/base/251307 Log: MFC: r251186 Fix a long standing logic bug introduced in r167814. The code was added to get RSDP from loader(8) hint via kenv(2) but the bug nullified the new code and we always fell back to the previous method, i. e., sysctlbyname(3). Modified: stable/9/usr.sbin/acpi/acpidump/acpi_user.c Directory Properties: stable/9/usr.sbin/acpi/acpidump/ (props changed) Modified: stable/9/usr.sbin/acpi/acpidump/acpi_user.c ============================================================================== --- stable/9/usr.sbin/acpi/acpidump/acpi_user.c Mon Jun 3 16:22:19 2013 (r251306) +++ stable/9/usr.sbin/acpi/acpidump/acpi_user.c Mon Jun 3 16:46:37 2013 (r251307) @@ -172,7 +172,7 @@ acpi_find_rsd_ptr(void) addr = 0; /* Attempt to use kenv or sysctl to find RSD PTR record. */ - if (kenv(KENV_GET, hint_acpi_0_rsdp, buf, 20) == 0) + if (kenv(KENV_GET, hint_acpi_0_rsdp, buf, 20) > 0) addr = strtoul(buf, NULL, 0); if (addr == 0) { len = sizeof(addr); From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:48:24 2013 Return-Path: Delivered-To: svn-src-stable-9@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E424CAB1; Mon, 3 Jun 2013 16:48:24 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id 871BB19CF; Mon, 3 Jun 2013 16:48:13 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.5/8.14.5) with ESMTP id r53Gm7pT078043; Mon, 3 Jun 2013 11:48:07 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.5/8.14.5/Submit) id r53Gm7AM078042; Mon, 3 Jun 2013 11:48:07 -0500 (CDT) (envelope-from brooks) Date: Mon, 3 Jun 2013 11:48:07 -0500 From: Brooks Davis To: Maxim Sobolev Subject: Re: svn: stable/9: . usr.bin/xinstall Message-ID: <20130603164807.GA77693@lor.one-eyed-alien.net> References: <201303151519.r2FFJYjS060493@svn.freebsd.org> <51AA52FD.9090303@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x+6KMIRAuhnl3hBn" Content-Disposition: inline In-Reply-To: <51AA52FD.9090303@FreeBSD.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@FreeBSD.org, svn-src-all@FreeBSD.org, Brooks Davis , src-committers@FreeBSD.org, svn-src-stable-9@FreeBSD.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:48:25 -0000 --x+6KMIRAuhnl3hBn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 01, 2013 at 01:01:01PM -0700, Maxim Sobolev wrote: > Hmm, I believe this breaks build for me. Any ideas why? Presumably you are building in some less common way since this change has been working for months. What command line resulted in this error? Is this tree fully up to date? Do you have anything in src.conf or make.conf? From the error, it looks like you haven't bootstrapped a new libc properly. -- Brooks > =3D=3D=3D> usr.bin/xinstall (all) > cc -O2 -pipe -I/usr/src/usr.bin/xinstall/../../contrib/mtree=20 > -I/usr/src/usr.bin/xinstall/../../lib/libnetbsd=20 > -I/usr/src/usr.bin/xinstall/../../lib/libmd -std=3Dgnu99 -fstack-protecto= r=20 > -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter= =20 > -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type=20 > -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter=20 > -Wcast-align -Wchar-subscripts -Winline -Wnested-externs=20 > -Wredundant-decls -Wold-style-definition -Wno-pointer-sign -c=20 > /usr/src/usr.bin/xinstall/xinstall.c > cc1: warnings being treated as errors > /usr/src/usr.bin/xinstall/xinstall.c: In function 'metadata_log': > /usr/src/usr.bin/xinstall/xinstall.c:1331: warning: implicit declaration= =20 > of function 'strsvis' > /usr/src/usr.bin/xinstall/xinstall.c:1331: warning: nested extern=20 > declaration of 'strsvis' > *** [xinstall.o] Error code 1 >=20 > Stop in /usr/src/usr.bin/xinstall. > *** [all] Error code 1 >=20 > uname -a > FreeBSD dal09 9.1-RELEASE FreeBSD 9.1-RELEASE #2: Thu Dec 27 09:39:03=20 > UTC 2012 root@pioneer:/usr/obj/usr/src91/sys/SSP-PRODUCTION9_X64 amd= 64 >=20 >=20 >=20 > On 3/15/2013 8:19 AM, Brooks Davis wrote: > > Author: brooks > > Date: Fri Mar 15 15:19:33 2013 > > New Revision: 248331 > > URL: http://svnweb.freebsd.org/changeset/base/248331 > > > > Log: > > MFC all changes to install(1) through r246784. Notable functional > > changes are: > > > > r245617: > > Introduce six new options from NetBSD: > > * -M Log metadata in mtree format. > > * -D Log paths relative to . > > * -h Log digest of type . > > * -T Specify which mtree tags to log. > > * -l Create hard or symbolic links (allows logging). > > * -U Install without root privileges (owner, group, mod= e, > > and flags can be logged via -M > > > > NOTE: In the interest of compatibility with NetBSD and because it is= the > > obvious letter, the nearly useless -M option (disable mmap) has been > > repurposed. > > > > Sponsored by: DARPA, AFRL > > Obtained from: NetBSD > > Reviewed by: bz > > > > r245312: > > Implement the -N option which allows an alternate passwd and > > group file to be used. This is useful for installing on systems whe= re > > a user or group does not currently exist. > > > > Sponsored by: DARPA, AFRL > > Obtained from: NetBSD > > > > Modified: > > stable/9/UPDATING (contents, props changed) > > stable/9/usr.bin/xinstall/Makefile > > stable/9/usr.bin/xinstall/install.1 > > stable/9/usr.bin/xinstall/xinstall.c > > Directory Properties: > > stable/9/usr.bin/xinstall/ (props changed) > > > > Modified: stable/9/UPDATING > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- stable/9/UPDATING Fri Mar 15 14:53:29 2013 (r248330) > > +++ stable/9/UPDATING Fri Mar 15 15:19:33 2013 (r248331) > > @@ -11,6 +11,15 @@ handbook: > > Items affecting the ports and packages system can be found in > > /usr/ports/UPDATING. Please read that file before running portupgrad= e. > > > > +20130315: > > + The install(1) option -M has changed meaning and now takes an > > + argument that is a file or path to append logs to. In the > > + unlikely event that -M was the last option on the command line > > + and the command line contained at least two files and a target > > + directory the first file will have logs appended to it. The -M > > + option served little practical purpose in the last decade so it's > > + used expected to be extremely rare. > > + > > 20130225: > > A new compression method (lz4) has been merged to. Please refer to > > zpool-features(7) for more information. > > > > Modified: stable/9/usr.bin/xinstall/Makefile > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- stable/9/usr.bin/xinstall/Makefile Fri Mar 15 14:53:29 2013 (r24833= 0) > > +++ stable/9/usr.bin/xinstall/Makefile Fri Mar 15 15:19:33 2013 (r24833= 1) > > @@ -3,6 +3,16 @@ > > > > PROG=3D xinstall > > PROGNAME=3D install > > +SRCS=3D xinstall.c getid.c > > MAN=3D install.1 > > > > +.PATH: ${.CURDIR}/../../contrib/mtree > > +.PATH: ${.CURDIR}/../../lib/libmd > > +CFLAGS+=3D -I${.CURDIR}/../../contrib/mtree > > +CFLAGS+=3D -I${.CURDIR}/../../lib/libnetbsd > > +CFLAGS+=3D -I${.CURDIR}/../../lib/libmd > > + > > +DPADD+=3D ${LIBMD} > > +LDADD+=3D -lmd > > + > > .include > > > > Modified: stable/9/usr.bin/xinstall/install.1 > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- stable/9/usr.bin/xinstall/install.1 Fri Mar 15 14:53:29 2013 (r2483= 30) > > +++ stable/9/usr.bin/xinstall/install.1 Fri Mar 15 15:19:33 2013 (r2483= 31) > > @@ -28,7 +28,7 @@ > > .\" From: @(#)install.1 8.1 (Berkeley) 6/6/93 > > .\" $FreeBSD$ > > .\" > > -.Dd March 6, 2006 > > +.Dd January 18, 2013 > > .Dt INSTALL 1 > > .Os > > .Sh NAME > > @@ -36,31 +36,50 @@ > > .Nd install binaries > > .Sh SYNOPSIS > > .Nm > > -.Op Fl bCcMpSsv > > +.Op Fl bCcpSsUv > > .Op Fl B Ar suffix > > +.Op Fl D Ar destdir > > .Op Fl f Ar flags > > .Op Fl g Ar group > > +.Op Fl h Ar hash > > +.Op Fl l Ar linkflags > > +.Op Fl M Ar metalog > > .Op Fl m Ar mode > > +.Op Fl N Ar dbdir > > .Op Fl o Ar owner > > +.Op Fl T Ar tags > > .Ar file1 file2 > > .Nm > > -.Op Fl bCcMpSsv > > +.Op Fl bCcpSsUv > > .Op Fl B Ar suffix > > +.Op Fl D Ar destdir > > .Op Fl f Ar flags > > .Op Fl g Ar group > > +.Op Fl h Ar hash > > +.Op Fl l Ar linkflags > > +.Op Fl M Ar metalog > > .Op Fl m Ar mode > > +.Op Fl N Ar dbdir > > .Op Fl o Ar owner > > +.Op Fl T Ar tags > > .Ar file1 ... fileN directory > > .Nm > > .Fl d > > -.Op Fl v > > +.Op Fl Uv > > +.Op Fl D Ar destdir > > .Op Fl g Ar group > > +.Op Fl h Ar hash > > +.Op Fl M Ar metalog > > .Op Fl m Ar mode > > +.Op Fl N Ar dbdir > > .Op Fl o Ar owner > > +.Op Fl T Ar tags > > .Ar directory ... > > .Sh DESCRIPTION > > The file(s) are copied > > -to the target file or directory. > > +(or linked if the > > +.Fl l > > +option is specified) to the target file or directory. > > If the destination is a directory, then the > > .Ar file > > is copied into > > @@ -105,6 +124,17 @@ This is actually the default. > > The > > .Fl c > > option is only included for backwards compatibility. > > +.It Fl D Ar destdir > > +Specify the > > +.Ev DESTDIR > > +(top of the file hierarchy) that the items are installed in to. > > +If > > +.Fl M Ar metalog > > +is in use, a leading string of > > +.Dq Ar destdir > > +will be removed from the file names logged to the > > +.Ar metalog . > > +This option does not affect where the actual files are installed. > > .It Fl d > > Create directories. > > Missing parent directories are created as required. > > @@ -115,15 +145,82 @@ for a list of possible flags and their m > > .It Fl g > > Specify a group. > > A numeric GID is allowed. > > -.It Fl M > > -Disable all use of > > -.Xr mmap 2 . > > +.It Fl h Ar hash > > +When copying, calculate the digest of the files with > > +.Ar hash > > +to store in the > > +.Fl M Ar metalog . > > +When > > +.Fl d > > +is given no hash is emitted. > > +Supported digests: > > +.Bl -tag -width rmd160 -offset indent > > +.It Sy none > > +No hash. > > +This is the default. > > +.It Sy md5 > > +The MD5 cryptographic message digest. > > +.It Sy rmd160 > > +The RMD-160 cryptographic message digest. > > +.It Sy sha1 > > +The SHA-1 cryptographic message digest. > > +.It Sy sha256 > > +The 256-bits > > +.Tn SHA-2 > > +cryptographic message digest of the file. > > +.It Sy sha512 > > +The 512-bits > > +.Tn SHA-2 > > +cryptographic message digest of the file. > > +.El > > +.It Fl l Ar linkflags > > +Instead of copying the file make a link to the source. > > +The type of the link is determined by the > > +.Ar linkflags > > +argument. > > +Valid > > +.Ar linkflags > > +are: > > +.Ar a > > +(absolute), > > +.Ar r > > +(relative), > > +.Ar h > > +(hard), > > +.Ar s > > +(symbolic), > > +.Ar m > > +(mixed). > > +Absolute and relative have effect only for symbolic links. > > +Mixed links > > +are hard links for files on the same filesystem, symbolic otherwise. > > +.It Fl M Ar metalog > > +Write the metadata associated with each item installed to > > +.Ar metalog > > +in an > > +.Xr mtree 8 > > +.Dq full path > > +specification line. > > +The metadata includes: the file name and file type, and depending upon > > +other options, the owner, group, file flags, modification time, and ta= gs. > > .It Fl m > > Specify an alternate mode. > > The default mode is set to rwxr-xr-x (0755). > > The specified mode may be either an octal or symbolic value; see > > .Xr chmod 1 > > for a description of possible mode values. > > +.It Fl N > > +Use the user database text file > > +.Pa master.passwd > > +and group database text file > > +.Pa group > > +from > > +.Ar dbdir , > > +rather than using the results from the system's > > +.Xr getpwnam 3 > > +and > > +.Xr getgrnam 3 > > +(and related) library calls. > > .It Fl o > > Specify an owner. > > A numeric UID is allowed. > > @@ -156,6 +253,17 @@ number of systems and binary types. > > See below for how > > .Nm > > can be instructed to use another program to strip binaries. > > +.It Fl T Ar tags > > +Specify the > > +.Xr mtree 8 > > +tags to write out for the file when using > > +.Fl M Ar metalog . > > +.It Fl U > > +Indicate that install is running unprivileged, and that it should not > > +try to change the owner, the group, or the file flags of the destinati= on. > > +The information that would have been updated can be stored in a log > > +file with > > +.Fl M Ar metalog . > > .It Fl v > > Cause > > .Nm > > @@ -231,6 +339,8 @@ The default was changed to copy in > > .Xr mv 1 , > > .Xr strip 1 , > > .Xr mmap 2 , > > +.Xr getgrnam 3 , > > +.Xr getpwnam 3 , > > .Xr chown 8 > > .Sh HISTORY > > The > > @@ -238,6 +348,16 @@ The > > utility appeared in > > .Bx 4.2 . > > .Sh BUGS > > +The meaning of the > > +.Fl M > > +option has changed as of > > +.Fx 10 > > +and it now takes an argument. > > +Command lines that used the old > > +.Fl M > > +will get an error or in rare cases will append logs to the first of > > +multiple source files rather than installing it. > > +.Pp > > Temporary files may be left in the target directory if > > .Nm > > exits abnormally. > > > > Modified: stable/9/usr.bin/xinstall/xinstall.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 > > --- stable/9/usr.bin/xinstall/xinstall.c Fri Mar 15 14:53:29 2013 (r248= 330) > > +++ stable/9/usr.bin/xinstall/xinstall.c Fri Mar 15 15:19:33 2013 (r248= 331) > > @@ -1,4 +1,5 @@ > > /* > > + * Copyright (c) 2012, 2013 SRI International > > * Copyright (c) 1987, 1993 > > * The Regents of the University of California. All rights reserved. > > * > > @@ -53,14 +54,23 @@ __FBSDID("$FreeBSD$"); > > #include > > #include > > #include > > +#include > > +#include > > #include > > #include > > +#include > > +#include > > +#include > > +#include > > #include > > #include > > #include > > #include > > #include > > #include > > +#include > > + > > +#include "mtree.h" > > > > /* Bootstrap aid - this doesn't exist in most older releases */ > > #ifndef MAP_FAILED > > @@ -69,26 +79,63 @@ __FBSDID("$FreeBSD$"); > > > > #define MAX_CMP_SIZE (16 * 1024 * 1024) > > > > +#define LN_ABSOLUTE 0x01 > > +#define LN_RELATIVE 0x02 > > +#define LN_HARD 0x04 > > +#define LN_SYMBOLIC 0x08 > > +#define LN_MIXED 0x10 > > + > > #define DIRECTORY 0x01 /* Tell install it's a directory. */ > > #define SETFLAGS 0x02 /* Tell install to set flags. */ > > #define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_AP= PEND) > > #define BACKUP_SUFFIX ".old" > > > > -struct passwd *pp; > > -struct group *gp; > > -gid_t gid; > > -uid_t uid; > > -int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy,= verbose; > > -mode_t mode =3D S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; > > -const char *suffix =3D BACKUP_SUFFIX; > > - > > -static int compare(int, const char *, size_t, int, const char *, size_= t); > > -static void copy(int, const char *, int, const char *, off_t); > > +typedef union { > > + MD5_CTX MD5; > > + RIPEMD160_CTX RIPEMD160; > > + SHA1_CTX SHA1; > > + SHA256_CTX SHA256; > > + SHA512_CTX SHA512; > > +} DIGEST_CTX; > > + > > +static enum { > > + DIGEST_NONE =3D 0, > > + DIGEST_MD5, > > + DIGEST_RIPEMD160, > > + DIGEST_SHA1, > > + DIGEST_SHA256, > > + DIGEST_SHA512, > > +} digesttype =3D DIGEST_NONE; > > + > > +static gid_t gid; > > +static uid_t uid; > > +static int dobackup, docompare, dodir, dolink, dopreserve, dostrip, do= unpriv, > > + safecopy, verbose; > > +static int haveopt_f, haveopt_g, haveopt_m, haveopt_o; > > +static mode_t mode =3D S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; > > +static FILE *metafp; > > +static const char *group, *owner; > > +static const char *suffix =3D BACKUP_SUFFIX; > > +static char *destdir, *digest, *fflags, *metafile, *tags; > > + > > +static int compare(int, const char *, size_t, int, const char *, size_= t, > > + char **); > > +static char *copy(int, const char *, int, const char *, off_t); > > static int create_newfile(const char *, int, struct stat *); > > static int create_tempfile(const char *, char *, size_t); > > +static char *quiet_mktemp(char *template); > > +static char *digest_file(const char *); > > +static void digest_init(DIGEST_CTX *); > > +static void digest_update(DIGEST_CTX *, const unsigned char *, size_t); > > +static char *digest_end(DIGEST_CTX *, char *); > > +static int do_link(const char *, const char *, const struct stat *); > > +static void do_symlink(const char *, const char *, const struct stat *= ); > > +static void makelink(const char *, const char *, const struct stat *); > > static void install(const char *, const char *, u_long, u_int); > > static void install_dir(char *); > > -static u_long numeric_id(const char *, const char *); > > +static void metadata_log(const char *, const char *, struct timeval *, > > + const char *, const char *, off_t); > > +static int parseid(const char *, id_t *); > > static void strip(const char *); > > static int trymmap(int); > > static void usage(void); > > @@ -101,12 +148,13 @@ main(int argc, char *argv[]) > > u_long fset; > > int ch, no_target; > > u_int iflags; > > - char *flags; > > - const char *group, *owner, *to_name; > > + char *p; > > + const char *to_name; > > > > iflags =3D 0; > > group =3D owner =3D NULL; > > - while ((ch =3D getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) !=3D -1) > > + while ((ch =3D getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uv"))= !=3D > > + -1) > > switch((char)ch) { > > case 'B': > > suffix =3D optarg; > > @@ -120,29 +168,69 @@ main(int argc, char *argv[]) > > case 'c': > > /* For backwards compatibility. */ > > break; > > + case 'D': > > + destdir =3D optarg; > > + break; > > case 'd': > > dodir =3D 1; > > break; > > case 'f': > > - flags =3D optarg; > > - if (strtofflags(&flags, &fset, NULL)) > > - errx(EX_USAGE, "%s: invalid flag", flags); > > - iflags |=3D SETFLAGS; > > + haveopt_f =3D 1; > > + fflags =3D optarg; > > break; > > case 'g': > > + haveopt_g =3D 1; > > group =3D optarg; > > break; > > + case 'h': > > + digest =3D optarg; > > + break; > > + case 'l': > > + for (p =3D optarg; *p !=3D '\0'; p++) > > + switch (*p) { > > + case 's': > > + dolink &=3D ~(LN_HARD|LN_MIXED); > > + dolink |=3D LN_SYMBOLIC; > > + break; > > + case 'h': > > + dolink &=3D ~(LN_SYMBOLIC|LN_MIXED); > > + dolink |=3D LN_HARD; > > + break; > > + case 'm': > > + dolink &=3D ~(LN_SYMBOLIC|LN_HARD); > > + dolink |=3D LN_MIXED; > > + break; > > + case 'a': > > + dolink &=3D ~LN_RELATIVE; > > + dolink |=3D LN_ABSOLUTE; > > + break; > > + case 'r': > > + dolink &=3D ~LN_ABSOLUTE; > > + dolink |=3D LN_RELATIVE; > > + break; > > + default: > > + errx(1, "%c: invalid link type", *p); > > + /* NOTREACHED */ > > + } > > + break; > > case 'M': > > - nommap =3D 1; > > + metafile =3D optarg; > > break; > > case 'm': > > + haveopt_m =3D 1; > > if (!(set =3D setmode(optarg))) > > errx(EX_USAGE, "invalid file mode: %s", > > optarg); > > mode =3D getmode(set, 0); > > free(set); > > break; > > + case 'N': > > + if (!setup_getid(optarg)) > > + err(EX_OSERR, "Unable to use user and group " > > + "databases in `%s'", optarg); > > + break; > > case 'o': > > + haveopt_o =3D 1; > > owner =3D optarg; > > break; > > case 'p': > > @@ -154,6 +242,12 @@ main(int argc, char *argv[]) > > case 's': > > dostrip =3D 1; > > break; > > + case 'T': > > + tags =3D optarg; > > + break; > > + case 'U': > > + dounpriv =3D 1; > > + break; > > case 'v': > > verbose =3D 1; > > break; > > @@ -179,27 +273,62 @@ main(int argc, char *argv[]) > > if (argc =3D=3D 0 || (argc =3D=3D 1 && !dodir)) > > usage(); > > > > + if (digest !=3D NULL) { > > + if (strcmp(digest, "none") =3D=3D 0) { > > + digesttype =3D DIGEST_NONE; > > + } else if (strcmp(digest, "md5") =3D=3D 0) { > > + digesttype =3D DIGEST_MD5; > > + } else if (strcmp(digest, "rmd160") =3D=3D 0) { > > + digesttype =3D DIGEST_RIPEMD160; > > + } else if (strcmp(digest, "sha1") =3D=3D 0) { > > + digesttype =3D DIGEST_SHA1; > > + } else if (strcmp(digest, "sha256") =3D=3D 0) { > > + digesttype =3D DIGEST_SHA256; > > + } else if (strcmp(digest, "sha512") =3D=3D 0) { > > + digesttype =3D DIGEST_SHA512; > > + } else { > > + warnx("unknown digest `%s'", digest); > > + usage(); > > + } > > + } > > + > > /* need to make a temp copy so we can compare stripped version */ > > if (docompare && dostrip) > > safecopy =3D 1; > > > > /* get group and owner id's */ > > - if (group !=3D NULL) { > > - if ((gp =3D getgrnam(group)) !=3D NULL) > > - gid =3D gp->gr_gid; > > - else > > - gid =3D (gid_t)numeric_id(group, "group"); > > + if (group !=3D NULL && !dounpriv) { > > + if (gid_from_group(group, &gid) =3D=3D -1) { > > + id_t id; > > + if (!parseid(group, &id)) > > + errx(1, "unknown group %s", group); > > + gid =3D id; > > + } > > } else > > gid =3D (gid_t)-1; > > > > - if (owner !=3D NULL) { > > - if ((pp =3D getpwnam(owner)) !=3D NULL) > > - uid =3D pp->pw_uid; > > - else > > - uid =3D (uid_t)numeric_id(owner, "user"); > > + if (owner !=3D NULL && !dounpriv) { > > + if (uid_from_user(owner, &uid) =3D=3D -1) { > > + id_t id; > > + if (!parseid(owner, &id)) > > + errx(1, "unknown user %s", owner); > > + uid =3D id; > > + } > > } else > > uid =3D (uid_t)-1; > > > > + if (fflags !=3D NULL && !dounpriv) { > > + if (strtofflags(&fflags, &fset, NULL)) > > + errx(EX_USAGE, "%s: invalid flag", fflags); > > + iflags |=3D SETFLAGS; > > + } > > + > > + if (metafile !=3D NULL) { > > + if ((metafp =3D fopen(metafile, "a")) =3D=3D NULL) > > + warn("open %s", metafile); > > + } else > > + digesttype =3D DIGEST_NONE; > > + > > if (dodir) { > > for (; *argv !=3D NULL; ++argv) > > install_dir(*argv); > > @@ -207,8 +336,21 @@ main(int argc, char *argv[]) > > /* NOTREACHED */ > > } > > > > - no_target =3D stat(to_name =3D argv[argc - 1], &to_sb); > > + to_name =3D argv[argc - 1]; > > + no_target =3D stat(to_name, &to_sb); > > if (!no_target && S_ISDIR(to_sb.st_mode)) { > > + if (dolink & LN_SYMBOLIC) { > > + if (lstat(to_name, &to_sb) !=3D 0) > > + err(EX_OSERR, "%s vanished", to_name); > > + if (S_ISLNK(to_sb.st_mode)) { > > + if (argc !=3D 2) { > > + errno =3D ENOTDIR; > > + err(EX_USAGE, "%s", to_name); > > + } > > + install(*argv, to_name, fset, iflags); > > + exit(EX_OK); > > + } > > + } > > for (; *argv !=3D to_name; ++argv) > > install(*argv, to_name, fset, iflags | DIRECTORY); > > exit(EX_OK); > > @@ -226,7 +368,7 @@ main(int argc, char *argv[]) > > usage(); > > } > > > > - if (!no_target) { > > + if (!no_target && !dolink) { > > if (stat(*argv, &from_sb)) > > err(EX_OSERR, "%s", *argv); > > if (!S_ISREG(to_sb.st_mode)) { > > @@ -243,23 +385,327 @@ main(int argc, char *argv[]) > > /* NOTREACHED */ > > } > > > > -static u_long > > -numeric_id(const char *name, const char *type) > > +static char * > > +digest_file(const char *name) > > +{ > > + > > + switch (digesttype) { > > + case DIGEST_MD5: > > + return (MD5File(name, NULL)); > > + case DIGEST_RIPEMD160: > > + return (RIPEMD160_File(name, NULL)); > > + case DIGEST_SHA1: > > + return (SHA1_File(name, NULL)); > > + case DIGEST_SHA256: > > + return (SHA256_File(name, NULL)); > > + case DIGEST_SHA512: > > + return (SHA512_File(name, NULL)); > > + default: > > + return (NULL); > > + } > > +} > > + > > +static void > > +digest_init(DIGEST_CTX *c) > > +{ > > + > > + switch (digesttype) { > > + case DIGEST_NONE: > > + break; > > + case DIGEST_MD5: > > + MD5Init(&(c->MD5)); > > + break; > > + case DIGEST_RIPEMD160: > > + RIPEMD160_Init(&(c->RIPEMD160)); > > + break; > > + case DIGEST_SHA1: > > + SHA1_Init(&(c->SHA1)); > > + break; > > + case DIGEST_SHA256: > > + SHA256_Init(&(c->SHA256)); > > + break; > > + case DIGEST_SHA512: > > + SHA512_Init(&(c->SHA512)); > > + break; > > + } > > +} > > + > > +static void > > +digest_update(DIGEST_CTX *c, const unsigned char *data, size_t len) > > +{ > > + > > + switch (digesttype) { > > + case DIGEST_NONE: > > + break; > > + case DIGEST_MD5: > > + MD5Update(&(c->MD5), data, len); > > + break; > > + case DIGEST_RIPEMD160: > > + RIPEMD160_Update(&(c->RIPEMD160), data, len); > > + break; > > + case DIGEST_SHA1: > > + SHA1_Update(&(c->SHA1), data, len); > > + break; > > + case DIGEST_SHA256: > > + SHA256_Update(&(c->SHA256), data, len); > > + break; > > + case DIGEST_SHA512: > > + SHA512_Update(&(c->SHA512), data, len); > > + break; > > + } > > +} > > + > > +static char * > > +digest_end(DIGEST_CTX *c, char *buf) > > +{ > > + > > + switch (digesttype) { > > + case DIGEST_MD5: > > + return (MD5End(&(c->MD5), buf)); > > + case DIGEST_RIPEMD160: > > + return (RIPEMD160_End(&(c->RIPEMD160), buf)); > > + case DIGEST_SHA1: > > + return (SHA1_End(&(c->SHA1), buf)); > > + case DIGEST_SHA256: > > + return (SHA256_End(&(c->SHA256), buf)); > > + case DIGEST_SHA512: > > + return (SHA512_End(&(c->SHA512), buf)); > > + default: > > + return (NULL); > > + } > > +} > > + > > +/* > > + * parseid -- > > + * parse uid or gid from arg into id, returning non-zero if successful > > + */ > > +static int > > +parseid(const char *name, id_t *id) > > +{ > > + char *ep; > > + errno =3D 0; > > + *id =3D (id_t)strtoul(name, &ep, 10); > > + if (errno || *ep !=3D '\0') > > + return (0); > > + return (1); > > +} > > + > > +/* > > + * quiet_mktemp -- > > + * mktemp implementation used mkstemp to avoid mktemp warnings. We > > + * really do need mktemp semantics here as we will be creating a link. > > + */ > > +static char * > > +quiet_mktemp(char *template) > > +{ > > + int fd; > > + > > + if ((fd =3D mkstemp(template)) =3D=3D -1) > > + return (NULL); > > + close (fd); > > + if (unlink(template) =3D=3D -1) > > + err(EX_OSERR, "unlink %s", template); > > + return (template); > > +} > > + > > +/* > > + * do_link -- > > + * make a hard link, obeying dorename if set > > + * return -1 on failure > > + */ > > +static int > > +do_link(const char *from_name, const char *to_name, > > + const struct stat *target_sb) > > +{ > > + char tmpl[MAXPATHLEN]; > > + int ret; > > + > > + if (safecopy && target_sb !=3D NULL) { > > + (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); > > + /* This usage is safe. */ > > + if (quiet_mktemp(tmpl) =3D=3D NULL) > > + err(EX_OSERR, "%s: mktemp", tmpl); > > + ret =3D link(from_name, tmpl); > > + if (ret =3D=3D 0) { > > + if (target_sb->st_mode & S_IFDIR && rmdir(to_name) =3D=3D > > + -1) { > > + unlink(tmpl); > > + err(EX_OSERR, "%s", to_name); > > + } > > + if (target_sb->st_flags & NOCHANGEBITS) > > + (void)chflags(to_name, target_sb->st_flags & > > + ~NOCHANGEBITS); > > + unlink(to_name); > > + ret =3D rename(tmpl, to_name); > > + /* > > + * If rename has posix semantics, then the temporary > > + * file may still exist when from_name and to_name point > > + * to the same file, so unlink it unconditionally. > > + */ > > + (void)unlink(tmpl); > > + } > > + return (ret); > > + } else > > + return (link(from_name, to_name)); > > +} > > + > > +/* > > + * do_symlink -- > > + * Make a symbolic link, obeying dorename if set. Exit on failure. > > + */ > > +static void > > +do_symlink(const char *from_name, const char *to_name, > > + const struct stat *target_sb) > > +{ > > + char tmpl[MAXPATHLEN]; > > + > > + if (safecopy && target_sb !=3D NULL) { > > + (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); > > + /* This usage is safe. */ > > + if (quiet_mktemp(tmpl) =3D=3D NULL) > > + err(EX_OSERR, "%s: mktemp", tmpl); > > + > > + if (symlink(from_name, tmpl) =3D=3D -1) > > + err(EX_OSERR, "symlink %s -> %s", from_name, tmpl); > > + > > + if (target_sb->st_mode & S_IFDIR && rmdir(to_name) =3D=3D -1) { > > + (void)unlink(tmpl); > > + err(EX_OSERR, "%s", to_name); > > + } > > + if (target_sb->st_flags & NOCHANGEBITS) > > + (void)chflags(to_name, target_sb->st_flags & > > + ~NOCHANGEBITS); > > + unlink(to_name); > > + > > + if (rename(tmpl, to_name) =3D=3D -1) { > > + /* Remove temporary link before exiting. */ > > + (void)unlink(tmpl); > > + err(EX_OSERR, "%s: rename", to_name); > > + } > > + } else { > > + if (symlink(from_name, to_name) =3D=3D -1) > > + err(EX_OSERR, "symlink %s -> %s", from_name, to_name); > > + } > > +} > > + > > +/* > > + * makelink -- > > + * make a link from source to destination > > + */ > > +static void > > +makelink(const char *from_name, const char *to_name, > > + const struct stat *target_sb) > > { > > - u_long val; > > - char *ep; > > + char src[MAXPATHLEN], dst[MAXPATHLEN], lnk[MAXPATHLEN]; > > + struct stat to_sb; > > + > > + /* Try hard links first. */ > > + if (dolink & (LN_HARD|LN_MIXED)) { > > + if (do_link(from_name, to_name, target_sb) =3D=3D -1) { > > + if ((dolink & LN_HARD) || errno !=3D EXDEV) > > + err(EX_OSERR, "link %s -> %s", from_name, to_name); > > + } else { > > + if (stat(to_name, &to_sb)) > > + err(EX_OSERR, "%s: stat", to_name); > > + if (S_ISREG(to_sb.st_mode)) { > > + /* > > + * XXX: hard links to anything other than > > + * plain files are not metalogged > > + */ > > + int omode; > > + const char *oowner, *ogroup; > > + char *offlags; > > + char *dres; > > + > > + /* > > + * XXX: use underlying perms, unless > > + * overridden on command line. > > + */ > > + omode =3D mode; > > + if (!haveopt_m) > > + mode =3D (to_sb.st_mode & 0777); > > + oowner =3D owner; > > + if (!haveopt_o) > > + owner =3D NULL; > > + ogroup =3D group; > > + if (!haveopt_g) > > + group =3D NULL; > > + offlags =3D fflags; > > + if (!haveopt_f) > > + fflags =3D NULL; > > + dres =3D digest_file(from_name); > > + metadata_log(to_name, "file", NULL, NULL, > > + dres, to_sb.st_size); > > + free(dres); > > + mode =3D omode; > > + owner =3D oowner; > > + group =3D ogroup; > > + fflags =3D offlags; > > + } > > + return; > > + } > > + } > > + > > + /* Symbolic links. */ > > + if (dolink & LN_ABSOLUTE) { > > + /* Convert source path to absolute. */ > > + if (realpath(from_name, src) =3D=3D NULL) > > + err(EX_OSERR, "%s: realpath", from_name); > > + do_symlink(src, to_name, target_sb); > > + /* XXX: src may point outside of destdir */ > > + metadata_log(to_name, "link", NULL, src, NULL, 0); > > + return; > > + } > > + > > + if (dolink & LN_RELATIVE) { > > + char *cp, *d, *s; > > + > > + /* Resolve pathnames. */ > > + if (realpath(from_name, src) =3D=3D NULL) > > + err(EX_OSERR, "%s: realpath", from_name); > > + > > + /* > > + * The last component of to_name may be a symlink, > > + * so use realpath to resolve only the directory. > > + */ > > + cp =3D dirname(to_name); > > + if (realpath(cp, dst) =3D=3D NULL) > > + err(EX_OSERR, "%s: realpath", cp); > > + /* .. and add the last component. */ > > + if (strcmp(dst, "/") !=3D 0) { > > + if (strlcat(dst, "/", sizeof(dst)) > sizeof(dst)) > > + errx(1, "resolved pathname too long"); > > + } > > + cp =3D basename(to_name); > > + if (strlcat(dst, cp, sizeof(dst)) > sizeof(dst)) > > + errx(1, "resolved pathname too long"); > > + > > + /* Trim common path components. */ > > + for (s =3D src, d =3D dst; *s =3D=3D *d; s++, d++) > > + continue; > > + while (*s !=3D '/') > > + s--, d--; > > + > > + /* Count the number of directories we need to backtrack. */ > > + for (++d, lnk[0] =3D '\0'; *d; d++) > > + if (*d =3D=3D '/') > > + (void)strlcat(lnk, "../", sizeof(lnk)); > > + > > + (void)strlcat(lnk, ++s, sizeof(lnk)); > > + > > + do_symlink(lnk, to_name, target_sb); > > + /* XXX: Link may point outside of destdir. */ > > + metadata_log(to_name, "link", NULL, lnk, NULL, 0); > > + return; > > + } > > > > /* > > - * XXX > > - * We know that uid_t's and gid_t's are unsigned longs. > > + * If absolute or relative was not specified, try the names the > > + * user provided. > > */ > > - errno =3D 0; > > - val =3D strtoul(name, &ep, 10); > > - if (errno) > > - err(EX_NOUSER, "%s", name); > > - if (*ep !=3D '\0') > > - errx(EX_NOUSER, "unknown %s %s", type, name); > > - return (val); > > + do_symlink(from_name, to_name, target_sb); > > + /* XXX: from_name may point outside of destdir. */ > > + metadata_log(to_name, "link", NULL, from_name, NULL, 0); > > } > > > > /* > > @@ -274,6 +720,7 @@ install(const char *from_name, const cha > > int devnull, files_match, from_fd, serrno, target; > > int tempcopy, temp_fd, to_fd; > > char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLE= N]; > > + char *digestresult; > > > > files_match =3D 0; > > from_fd =3D -1; > > @@ -281,11 +728,13 @@ install(const char *from_name, const cha > > > > /* If try to install NULL file to a directory, fails. */ > > if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) { > > - if (stat(from_name, &from_sb)) > > - err(EX_OSERR, "%s", from_name); > > - if (!S_ISREG(from_sb.st_mode)) { > > - errno =3D EFTYPE; > > - err(EX_OSERR, "%s", from_name); > > + if (!dolink) { > > + if (stat(from_name, &from_sb)) > > + err(EX_OSERR, "%s", from_name); > > + if (!S_ISREG(from_sb.st_mode)) { > > + errno =3D EFTYPE; > > + err(EX_OSERR, "%s", from_name); > > + } > > } > > /* Build the target path. */ > > if (flags & DIRECTORY) { > > @@ -299,7 +748,23 @@ install(const char *from_name, const cha > > devnull =3D 1; > > } > > > > - target =3D stat(to_name, &to_sb) =3D=3D 0; > > + if (!dolink) > > + target =3D (stat(to_name, &to_sb) =3D=3D 0); > > + else > > + target =3D (lstat(to_name, &to_sb) =3D=3D 0); > > + > > + if (dolink) { > > + if (target && !safecopy) { > > + if (to_sb.st_mode & S_IFDIR && rmdir(to_name) =3D=3D -1) > > + err(EX_OSERR, "%s", to_name); > > + if (to_sb.st_flags & NOCHANGEBITS) > > + (void)chflags(to_name, > > + to_sb.st_flags & ~NOCHANGEBITS); > > + unlink(to_name); > > + } > > + makelink(from_name, to_name, target ? &to_sb : NULL); > > + return; > > + } > > > > /* Only install to regular files. */ > > if (target && !S_ISREG(to_sb.st_mode)) { > > @@ -323,7 +788,7 @@ install(const char *from_name, const cha > > else > > files_match =3D !(compare(from_fd, from_name, > > (size_t)from_sb.st_size, to_fd, > > - to_name, (size_t)to_sb.st_size)); > > + to_name, (size_t)to_sb.st_size, &digestresult)); > > > > /* Close "to" file unless we match. */ > > if (!files_match) > > @@ -345,8 +810,10 @@ install(const char *from_name, const cha > > from_name, to_name); > > } > > if (!devnull) > > - copy(from_fd, from_name, to_fd, > > + digestresult =3D copy(from_fd, from_name, to_fd, > > tempcopy ? tempfile : to_name, from_sb.st_size); > > + else > > + digestresult =3D NULL; > > } > > > > if (dostrip) { > > @@ -380,7 +847,8 @@ install(const char *from_name, const cha > > } > > > > if (compare(temp_fd, tempfile, (size_t)temp_sb.st_size, to_fd, > > - to_name, (size_t)to_sb.st_size) =3D=3D 0) { > > + to_name, (size_t)to_sb.st_size, &digestresult) > > + =3D=3D 0) { > > /* > > * If target has more than one link we need to > > * replace it in order to snap the extra links. > > @@ -400,6 +868,9 @@ install(const char *from_name, const cha > > } > > } > > > > + if (dostrip && (!docompare || !target)) > > + digestresult =3D digest_file(tempfile); > > + > > /* > > > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > > > > >=20 --x+6KMIRAuhnl3hBn Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFRrMjHXY6L6fI4GtQRAoDqAKC7ZMEi5qJHTzg26sLui5odnxYnXQCfQtwu h9ScwoynxNU+VaAJkV32VQs= =RT1W -----END PGP SIGNATURE----- --x+6KMIRAuhnl3hBn-- From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:50:17 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0F959C47; Mon, 3 Jun 2013 16:50:17 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 023D819E4; Mon, 3 Jun 2013 16:50:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53GoGFa076513; Mon, 3 Jun 2013 16:50:16 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53GoGPA076512; Mon, 3 Jun 2013 16:50:16 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031650.r53GoGPA076512@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 16:50:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251309 - stable/9/sys/sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:50:17 -0000 Author: smh Date: Mon Jun 3 16:50:16 2013 New Revision: 251309 URL: http://svnweb.freebsd.org/changeset/base/251309 Log: MFC r249931: Added Dataset Management defines to be used by TRIM Modified: stable/9/sys/sys/ata.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/sys/ata.h ============================================================================== --- stable/9/sys/sys/ata.h Mon Jun 3 16:47:46 2013 (r251308) +++ stable/9/sys/sys/ata.h Mon Jun 3 16:50:16 2013 (r251309) @@ -261,6 +261,12 @@ struct ata_params { /*255*/ u_int16_t integrity; } __packed; +/* ATA Dataset Management */ +#define ATA_DSM_BLK_SIZE 512 +#define ATA_DSM_BLK_RANGES 64 +#define ATA_DSM_RANGE_SIZE 8 +#define ATA_DSM_RANGE_MAX 65535 + /* * ATA Device Register * From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 16:54:57 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B1311163; Mon, 3 Jun 2013 16:54:57 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 945121A29; Mon, 3 Jun 2013 16:54:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53GsvIl077663; Mon, 3 Jun 2013 16:54:57 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53Gsv1B077661; Mon, 3 Jun 2013 16:54:57 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306031654.r53Gsv1B077661@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 16:54:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251310 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 16:54:57 -0000 Author: smh Date: Mon Jun 3 16:54:56 2013 New Revision: 251310 URL: http://svnweb.freebsd.org/changeset/base/251310 Log: MFC r249933: Added the ability to send ATA identify and TRIM commands via SCSI Modified: stable/9/sys/cam/scsi/scsi_all.c stable/9/sys/cam/scsi/scsi_all.h Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 16:50:16 2013 (r251309) +++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 16:54:56 2013 (r251310) @@ -5848,6 +5848,57 @@ scsi_write_same(struct ccb_scsiio *csio, } void +scsi_ata_identify(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t *data_ptr, + u_int16_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout) +{ + scsi_ata_pass_16(csio, + retries, + cbfcnp, + /*flags*/CAM_DIR_IN, + tag_action, + /*protocol*/AP_PROTO_PIO_IN, + /*ata_flags*/AP_FLAG_TDIR_FROM_DEV| + AP_FLAG_BYT_BLOK_BYTES|AP_FLAG_TLEN_SECT_CNT, + /*features*/0, + /*sector_count*/dxfer_len, + /*lba*/0, + /*command*/ATA_ATA_IDENTIFY, + /*control*/0, + data_ptr, + dxfer_len, + sense_len, + timeout); +} + +void +scsi_ata_trim(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int16_t block_count, + u_int8_t *data_ptr, u_int16_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout) +{ + scsi_ata_pass_16(csio, + retries, + cbfcnp, + /*flags*/CAM_DIR_OUT, + tag_action, + /*protocol*/AP_EXTEND|AP_PROTO_DMA, + /*ata_flags*/AP_FLAG_TLEN_SECT_CNT|AP_FLAG_BYT_BLOK_BLOCKS, + /*features*/ATA_DSM_TRIM, + /*sector_count*/block_count, + /*lba*/0, + /*command*/ATA_DATA_SET_MANAGEMENT, + /*control*/0, + data_ptr, + dxfer_len, + sense_len, + timeout); +} + +void scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int32_t flags, u_int8_t tag_action, Modified: stable/9/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 16:50:16 2013 (r251309) +++ stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 16:54:56 2013 (r251310) @@ -1429,6 +1429,61 @@ struct scsi_diag_page { uint8_t params[0]; }; +/* + * Logical Block Provisioning VPD Page based on + * T10/1799-D Revision 31 + */ +struct scsi_vpd_logical_block_prov +{ + u_int8_t device; + u_int8_t page_code; +#define SVPD_LBP 0xB2 + u_int8_t page_length[2]; +#define SVPD_LBP_PL_BASIC 0x04 + u_int8_t threshold_exponent; + u_int8_t flags; +#define SVPD_LBP_UNMAP 0x80 +#define SVPD_LBP_WS16 0x40 +#define SVPD_LBP_WS10 0x20 +#define SVPD_LBP_RZ 0x04 +#define SVPD_LBP_ANC_SUP 0x02 +#define SVPD_LBP_DP 0x01 + u_int8_t prov_type; +#define SVPD_LBP_RESOURCE 0x01 +#define SVPD_LBP_THIN 0x02 + u_int8_t reserved; + /* + * Provisioning Group Descriptor can be here if SVPD_LBP_DP is set + * Its size can be determined from page_length - 4 + */ +}; + +/* + * Block Limits VDP Page based on + * T10/1799-D Revision 31 + */ +struct scsi_vpd_block_limits +{ + u_int8_t device; + u_int8_t page_code; +#define SVPD_BLOCK_LIMITS 0xB0 + u_int8_t page_length[2]; +#define SVPD_BL_PL_BASIC 0x10 +#define SVPD_BL_PL_TP 0x3C + u_int8_t reserved1; + u_int8_t max_cmp_write_len; + u_int8_t opt_txfer_len_grain[2]; + u_int8_t max_txfer_len[4]; + u_int8_t opt_txfer_len[4]; + u_int8_t max_prefetch[4]; + u_int8_t max_unmap_lba_cnt[4]; + u_int8_t max_unmap_blk_cnt[4]; + u_int8_t opt_unmap_grain[4]; + u_int8_t unmap_grain_align[4]; + u_int8_t max_write_same_length[8]; + u_int8_t reserved2[20]; +}; + struct scsi_read_capacity { u_int8_t opcode; @@ -2392,6 +2447,18 @@ void scsi_write_same(struct ccb_scsiio * u_int32_t dxfer_len, u_int8_t sense_len, u_int32_t timeout); +void scsi_ata_identify(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t *data_ptr, + u_int16_t dxfer_len, u_int8_t sense_len, + u_int32_t timeout); + +void scsi_ata_trim(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int16_t block_count, + u_int8_t *data_ptr, u_int16_t dxfer_len, + u_int8_t sense_len, u_int32_t timeout); + void scsi_ata_pass_16(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int32_t flags, u_int8_t tag_action, From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 17:07:34 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 865EA516; Mon, 3 Jun 2013 17:07:34 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 775D91AE5; Mon, 3 Jun 2013 17:07:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53H7YYJ082157; Mon, 3 Jun 2013 17:07:34 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53H7YXg082156; Mon, 3 Jun 2013 17:07:34 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201306031707.r53H7YXg082156@svn.freebsd.org> From: John Baldwin Date: Mon, 3 Jun 2013 17:07:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251311 - stable/9/usr.bin/top X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 17:07:34 -0000 Author: jhb Date: Mon Jun 3 17:07:34 2013 New Revision: 251311 URL: http://svnweb.freebsd.org/changeset/base/251311 Log: MFC 248167: Fix the 'C' field for a running thread to match the behavior described in the manpage by having it display the current CPU (ki_oncpu) rather than the previously used CPU (ki_lastcpu). ki_lastcpu is still used for all other thread states. Modified: stable/9/usr.bin/top/machine.c Directory Properties: stable/9/usr.bin/top/ (props changed) Modified: stable/9/usr.bin/top/machine.c ============================================================================== --- stable/9/usr.bin/top/machine.c Mon Jun 3 16:54:56 2013 (r251310) +++ stable/9/usr.bin/top/machine.c Mon Jun 3 17:07:34 2013 (r251311) @@ -797,7 +797,7 @@ format_next_process(caddr_t handle, char double pct; struct handle *hp; char status[16]; - int state; + int cpu, state; struct rusage ru, *rup; long p_tot, s_tot; char *proc_fmt, thr_buf[6], jid_buf[6]; @@ -996,6 +996,13 @@ format_next_process(caddr_t handle, char } /* format this entry */ + if (smpmode) { + if (state == SRUN && pp->ki_oncpu != 0xff) + cpu = pp->ki_oncpu; + else + cpu = pp->ki_lastcpu; + } else + cpu = 0; proc_fmt = smpmode ? smp_Proc_format : up_Proc_format; if (ps.thread != 0) thr_buf[0] = '\0'; @@ -1013,7 +1020,7 @@ format_next_process(caddr_t handle, char format_k2(PROCSIZE(pp)), format_k2(pagetok(pp->ki_rssize)), status, - smpmode ? pp->ki_lastcpu : 0, + cpu, format_time(cputime), ps.wcpu ? 100.0 * weighted_cpu(pct, pp) : 100.0 * pct, screen_width > cmdlengthdelta ? screen_width - cmdlengthdelta : 0, From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 17:33:12 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id CD547612; Mon, 3 Jun 2013 17:33:12 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id BF9251C3C; Mon, 3 Jun 2013 17:33:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53HXCt6092648; Mon, 3 Jun 2013 17:33:12 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53HXCYE092647; Mon, 3 Jun 2013 17:33:12 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201306031733.r53HXCYE092647@svn.freebsd.org> From: John Baldwin Date: Mon, 3 Jun 2013 17:33:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251319 - stable/9/games/fortune/datfiles X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 17:33:12 -0000 Author: jhb Date: Mon Jun 3 17:33:12 2013 New Revision: 251319 URL: http://svnweb.freebsd.org/changeset/base/251319 Log: MFC 248200: Remove fortunes-o from the base system. Deleted: stable/9/games/fortune/datfiles/fortunes-o.fake stable/9/games/fortune/datfiles/fortunes-o.real stable/9/games/fortune/datfiles/fortunes-o.sp.ok Modified: stable/9/games/fortune/datfiles/Makefile Directory Properties: stable/9/games/fortune/ (props changed) Modified: stable/9/games/fortune/datfiles/Makefile ============================================================================== --- stable/9/games/fortune/datfiles/Makefile Mon Jun 3 17:30:40 2013 (r251318) +++ stable/9/games/fortune/datfiles/Makefile Mon Jun 3 17:33:12 2013 (r251319) @@ -1,37 +1,22 @@ # @(#)Makefile 8.2 (Berkeley) 4/19/94 # $FreeBSD$ -FILES= fortunes freebsd-tips murphy startrek zippy -BLDS= fortunes.dat murphy.dat startrek.dat zippy.dat \ - fortunes-o fortunes-o.dat freebsd-tips.dat +DB= fortunes freebsd-tips murphy startrek zippy # TO AVOID INSTALLING THE POTENTIALLY OFFENSIVE FORTUNES, COMMENT OUT THE -# THREE LINES AND UNCOMMENT THE FOURTH LINE. +# NEXT LINE. +DB+= limerick murphy-o gerrold.limerick -# THE THREE LINES: -FILES+= limerick murphy-o gerrold.limerick -BLDS+= limerick.dat murphy-o.dat gerrold.limerick.dat -TYPE= real - -# THE FOURTH LINE: -#TYPE= fake - -FILES+= ${BLDS} +BLDS= ${DB:S/$/.dat/} +FILES= ${DB} ${BLDS} CLEANFILES+=${BLDS} FILESDIR= ${SHAREDIR}/games/fortune -.for f in fortunes freebsd-tips gerrold.limerick limerick murphy murphy-o startrek zippy +.for f in ${DB} $f.dat: $f PATH=$$PATH:/usr/games:${.OBJDIR}/../strfile \ strfile -Cs ${.ALLSRC} ${.TARGET} .endfor -fortunes-o.dat: fortunes-o - PATH=$$PATH:/usr/games:${.OBJDIR}/../strfile \ - strfile -Csx ${.ALLSRC} ${.TARGET} - -fortunes-o: fortunes-o.${TYPE} - LC_ALL=C tr a-zA-Z n-za-mN-ZA-M < ${.ALLSRC} > ${.TARGET} - .include From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 21:35:05 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 360ED389; Mon, 3 Jun 2013 21:35:05 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 283F2196A; Mon, 3 Jun 2013 21:35:05 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53LZ5dH088807; Mon, 3 Jun 2013 21:35:05 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53LZ5tu088806; Mon, 3 Jun 2013 21:35:05 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306032135.r53LZ5tu088806@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 21:35:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251348 - stable/9/sys/cam/ata X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 21:35:05 -0000 Author: smh Date: Mon Jun 3 21:35:04 2013 New Revision: 251348 URL: http://svnweb.freebsd.org/changeset/base/251348 Log: MFC r249934: Updated TRIM calculations in CAM ATA to be based off ATA_DSM_* defines Modified: stable/9/sys/cam/ata/ata_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Mon Jun 3 20:52:20 2013 (r251347) +++ stable/9/sys/cam/ata/ata_da.c Mon Jun 3 21:35:04 2013 (r251348) @@ -118,10 +118,10 @@ struct disk_params { }; #define TRIM_MAX_BLOCKS 8 -#define TRIM_MAX_RANGES (TRIM_MAX_BLOCKS * 64) +#define TRIM_MAX_RANGES (TRIM_MAX_BLOCKS * ATA_DSM_BLK_RANGES) #define TRIM_MAX_BIOS (TRIM_MAX_RANGES * 4) struct trim_request { - uint8_t data[TRIM_MAX_RANGES * 8]; + uint8_t data[TRIM_MAX_RANGES * ATA_DSM_RANGE_SIZE]; struct bio *bps[TRIM_MAX_BIOS]; }; @@ -1113,8 +1113,8 @@ adaregister(struct cam_periph *periph, v softc->trim_max_ranges = TRIM_MAX_RANGES; if (cgd->ident_data.max_dsm_blocks != 0) { softc->trim_max_ranges = - min(cgd->ident_data.max_dsm_blocks * 64, - softc->trim_max_ranges); + min(cgd->ident_data.max_dsm_blocks * + ATA_DSM_BLK_RANGES, softc->trim_max_ranges); } } if (cgd->ident_data.support.command2 & ATA_SUPPORT_CFA) @@ -1190,10 +1190,12 @@ adaregister(struct cam_periph *periph, v softc->disk->d_flags = 0; if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE; - if ((softc->flags & ADA_FLAG_CAN_TRIM) || - ((softc->flags & ADA_FLAG_CAN_CFA) && - !(softc->flags & ADA_FLAG_CAN_48BIT))) + if (softc->flags & ADA_FLAG_CAN_TRIM) { softc->disk->d_flags |= DISKFLAG_CANDELETE; + } else if ((softc->flags & ADA_FLAG_CAN_CFA) && + !(softc->flags & ADA_FLAG_CAN_48BIT)) { + softc->disk->d_flags |= DISKFLAG_CANDELETE; + } strlcpy(softc->disk->d_descr, cgd->ident_data.model, MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model))); strlcpy(softc->disk->d_ident, cgd->ident_data.serial, @@ -1360,9 +1362,9 @@ adastart(struct cam_periph *periph, unio /* Try to extend the previous range. */ if (lba == lastlba) { - c = min(count, 0xffff - lastcount); + c = min(count, ATA_DSM_RANGE_MAX - lastcount); lastcount += c; - off = (ranges - 1) * 8; + off = (ranges - 1) * ATA_DSM_RANGE_SIZE; req->data[off + 6] = lastcount & 0xff; req->data[off + 7] = (lastcount >> 8) & 0xff; @@ -1371,8 +1373,8 @@ adastart(struct cam_periph *periph, unio } while (count > 0) { - c = min(count, 0xffff); - off = ranges * 8; + c = min(count, ATA_DSM_RANGE_MAX); + off = ranges * ATA_DSM_RANGE_SIZE; req->data[off + 0] = lba & 0xff; req->data[off + 1] = (lba >> 8) & 0xff; req->data[off + 2] = (lba >> 16) & 0xff; @@ -1385,6 +1387,11 @@ adastart(struct cam_periph *periph, unio count -= c; lastcount = c; ranges++; + /* + * Its the caller's responsibility to ensure the + * request will fit so we don't need to check for + * overrun here + */ } lastlba = lba; req->bps[bps++] = bp1; @@ -1392,7 +1399,8 @@ adastart(struct cam_periph *periph, unio if (bps >= TRIM_MAX_BIOS || bp1 == NULL || bp1->bio_bcount / softc->params.secsize > - (softc->trim_max_ranges - ranges) * 0xffff) + (softc->trim_max_ranges - ranges) * + ATA_DSM_RANGE_MAX) break; } while (1); cam_fill_ataio(ataio, @@ -1401,10 +1409,12 @@ adastart(struct cam_periph *periph, unio CAM_DIR_OUT, 0, req->data, - ((ranges + 63) / 64) * 512, + ((ranges + ATA_DSM_BLK_RANGES - 1) / + ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE, ada_default_timeout * 1000); ata_48bit_cmd(ataio, ATA_DATA_SET_MANAGEMENT, - ATA_DSM_TRIM, 0, (ranges + 63) / 64); + ATA_DSM_TRIM, 0, (ranges + ATA_DSM_BLK_RANGES - + 1) / ATA_DSM_BLK_RANGES); start_ccb->ccb_h.ccb_state = ADA_CCB_TRIM; goto out; } From owner-svn-src-stable-9@FreeBSD.ORG Mon Jun 3 22:06:10 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 62B34176; Mon, 3 Jun 2013 22:06:10 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 52D1F1A9F; Mon, 3 Jun 2013 22:06:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53M6AMr099473; Mon, 3 Jun 2013 22:06:10 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53M69tT099467; Mon, 3 Jun 2013 22:06:09 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306032206.r53M69tT099467@svn.freebsd.org> From: Steven Hartland Date: Mon, 3 Jun 2013 22:06:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251350 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jun 2013 22:06:10 -0000 Author: smh Date: Mon Jun 3 22:06:09 2013 New Revision: 251350 URL: http://svnweb.freebsd.org/changeset/base/251350 Log: MFC r249937: Refactored scsi_xpt use of device_has_vpd Modified: stable/9/sys/cam/scsi/scsi_all.c stable/9/sys/cam/scsi/scsi_all.h stable/9/sys/cam/scsi/scsi_xpt.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_all.c Mon Jun 3 22:06:09 2013 (r251350) @@ -40,6 +40,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include +#include #include #else #include @@ -55,7 +58,13 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifndef _KERNEL + +#ifdef _KERNEL +#include +#include +#include +#include +#else #include #include @@ -6252,6 +6261,28 @@ scsi_devid_match(uint8_t *lhs, size_t lh } #ifdef _KERNEL +int +scsi_vpd_supported_page(struct cam_periph *periph, uint8_t page_id) +{ + struct cam_ed *device; + struct scsi_vpd_supported_pages *vpds; + int i, num_pages; + + device = periph->path->device; + vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; + + if (vpds != NULL) { + num_pages = device->supported_vpds_len - + SVPD_SUPPORTED_PAGES_HDR_LEN; + for (i = 0; i < num_pages; i++) { + if (vpds->page_list[i] == page_id) + return (1); + } + } + + return (0); +} + static void init_scsi_delay(void) { Modified: stable/9/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_all.h Mon Jun 3 22:06:09 2013 (r251350) @@ -2257,6 +2257,8 @@ int scsi_sense_sbuf(struct ccb_scsiio * char * scsi_sense_string(struct ccb_scsiio *csio, char *str, int str_len); void scsi_sense_print(struct ccb_scsiio *csio); +int scsi_vpd_supported_page(struct cam_periph *periph, + uint8_t page_id); #else /* _KERNEL */ int scsi_command_string(struct cam_device *device, struct ccb_scsiio *csio, struct sbuf *sb); Modified: stable/9/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_xpt.c Mon Jun 3 21:52:19 2013 (r251349) +++ stable/9/sys/cam/scsi/scsi_xpt.c Mon Jun 3 22:06:09 2013 (r251350) @@ -556,7 +556,6 @@ static const int scsi_quirk_table_size = static cam_status proberegister(struct cam_periph *periph, void *arg); static void probeschedule(struct cam_periph *probe_periph); -static int device_has_vpd(struct cam_ed *device, uint8_t page_id); static void probestart(struct cam_periph *periph, union ccb *start_ccb); static void proberequestdefaultnegotiation(struct cam_periph *periph); static int proberequestbackoff(struct cam_periph *periph, @@ -708,21 +707,6 @@ probeschedule(struct cam_periph *periph) xpt_schedule(periph, CAM_PRIORITY_XPT); } -static int -device_has_vpd(struct cam_ed *device, uint8_t page_id) -{ - int i, num_pages; - struct scsi_vpd_supported_pages *vpds; - - vpds = (struct scsi_vpd_supported_pages *)device->supported_vpds; - num_pages = device->supported_vpds_len - SVPD_SUPPORTED_PAGES_HDR_LEN; - for (i = 0;i < num_pages;i++) - if (vpds->page_list[i] == page_id) - return 1; - - return 0; -} - static void probestart(struct cam_periph *periph, union ccb *start_ccb) { @@ -910,11 +894,9 @@ again: case PROBE_DEVICE_ID: { struct scsi_vpd_device_id *devid; - struct cam_ed *device; devid = NULL; - device = periph->path->device; - if (device_has_vpd(device, SVPD_DEVICE_ID)) + if (scsi_vpd_supported_page(periph, SVPD_DEVICE_ID)) devid = malloc(SVPD_DEVICE_ID_MAX_SIZE, M_CAMXPT, M_NOWAIT | M_ZERO); @@ -952,7 +934,7 @@ again: device->serial_num_len = 0; } - if (device_has_vpd(device, SVPD_UNIT_SERIAL_NUMBER)) + if (scsi_vpd_supported_page(periph, SVPD_UNIT_SERIAL_NUMBER)) serial_buf = (struct scsi_vpd_unit_serial_number *) malloc(sizeof(*serial_buf), M_CAMXPT, M_NOWAIT|M_ZERO); From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 05:07:06 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 173DCE97; Tue, 4 Jun 2013 05:07:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 063951B0C; Tue, 4 Jun 2013 05:07:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54575E3033640; Tue, 4 Jun 2013 05:07:05 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54573iV033621; Tue, 4 Jun 2013 05:07:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306040507.r54573iV033621@svn.freebsd.org> From: Konstantin Belousov Date: Tue, 4 Jun 2013 05:07:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251365 - in stable/9: lib/libc/amd64/gen lib/libc/arm/gen lib/libc/gen lib/libc/i386/gen lib/libc/ia64/gen lib/libc/mips/gen lib/libc/powerpc/gen lib/libc/powerpc64/gen lib/libc/sparc6... X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 05:07:06 -0000 Author: kib Date: Tue Jun 4 05:07:03 2013 New Revision: 251365 URL: http://svnweb.freebsd.org/changeset/base/251365 Log: MFC r251047: Avoid a nested frame for getcontext() call in check_deferred_signal(). Modified: stable/9/lib/libc/amd64/gen/getcontextx.c stable/9/lib/libc/arm/gen/getcontextx.c stable/9/lib/libc/gen/Symbol.map stable/9/lib/libc/i386/gen/getcontextx.c stable/9/lib/libc/ia64/gen/getcontextx.c stable/9/lib/libc/mips/gen/getcontextx.c stable/9/lib/libc/powerpc/gen/getcontextx.c stable/9/lib/libc/powerpc64/gen/getcontextx.c stable/9/lib/libc/sparc64/gen/getcontextx.c stable/9/lib/libthr/thread/thr_sig.c stable/9/sys/sys/ucontext.h Directory Properties: stable/9/lib/libc/ (props changed) stable/9/lib/libthr/ (props changed) stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/lib/libc/amd64/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/amd64/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/amd64/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -57,14 +57,12 @@ __getcontextx_size(void) } int -__fillcontextx(char *ctx) +__fillcontextx2(char *ctx) { struct amd64_get_xfpustate xfpu; ucontext_t *ucp; ucp = (ucontext_t *)ctx; - if (getcontext(ucp) == -1) - return (-1); if (xstate_sz != 0) { xfpu.addr = (char *)(ucp + 1); xfpu.len = xstate_sz; @@ -80,6 +78,18 @@ __fillcontextx(char *ctx) return (0); } +int +__fillcontextx(char *ctx) +{ + ucontext_t *ucp; + + ucp = (ucontext_t *)ctx; + if (getcontext(ucp) == -1) + return (-1); + __fillcontextx2(ctx); + return (0); +} + __weak_reference(__getcontextx, getcontextx); ucontext_t * Modified: stable/9/lib/libc/arm/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/arm/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/arm/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libc/gen/Symbol.map ============================================================================== --- stable/9/lib/libc/gen/Symbol.map Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/gen/Symbol.map Tue Jun 4 05:07:03 2013 (r251365) @@ -526,5 +526,6 @@ FBSDprivate_1.0 { __elf_aux_vector; __pthread_map_stacks_exec; __fillcontextx; + __fillcontextx2; __getcontextx_size; }; Modified: stable/9/lib/libc/i386/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/i386/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/i386/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -89,14 +89,12 @@ __getcontextx_size(void) } int -__fillcontextx(char *ctx) +__fillcontextx2(char *ctx) { struct i386_get_xfpustate xfpu; ucontext_t *ucp; ucp = (ucontext_t *)ctx; - if (getcontext(ucp) == -1) - return (-1); if (xstate_sz != 0) { xfpu.addr = (char *)(ucp + 1); xfpu.len = xstate_sz; @@ -112,6 +110,18 @@ __fillcontextx(char *ctx) return (0); } +int +__fillcontextx(char *ctx) +{ + ucontext_t *ucp; + + ucp = (ucontext_t *)ctx; + if (getcontext(ucp) == -1) + return (-1); + __fillcontextx2(ctx); + return (0); +} + __weak_reference(__getcontextx, getcontextx); ucontext_t * Modified: stable/9/lib/libc/ia64/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/ia64/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/ia64/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libc/mips/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/mips/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/mips/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libc/powerpc/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/powerpc/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/powerpc/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libc/powerpc64/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/powerpc64/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/powerpc64/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libc/sparc64/gen/getcontextx.c ============================================================================== --- stable/9/lib/libc/sparc64/gen/getcontextx.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libc/sparc64/gen/getcontextx.c Tue Jun 4 05:07:03 2013 (r251365) @@ -40,6 +40,13 @@ __getcontextx_size(void) } int +__fillcontextx2(char *ctx) +{ + + return (0); +} + +int __fillcontextx(char *ctx) { ucontext_t *ucp; Modified: stable/9/lib/libthr/thread/thr_sig.c ============================================================================== --- stable/9/lib/libthr/thread/thr_sig.c Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/lib/libthr/thread/thr_sig.c Tue Jun 4 05:07:03 2013 (r251365) @@ -323,8 +323,13 @@ check_deferred_signal(struct pthread *cu return; #if defined(__amd64__) || defined(__i386__) - uc = alloca(__getcontextx_size()); - __fillcontextx((char *)uc); + int uc_len; + uc_len = __getcontextx_size(); + uc = alloca(uc_len); + getcontext(uc); + if (curthread->deferred_siginfo.si_signo == 0) + return; + __fillcontextx2((char *)uc); #else ucontext_t ucv; uc = &ucv; Modified: stable/9/sys/sys/ucontext.h ============================================================================== --- stable/9/sys/sys/ucontext.h Tue Jun 4 03:47:21 2013 (r251364) +++ stable/9/sys/sys/ucontext.h Tue Jun 4 05:07:03 2013 (r251365) @@ -80,7 +80,8 @@ int swapcontext(ucontext_t *, const ucon #if __BSD_VISIBLE int __getcontextx_size(void); -int __fillcontextx(char *ctx); +int __fillcontextx(char *ctx) __returns_twice; +int __fillcontextx2(char *ctx); #endif __END_DECLS From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 10:47:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A0DE1F9C; Tue, 4 Jun 2013 10:47:45 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8151119E9; Tue, 4 Jun 2013 10:47:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54Alj9J050736; Tue, 4 Jun 2013 10:47:45 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54AljAX050733; Tue, 4 Jun 2013 10:47:45 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306041047.r54AljAX050733@svn.freebsd.org> From: Steven Hartland Date: Tue, 4 Jun 2013 10:47:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251372 - in stable/9/sys/cam: ata scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 10:47:45 -0000 Author: smh Date: Tue Jun 4 10:47:44 2013 New Revision: 251372 URL: http://svnweb.freebsd.org/changeset/base/251372 Log: Enhanced BIO_DELETE support for CAM SCSI to add ATA_TRIM support. Disable CAM BIO queue sorting for non-rotating media by default. MFC r249939 Added available delete methods discovery during device probe MFC r249941 Automatically disable BIO queue sorting for non-rotating media MFC r250033 Correct comment typo's MFC r250179 Update probe flow so that devices with lbp can also disable disksort MFC r250180 Fix probe in progress check in dareprobe MFC r250181 Check for ATA Information VPD before querying for ATA MFC r250183 Enable CAM SCSI to choice ATA TRIM during autodetection MFC r250967 Enforce validation on the selected delete method via sysctl Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/scsi/scsi_all.h stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Tue Jun 4 09:33:03 2013 (r251371) +++ stable/9/sys/cam/ata/ata_da.c Tue Jun 4 10:47:44 2013 (r251372) @@ -1159,7 +1159,11 @@ adaregister(struct cam_periph *periph, v snprintf(announce_buf, sizeof(announce_buf), "kern.cam.ada.%d.write_cache", periph->unit_number); TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); - softc->sort_io_queue = -1; + /* Disable queue sorting for non-rotational media by default. */ + if (cgd->ident_data.media_rotation_rate == 1) + softc->sort_io_queue = 0; + else + softc->sort_io_queue = -1; adagetparams(periph, cgd); softc->disk = disk_alloc(); softc->disk->d_devstat = devstat_new_entry(periph->periph_name, Modified: stable/9/sys/cam/scsi/scsi_all.h ============================================================================== --- stable/9/sys/cam/scsi/scsi_all.h Tue Jun 4 09:33:03 2013 (r251371) +++ stable/9/sys/cam/scsi/scsi_all.h Tue Jun 4 10:47:44 2013 (r251372) @@ -1430,6 +1430,36 @@ struct scsi_diag_page { }; /* + * ATA Information VPD Page based on + * T10/2126-D Revision 04 + */ +#define SVPD_ATA_INFORMATION 0x89 + +/* + * Block Device Characteristics VPD Page based on + * T10/1799-D Revision 31 + */ +struct scsi_vpd_block_characteristics +{ + u_int8_t device; + u_int8_t page_code; +#define SVPD_BDC 0xB1 + u_int8_t page_length[2]; + u_int8_t medium_rotation_rate[2]; +#define SVPD_BDC_RATE_NOT_REPORTED 0x00 +#define SVPD_BDC_RATE_NONE_ROTATING 0x01 + u_int8_t reserved1; + u_int8_t nominal_form_factor; +#define SVPD_BDC_FORM_NOT_REPORTED 0x00 +#define SVPD_BDC_FORM_5_25INCH 0x01 +#define SVPD_BDC_FORM_3_5INCH 0x02 +#define SVPD_BDC_FORM_2_5INCH 0x03 +#define SVPD_BDC_FORM_1_5INCH 0x04 +#define SVPD_BDC_FORM_LESSTHAN_1_5INCH 0x05 + u_int8_t reserved2[56]; +}; + +/* * Logical Block Provisioning VPD Page based on * T10/1799-D Revision 31 */ Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 09:33:03 2013 (r251371) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 10:47:44 2013 (r251372) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #endif /* _KERNEL */ @@ -67,8 +68,12 @@ __FBSDID("$FreeBSD$"); #ifdef _KERNEL typedef enum { - DA_STATE_PROBE, - DA_STATE_PROBE2, + DA_STATE_PROBE_RC, + DA_STATE_PROBE_RC16, + DA_STATE_PROBE_LBP, + DA_STATE_PROBE_BLK_LIMITS, + DA_STATE_PROBE_BDC, + DA_STATE_PROBE_ATA, DA_STATE_NORMAL } da_state; @@ -96,29 +101,47 @@ typedef enum { } da_quirks; typedef enum { - DA_CCB_PROBE = 0x01, - DA_CCB_PROBE2 = 0x02, - DA_CCB_BUFFER_IO = 0x03, - DA_CCB_WAITING = 0x04, - DA_CCB_DUMP = 0x05, - DA_CCB_DELETE = 0x06, - DA_CCB_TUR = 0x07, + DA_CCB_PROBE_RC = 0x01, + DA_CCB_PROBE_RC16 = 0x02, + DA_CCB_PROBE_LBP = 0x03, + DA_CCB_PROBE_BLK_LIMITS = 0x04, + DA_CCB_PROBE_BDC = 0x05, + DA_CCB_PROBE_ATA = 0x06, + DA_CCB_BUFFER_IO = 0x07, + DA_CCB_WAITING = 0x08, + DA_CCB_DUMP = 0x0A, + DA_CCB_DELETE = 0x0B, + DA_CCB_TUR = 0x0C, DA_CCB_TYPE_MASK = 0x0F, DA_CCB_RETRY_UA = 0x10 } da_ccb_state; +/* + * Order here is important for method choice + * + * We prefer ATA_TRIM as tests run against a Sandforce 2281 SSD attached to + * LSI 2008 (mps) controller (FW: v12, Drv: v14) resulted 20% quicker deletes + * using ATA_TRIM than the corresponding UNMAP results for a real world mysql + * import taking 5mins. + * + */ typedef enum { DA_DELETE_NONE, DA_DELETE_DISABLE, - DA_DELETE_ZERO, - DA_DELETE_WS10, - DA_DELETE_WS16, + DA_DELETE_ATA_TRIM, DA_DELETE_UNMAP, - DA_DELETE_MAX = DA_DELETE_UNMAP + DA_DELETE_WS16, + DA_DELETE_WS10, + DA_DELETE_ZERO, + DA_DELETE_MIN = DA_DELETE_ATA_TRIM, + DA_DELETE_MAX = DA_DELETE_ZERO } da_delete_methods; static const char *da_delete_method_names[] = - { "NONE", "DISABLE", "ZERO", "WS10", "WS16", "UNMAP" }; + { "NONE", "DISABLE", "ATA_TRIM", "UNMAP", "WS16", "WS10", "ZERO" }; +static const char *da_delete_method_desc[] = + { "NONE", "DISABLED", "ATA TRIM", "UNMAP", "WRITE SAME(16) with UNMAP", + "WRITE SAME(10) with UNMAP", "ZERO" }; /* Offsets into our private area for storing information */ #define ccb_state ppriv_field0 @@ -134,7 +157,17 @@ struct disk_params { u_int stripeoffset; }; -#define UNMAP_MAX_RANGES 512 +#define UNMAP_RANGE_MAX 0xffffffff +#define UNMAP_HEAD_SIZE 8 +#define UNMAP_RANGE_SIZE 16 +#define UNMAP_MAX_RANGES 2048 /* Protocol Max is 4095 */ +#define UNMAP_BUF_SIZE ((UNMAP_MAX_RANGES * UNMAP_RANGE_SIZE) + \ + UNMAP_HEAD_SIZE) + +#define WS10_MAX_BLKS 0xffff +#define WS16_MAX_BLKS 0xffffffff +#define ATA_TRIM_MAX_RANGES ((UNMAP_BUF_SIZE / \ + (ATA_DSM_RANGE_SIZE * ATA_DSM_BLK_SIZE)) * ATA_DSM_BLK_SIZE) struct da_softc { struct bio_queue_head bio_queue; @@ -150,11 +183,14 @@ struct da_softc { int error_inject; int ordered_tag_count; int outstanding_cmds; - int unmap_max_ranges; - int unmap_max_lba; + int trim_max_ranges; int delete_running; int tur; - da_delete_methods delete_method; + int delete_available; /* Delete methods possibly available */ + uint32_t unmap_max_ranges; + uint32_t unmap_max_lba; + uint64_t ws_max_blks; + da_delete_methods delete_method; struct disk_params params; struct disk *disk; union ccb saved_ccb; @@ -163,11 +199,18 @@ struct da_softc { struct sysctl_oid *sysctl_tree; struct callout sendordered_c; uint64_t wwpn; - uint8_t unmap_buf[UNMAP_MAX_RANGES * 16 + 8]; + uint8_t unmap_buf[UNMAP_BUF_SIZE]; struct scsi_read_capacity_data_long rcaplong; struct callout mediapoll_c; }; +#define dadeleteflag(softc, delete_method, enable) \ + if (enable) { \ + softc->delete_available |= (1 << delete_method); \ + } else { \ + softc->delete_available &= ~(1 << delete_method); \ + } + struct da_quirk_entry { struct scsi_inquiry_pattern inq_pat; da_quirks quirks; @@ -870,6 +913,10 @@ static int dacmdsizesysctl(SYSCTL_HANDL static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS); static void dadeletemethodset(struct da_softc *softc, da_delete_methods delete_method); +static void dadeletemethodchoose(struct da_softc *softc, + da_delete_methods default_method); +static void daprobedone(struct cam_periph *periph, union ccb *ccb); + static periph_ctor_t daregister; static periph_dtor_t dacleanup; static periph_start_t dastart; @@ -1581,6 +1628,85 @@ dadeletemethodset(struct da_softc *softc softc->disk->d_flags &= ~DISKFLAG_CANDELETE; } +static void +daprobedone(struct cam_periph *periph, union ccb *ccb) +{ + struct da_softc *softc; + + softc = (struct da_softc *)periph->softc; + + dadeletemethodchoose(softc, DA_DELETE_NONE); + + if (bootverbose && (softc->flags & DA_FLAG_PROBED) == 0) { + char buf[80]; + int i, sep; + + snprintf(buf, sizeof(buf), "Delete methods: <"); + sep = 0; + for (i = DA_DELETE_MIN; i <= DA_DELETE_MAX; i++) { + if (softc->delete_available & (1 << i)) { + if (sep) { + strlcat(buf, ",", sizeof(buf)); + } else { + sep = 1; + } + strlcat(buf, da_delete_method_names[i], + sizeof(buf)); + if (i == softc->delete_method) { + strlcat(buf, "(*)", sizeof(buf)); + } + } + } + if (sep == 0) { + if (softc->delete_method == DA_DELETE_NONE) + strlcat(buf, "NONE(*)", sizeof(buf)); + else + strlcat(buf, "DISABLED(*)", sizeof(buf)); + } + strlcat(buf, ">", sizeof(buf)); + printf("%s%d: %s\n", periph->periph_name, + periph->unit_number, buf); + } + + /* + * Since our peripheral may be invalidated by an error + * above or an external event, we must release our CCB + * before releasing the probe lock on the peripheral. + * The peripheral will only go away once the last lock + * is removed, and we need it around for the CCB release + * operation. + */ + xpt_release_ccb(ccb); + softc->state = DA_STATE_NORMAL; + daschedule(periph); + wakeup(&softc->disk->d_mediasize); + if ((softc->flags & DA_FLAG_PROBED) == 0) { + softc->flags |= DA_FLAG_PROBED; + cam_periph_unhold(periph); + } else + cam_periph_release_locked(periph); +} + +static void +dadeletemethodchoose(struct da_softc *softc, da_delete_methods default_method) +{ + int i, delete_method; + + delete_method = default_method; + + /* + * Use the pre-defined order to choose the best + * performing delete. + */ + for (i = DA_DELETE_MIN; i <= DA_DELETE_MAX; i++) { + if (softc->delete_available & (1 << i)) { + dadeletemethodset(softc, i); + return; + } + } + dadeletemethodset(softc, delete_method); +} + static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS) { @@ -1601,7 +1727,8 @@ dadeletemethodsysctl(SYSCTL_HANDLER_ARGS if (error != 0 || req->newptr == NULL) return (error); for (i = 0; i <= DA_DELETE_MAX; i++) { - if (strcmp(buf, da_delete_method_names[i]) != 0) + if (!(softc->delete_available & (1 << i)) || + strcmp(buf, da_delete_method_names[i]) != 0) continue; dadeletemethodset(softc, i); return (0); @@ -1634,14 +1761,16 @@ daregister(struct cam_periph *periph, vo } LIST_INIT(&softc->pending_ccbs); - softc->state = DA_STATE_PROBE; + softc->state = DA_STATE_PROBE_RC; bioq_init(&softc->bio_queue); bioq_init(&softc->delete_queue); bioq_init(&softc->delete_run_queue); if (SID_IS_REMOVABLE(&cgd->inq_data)) softc->flags |= DA_FLAG_PACK_REMOVABLE; softc->unmap_max_ranges = UNMAP_MAX_RANGES; - softc->unmap_max_lba = 1024*1024*2; + softc->unmap_max_lba = UNMAP_RANGE_MAX; + softc->ws_max_blks = WS16_MAX_BLKS; + softc->trim_max_ranges = ATA_TRIM_MAX_RANGES; softc->sort_io_queue = -1; periph->softc = softc; @@ -1718,7 +1847,7 @@ daregister(struct cam_periph *periph, vo /* Predict whether device may support READ CAPACITY(16). */ if (SID_ANSI_REV(&cgd->inq_data) >= SCSI_REV_SPC3) { softc->flags |= DA_FLAG_CAN_RC16; - softc->state = DA_STATE_PROBE2; + softc->state = DA_STATE_PROBE_RC16; } /* @@ -1818,6 +1947,7 @@ dastart(struct cam_periph *periph, union CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dastart\n")); +skipstate: switch (softc->state) { case DA_STATE_NORMAL: { @@ -1842,13 +1972,36 @@ dastart(struct cam_periph *periph, union if (!softc->delete_running && (bp = bioq_first(&softc->delete_queue)) != NULL) { uint64_t lba; - u_int count; + uint64_t count; /* forward compat with WS32 */ + + /* + * In each of the methods below, while its the caller's + * responsibility to ensure the request will fit into a + * single device request, we might have changed the delete + * method due to the device incorrectly advertising either + * its supported methods or limits. + * + * To prevent this causing further issues we validate the + * against the methods limits, and warn which would + * otherwise be unnecessary. + */ if (softc->delete_method == DA_DELETE_UNMAP) { uint8_t *buf = softc->unmap_buf; uint64_t lastlba = (uint64_t)-1; - uint32_t lastcount = 0; - int blocks = 0, off, ranges = 0; + uint32_t lastcount = 0, c; + uint64_t totalcount = 0; + uint32_t off, ranges = 0; + + /* + * Currently this doesn't take the UNMAP + * Granularity and Granularity Alignment + * fields into account. + * + * This could result in both unoptimal unmap + * requests as as well as UNMAP calls unmapping + * fewer LBA's than requested. + */ softc->delete_running = 1; bzero(softc->unmap_buf, sizeof(softc->unmap_buf)); @@ -1862,22 +2015,44 @@ dastart(struct cam_periph *periph, union /* Try to extend the previous range. */ if (lba == lastlba) { - lastcount += count; - off = (ranges - 1) * 16 + 8; + c = min(count, softc->unmap_max_lba - + lastcount); + lastcount += c; + off = ((ranges - 1) * UNMAP_RANGE_SIZE) + + UNMAP_HEAD_SIZE; scsi_ulto4b(lastcount, &buf[off + 8]); - } else if (count > 0) { - off = ranges * 16 + 8; + count -= c; + lba +=c; + totalcount += c; + } + + while (count > 0) { + c = min(count, softc->unmap_max_lba); + if (totalcount + c > softc->unmap_max_lba || + ranges >= softc->unmap_max_ranges) { + xpt_print(periph->path, + "%s issuing short delete %ld > %ld" + "|| %d >= %d", + da_delete_method_desc[softc->delete_method], + totalcount + c, softc->unmap_max_lba, + ranges, softc->unmap_max_ranges); + break; + } + off = (ranges * UNMAP_RANGE_SIZE) + + UNMAP_HEAD_SIZE; scsi_u64to8b(lba, &buf[off + 0]); - scsi_ulto4b(count, &buf[off + 8]); - lastcount = count; + scsi_ulto4b(c, &buf[off + 8]); + lba += c; + totalcount += c; ranges++; + count -= c; + lastcount = c; } - blocks += count; - lastlba = lba + count; + lastlba = lba; bp1 = bioq_first(&softc->delete_queue); if (bp1 == NULL || ranges >= softc->unmap_max_ranges || - blocks + bp1->bio_bcount / + totalcount + bp1->bio_bcount / softc->params.secsize > softc->unmap_max_lba) break; } while (1); @@ -1895,9 +2070,87 @@ dastart(struct cam_periph *periph, union da_default_timeout * 1000); start_ccb->ccb_h.ccb_state = DA_CCB_DELETE; goto out; + } else if (softc->delete_method == DA_DELETE_ATA_TRIM) { + uint8_t *buf = softc->unmap_buf; + uint64_t lastlba = (uint64_t)-1; + uint32_t lastcount = 0, c, requestcount; + int ranges = 0, off, block_count; + + softc->delete_running = 1; + bzero(softc->unmap_buf, sizeof(softc->unmap_buf)); + bp1 = bp; + do { + bioq_remove(&softc->delete_queue, bp1); + if (bp1 != bp) + bioq_insert_tail(&softc->delete_run_queue, bp1); + lba = bp1->bio_pblkno; + count = bp1->bio_bcount / softc->params.secsize; + requestcount = count; + + /* Try to extend the previous range. */ + if (lba == lastlba) { + c = min(count, ATA_DSM_RANGE_MAX - lastcount); + lastcount += c; + off = (ranges - 1) * 8; + buf[off + 6] = lastcount & 0xff; + buf[off + 7] = (lastcount >> 8) & 0xff; + count -= c; + lba += c; + } + + while (count > 0) { + c = min(count, ATA_DSM_RANGE_MAX); + off = ranges * 8; + + buf[off + 0] = lba & 0xff; + buf[off + 1] = (lba >> 8) & 0xff; + buf[off + 2] = (lba >> 16) & 0xff; + buf[off + 3] = (lba >> 24) & 0xff; + buf[off + 4] = (lba >> 32) & 0xff; + buf[off + 5] = (lba >> 40) & 0xff; + buf[off + 6] = c & 0xff; + buf[off + 7] = (c >> 8) & 0xff; + lba += c; + ranges++; + count -= c; + lastcount = c; + if (count != 0 && ranges == softc->trim_max_ranges) { + xpt_print(periph->path, + "%s issuing short delete %ld > %ld", + da_delete_method_desc[softc->delete_method], + requestcount, + (softc->trim_max_ranges - ranges) * + ATA_DSM_RANGE_MAX); + break; + } + } + lastlba = lba; + bp1 = bioq_first(&softc->delete_queue); + if (bp1 == NULL || + bp1->bio_bcount / softc->params.secsize > + (softc->trim_max_ranges - ranges) * + ATA_DSM_RANGE_MAX) + break; + } while (1); + + block_count = (ranges + ATA_DSM_BLK_RANGES - 1) / + ATA_DSM_BLK_RANGES; + scsi_ata_trim(&start_ccb->csio, + /*retries*/da_retry_count, + /*cbfcnp*/dadone, + /*tag_action*/MSG_SIMPLE_Q_TAG, + block_count, + /*data_ptr*/buf, + /*dxfer_len*/block_count * ATA_DSM_BLK_SIZE, + /*sense_len*/SSD_FULL_SIZE, + da_default_timeout * 1000); + start_ccb->ccb_h.ccb_state = DA_CCB_DELETE; + goto out; } else if (softc->delete_method == DA_DELETE_ZERO || softc->delete_method == DA_DELETE_WS10 || softc->delete_method == DA_DELETE_WS16) { + uint64_t ws_max_blks; + ws_max_blks = softc->ws_max_blks / softc->params.secsize; softc->delete_running = 1; lba = bp->bio_pblkno; count = 0; @@ -1907,11 +2160,19 @@ dastart(struct cam_periph *periph, union if (bp1 != bp) bioq_insert_tail(&softc->delete_run_queue, bp1); count += bp1->bio_bcount / softc->params.secsize; + if (count > ws_max_blks) { + count = min(count, ws_max_blks); + xpt_print(periph->path, + "%s issuing short delete %ld > %ld", + da_delete_method_desc[softc->delete_method], + count, ws_max_blks); + break; + } bp1 = bioq_first(&softc->delete_queue); if (bp1 == NULL || lba + count != bp1->bio_pblkno || count + bp1->bio_bcount / - softc->params.secsize > 0xffff) + softc->params.secsize > ws_max_blks) break; } while (1); @@ -2031,7 +2292,7 @@ out: daschedule(periph); break; } - case DA_STATE_PROBE: + case DA_STATE_PROBE_RC: { struct scsi_read_capacity_data *rcap; @@ -2050,11 +2311,11 @@ out: SSD_FULL_SIZE, /*timeout*/5000); start_ccb->ccb_h.ccb_bp = NULL; - start_ccb->ccb_h.ccb_state = DA_CCB_PROBE; + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_RC; xpt_action(start_ccb); break; } - case DA_STATE_PROBE2: + case DA_STATE_PROBE_RC16: { struct scsi_read_capacity_data_long *rcaplong; @@ -2076,8 +2337,148 @@ out: /*sense_len*/ SSD_FULL_SIZE, /*timeout*/ da_default_timeout * 1000); start_ccb->ccb_h.ccb_bp = NULL; - start_ccb->ccb_h.ccb_state = DA_CCB_PROBE2; - xpt_action(start_ccb); + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_RC16; + xpt_action(start_ccb); + break; + } + case DA_STATE_PROBE_LBP: + { + struct scsi_vpd_logical_block_prov *lbp; + + if (!scsi_vpd_supported_page(periph, SVPD_LBP)) { + /* + * If we get here we don't support any SBC-3 delete + * methods with UNMAP as the Logical Block Provisioning + * VPD page support is required for devices which + * support it according to T10/1799-D Revision 31 + * however older revisions of the spec don't mandate + * this so we currently don't remove these methods + * from the available set. + */ + softc->state = DA_STATE_PROBE_BLK_LIMITS; + goto skipstate; + } + + lbp = (struct scsi_vpd_logical_block_prov *) + malloc(sizeof(*lbp), M_SCSIDA, M_NOWAIT|M_ZERO); + + if (lbp == NULL) { + printf("dastart: Couldn't malloc lbp data\n"); + /* da_free_periph??? */ + break; + } + + scsi_inquiry(&start_ccb->csio, + /*retries*/da_retry_count, + /*cbfcnp*/dadone, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*inq_buf*/(u_int8_t *)lbp, + /*inq_len*/sizeof(*lbp), + /*evpd*/TRUE, + /*page_code*/SVPD_LBP, + /*sense_len*/SSD_MIN_SIZE, + /*timeout*/da_default_timeout * 1000); + start_ccb->ccb_h.ccb_bp = NULL; + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_LBP; + xpt_action(start_ccb); + break; + } + case DA_STATE_PROBE_BLK_LIMITS: + { + struct scsi_vpd_block_limits *block_limits; + + if (!scsi_vpd_supported_page(periph, SVPD_BLOCK_LIMITS)) { + /* Not supported skip to next probe */ + softc->state = DA_STATE_PROBE_BDC; + goto skipstate; + } + + block_limits = (struct scsi_vpd_block_limits *) + malloc(sizeof(*block_limits), M_SCSIDA, M_NOWAIT|M_ZERO); + + if (block_limits == NULL) { + printf("dastart: Couldn't malloc block_limits data\n"); + /* da_free_periph??? */ + break; + } + + scsi_inquiry(&start_ccb->csio, + /*retries*/da_retry_count, + /*cbfcnp*/dadone, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*inq_buf*/(u_int8_t *)block_limits, + /*inq_len*/sizeof(*block_limits), + /*evpd*/TRUE, + /*page_code*/SVPD_BLOCK_LIMITS, + /*sense_len*/SSD_MIN_SIZE, + /*timeout*/da_default_timeout * 1000); + start_ccb->ccb_h.ccb_bp = NULL; + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_BLK_LIMITS; + xpt_action(start_ccb); + break; + } + case DA_STATE_PROBE_BDC: + { + struct scsi_vpd_block_characteristics *bdc; + + if (!scsi_vpd_supported_page(periph, SVPD_BDC)) { + softc->state = DA_STATE_PROBE_ATA; + goto skipstate; + } + + bdc = (struct scsi_vpd_block_characteristics *) + malloc(sizeof(*bdc), M_SCSIDA, M_NOWAIT|M_ZERO); + + if (bdc == NULL) { + printf("dastart: Couldn't malloc bdc data\n"); + /* da_free_periph??? */ + break; + } + + scsi_inquiry(&start_ccb->csio, + /*retries*/da_retry_count, + /*cbfcnp*/dadone, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*inq_buf*/(u_int8_t *)bdc, + /*inq_len*/sizeof(*bdc), + /*evpd*/TRUE, + /*page_code*/SVPD_BDC, + /*sense_len*/SSD_MIN_SIZE, + /*timeout*/da_default_timeout * 1000); + start_ccb->ccb_h.ccb_bp = NULL; + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_BDC; + xpt_action(start_ccb); + break; + } + case DA_STATE_PROBE_ATA: + { + struct ata_params *ata_params; + + if (!scsi_vpd_supported_page(periph, SVPD_ATA_INFORMATION)) { + daprobedone(periph, start_ccb); + break; + } + + ata_params = (struct ata_params*) + malloc(sizeof(*ata_params), M_SCSIDA, M_NOWAIT|M_ZERO); + + if (ata_params == NULL) { + printf("dastart: Couldn't malloc ata_params data\n"); + /* da_free_periph??? */ + break; + } + + scsi_ata_identify(&start_ccb->csio, + /*retries*/da_retry_count, + /*cbfcnp*/dadone, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*data_ptr*/(u_int8_t *)ata_params, + /*dxfer_len*/sizeof(*ata_params), + /*sense_len*/SSD_FULL_SIZE, + /*timeout*/da_default_timeout * 1000); + start_ccb->ccb_h.ccb_bp = NULL; + start_ccb->ccb_h.ccb_state = DA_CCB_PROBE_ATA; + xpt_action(start_ccb); break; } } @@ -2097,27 +2498,31 @@ cmd6workaround(union ccb *ccb) softc = (struct da_softc *)xpt_path_periph(ccb->ccb_h.path)->softc; if (ccb->ccb_h.ccb_state == DA_CCB_DELETE) { - if (softc->delete_method == DA_DELETE_UNMAP) { - xpt_print(ccb->ccb_h.path, "UNMAP is not supported, " - "switching to WRITE SAME(16) with UNMAP.\n"); - dadeletemethodset(softc, DA_DELETE_WS16); - } else if (softc->delete_method == DA_DELETE_WS16) { - xpt_print(ccb->ccb_h.path, - "WRITE SAME(16) with UNMAP is not supported, " - "disabling BIO_DELETE.\n"); - dadeletemethodset(softc, DA_DELETE_DISABLE); - } else if (softc->delete_method == DA_DELETE_WS10) { + da_delete_methods old_method = softc->delete_method; + + /* + * Typically there are two reasons for failure here + * 1. Delete method was detected as supported but isn't + * 2. Delete failed due to invalid params e.g. too big + * + * While we will attempt to choose an alternative delete method + * this may result in short deletes if the existing delete + * requests from geom are big for the new method choosen. + * + * This method assumes that the error which triggered this + * will not retry the io otherwise a panic will occur + */ + dadeleteflag(softc, old_method, 0); + dadeletemethodchoose(softc, DA_DELETE_DISABLE); + if (softc->delete_method == DA_DELETE_DISABLE) xpt_print(ccb->ccb_h.path, - "WRITE SAME(10) with UNMAP is not supported, " - "disabling BIO_DELETE.\n"); - dadeletemethodset(softc, DA_DELETE_DISABLE); - } else if (softc->delete_method == DA_DELETE_ZERO) { + "%s failed, disabling BIO_DELETE\n", + da_delete_method_desc[old_method]); + else xpt_print(ccb->ccb_h.path, - "WRITE SAME(10) is not supported, " - "disabling BIO_DELETE.\n"); - dadeletemethodset(softc, DA_DELETE_DISABLE); - } else - dadeletemethodset(softc, DA_DELETE_DISABLE); + "%s failed, switching to %s BIO_DELETE\n", + da_delete_method_desc[old_method], + da_delete_method_desc[softc->delete_method]); if (DA_SIO) { while ((bp = bioq_takefirst(&softc->delete_run_queue)) @@ -2201,7 +2606,7 @@ dadone(struct cam_periph *periph, union error = daerror(done_ccb, CAM_RETRY_SELTO, sf); if (error == ERESTART) { /* - * A retry was scheuled, so + * A retry was scheduled, so * just return. */ return; @@ -2297,16 +2702,18 @@ dadone(struct cam_periph *periph, union biodone(bp); break; } - case DA_CCB_PROBE: - case DA_CCB_PROBE2: + case DA_CCB_PROBE_RC: + case DA_CCB_PROBE_RC16: { struct scsi_read_capacity_data *rdcap; struct scsi_read_capacity_data_long *rcaplong; char announce_buf[80]; + int lbp; + lbp = 0; rdcap = NULL; rcaplong = NULL; - if (state == DA_CCB_PROBE) + if (state == DA_CCB_PROBE_RC) rdcap =(struct scsi_read_capacity_data *)csio->data_ptr; else rcaplong = (struct scsi_read_capacity_data_long *) @@ -2319,7 +2726,7 @@ dadone(struct cam_periph *periph, union u_int lbppbe; /* LB per physical block exponent. */ u_int lalba; /* Lowest aligned LBA. */ - if (state == DA_CCB_PROBE) { + if (state == DA_CCB_PROBE_RC) { block_size = scsi_4btoul(rdcap->length); maxsector = scsi_4btoul(rdcap->addr); lbppbe = 0; @@ -2334,9 +2741,9 @@ dadone(struct cam_periph *periph, union * with the short version of the command. */ if (maxsector == 0xffffffff) { - softc->state = DA_STATE_PROBE2; free(rdcap, M_SCSIDA); xpt_release_ccb(done_ccb); + softc->state = DA_STATE_PROBE_RC16; xpt_schedule(periph, priority); return; } @@ -2369,9 +2776,7 @@ dadone(struct cam_periph *periph, union */ dasetgeom(periph, block_size, maxsector, rcaplong, sizeof(*rcaplong)); - if ((lalba & SRC16_LBPME_A) - && softc->delete_method == DA_DELETE_NONE) - dadeletemethodset(softc, DA_DELETE_UNMAP); + lbp = (lalba & SRC16_LBPME_A); dp = &softc->params; snprintf(announce_buf, sizeof(announce_buf), "%juMB (%ju %u byte sectors: %dH %dS/T " @@ -2432,7 +2837,7 @@ dadone(struct cam_periph *periph, union * If we tried READ CAPACITY(16) and failed, * fallback to READ CAPACITY(10). */ - if ((state == DA_CCB_PROBE2) && + if ((state == DA_CCB_PROBE_RC16) && (softc->flags & DA_FLAG_CAN_RC16) && (((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INVALID) || @@ -2440,9 +2845,9 @@ dadone(struct cam_periph *periph, union (error_code == SSD_CURRENT_ERROR) && (sense_key == SSD_KEY_ILLEGAL_REQUEST)))) { softc->flags &= ~DA_FLAG_CAN_RC16; - softc->state = DA_STATE_PROBE; free(rdcap, M_SCSIDA); xpt_release_ccb(done_ccb); + softc->state = DA_STATE_PROBE_RC; xpt_schedule(periph, priority); return; } else @@ -2498,28 +2903,248 @@ dadone(struct cam_periph *periph, union taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); xpt_announce_periph(periph, announce_buf); + } else { xpt_print(periph->path, "fatal error, " "could not acquire reference count\n"); } } - /* - * Since our peripheral may be invalidated by an error - * above or an external event, we must release our CCB - * before releasing the probe lock on the peripheral. - * The peripheral will only go away once the last lock - * is removed, and we need it around for the CCB release - * operation. - */ + + /* Ensure re-probe doesn't see old delete. */ + softc->delete_available = 0; + if (lbp) { + /* + * Based on older SBC-3 spec revisions + * any of the UNMAP methods "may" be + * available via LBP given this flag so + * we flag all of them as availble and + * then remove those which further + * probes confirm aren't available + * later. + * + * We could also check readcap(16) p_type + * flag to exclude one or more invalid + * write same (X) types here + */ + dadeleteflag(softc, DA_DELETE_WS16, 1); + dadeleteflag(softc, DA_DELETE_WS10, 1); + dadeleteflag(softc, DA_DELETE_ZERO, 1); + dadeleteflag(softc, DA_DELETE_UNMAP, 1); + + xpt_release_ccb(done_ccb); + softc->state = DA_STATE_PROBE_LBP; + xpt_schedule(periph, priority); + return; + } + xpt_release_ccb(done_ccb); - softc->state = DA_STATE_NORMAL; - daschedule(periph); - wakeup(&softc->disk->d_mediasize); - if ((softc->flags & DA_FLAG_PROBED) == 0) { - softc->flags |= DA_FLAG_PROBED; - cam_periph_unhold(periph); - } else - cam_periph_release_locked(periph); + softc->state = DA_STATE_PROBE_BDC; + xpt_schedule(periph, priority); + return; + } + case DA_CCB_PROBE_LBP: + { + struct scsi_vpd_logical_block_prov *lbp; + + lbp = (struct scsi_vpd_logical_block_prov *)csio->data_ptr; + + if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { + /* + * T10/1799-D Revision 31 states at least one of these + * must be supported but we don't currently enforce this. + */ + dadeleteflag(softc, DA_DELETE_WS16, + (lbp->flags & SVPD_LBP_WS16)); + dadeleteflag(softc, DA_DELETE_WS10, + (lbp->flags & SVPD_LBP_WS10)); + dadeleteflag(softc, DA_DELETE_ZERO, + (lbp->flags & SVPD_LBP_WS10)); + dadeleteflag(softc, DA_DELETE_UNMAP, + (lbp->flags & SVPD_LBP_UNMAP)); + + if (lbp->flags & SVPD_LBP_UNMAP) { + free(lbp, M_SCSIDA); + xpt_release_ccb(done_ccb); + softc->state = DA_STATE_PROBE_BLK_LIMITS; + xpt_schedule(periph, priority); + return; + } + } else { + int error; + error = daerror(done_ccb, CAM_RETRY_SELTO, + SF_RETRY_UA|SF_NO_PRINT); + if (error == ERESTART) + return; + else if (error != 0) { + if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { + /* Don't wedge this device's queue */ + cam_release_devq(done_ccb->ccb_h.path, + /*relsim_flags*/0, + /*reduction*/0, + /*timeout*/0, + /*getcount_only*/0); + } + + /* + * Failure indicates we don't support any SBC-3 + * delete methods with UNMAP + */ + } + } + + free(lbp, M_SCSIDA); + xpt_release_ccb(done_ccb); + softc->state = DA_STATE_PROBE_BDC; + xpt_schedule(periph, priority); + return; + } + case DA_CCB_PROBE_BLK_LIMITS: + { + struct scsi_vpd_block_limits *block_limits; + + block_limits = (struct scsi_vpd_block_limits *)csio->data_ptr; + + if ((csio->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) { + uint32_t max_unmap_lba_cnt = scsi_4btoul( + block_limits->max_unmap_lba_cnt); + uint32_t max_unmap_blk_cnt = scsi_4btoul( + block_limits->max_unmap_blk_cnt); + uint64_t ws_max_blks = scsi_8btou64( + block_limits->max_write_same_length); + /* + * We should already support UNMAP but we check lba + * and block count to be sure + */ + if (max_unmap_lba_cnt != 0x00L && + max_unmap_blk_cnt != 0x00L) { + softc->unmap_max_lba = max_unmap_lba_cnt; + softc->unmap_max_ranges = min(max_unmap_blk_cnt, + UNMAP_MAX_RANGES); + } else { + /* + * Unexpected UNMAP limits which means the + * device doesn't actually support UNMAP + */ + dadeleteflag(softc, DA_DELETE_UNMAP, 0); + } + + if (ws_max_blks != 0x00L) + softc->ws_max_blks = ws_max_blks; + } else { + int error; + error = daerror(done_ccb, CAM_RETRY_SELTO, + SF_RETRY_UA|SF_NO_PRINT); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 14:38:51 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 16BB2F70; Tue, 4 Jun 2013 14:38:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 08BEF16ED; Tue, 4 Jun 2013 14:38:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54EcoLM027236; Tue, 4 Jun 2013 14:38:50 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54EcogP027235; Tue, 4 Jun 2013 14:38:50 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201306041438.r54EcogP027235@svn.freebsd.org> From: John Baldwin Date: Tue, 4 Jun 2013 14:38:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251378 - stable/9/sys/ofed/drivers/infiniband/ulp/sdp X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 14:38:51 -0000 Author: jhb Date: Tue Jun 4 14:38:50 2013 New Revision: 251378 URL: http://svnweb.freebsd.org/changeset/base/251378 Log: MFC 249066: Check for SS_NBIO in the socket state field rather than socket buffer flags. Modified: stable/9/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c ============================================================================== --- stable/9/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Tue Jun 4 13:55:03 2013 (r251377) +++ stable/9/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c Tue Jun 4 14:38:50 2013 (r251378) @@ -1267,7 +1267,7 @@ sdp_sorecv(struct socket *so, struct soc /* Socket buffer is empty and we shall not block. */ if (sb->sb_cc == 0 && - ((sb->sb_flags & SS_NBIO) || (flags & (MSG_DONTWAIT|MSG_NBIO)))) { + ((so->so_state & SS_NBIO) || (flags & (MSG_DONTWAIT|MSG_NBIO)))) { error = EAGAIN; goto out; } @@ -1297,7 +1297,7 @@ restart: /* Socket buffer got some data that we shall deliver now. */ if (sb->sb_cc > 0 && !(flags & MSG_WAITALL) && - ((sb->sb_flags & SS_NBIO) || + ((so->so_state & SS_NBIO) || (flags & (MSG_DONTWAIT|MSG_NBIO)) || sb->sb_cc >= sb->sb_lowat || sb->sb_cc >= uio->uio_resid || From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 16:16:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 82457BC; Tue, 4 Jun 2013 16:16:45 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 740821C2F; Tue, 4 Jun 2013 16:16:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54GGjp8062835; Tue, 4 Jun 2013 16:16:45 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54GGhaG062821; Tue, 4 Jun 2013 16:16:43 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306041616.r54GGhaG062821@svn.freebsd.org> From: Steven Hartland Date: Tue, 4 Jun 2013 16:16:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251386 - in stable/9/sys: cam cam/ata cam/scsi dev/ahci X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 16:16:45 -0000 Author: smh Date: Tue Jun 4 16:16:43 2013 New Revision: 251386 URL: http://svnweb.freebsd.org/changeset/base/251386 Log: MFC r250792: Added output of device QUIRKS for CAM and AHCI devices during boot. Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/cam_xpt.c stable/9/sys/cam/cam_xpt_periph.h stable/9/sys/cam/scsi/scsi_cd.c stable/9/sys/cam/scsi/scsi_ch.c stable/9/sys/cam/scsi/scsi_da.c stable/9/sys/cam/scsi/scsi_sa.c stable/9/sys/dev/ahci/ahci.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/ata/ata_da.c Tue Jun 4 16:16:43 2013 (r251386) @@ -95,6 +95,10 @@ typedef enum { ADA_Q_4K = 0x01, } ada_quirks; +#define ADA_Q_BIT_STRING \ + "\020" \ + "\0014K" + typedef enum { ADA_CCB_RAHEAD = 0x01, ADA_CCB_WCACHE = 0x02, @@ -1267,6 +1271,7 @@ adaregister(struct cam_periph *periph, v dp->secsize, dp->heads, dp->secs_per_track, dp->cylinders); xpt_announce_periph(periph, announce_buf); + xpt_announce_quirks(periph, softc->quirks, ADA_Q_BIT_STRING); if (legacy_id >= 0) printf("%s%d: Previously was known as ad%d\n", periph->periph_name, periph->unit_number, legacy_id); Modified: stable/9/sys/cam/cam_xpt.c ============================================================================== --- stable/9/sys/cam/cam_xpt.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/cam_xpt.c Tue Jun 4 16:16:43 2013 (r251386) @@ -1114,6 +1114,15 @@ xpt_announce_periph(struct cam_periph *p periph->unit_number, announce_string); } +void +xpt_announce_quirks(struct cam_periph *periph, int quirks, char *bit_string) +{ + if (quirks != 0) { + printf("%s%d: quirks=0x%b\n", periph->periph_name, + periph->unit_number, quirks, bit_string); + } +} + int xpt_getattr(char *buf, size_t len, const char *attr, struct cam_path *path) { Modified: stable/9/sys/cam/cam_xpt_periph.h ============================================================================== --- stable/9/sys/cam/cam_xpt_periph.h Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/cam_xpt_periph.h Tue Jun 4 16:16:43 2013 (r251386) @@ -46,6 +46,8 @@ void xpt_remove_periph(struct cam_perip int topology_lock_held); void xpt_announce_periph(struct cam_periph *periph, char *announce_string); +void xpt_announce_quirks(struct cam_periph *periph, + int quirks, char *bit_string); #endif #endif /* _CAM_CAM_XPT_PERIPH_H */ Modified: stable/9/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_cd.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/scsi/scsi_cd.c Tue Jun 4 16:16:43 2013 (r251386) @@ -92,6 +92,14 @@ typedef enum { CD_Q_10_BYTE_ONLY = 0x10 } cd_quirks; +#define CD_Q_BIT_STRING \ + "\020" \ + "\001NO_TOUCH" \ + "\002BCD_TRACKS" \ + "\003NO_CHANGER" \ + "\004CHANGER" \ + "\00510_BYTE_ONLY" + typedef enum { CD_FLAG_INVALID = 0x0001, CD_FLAG_NEW_DISC = 0x0002, @@ -1866,6 +1874,8 @@ cddone(struct cam_periph *periph, union free(rdcap, M_SCSICD); if (announce_buf[0] != '\0') { xpt_announce_periph(periph, announce_buf); + xpt_announce_quirks(periph, softc->quirks, + CD_Q_BIT_STRING); if (softc->flags & CD_FLAG_CHANGER) cdchangerschedule(softc); /* Modified: stable/9/sys/cam/scsi/scsi_ch.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_ch.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/scsi/scsi_ch.c Tue Jun 4 16:16:43 2013 (r251386) @@ -125,6 +125,10 @@ typedef enum { CH_Q_NO_DBD = 0x01 } ch_quirks; +#define CH_Q_BIT_STRING \ + "\020" \ + "\001NO_DBD" + #define ccb_state ppriv_field0 #define ccb_bp ppriv_ptr1 @@ -703,8 +707,11 @@ chdone(struct cam_periph *periph, union announce_buf[0] = '\0'; } } - if (announce_buf[0] != '\0') + if (announce_buf[0] != '\0') { xpt_announce_periph(periph, announce_buf); + xpt_announce_quirks(periph, softc->quirks, + CH_Q_BIT_STRING); + } softc->state = CH_STATE_NORMAL; free(mode_header, M_SCSICH); /* Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 16:16:43 2013 (r251386) @@ -100,6 +100,13 @@ typedef enum { DA_Q_4K = 0x08 } da_quirks; +#define DA_Q_BIT_STRING \ + "\020" \ + "\001NO_SYNC_CACHE" \ + "\002NO_6_BYTE" \ + "\003NO_PREVENT" \ + "\0044K" + typedef enum { DA_CCB_PROBE_RC = 0x01, DA_CCB_PROBE_RC16 = 0x02, @@ -2903,7 +2910,8 @@ dadone(struct cam_periph *periph, union taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); xpt_announce_periph(periph, announce_buf); - + xpt_announce_quirks(periph, softc->quirks, + DA_Q_BIT_STRING); } else { xpt_print(periph->path, "fatal error, " "could not acquire reference count\n"); Modified: stable/9/sys/cam/scsi/scsi_sa.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_sa.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/cam/scsi/scsi_sa.c Tue Jun 4 16:16:43 2013 (r251386) @@ -173,6 +173,17 @@ typedef enum { SA_QUIRK_NO_CPAGE = 0x80 /* Don't use DEVICE COMPRESSION page */ } sa_quirks; +#define SA_QUIRK_BIT_STRING \ + "\020" \ + "\001NOCOMP" \ + "\002FIXED" \ + "\003VARIABLE" \ + "\0042FM" \ + "\0051FM" \ + "\006NODREAD" \ + "\007NO_MODESEL" \ + "\010NO_CPAGE" + #define SAMODE(z) (dev2unit(z) & 0x3) #define SADENSITY(z) ((dev2unit(z) >> 2) & 0x3) #define SA_IS_CTRL(z) (dev2unit(z) & (1 << 4)) @@ -1546,6 +1557,7 @@ saregister(struct cam_periph *periph, vo xpt_register_async(AC_LOST_DEVICE, saasync, periph, periph->path); xpt_announce_periph(periph, NULL); + xpt_announce_quirks(periph, softc->quirks, SA_QUIRK_BIT_STRING); return (CAM_REQ_CMP); } Modified: stable/9/sys/dev/ahci/ahci.c ============================================================================== --- stable/9/sys/dev/ahci/ahci.c Tue Jun 4 16:02:00 2013 (r251385) +++ stable/9/sys/dev/ahci/ahci.c Tue Jun 4 16:16:43 2013 (r251386) @@ -121,6 +121,22 @@ static struct { #define AHCI_Q_NOCOUNT 1024 #define AHCI_Q_ALTSIG 2048 #define AHCI_Q_NOMSI 4096 + +#define AHCI_Q_BIT_STRING \ + "\020" \ + "\001NOFORCE" \ + "\002NOPMP" \ + "\003NONCQ" \ + "\0041CH" \ + "\0052CH" \ + "\0064CH" \ + "\007EDGEIS" \ + "\010SATA2" \ + "\011NOBSYRES" \ + "\012NOAA" \ + "\013NOCOUNT" \ + "\014ALTSIG" \ + "\015NOMSI" } ahci_ids[] = { {0x43801002, 0x00, "ATI IXP600", AHCI_Q_NOMSI}, {0x43901002, 0x00, "ATI IXP700", 0}, @@ -496,6 +512,10 @@ ahci_attach(device_t dev) "supported" : "not supported", (ctlr->caps & AHCI_CAP_FBSS) ? " with FBS" : ""); + if (ctlr->quirks != 0) { + device_printf(dev, "quirks=0x%b\n", ctlr->quirks, + AHCI_Q_BIT_STRING); + } if (bootverbose) { device_printf(dev, "Caps:%s%s%s%s%s%s%s%s %sGbps", (ctlr->caps & AHCI_CAP_64BIT) ? " 64bit":"", From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 16:32:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7A3ED920; Tue, 4 Jun 2013 16:32:18 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6C36D1CD5; Tue, 4 Jun 2013 16:32:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54GWIeY068586; Tue, 4 Jun 2013 16:32:18 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54GWI0k068584; Tue, 4 Jun 2013 16:32:18 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306041632.r54GWI0k068584@svn.freebsd.org> From: Steven Hartland Date: Tue, 4 Jun 2013 16:32:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251388 - in stable/9/sys/cam: ata scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 16:32:18 -0000 Author: smh Date: Tue Jun 4 16:32:17 2013 New Revision: 251388 URL: http://svnweb.freebsd.org/changeset/base/251388 Log: MFC r251061: More 4k quirks for SSD's Modified: stable/9/sys/cam/ata/ata_da.c stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/ata/ata_da.c ============================================================================== --- stable/9/sys/cam/ata/ata_da.c Tue Jun 4 16:24:38 2013 (r251387) +++ stable/9/sys/cam/ata/ata_da.c Tue Jun 4 16:32:17 2013 (r251388) @@ -274,12 +274,11 @@ static struct ada_quirk_entry ada_quirk_ { T_DIRECT, SIP_MEDIA_FIXED, "*", "WDC WD?????PVT*", "*" }, /*quirks*/ADA_Q_4K }, + /* SSDs */ { /* * Corsair Force 2 SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Corsair CSSD-F*", "*" }, /*quirks*/ADA_Q_4K @@ -288,100 +287,136 @@ static struct ada_quirk_entry ada_quirk_ /* * Corsair Force 3 SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Corsair Force 3*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * OCZ Agility 3 SSDs + * Corsair Force GT SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-AGILITY3*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "Corsair Force GT*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * OCZ Vertex 2 SSDs (inc pro series) + * Crucial M4 SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ?VERTEX2*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "M4-CT???M4SSD2*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * OCZ Vertex 3 SSDs + * Crucial RealSSD C300 SSDs + * 4k optimised + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "C300-CTFDDAC???MAG*", + "*" }, /*quirks*/ADA_Q_4K + }, + { + /* + * Intel 320 Series SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-VERTEX3*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "INTEL SSDSA2CW*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * SuperTalent TeraDrive CT SSDs + * Intel 330 Series SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "FTM??CT25H*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "INTEL SSDSC2CT*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * Crucial RealSSD C300 SSDs - * 4k optimised - * Submitted by: Steven Hartland - * PR: 169974 + * Intel 510 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "C300-CTFDDAC???MAG*", - "*" }, /*quirks*/ADA_Q_4K + { T_DIRECT, SIP_MEDIA_FIXED, "*", "INTEL SSDSC2MH*", "*" }, + /*quirks*/ADA_Q_4K }, { /* - * XceedIOPS SATA SSDs - * 4k optimised - * Submitted by: Steven Hartland - * PR: 169974 + * Intel 520 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "SG9XCS2D*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "INTEL SSDSC2BW*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * Intel 330 Series SSDs + * Kingston E100 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "KINGSTON SE100S3*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * Kingston HyperX 3k SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "KINGSTON SH103S3*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * OCZ Agility 3 SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "INTEL SSDSC2ct*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-AGILITY3*", "*" }, /*quirks*/ADA_Q_4K }, { /* * OCZ Deneva R Series SSDs * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ { T_DIRECT, SIP_MEDIA_FIXED, "*", "DENRSTE251M45*", "*" }, /*quirks*/ADA_Q_4K }, { /* - * Kingston HyperX 3k SSDs + * OCZ Vertex 2 SSDs (inc pro series) * 4k optimised & trim only works in 4k requests + 4k aligned - * Submitted by: Steven Hartland - * PR: 169974 */ - { T_DIRECT, SIP_MEDIA_FIXED, "*", "KINGSTON SH103S3*", "*" }, + { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ?VERTEX2*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * OCZ Vertex 3 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "OCZ-VERTEX3*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * Samsung 830 Series SSDs + * 4k optimised + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG SSD 830 Series*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * SuperTalent TeraDrive CT SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "FTM??CT25H*", "*" }, + /*quirks*/ADA_Q_4K + }, + { + /* + * XceedIOPS SATA SSDs + * 4k optimised + */ + { T_DIRECT, SIP_MEDIA_FIXED, "*", "SG9XCS2D*", "*" }, /*quirks*/ADA_Q_4K }, { Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 16:24:38 2013 (r251387) +++ stable/9/sys/cam/scsi/scsi_da.c Tue Jun 4 16:32:17 2013 (r251388) @@ -908,6 +908,151 @@ static struct da_quirk_entry da_quirk_ta {T_DIRECT, SIP_MEDIA_FIXED, "SAMSUNG", "HM250JI", "*"}, /*quirks*/ DA_Q_NO_SYNC_CACHE }, + /* SATA SSDs */ + { + /* + * Corsair Force 2 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "Corsair CSSD-F*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Corsair Force 3 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "Corsair Force 3*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Corsair Force GT SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "Corsair Force GT*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Crucial M4 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "M4-CT???M4SSD2*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Crucial RealSSD C300 SSDs + * 4k optimised + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "C300-CTFDDAC???MAG*", + "*" }, /*quirks*/DA_Q_4K + }, + { + /* + * Intel 320 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "INTEL SSDSA2CW*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Intel 330 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "INTEL SSDSC2CT*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Intel 510 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "INTEL SSDSC2MH*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Intel 520 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "INTEL SSDSC2BW*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Kingston E100 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "KINGSTON SE100S3*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Kingston HyperX 3k SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "KINGSTON SH103S3*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * OCZ Agility 3 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-AGILITY3*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * OCZ Deneva R Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "DENRSTE251M45*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * OCZ Vertex 2 SSDs (inc pro series) + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ?VERTEX2*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * OCZ Vertex 3 SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "OCZ-VERTEX3*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * Samsung 830 Series SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "SAMSUNG SSD 830 Series*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * SuperTalent TeraDrive CT SSDs + * 4k optimised & trim only works in 4k requests + 4k aligned + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "FTM??CT25H*", "*" }, + /*quirks*/DA_Q_4K + }, + { + /* + * XceedIOPS SATA SSDs + * 4k optimised + */ + { T_DIRECT, SIP_MEDIA_FIXED, "ATA", "SG9XCS2D*", "*" }, + /*quirks*/DA_Q_4K + }, }; static disk_strategy_t dastrategy; From owner-svn-src-stable-9@FreeBSD.ORG Tue Jun 4 22:29:20 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3E371B64; Tue, 4 Jun 2013 22:29:20 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2FE7E1F97; Tue, 4 Jun 2013 22:29:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r54MTKmo001826; Tue, 4 Jun 2013 22:29:20 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r54MTKSK001825; Tue, 4 Jun 2013 22:29:20 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201306042229.r54MTKSK001825@svn.freebsd.org> From: Rick Macklem Date: Tue, 4 Jun 2013 22:29:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251395 - stable/9/sys/fs/nfsclient X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Jun 2013 22:29:20 -0000 Author: rmacklem Date: Tue Jun 4 22:29:19 2013 New Revision: 251395 URL: http://svnweb.freebsd.org/changeset/base/251395 Log: MFC: r251079 Post-r248567, there were times when the client would return a truncated directory for some NFS servers. This turned out to be because the size of a directory reported by an NFS server can be smaller that the ufs-like directory created from the RPC XDR in the client. This patch fixes the problem by changing r248567 so that vnode_pager_setsize() is only done for regular files. Modified: stable/9/sys/fs/nfsclient/nfs_clport.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/nfsclient/nfs_clport.c ============================================================================== --- stable/9/sys/fs/nfsclient/nfs_clport.c Tue Jun 4 20:49:17 2013 (r251394) +++ stable/9/sys/fs/nfsclient/nfs_clport.c Tue Jun 4 22:29:19 2013 (r251395) @@ -454,12 +454,10 @@ nfscl_loadattrcache(struct vnode **vpp, np->n_size = vap->va_size; np->n_flag |= NSIZECHANGED; } - } else { - np->n_size = vap->va_size; - } - if (vap->va_type == VREG || vap->va_type == VDIR) { setnsize = 1; nsize = vap->va_size; + } else { + np->n_size = vap->va_size; } } /* From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 09:48:13 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F2FE89B6; Wed, 5 Jun 2013 09:48:12 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB06D1E8C; Wed, 5 Jun 2013 09:48:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r559mCBL026868; Wed, 5 Jun 2013 09:48:12 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r559mCfj026867; Wed, 5 Jun 2013 09:48:12 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306050948.r559mCfj026867@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 09:48:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251406 - stable/9/sys/dev/mfi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 09:48:13 -0000 Author: smh Date: Wed Jun 5 09:48:12 2013 New Revision: 251406 URL: http://svnweb.freebsd.org/changeset/base/251406 Log: MFC r247426: Add hw.mfi.cmd_timeout loader / sysctl tuneable. Modified: stable/9/sys/dev/mfi/mfi.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/mfi/mfi.c ============================================================================== --- stable/9/sys/dev/mfi/mfi.c Wed Jun 5 07:37:45 2013 (r251405) +++ stable/9/sys/dev/mfi/mfi.c Wed Jun 5 09:48:12 2013 (r251406) @@ -157,6 +157,11 @@ SYSCTL_INT(_hw_mfi, OID_AUTO, polled_cmd &mfi_polled_cmd_timeout, 0, "Polled command timeout - used for firmware flash etc (in seconds)"); +static int mfi_cmd_timeout = MFI_CMD_TIMEOUT; +TUNABLE_INT("hw.mfi.cmd_timeout", &mfi_cmd_timeout); +SYSCTL_INT(_hw_mfi, OID_AUTO, cmd_timeout, CTLFLAG_RWTUN, &mfi_cmd_timeout, + 0, "Command timeout (in seconds)"); + /* Management interface */ static d_open_t mfi_open; static d_close_t mfi_close; @@ -782,7 +787,7 @@ mfi_attach(struct mfi_softc *sc) /* Start the timeout watchdog */ callout_init(&sc->mfi_watchdog_callout, CALLOUT_MPSAFE); - callout_reset(&sc->mfi_watchdog_callout, MFI_CMD_TIMEOUT * hz, + callout_reset(&sc->mfi_watchdog_callout, mfi_cmd_timeout * hz, mfi_timeout, sc); if (sc->mfi_flags & MFI_FLAGS_TBOLT) { @@ -3703,7 +3708,7 @@ mfi_dump_all(void) break; device_printf(sc->mfi_dev, "Dumping\n\n"); timedout = 0; - deadline = time_uptime - MFI_CMD_TIMEOUT; + deadline = time_uptime - mfi_cmd_timeout; mtx_lock(&sc->mfi_io_lock); TAILQ_FOREACH(cm, &sc->mfi_busy, cm_link) { if (cm->cm_timestamp <= deadline) { @@ -3734,10 +3739,11 @@ mfi_timeout(void *data) time_t deadline; int timedout = 0; - deadline = time_uptime - MFI_CMD_TIMEOUT; + deadline = time_uptime - mfi_cmd_timeout; if (sc->adpreset == 0) { if (!mfi_tbolt_reset(sc)) { - callout_reset(&sc->mfi_watchdog_callout, MFI_CMD_TIMEOUT * hz, mfi_timeout, sc); + callout_reset(&sc->mfi_watchdog_callout, + mfi_cmd_timeout * hz, mfi_timeout, sc); return; } } @@ -3774,7 +3780,7 @@ mfi_timeout(void *data) mtx_unlock(&sc->mfi_io_lock); - callout_reset(&sc->mfi_watchdog_callout, MFI_CMD_TIMEOUT * hz, + callout_reset(&sc->mfi_watchdog_callout, mfi_cmd_timeout * hz, mfi_timeout, sc); if (0) From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 11:39:22 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 94BC97B; Wed, 5 Jun 2013 11:39:22 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 85BA7127A; Wed, 5 Jun 2013 11:39:22 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55BdMUm062879; Wed, 5 Jun 2013 11:39:22 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55BdMPO062878; Wed, 5 Jun 2013 11:39:22 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051139.r55BdMPO062878@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 11:39:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251414 - stable/9/sys/dev/mps X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 11:39:22 -0000 Author: smh Date: Wed Jun 5 11:39:22 2013 New Revision: 251414 URL: http://svnweb.freebsd.org/changeset/base/251414 Log: MFC r250206: Fix uninitialized warning in mps Modified: stable/9/sys/dev/mps/mps_mapping.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/mps/mps_mapping.c ============================================================================== --- stable/9/sys/dev/mps/mps_mapping.c Wed Jun 5 11:37:00 2013 (r251413) +++ stable/9/sys/dev/mps/mps_mapping.c Wed Jun 5 11:39:22 2013 (r251414) @@ -331,6 +331,8 @@ _mapping_get_high_missing_mt_idx(struct u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags); start_idx = 0; + start_idx_ir = 0; + end_idx_ir = 0; end_idx = sc->max_devices; if (ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_RESERVED_TARGETID_0) start_idx = 1; From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 11:42:04 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 618FC253; Wed, 5 Jun 2013 11:42:04 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 51FD3129F; Wed, 5 Jun 2013 11:42:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55Bg4XT064912; Wed, 5 Jun 2013 11:42:04 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55Bg4cP064911; Wed, 5 Jun 2013 11:42:04 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051142.r55Bg4cP064911@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 11:42:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251415 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 11:42:04 -0000 Author: smh Date: Wed Jun 5 11:42:03 2013 New Revision: 251415 URL: http://svnweb.freebsd.org/changeset/base/251415 Log: MFC r248579: Add missing descriptions for ZFS sysctls Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Wed Jun 5 11:39:22 2013 (r251414) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Wed Jun 5 11:42:03 2013 (r251415) @@ -78,10 +78,11 @@ SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, write_l &zfs_write_limit_max, 0, "Maximum data payload per txg"); TUNABLE_QUAD("vfs.zfs.write_limit_inflated", &zfs_write_limit_inflated); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, write_limit_inflated, CTLFLAG_RDTUN, - &zfs_write_limit_inflated, 0, ""); + &zfs_write_limit_inflated, 0, "Maximum size of the dynamic write limit"); TUNABLE_QUAD("vfs.zfs.write_limit_override", &zfs_write_limit_override); SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, write_limit_override, CTLFLAG_RDTUN, - &zfs_write_limit_override, 0, ""); + &zfs_write_limit_override, 0, + "Force a txg if dirty buffers exceed this value (bytes)"); int dsl_pool_open_special_dir(dsl_pool_t *dp, const char *name, dsl_dir_t **ddp) From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 11:46:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id DFA3D4EA; Wed, 5 Jun 2013 11:46:43 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D1F7512CA; Wed, 5 Jun 2013 11:46:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55Bkhjr065717; Wed, 5 Jun 2013 11:46:43 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55BkhlT065716; Wed, 5 Jun 2013 11:46:43 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051146.r55BkhlT065716@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 11:46:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251416 - stable/9/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 11:46:44 -0000 Author: smh Date: Wed Jun 5 11:46:43 2013 New Revision: 251416 URL: http://svnweb.freebsd.org/changeset/base/251416 Log: MFC r245479: Report pools which have a removed l2cache disk under zpool status -x Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c Wed Jun 5 11:42:03 2013 (r251415) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_status.c Wed Jun 5 11:46:43 2013 (r251416) @@ -150,6 +150,16 @@ find_vdev_problem(nvlist_t *vdev, int (* return (B_TRUE); } + /* + * Check any L2 cache devs + */ + if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_L2CACHE, &child, + &children) == 0) { + for (c = 0; c < children; c++) + if (find_vdev_problem(child[c], func)) + return (B_TRUE); + } + return (B_FALSE); } From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 11:55:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D99C999C; Wed, 5 Jun 2013 11:55:35 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB82B1318; Wed, 5 Jun 2013 11:55:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55BtZUa068871; Wed, 5 Jun 2013 11:55:35 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55BtZwt068870; Wed, 5 Jun 2013 11:55:35 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051155.r55BtZwt068870@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 11:55:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251417 - stable/9/cddl/contrib/opensolaris/lib/libzfs/common X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 11:55:35 -0000 Author: smh Date: Wed Jun 5 11:55:35 2013 New Revision: 251417 URL: http://svnweb.freebsd.org/changeset/base/251417 Log: MFC r244194: Fix zfs receive errors caused by snapshot replication being processed in random order. PR: kern/172259 Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/cddl/contrib/opensolaris/lib/libzfs/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Jun 5 11:46:43 2013 (r251416) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c Wed Jun 5 11:55:35 2013 (r251417) @@ -731,7 +731,7 @@ send_iterate_fs(zfs_handle_t *zhp, void 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, B_FALSE, send_iterate_snap, sd); + (void) zfs_iter_snapshots_sorted(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); @@ -1946,11 +1946,12 @@ recv_incremental_replication(libzfs_hand recvflags_t *flags, nvlist_t *stream_nv, avl_tree_t *stream_avl, nvlist_t *renamed) { - nvlist_t *local_nv; + nvlist_t *local_nv, *deleted = NULL; avl_tree_t *local_avl; nvpair_t *fselem, *nextfselem; char *fromsnap; char newname[ZFS_MAXNAMELEN]; + char guidname[32]; int error; boolean_t needagain, progress, recursive; char *s1, *s2; @@ -1966,6 +1967,8 @@ recv_incremental_replication(libzfs_hand again: needagain = progress = B_FALSE; + VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0)); + if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL, recursive, &local_nv, &local_avl)) != 0) return (error); @@ -2080,6 +2083,8 @@ again: needagain = B_TRUE; else progress = B_TRUE; + sprintf(guidname, "%lu", thisguid); + nvlist_add_boolean(deleted, guidname); continue; } @@ -2135,6 +2140,8 @@ again: needagain = B_TRUE; else progress = B_TRUE; + sprintf(guidname, "%lu", parent_fromsnap_guid); + nvlist_add_boolean(deleted, guidname); continue; } @@ -2157,6 +2164,24 @@ again: s2 = strrchr(stream_fsname, '/'); /* + * Check if we're going to rename based on parent guid change + * and the current parent guid was also deleted. If it was then + * rename will fail and is likely unneeded, so avoid this and + * force an early retry to determine the new + * parent_fromsnap_guid. + */ + if (stream_parent_fromsnap_guid != 0 && + parent_fromsnap_guid != 0 && + stream_parent_fromsnap_guid != parent_fromsnap_guid) { + sprintf(guidname, "%lu", parent_fromsnap_guid); + if (nvlist_exists(deleted, guidname)) { + progress = B_TRUE; + needagain = B_TRUE; + goto doagain; + } + } + + /* * Check for rename. If the exact receive path is specified, it * does not count as a rename, but we still need to check the * datasets beneath it. @@ -2210,8 +2235,10 @@ again: } } +doagain: fsavl_destroy(local_avl); nvlist_free(local_nv); + nvlist_free(deleted); if (needagain && progress) { /* do another pass to fix up temporary names */ From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 11:59:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8D41EB4D; Wed, 5 Jun 2013 11:59:36 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7EB8D1333; Wed, 5 Jun 2013 11:59:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55Bxaav069436; Wed, 5 Jun 2013 11:59:36 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55BxaOu069435; Wed, 5 Jun 2013 11:59:36 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051159.r55BxaOu069435@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 11:59:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251418 - stable/9/etc X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 11:59:36 -0000 Author: smh Date: Wed Jun 5 11:59:36 2013 New Revision: 251418 URL: http://svnweb.freebsd.org/changeset/base/251418 Log: MFC r245250: Allow perl scripts to be used in rc.d scripts PR: conf/117027 Modified: stable/9/etc/rc.subr Directory Properties: stable/9/etc/ (props changed) Modified: stable/9/etc/rc.subr ============================================================================== --- stable/9/etc/rc.subr Wed Jun 5 11:55:35 2013 (r251417) +++ stable/9/etc/rc.subr Wed Jun 5 11:59:36 2013 (r251418) @@ -331,7 +331,7 @@ _find_processes() _interpbn=${1##*/} _fp_args='_argv' _fp_match='case "$_argv" in - ${_interp}|"${_interp} "*|"${_interpbn}: ${_procname}"*)' + ${_interp}|"${_interp} "*|"[${_interpbn}]"|"${_interpbn}: ${_procname}"*)' else # a normal daemon _procnamebn=${_procname##*/} _fp_args='_arg0 _argv' From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 13:03:52 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id A14ECDD6; Wed, 5 Jun 2013 13:03:52 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8F62C186C; Wed, 5 Jun 2013 13:03:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55D3qmI090789; Wed, 5 Jun 2013 13:03:52 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55D3mxk090757; Wed, 5 Jun 2013 13:03:48 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306051303.r55D3mxk090757@svn.freebsd.org> From: Steven Hartland Date: Wed, 5 Jun 2013 13:03:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251419 - in stable/9: . cddl/lib/libzpool sys/cddl/compat/opensolaris/kern sys/cddl/compat/opensolaris/sys sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/u... X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 13:03:52 -0000 Author: smh Date: Wed Jun 5 13:03:47 2013 New Revision: 251419 URL: http://svnweb.freebsd.org/changeset/base/251419 Log: Added ZFS TRIM support which is enabled by default. To disable ZFS TRIM support set vfs.zfs.trim.enabled=0 in loader.conf. Creating new ZFS pools and adding new devices to existing pools first performs a full device level TRIM which can take a significant amount of time. The sysctl vfs.zfs.vdev.trim_on_init can be set to 0 to disable this behaviour. ZFS TRIM requires the underlying device support BIO_DELETE which is currently provided by methods such as ATA TRIM and SCSI UNMAP via CAM, which are typically supported by SSD's. Stats for ZFS TRIM can be monitored by looking at the sysctl's under kstat.zfs.misc.zio_trim. MFC r240868: Add TRIM support MFC r244155: Renamed zfs trim stats MFC r244187: Upgrade TRIM free request sizes optimisation MFC r244188: Added vfs.zfs.vdev.trim_on_init sysctl MFC r248572: Add TRIM support for L2ARC MFC r248574: Improve TXG handling in the TRIM module MFC r248575: TRIM cache devices based on time instead of TXGs MFC r248576: Names the ZFS TRIM thread MFC r248577: Optimisation of TRIM processing MFC r248602: Fix for building libzpool under i386 MFC r249921: Enabled ZFS TRIM by default Added: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h - copied, changed from r240868, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c - copied, changed from r240868, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c Modified: stable/9/UPDATING stable/9/cddl/lib/libzpool/Makefile stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c stable/9/sys/cddl/compat/opensolaris/sys/dkio.h stable/9/sys/cddl/compat/opensolaris/sys/kstat.h stable/9/sys/cddl/compat/opensolaris/sys/time.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zil.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c stable/9/sys/modules/zfs/Makefile Directory Properties: stable/9/cddl/lib/ (props changed) stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/UPDATING ============================================================================== --- stable/9/UPDATING Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/UPDATING Wed Jun 5 13:03:47 2013 (r251419) @@ -11,6 +11,22 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +20130605: + Added ZFS TRIM support which is enabled by default. To disable + ZFS TRIM support set vfs.zfs.trim.enabled=0 in loader.conf. + + Creating new ZFS pools and adding new devices to existing pools + first performs a full device level TRIM which can take a significant + amount of time. The sysctl vfs.zfs.vdev.trim_on_init can be set to 0 + to disable this behaviour. + + ZFS TRIM requires the underlying device support BIO_DELETE which + is currently provided by methods such as ATA TRIM and SCSI UNMAP + via CAM, which are typically supported by SSD's. + + Stats for ZFS TRIM can be monitored by looking at the sysctl's + under kstat.zfs.misc.zio_trim. + 20130524: `list' command has been added to hastctl(8). For now, it is full equivalent of `status' command. Modified: stable/9/cddl/lib/libzpool/Makefile ============================================================================== --- stable/9/cddl/lib/libzpool/Makefile Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/cddl/lib/libzpool/Makefile Wed Jun 5 13:03:47 2013 (r251419) @@ -26,7 +26,7 @@ ATOMIC_SRCS= opensolaris_atomic.c LIB= zpool -ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c +ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c trim_map.c ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/} KERNEL_SRCS= kernel.c taskq.c util.c LIST_SRCS= list.c Modified: stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c ============================================================================== --- stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Wed Jun 5 13:03:47 2013 (r251419) @@ -118,7 +118,7 @@ kstat_install(kstat_t *ksp) SYSCTL_ADD_PROC(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(ksp->ks_sysctl_root), OID_AUTO, ksent->name, CTLTYPE_U64 | CTLFLAG_RD, ksent, sizeof(*ksent), - kstat_sysctl, "QU", ""); + kstat_sysctl, "QU", ksent->desc); } } Modified: stable/9/sys/cddl/compat/opensolaris/sys/dkio.h ============================================================================== --- stable/9/sys/cddl/compat/opensolaris/sys/dkio.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/compat/opensolaris/sys/dkio.h Wed Jun 5 13:03:47 2013 (r251419) @@ -75,6 +75,8 @@ extern "C" { */ #define DKIOCFLUSHWRITECACHE (DKIOC|34) /* flush cache to phys medium */ +#define DKIOCTRIM (DKIOC|35) /* TRIM a block */ + struct dk_callback { void (*dkc_callback)(void *dkc_cookie, int error); void *dkc_cookie; Modified: stable/9/sys/cddl/compat/opensolaris/sys/kstat.h ============================================================================== --- stable/9/sys/cddl/compat/opensolaris/sys/kstat.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/compat/opensolaris/sys/kstat.h Wed Jun 5 13:03:47 2013 (r251419) @@ -53,6 +53,8 @@ typedef struct kstat_named { #define KSTAT_DATA_INT64 3 #define KSTAT_DATA_UINT64 4 uchar_t data_type; +#define KSTAT_DESCLEN 128 + char desc[KSTAT_DESCLEN]; union { uint64_t ui64; } value; Modified: stable/9/sys/cddl/compat/opensolaris/sys/time.h ============================================================================== --- stable/9/sys/cddl/compat/opensolaris/sys/time.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/compat/opensolaris/sys/time.h Wed Jun 5 13:03:47 2013 (r251419) @@ -35,6 +35,7 @@ #define MILLISEC 1000 #define MICROSEC 1000000 #define NANOSEC 1000000000 +#define TIME_MAX LLONG_MAX typedef longlong_t hrtime_t; Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Jun 5 13:03:47 2013 (r251419) @@ -130,6 +130,7 @@ #endif #include #include +#include #include #include @@ -1691,6 +1692,8 @@ arc_hdr_destroy(arc_buf_hdr_t *hdr) } if (l2hdr != NULL) { + trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr, + hdr->b_size, 0); list_remove(l2hdr->b_dev->l2ad_buflist, hdr); ARCSTAT_INCR(arcstat_l2_size, -hdr->b_size); kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t)); @@ -3528,6 +3531,8 @@ arc_release(arc_buf_t *buf, void *tag) buf->b_private = NULL; if (l2hdr) { + trim_map_free(l2hdr->b_dev->l2ad_vdev, l2hdr->b_daddr, + hdr->b_size, 0); list_remove(l2hdr->b_dev->l2ad_buflist, hdr); kmem_free(l2hdr, sizeof (l2arc_buf_hdr_t)); ARCSTAT_INCR(arcstat_l2_size, -buf_size); @@ -4442,6 +4447,8 @@ l2arc_write_done(zio_t *zio) list_remove(buflist, ab); abl2 = ab->b_l2hdr; ab->b_l2hdr = NULL; + trim_map_free(abl2->b_dev->l2ad_vdev, abl2->b_daddr, + ab->b_size, 0); kmem_free(abl2, sizeof (l2arc_buf_hdr_t)); ARCSTAT_INCR(arcstat_l2_size, -ab->b_size); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Wed Jun 5 13:03:47 2013 (r251419) @@ -397,7 +397,8 @@ void dsl_free_sync(zio_t *pio, dsl_pool_t *dp, uint64_t txg, const blkptr_t *bpp) { ASSERT(dsl_pool_sync_context(dp)); - zio_nowait(zio_free_sync(pio, dp->dp_spa, txg, bpp, pio->io_flags)); + zio_nowait(zio_free_sync(pio, dp->dp_spa, txg, bpp, BP_GET_PSIZE(bpp), + pio->io_flags)); } static uint64_t @@ -1364,7 +1365,7 @@ dsl_scan_free_block_cb(void *arg, const } zio_nowait(zio_free_sync(scn->scn_zio_root, scn->scn_dp->dp_spa, - dmu_tx_get_txg(tx), bp, 0)); + dmu_tx_get_txg(tx), bp, BP_GET_PSIZE(bp), 0)); dsl_dir_diduse_space(tx->tx_pool->dp_free_dir, DD_USED_HEAD, -bp_get_dsize_sync(scn->scn_dp->dp_spa, bp), -BP_GET_PSIZE(bp), -BP_GET_UCSIZE(bp), tx); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Jun 5 13:03:47 2013 (r251419) @@ -67,6 +67,7 @@ #include #include #include +#include #ifdef _KERNEL #include @@ -1001,6 +1002,11 @@ spa_activate(spa_t *spa, int mode) spa_create_zio_taskqs(spa); } + /* + * Start TRIM thread. + */ + trim_thread_create(spa); + list_create(&spa->spa_config_dirty_list, sizeof (vdev_t), offsetof(vdev_t, vdev_config_dirty_node)); list_create(&spa->spa_state_dirty_list, sizeof (vdev_t), @@ -1029,6 +1035,12 @@ spa_deactivate(spa_t *spa) ASSERT(spa->spa_async_zio_root == NULL); ASSERT(spa->spa_state != POOL_STATE_UNINITIALIZED); + /* + * Stop TRIM thread in case spa_unload() wasn't called directly + * before spa_deactivate(). + */ + trim_thread_destroy(spa); + txg_list_destroy(&spa->spa_vdev_txg_list); list_destroy(&spa->spa_config_dirty_list); @@ -1145,6 +1157,11 @@ spa_unload(spa_t *spa) ASSERT(MUTEX_HELD(&spa_namespace_lock)); /* + * Stop TRIM thread. + */ + trim_thread_destroy(spa); + + /* * Stop async tasks. */ spa_async_suspend(spa); @@ -5875,7 +5892,7 @@ spa_free_sync_cb(void *arg, const blkptr zio_t *zio = arg; zio_nowait(zio_free_sync(zio, zio->io_spa, dmu_tx_get_txg(tx), bp, - zio->io_flags)); + BP_GET_PSIZE(bp), zio->io_flags)); return (0); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h Wed Jun 5 13:03:47 2013 (r251419) @@ -221,6 +221,9 @@ struct spa { spa_proc_state_t spa_proc_state; /* see definition */ struct proc *spa_proc; /* "zpool-poolname" process */ uint64_t spa_did; /* if procp != p0, did of t1 */ + kthread_t *spa_trim_thread; /* thread sending TRIM I/Os */ + kmutex_t spa_trim_lock; /* protects spa_trim_cv */ + kcondvar_t spa_trim_cv; /* used to notify TRIM thread */ boolean_t spa_autoreplace; /* autoreplace set in open */ int spa_vdev_locks; /* locks grabbed */ uint64_t spa_creation_version; /* version at pool creation */ Copied and modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h (from r240868, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h) ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h Sun Sep 23 19:40:58 2012 (r240868, copy source) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/trim_map.h Wed Jun 5 13:03:47 2013 (r251419) @@ -36,7 +36,7 @@ extern "C" { extern void trim_map_create(vdev_t *vd); extern void trim_map_destroy(vdev_t *vd); -extern void trim_map_free(zio_t *zio); +extern void trim_map_free(vdev_t *vd, uint64_t offset, uint64_t size, uint64_t txg); extern boolean_t trim_map_write_start(zio_t *zio); extern void trim_map_write_done(zio_t *zio); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev.h Wed Jun 5 13:03:47 2013 (r251419) @@ -46,6 +46,7 @@ typedef enum vdev_dtl_type { } vdev_dtl_type_t; extern boolean_t zfs_nocacheflush; +extern boolean_t zfs_trim_enabled; extern int vdev_open(vdev_t *); extern void vdev_open_children(vdev_t *); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/vdev_impl.h Wed Jun 5 13:03:47 2013 (r251419) @@ -183,6 +183,7 @@ struct vdev { uint64_t vdev_unspare; /* unspare when resilvering done */ hrtime_t vdev_last_try; /* last reopen time */ boolean_t vdev_nowritecache; /* true if flushwritecache failed */ + boolean_t vdev_notrim; /* true if trim failed */ boolean_t vdev_checkremove; /* temporary online test */ boolean_t vdev_forcefault; /* force online fault */ boolean_t vdev_splitting; /* split or repair in progress */ @@ -198,6 +199,7 @@ struct vdev { spa_aux_vdev_t *vdev_aux; /* for l2cache vdevs */ zio_t *vdev_probe_zio; /* root of current probe */ vdev_aux_t vdev_label_aux; /* on-disk aux state */ + struct trim_map *vdev_trimmap; /* * For DTrace to work in userland (libzpool) context, these fields must Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio.h Wed Jun 5 13:03:47 2013 (r251419) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -137,7 +138,8 @@ enum zio_compress { #define ZIO_PRIORITY_RESILVER (zio_priority_table[9]) #define ZIO_PRIORITY_SCRUB (zio_priority_table[10]) #define ZIO_PRIORITY_DDT_PREFETCH (zio_priority_table[11]) -#define ZIO_PRIORITY_TABLE_SIZE 12 +#define ZIO_PRIORITY_TRIM (zio_priority_table[12]) +#define ZIO_PRIORITY_TABLE_SIZE 13 #define ZIO_PIPELINE_CONTINUE 0x100 #define ZIO_PIPELINE_STOP 0x101 @@ -367,6 +369,39 @@ typedef struct zio_link { list_node_t zl_child_node; } zio_link_t; +/* + * Used for TRIM kstat. + */ +typedef struct zio_trim_stats { + /* + * Number of bytes successfully TRIMmed. + */ + kstat_named_t bytes; + + /* + * Number of successful TRIM requests. + */ + kstat_named_t success; + + /* + * Number of TRIM requests that failed because TRIM is not + * supported. + */ + kstat_named_t unsupported; + + /* + * Number of TRIM requests that failed for other reasons. + */ + kstat_named_t failed; +} zio_trim_stats_t; + +extern zio_trim_stats_t zio_trim_stats; + +#define ZIO_TRIM_STAT_INCR(stat, val) \ + atomic_add_64(&zio_trim_stats.stat.value.ui64, (val)); +#define ZIO_TRIM_STAT_BUMP(stat) \ + ZIO_TRIM_STAT_INCR(stat, 1); + struct zio { /* Core information about this I/O */ zbookmark_t io_bookmark; @@ -441,6 +476,8 @@ struct zio { /* FreeBSD only. */ struct ostask io_task; #endif + avl_node_t io_trim_node; + list_node_t io_trim_link; }; extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd, @@ -472,8 +509,8 @@ extern zio_t *zio_claim(zio_t *pio, spa_ zio_done_func_t *done, void *priv, enum zio_flag flags); extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, - zio_done_func_t *done, void *priv, int priority, - enum zio_flag flags); + uint64_t offset, uint64_t size, zio_done_func_t *done, void *priv, + int priority, enum zio_flag flags); extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size, void *data, int checksum, @@ -486,12 +523,14 @@ extern zio_t *zio_write_phys(zio_t *pio, boolean_t labels); extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, - const blkptr_t *bp, enum zio_flag flags); + const blkptr_t *bp, uint64_t size, enum zio_flag flags); extern int zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, blkptr_t *old_bp, uint64_t size, boolean_t use_slog); extern void zio_free_zil(spa_t *spa, uint64_t txg, blkptr_t *bp); extern void zio_flush(zio_t *zio, vdev_t *vd); +extern zio_t *zio_trim(zio_t *zio, spa_t *spa, vdev_t *vd, uint64_t offset, + uint64_t size); extern void zio_shrink(zio_t *zio, uint64_t size); extern int zio_wait(zio_t *zio); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zio_impl.h Wed Jun 5 13:03:47 2013 (r251419) @@ -130,9 +130,9 @@ enum zio_stage { ZIO_STAGE_READY = 1 << 16, /* RWFCI */ - ZIO_STAGE_VDEV_IO_START = 1 << 17, /* RW--I */ - ZIO_STAGE_VDEV_IO_DONE = 1 << 18, /* RW--- */ - ZIO_STAGE_VDEV_IO_ASSESS = 1 << 19, /* RW--I */ + ZIO_STAGE_VDEV_IO_START = 1 << 17, /* RWF-I */ + ZIO_STAGE_VDEV_IO_DONE = 1 << 18, /* RWF-- */ + ZIO_STAGE_VDEV_IO_ASSESS = 1 << 19, /* RWF-I */ ZIO_STAGE_CHECKSUM_VERIFY = 1 << 20, /* R---- */ @@ -214,7 +214,9 @@ enum zio_stage { (ZIO_INTERLOCK_STAGES | \ ZIO_STAGE_FREE_BP_INIT | \ ZIO_STAGE_ISSUE_ASYNC | \ - ZIO_STAGE_DVA_FREE) + ZIO_STAGE_DVA_FREE | \ + ZIO_STAGE_VDEV_IO_START | \ + ZIO_STAGE_VDEV_IO_ASSESS) #define ZIO_DDT_FREE_PIPELINE \ (ZIO_INTERLOCK_STAGES | \ Copied and modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c (from r240868, head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c) ============================================================================== --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c Sun Sep 23 19:40:58 2012 (r240868, copy source) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/trim_map.c Wed Jun 5 13:03:47 2013 (r251419) @@ -27,6 +27,30 @@ #include #include #include +#include + +/* + * Calculate the zio end, upgrading based on ashift which would be + * done by zio_vdev_io_start. + * + * This makes free range consolidation much more effective + * than it would otherwise be as well as ensuring that entire + * blocks are invalidated by writes. + */ +#define TRIM_ZIO_END(vd, offset, size) (offset + \ + P2ROUNDUP(size, 1ULL << vd->vdev_top->vdev_ashift)) + +#define TRIM_MAP_SINC(tm, size) \ + atomic_add_64(&(tm)->tm_bytes, (size)) + +#define TRIM_MAP_SDEC(tm, size) \ + atomic_add_64(&(tm)->tm_bytes, -(size)) + +#define TRIM_MAP_QINC(tm) \ + atomic_inc_64(&(tm)->tm_pending); \ + +#define TRIM_MAP_QDEC(tm) \ + atomic_dec_64(&(tm)->tm_pending); typedef struct trim_map { list_t tm_head; /* List of segments sorted by txg. */ @@ -35,6 +59,8 @@ typedef struct trim_map { avl_tree_t tm_inflight_writes; /* AVL tree of in-flight writes. */ list_t tm_pending_writes; /* Writes blocked on in-flight frees. */ kmutex_t tm_lock; + uint64_t tm_pending; /* Count of pending TRIMs. */ + uint64_t tm_bytes; /* Total size in bytes of queued TRIMs. */ } trim_map_t; typedef struct trim_seg { @@ -43,16 +69,46 @@ typedef struct trim_seg { uint64_t ts_start; /* Starting offset of this segment. */ uint64_t ts_end; /* Ending offset (non-inclusive). */ uint64_t ts_txg; /* Segment creation txg. */ + hrtime_t ts_time; /* Segment creation time. */ } trim_seg_t; -extern boolean_t zfs_notrim; +extern boolean_t zfs_trim_enabled; + +static u_int trim_txg_delay = 32; +static u_int trim_timeout = 30; +static u_int trim_max_interval = 1; +/* Limit outstanding TRIMs to 2G (max size for a single TRIM request) */ +static uint64_t trim_vdev_max_bytes = 2147483648; +/* Limit outstanding TRIMs to 64 (max ranges for a single TRIM request) */ +static u_int trim_vdev_max_pending = 64; SYSCTL_DECL(_vfs_zfs); -/* Delay TRIMs by that many TXGs. */ -static int trim_txg_limit = 64; -TUNABLE_INT("vfs.zfs.trim_txg_limit", &trim_txg_limit); -SYSCTL_INT(_vfs_zfs, OID_AUTO, trim_txg_limit, CTLFLAG_RW, &trim_txg_limit, 0, - "Delay TRIMs by that many TXGs."); +SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RD, 0, "ZFS TRIM"); + +TUNABLE_INT("vfs.zfs.trim.txg_delay", &trim_txg_delay); +SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, txg_delay, CTLFLAG_RWTUN, &trim_txg_delay, + 0, "Delay TRIMs by up to this many TXGs"); + +TUNABLE_INT("vfs.zfs.trim.timeout", &trim_timeout); +SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, timeout, CTLFLAG_RWTUN, &trim_timeout, 0, + "Delay TRIMs by up to this many seconds"); + +TUNABLE_INT("vfs.zfs.trim.max_interval", &trim_max_interval); +SYSCTL_UINT(_vfs_zfs_trim, OID_AUTO, max_interval, CTLFLAG_RWTUN, + &trim_max_interval, 0, + "Maximum interval between TRIM queue processing (seconds)"); + +SYSCTL_DECL(_vfs_zfs_vdev); +TUNABLE_QUAD("vfs.zfs.vdev.trim_max_bytes", &trim_vdev_max_bytes); +SYSCTL_QUAD(_vfs_zfs_vdev, OID_AUTO, trim_max_bytes, CTLFLAG_RWTUN, + &trim_vdev_max_bytes, 0, + "Maximum pending TRIM bytes for a vdev"); + +TUNABLE_INT("vfs.zfs.vdev.trim_max_pending", &trim_vdev_max_pending); +SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, trim_max_pending, CTLFLAG_RWTUN, + &trim_vdev_max_pending, 0, + "Maximum pending TRIM segments for a vdev"); + static void trim_map_vdev_commit_done(spa_t *spa, vdev_t *vd); @@ -101,7 +157,7 @@ trim_map_create(vdev_t *vd) ASSERT(vd->vdev_ops->vdev_op_leaf); - if (zfs_notrim) + if (!zfs_trim_enabled) return; tm = kmem_zalloc(sizeof (*tm), KM_SLEEP); @@ -127,7 +183,7 @@ trim_map_destroy(vdev_t *vd) ASSERT(vd->vdev_ops->vdev_op_leaf); - if (zfs_notrim) + if (!zfs_trim_enabled) return; tm = vd->vdev_trimmap; @@ -146,6 +202,8 @@ trim_map_destroy(vdev_t *vd) avl_remove(&tm->tm_queued_frees, ts); list_remove(&tm->tm_head, ts); kmem_free(ts, sizeof (*ts)); + TRIM_MAP_SDEC(tm, ts->ts_end - ts->ts_start); + TRIM_MAP_QDEC(tm); } mutex_exit(&tm->tm_lock); @@ -165,10 +223,12 @@ trim_map_segment_add(trim_map_t *tm, uin avl_index_t where; trim_seg_t tsearch, *ts_before, *ts_after, *ts; boolean_t merge_before, merge_after; + hrtime_t time; ASSERT(MUTEX_HELD(&tm->tm_lock)); VERIFY(start < end); + time = gethrtime(); tsearch.ts_start = start; tsearch.ts_end = end; @@ -184,25 +244,36 @@ trim_map_segment_add(trim_map_t *tm, uin ts_before = avl_nearest(&tm->tm_queued_frees, where, AVL_BEFORE); ts_after = avl_nearest(&tm->tm_queued_frees, where, AVL_AFTER); - merge_before = (ts_before != NULL && ts_before->ts_end == start && - ts_before->ts_txg == txg); - merge_after = (ts_after != NULL && ts_after->ts_start == end && - ts_after->ts_txg == txg); + merge_before = (ts_before != NULL && ts_before->ts_end == start); + merge_after = (ts_after != NULL && ts_after->ts_start == end); if (merge_before && merge_after) { + TRIM_MAP_SINC(tm, ts_after->ts_start - ts_before->ts_end); + TRIM_MAP_QDEC(tm); avl_remove(&tm->tm_queued_frees, ts_before); list_remove(&tm->tm_head, ts_before); ts_after->ts_start = ts_before->ts_start; + ts_after->ts_txg = txg; + ts_after->ts_time = time; kmem_free(ts_before, sizeof (*ts_before)); } else if (merge_before) { + TRIM_MAP_SINC(tm, end - ts_before->ts_end); ts_before->ts_end = end; + ts_before->ts_txg = txg; + ts_before->ts_time = time; } else if (merge_after) { + TRIM_MAP_SINC(tm, ts_after->ts_start - start); ts_after->ts_start = start; + ts_after->ts_txg = txg; + ts_after->ts_time = time; } else { + TRIM_MAP_SINC(tm, end - start); + TRIM_MAP_QINC(tm); ts = kmem_alloc(sizeof (*ts), KM_SLEEP); ts->ts_start = start; ts->ts_end = end; ts->ts_txg = txg; + ts->ts_time = time; avl_insert(&tm->tm_queued_frees, ts, where); list_insert_tail(&tm->tm_head, ts); } @@ -220,14 +291,17 @@ trim_map_segment_remove(trim_map_t *tm, left_over = (ts->ts_start < start); right_over = (ts->ts_end > end); + TRIM_MAP_SDEC(tm, end - start); if (left_over && right_over) { nts = kmem_alloc(sizeof (*nts), KM_SLEEP); nts->ts_start = end; nts->ts_end = ts->ts_end; nts->ts_txg = ts->ts_txg; + nts->ts_time = ts->ts_time; ts->ts_end = start; avl_insert_here(&tm->tm_queued_frees, nts, ts, AVL_AFTER); list_insert_after(&tm->tm_head, ts, nts); + TRIM_MAP_QINC(tm); } else if (left_over) { ts->ts_end = start; } else if (right_over) { @@ -235,6 +309,7 @@ trim_map_segment_remove(trim_map_t *tm, } else { avl_remove(&tm->tm_queued_frees, ts); list_remove(&tm->tm_head, ts); + TRIM_MAP_QDEC(tm); kmem_free(ts, sizeof (*ts)); } } @@ -261,17 +336,15 @@ trim_map_free_locked(trim_map_t *tm, uin } void -trim_map_free(zio_t *zio) +trim_map_free(vdev_t *vd, uint64_t offset, uint64_t size, uint64_t txg) { - vdev_t *vd = zio->io_vd; trim_map_t *tm = vd->vdev_trimmap; - if (zfs_notrim || vd->vdev_notrim || tm == NULL) + if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL) return; mutex_enter(&tm->tm_lock); - trim_map_free_locked(tm, zio->io_offset, zio->io_offset + zio->io_size, - vd->vdev_spa->spa_syncing_txg); + trim_map_free_locked(tm, offset, TRIM_ZIO_END(vd, offset, size), txg); mutex_exit(&tm->tm_lock); } @@ -284,11 +357,11 @@ trim_map_write_start(zio_t *zio) boolean_t left_over, right_over; uint64_t start, end; - if (zfs_notrim || vd->vdev_notrim || tm == NULL) + if (!zfs_trim_enabled || vd->vdev_notrim || tm == NULL) return (B_TRUE); start = zio->io_offset; - end = start + zio->io_size; + end = TRIM_ZIO_END(zio->io_vd, start, zio->io_size); tsearch.ts_start = start; tsearch.ts_end = end; @@ -331,7 +404,7 @@ trim_map_write_done(zio_t *zio) * Don't check for vdev_notrim, since the write could have * started before vdev_notrim was set. */ - if (zfs_notrim || tm == NULL) + if (!zfs_trim_enabled || tm == NULL) return; mutex_enter(&tm->tm_lock); @@ -348,19 +421,25 @@ trim_map_write_done(zio_t *zio) } /* - * Return the oldest segment (the one with the lowest txg) or false if - * the list is empty or the first element's txg is greater than txg given - * as function argument. + * Return the oldest segment (the one with the lowest txg / time) or NULL if: + * 1. The list is empty + * 2. The first element's txg is greater than txgsafe + * 3. The first element's txg is not greater than the txg argument and the + * the first element's time is not greater than time argument */ static trim_seg_t * -trim_map_first(trim_map_t *tm, uint64_t txg) +trim_map_first(trim_map_t *tm, uint64_t txg, uint64_t txgsafe, hrtime_t time) { trim_seg_t *ts; ASSERT(MUTEX_HELD(&tm->tm_lock)); + VERIFY(txgsafe >= txg); ts = list_head(&tm->tm_head); - if (ts != NULL && ts->ts_txg <= txg) + if (ts != NULL && ts->ts_txg <= txgsafe && + (ts->ts_txg <= txg || ts->ts_time <= time || + tm->tm_bytes > trim_vdev_max_bytes || + tm->tm_pending > trim_vdev_max_pending)) return (ts); return (NULL); } @@ -370,26 +449,37 @@ trim_map_vdev_commit(spa_t *spa, zio_t * { trim_map_t *tm = vd->vdev_trimmap; trim_seg_t *ts; - uint64_t start, size, txglimit; + uint64_t size, txgtarget, txgsafe; + hrtime_t timelimit; ASSERT(vd->vdev_ops->vdev_op_leaf); if (tm == NULL) return; - txglimit = MIN(spa->spa_syncing_txg, spa_freeze_txg(spa)) - - trim_txg_limit; + timelimit = gethrtime() - trim_timeout * NANOSEC; + if (vd->vdev_isl2cache) { + txgsafe = UINT64_MAX; + txgtarget = UINT64_MAX; + } else { + txgsafe = MIN(spa_last_synced_txg(spa), spa_freeze_txg(spa)); + if (txgsafe > trim_txg_delay) + txgtarget = txgsafe - trim_txg_delay; + else + txgtarget = 0; + } mutex_enter(&tm->tm_lock); - /* - * Loop until we send all frees up to the txglimit. - */ - while ((ts = trim_map_first(tm, txglimit)) != NULL) { + /* Loop until we have sent all outstanding free's */ + while ((ts = trim_map_first(tm, txgtarget, txgsafe, timelimit)) + != NULL) { list_remove(&tm->tm_head, ts); avl_remove(&tm->tm_queued_frees, ts); avl_add(&tm->tm_inflight_frees, ts); - zio_nowait(zio_trim(zio, spa, vd, ts->ts_start, - ts->ts_end - ts->ts_start)); + size = ts->ts_end - ts->ts_start; + zio_nowait(zio_trim(zio, spa, vd, ts->ts_start, size)); + TRIM_MAP_SDEC(tm, size); + TRIM_MAP_QDEC(tm); } mutex_exit(&tm->tm_lock); } @@ -434,7 +524,7 @@ trim_map_commit(spa_t *spa, zio_t *zio, { int c; - if (vd == NULL || spa->spa_syncing_txg <= trim_txg_limit) + if (vd == NULL) return; if (vd->vdev_ops->vdev_op_leaf) { @@ -467,6 +557,11 @@ trim_thread(void *arg) spa_t *spa = arg; zio_t *zio; +#ifdef _KERNEL + (void) snprintf(curthread->td_name, sizeof(curthread->td_name), + "trim %s", spa_name(spa)); +#endif + for (;;) { mutex_enter(&spa->spa_trim_lock); if (spa->spa_trim_thread == NULL) { @@ -475,7 +570,9 @@ trim_thread(void *arg) mutex_exit(&spa->spa_trim_lock); thread_exit(); } - cv_wait(&spa->spa_trim_cv, &spa->spa_trim_lock); + + (void) cv_timedwait(&spa->spa_trim_cv, &spa->spa_trim_lock, + hz * trim_max_interval); mutex_exit(&spa->spa_trim_lock); zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL); @@ -492,7 +589,7 @@ void trim_thread_create(spa_t *spa) { - if (zfs_notrim) + if (!zfs_trim_enabled) return; mutex_init(&spa->spa_trim_lock, NULL, MUTEX_DEFAULT, NULL); @@ -507,7 +604,7 @@ void trim_thread_destroy(spa_t *spa) { - if (zfs_notrim) + if (!zfs_trim_enabled) return; if (spa->spa_trim_thread == NULL) return; @@ -530,7 +627,7 @@ void trim_thread_wakeup(spa_t *spa) { - if (zfs_notrim) + if (!zfs_trim_enabled) return; if (spa->spa_trim_thread == NULL) return; Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c Wed Jun 5 13:03:47 2013 (r251419) @@ -43,6 +43,7 @@ #include #include #include +#include SYSCTL_DECL(_vfs_zfs); SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV"); @@ -1196,6 +1197,11 @@ vdev_open(vdev_t *vd) if (vd->vdev_ishole || vd->vdev_ops == &vdev_missing_ops) return (0); + if (vd->vdev_ops->vdev_op_leaf) { + vd->vdev_notrim = B_FALSE; + trim_map_create(vd); + } + for (int c = 0; c < vd->vdev_children; c++) { if (vd->vdev_child[c]->vdev_state != VDEV_STATE_HEALTHY) { vdev_set_state(vd, B_TRUE, VDEV_STATE_DEGRADED, @@ -1441,6 +1447,9 @@ vdev_close(vdev_t *vd) vdev_cache_purge(vd); + if (vd->vdev_ops->vdev_op_leaf) + trim_map_destroy(vd); + /* * We record the previous state before we close it, so that if we are * doing a reopen(), we don't generate FMA ereports if we notice that Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Wed Jun 5 13:03:47 2013 (r251419) @@ -49,14 +49,17 @@ struct g_class zfs_vdev_class = { DECLARE_GEOM_CLASS(zfs_vdev_class, zfs_vdev); -/* - * Don't send BIO_FLUSH. - */ +SYSCTL_DECL(_vfs_zfs_vdev); +/* Don't send BIO_FLUSH. */ static int vdev_geom_bio_flush_disable = 0; TUNABLE_INT("vfs.zfs.vdev.bio_flush_disable", &vdev_geom_bio_flush_disable); -SYSCTL_DECL(_vfs_zfs_vdev); SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_flush_disable, CTLFLAG_RW, &vdev_geom_bio_flush_disable, 0, "Disable BIO_FLUSH"); +/* Don't send BIO_DELETE. */ +static int vdev_geom_bio_delete_disable = 0; +TUNABLE_INT("vfs.zfs.vdev.bio_delete_disable", &vdev_geom_bio_delete_disable); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, bio_delete_disable, CTLFLAG_RW, + &vdev_geom_bio_delete_disable, 0, "Disable BIO_DELETE"); static void vdev_geom_orphan(struct g_consumer *cp) @@ -663,8 +666,8 @@ vdev_geom_open(vdev_t *vd, uint64_t *psi *ashift = highbit(MAX(pp->sectorsize, SPA_MINBLOCKSIZE)) - 1; /* - * Clear the nowritecache bit, so that on a vdev_reopen() we will - * try again. + * Clear the nowritecache settings, so that on a vdev_reopen() + * we will try again. */ vd->vdev_nowritecache = B_FALSE; @@ -710,6 +713,15 @@ vdev_geom_io_intr(struct bio *bp) */ vd->vdev_nowritecache = B_TRUE; } + if (bp->bio_cmd == BIO_DELETE && bp->bio_error == ENOTSUP) { + /* + * If we get ENOTSUP, we know that no future + * attempts will ever succeed. In this case we + * set a persistent bit so that we don't bother + * with the ioctl in the future. + */ + vd->vdev_notrim = B_TRUE; + } if (zio->io_error == EIO && !vd->vdev_remove_wanted) { /* * If provider's error is set we assume it is being @@ -752,17 +764,21 @@ vdev_geom_io_start(zio_t *zio) } switch (zio->io_cmd) { - case DKIOCFLUSHWRITECACHE: - if (zfs_nocacheflush || vdev_geom_bio_flush_disable) break; - if (vd->vdev_nowritecache) { zio->io_error = ENOTSUP; break; } - + goto sendreq; + case DKIOCTRIM: + if (vdev_geom_bio_delete_disable) + break; + if (vd->vdev_notrim) { + zio->io_error = ENOTSUP; + break; + } goto sendreq; default: zio->io_error = ENOTSUP; @@ -787,11 +803,21 @@ sendreq: bp->bio_length = zio->io_size; break; case ZIO_TYPE_IOCTL: - bp->bio_cmd = BIO_FLUSH; - bp->bio_flags |= BIO_ORDERED; - bp->bio_data = NULL; - bp->bio_offset = cp->provider->mediasize; - bp->bio_length = 0; + switch (zio->io_cmd) { + case DKIOCFLUSHWRITECACHE: + bp->bio_cmd = BIO_FLUSH; + bp->bio_flags |= BIO_ORDERED; + bp->bio_data = NULL; + bp->bio_offset = cp->provider->mediasize; + bp->bio_length = 0; + break; + case DKIOCTRIM: + bp->bio_cmd = BIO_DELETE; + bp->bio_data = NULL; + bp->bio_offset = zio->io_offset; + bp->bio_length = zio->io_size; + break; + } break; } bp->bio_done = vdev_geom_io_intr; Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_label.c Wed Jun 5 13:03:47 2013 (r251419) @@ -145,8 +145,14 @@ #include #include #include +#include #include +static boolean_t vdev_trim_on_init = B_TRUE; +SYSCTL_DECL(_vfs_zfs_vdev); +SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW, + &vdev_trim_on_init, 0, "Enable/disable full vdev trim on initialisation"); + /* * Basic routines to read and write from a vdev label. * Used throughout the rest of this file. @@ -718,6 +724,16 @@ vdev_label_init(vdev_t *vd, uint64_t crt } /* + * TRIM the whole thing so that we start with a clean slate. + * It's just an optimization, so we don't care if it fails. + * Don't TRIM if removing so that we don't interfere with zpool + * disaster recovery. + */ + if (zfs_trim_enabled && vdev_trim_on_init && (reason == VDEV_LABEL_CREATE || + reason == VDEV_LABEL_SPARE || reason == VDEV_LABEL_L2CACHE)) + zio_wait(zio_trim(NULL, spa, vd, 0, vd->vdev_psize)); + + /* * Initialize its label. */ vp = zio_buf_alloc(sizeof (vdev_phys_t)); @@ -1282,5 +1298,10 @@ vdev_config_sync(vdev_t **svd, int svdco * to disk to ensure that all odd-label updates are committed to * stable storage before the next transaction group begins. */ - return (vdev_label_sync_list(spa, 1, txg, flags)); + if ((error = vdev_label_sync_list(spa, 1, txg, flags)) != 0) + return (error); + + trim_thread_wakeup(spa); + + return (0); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_mirror.c Wed Jun 5 13:03:47 2013 (r251419) @@ -293,10 +293,11 @@ vdev_mirror_io_start(zio_t *zio) c = vdev_mirror_child_select(zio); children = (c >= 0); } else { - ASSERT(zio->io_type == ZIO_TYPE_WRITE); + ASSERT(zio->io_type == ZIO_TYPE_WRITE || + zio->io_type == ZIO_TYPE_FREE); /* - * Writes go to all children. + * Writes and frees go to all children. */ c = 0; children = mm->mm_children; @@ -377,6 +378,8 @@ vdev_mirror_io_done(zio_t *zio) zio->io_error = vdev_mirror_worst_error(mm); } return; + } else if (zio->io_type == ZIO_TYPE_FREE) { + return; } ASSERT(zio->io_type == ZIO_TYPE_READ); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c Wed Jun 5 11:59:36 2013 (r251418) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_raidz.c Wed Jun 5 13:03:47 2013 (r251419) @@ -259,7 +259,9 @@ vdev_raidz_map_free(raidz_map_t *rm) size_t size; for (c = 0; c < rm->rm_firstdatacol; c++) { - zio_buf_free(rm->rm_col[c].rc_data, rm->rm_col[c].rc_size); + if (rm->rm_col[c].rc_data != NULL) + zio_buf_free(rm->rm_col[c].rc_data, + rm->rm_col[c].rc_size); if (rm->rm_col[c].rc_gdata != NULL) zio_buf_free(rm->rm_col[c].rc_gdata, @@ -504,14 +506,20 @@ vdev_raidz_map_alloc(zio_t *zio, uint64_ ASSERT3U(rm->rm_asize - asize, ==, rm->rm_nskip << unit_shift); ASSERT3U(rm->rm_nskip, <=, nparity); - for (c = 0; c < rm->rm_firstdatacol; c++) - rm->rm_col[c].rc_data = zio_buf_alloc(rm->rm_col[c].rc_size); - - rm->rm_col[c].rc_data = zio->io_data; + if (zio->io_type != ZIO_TYPE_FREE) { + for (c = 0; c < rm->rm_firstdatacol; c++) { + rm->rm_col[c].rc_data = + zio_buf_alloc(rm->rm_col[c].rc_size); + } - for (c = c + 1; c < acols; c++) - rm->rm_col[c].rc_data = (char *)rm->rm_col[c - 1].rc_data + - rm->rm_col[c - 1].rc_size; + rm->rm_col[c].rc_data = zio->io_data; + + for (c = c + 1; c < acols; c++) { + rm->rm_col[c].rc_data = + (char *)rm->rm_col[c - 1].rc_data + + rm->rm_col[c - 1].rc_size; + } + } /* * If all data stored spans all columns, there's a danger that parity @@ -1536,6 +1544,18 @@ vdev_raidz_io_start(zio_t *zio) ASSERT3U(rm->rm_asize, ==, vdev_psize_to_asize(vd, zio->io_size)); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 13:30:52 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2301061A; Wed, 5 Jun 2013 13:30:52 +0000 (UTC) (envelope-from gibbs@scsiguy.com) Received: from aslan.scsiguy.com (aslan.scsiguy.com [70.89.174.89]) by mx1.freebsd.org (Postfix) with ESMTP id EEAF519B5; Wed, 5 Jun 2013 13:30:51 +0000 (UTC) Received: from [192.168.5.95] (ip-64-134-30-158.public.wayport.net [64.134.30.158]) (authenticated bits=0) by aslan.scsiguy.com (8.14.7/8.14.5) with ESMTP id r55DUmZu022024 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 5 Jun 2013 13:30:50 GMT (envelope-from gibbs@scsiguy.com) References: <201306041047.r54AljAX050733@svn.freebsd.org> Mime-Version: 1.0 (1.0) In-Reply-To: <201306041047.r54AljAX050733@svn.freebsd.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-Id: <4A91EB3F-56FD-4E94-9981-0422032C9240@scsiguy.com> X-Mailer: iPhone Mail (10B329) From: "Justin T. Gibbs" Subject: Re: svn commit: r251372 - in stable/9/sys/cam: ata scsi Date: Wed, 5 Jun 2013 06:30:44 -0700 To: Steven Hartland X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (aslan.scsiguy.com [70.89.174.89]); Wed, 05 Jun 2013 13:30:50 +0000 (UTC) Cc: "svn-src-stable@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" , "svn-src-stable-9@freebsd.org" X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 13:30:52 -0000 On Jun 4, 2013, at 3:47, Steven Hartland wrote: > Author: smh > Date: Tue Jun 4 10:47:44 2013 > New Revision: 251372 > URL: http://svnweb.freebsd.org/changeset/base/251372 >=20 > Log: > Enhanced BIO_DELETE support for CAM SCSI to add ATA_TRIM support. >=20 > Disable CAM BIO queue sorting for non-rotating media by default. Using the elevator makes perfect sense even for random access devices when o= perations can be merged. Even SSDs have fixed, per-command overheads and mer= ging writes may help prevent fragmentation. On drivers that support unmappe= d I/O, merging should be fairly cheap. It would be an interesting performance experiment. >=20 -- Justin= From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 15:03:14 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 80479FEF; Wed, 5 Jun 2013 15:03:14 +0000 (UTC) (envelope-from prvs=1868436c14=killing@multiplay.co.uk) Received: from mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) by mx1.freebsd.org (Postfix) with ESMTP id A931D1DFA; Wed, 5 Jun 2013 15:03:13 +0000 (UTC) Received: from r2d2 ([82.69.141.170]) by mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) (MDaemon PRO v10.0.4) with ESMTP id md50004168536.msg; Wed, 05 Jun 2013 16:03:05 +0100 X-Spam-Processed: mail1.multiplay.co.uk, Wed, 05 Jun 2013 16:03:05 +0100 (not processed: message from valid local sender) X-MDDKIM-Result: neutral (mail1.multiplay.co.uk) X-MDRemoteIP: 82.69.141.170 X-Return-Path: prvs=1868436c14=killing@multiplay.co.uk X-Envelope-From: killing@multiplay.co.uk Message-ID: <491E54742FDD4C299688DE36717EA531@multiplay.co.uk> From: "Steven Hartland" To: "Justin T. Gibbs" References: <201306041047.r54AljAX050733@svn.freebsd.org> <4A91EB3F-56FD-4E94-9981-0422032C9240@scsiguy.com> Subject: Re: svn commit: r251372 - in stable/9/sys/cam: ata scsi Date: Wed, 5 Jun 2013 16:02:54 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 15:03:14 -0000 ----- Original Message ----- From: "Justin T. Gibbs" On Jun 4, 2013, at 3:47, Steven Hartland wrote: > > Author: smh > > Date: Tue Jun 4 10:47:44 2013 > > New Revision: 251372 > > URL: http://svnweb.freebsd.org/changeset/base/251372 > > > > Log: > > Enhanced BIO_DELETE support for CAM SCSI to add ATA_TRIM support. > > > > Disable CAM BIO queue sorting for non-rotating media by default. > > Using the elevator makes perfect sense even for random access devices when > operations can be merged. Even SSDs have fixed, per-command overheads and > merging writes may help prevent fragmentation. On drivers that support > unmapped I/O, merging should be fairly cheap. > > It would be an interesting performance experiment. In theory I'd agree but in practice this was not the case with bioq becoming a noticable bottleneck for SSD based machines, hence this change. The sysctl's still allow this to be configured :) Regards Steve ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk. From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 16:25:40 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 481E6831 for ; Wed, 5 Jun 2013 16:25:40 +0000 (UTC) (envelope-from scott4long@yahoo.com) Received: from nm48-vm7.bullet.mail.ne1.yahoo.com (nm48-vm7.bullet.mail.ne1.yahoo.com [98.138.121.119]) by mx1.freebsd.org (Postfix) with ESMTP id 0D5FF11B1 for ; Wed, 5 Jun 2013 16:25:40 +0000 (UTC) Received: from [98.138.90.56] by nm48.bullet.mail.ne1.yahoo.com with NNFMP; 05 Jun 2013 16:20:04 -0000 Received: from [98.138.84.41] by tm9.bullet.mail.ne1.yahoo.com with NNFMP; 05 Jun 2013 16:20:04 -0000 Received: from [127.0.0.1] by smtp109.mail.ne1.yahoo.com with NNFMP; 05 Jun 2013 16:20:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1370449204; bh=KIT0ZdNPozqdIjjsXRe0I5n4FKaKutkAYvjAKdllP/g=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Subject:Mime-Version:Content-Type:From:X-Priority:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=iFc7IYdwXjSPha1Bll/y/YcngHILVOfELE85Splx+XagFsysSbLigSktguHQXO5yQ/KOgENyPomqiI6MUqUmnl35nsqnvSrFrS1BWfVLCM01ykNNyXRIv+W0mIPSLBxNSbJ/mcQG2le9C8YNh28q67KtZdErEshKE963Y/1Iaec= X-Yahoo-Newman-Id: 162850.40359.bm@smtp109.mail.ne1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: U6tdZ8kVM1lQslKauY7GRm9xsb7VrouRT1qQkSSyh_nsAga Q7IfqFx9eruPTzg5hjl6UGEcdUQ4z1.fb95t6AgaBpMabdQqHdEM0ldREZvx nWNDL5LDw.pK19zSzpe3sFMwZwI1GtVhBLUlO089P0gYEcUtK.V_iR7kTeoJ aaKL5AYKxXG9zTLeCjaZyYbPENyGLLSBMRyy98PCVE14n3VLBdMQm1Sfwh23 sLtS1f_jr2F6Zmuf1T7.09x69Cui4TgAPr00ECV2Di9fSf8DVbP01er.jVJm IAnaTHvOMNAt9CalpGht3cAjuzpG3_ft.c2N7QaWQ9Cdq3zPtUuhQbiyWHAM a73mjhDxGWDFXVYEB5P2HLtGa826U.si6pnSDiIWmskfP5iVQ.e7l0FFCN2W HWNXQhYcYWZy4d4gHbdVZpR_xpbQ7gn9GonhwRBaPkeSUyy6xDSR4iIpztDk tlorYaipXB7oAzOEzFwz4iRfHBDhhC1c1hRdYOupYIqX4Vq7PWgJTSa62hOO U X-Yahoo-SMTP: clhABp.swBB7fs.LwIJpv3jkWgo2NU8- X-Rocket-Received: from phobos.samsco.home (scott4long@168.103.85.57 with ) by smtp109.mail.ne1.yahoo.com with SMTP; 05 Jun 2013 09:20:04 -0700 PDT Subject: Re: svn commit: r251372 - in stable/9/sys/cam: ata scsi Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) Content-Type: text/plain; charset=iso-8859-1 From: Scott Long X-Priority: 3 In-Reply-To: <491E54742FDD4C299688DE36717EA531@multiplay.co.uk> Date: Wed, 5 Jun 2013 10:20:02 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <6F4A05CA-5C95-4862-9FBA-0352B7132214@yahoo.com> References: <201306041047.r54AljAX050733@svn.freebsd.org> <4A91EB3F-56FD-4E94-9981-0422032C9240@scsiguy.com> <491E54742FDD4C299688DE36717EA531@multiplay.co.uk> To: Steven Hartland X-Mailer: Apple Mail (2.1503) Cc: "Justin T. Gibbs" , svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 16:25:40 -0000 On Jun 5, 2013, at 9:02 AM, Steven Hartland = wrote: >=20 >=20 > ----- Original Message ----- From: "Justin T. Gibbs" = >=20 >=20 > On Jun 4, 2013, at 3:47, Steven Hartland wrote: >=20 >> > Author: smh >> > Date: Tue Jun 4 10:47:44 2013 >> > New Revision: 251372 >> > URL: http://svnweb.freebsd.org/changeset/base/251372 >> > > Log: >> > Enhanced BIO_DELETE support for CAM SCSI to add ATA_TRIM support. >> > > Disable CAM BIO queue sorting for non-rotating media by default. >>=20 >> Using the elevator makes perfect sense even for random access devices = when >> operations can be merged. Even SSDs have fixed, per-command overheads = and >> merging writes may help prevent fragmentation. On drivers that = support >> unmapped I/O, merging should be fairly cheap. >>=20 >> It would be an interesting performance experiment. >=20 > In theory I'd agree but in practice this was not the case with bioq > becoming a noticable bottleneck for SSD based machines, hence this = change. >=20 > The sysctl's still allow this to be configured :) >=20 Completely agree. The bioq_disksort() only serves to burn CPU cycles = with the column lock held (thus burning even more CPU cycles elsewhere) = once the queue grows to any appreciable size. Merging of adjacent = segments happens (mostly) right now thanks to lock serialization in the = issuing path and g_down thread serialization. Furthermore, = bioq_disksort() has no concept of the cost of reads vs writes as they = pertain to SSDs. It's better to have the order be random and/or = somewhat separated thanks to operational serialization, than to try = extra hard to gets reads and writes close together. A much better I/O scheduler is needed. In our tests, bioq_disksort() is = worse than no i/o scheduler, so we've turned it off. We've tried = Luigi's scheduler, but it adds too much latency to our workload. I'm = working on a better scheme. Scott From owner-svn-src-stable-9@FreeBSD.ORG Wed Jun 5 18:42:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id F34BD334; Wed, 5 Jun 2013 18:42:44 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D5A681A43; Wed, 5 Jun 2013 18:42:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r55Igirb098260; Wed, 5 Jun 2013 18:42:44 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r55IgifW098256; Wed, 5 Jun 2013 18:42:44 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201306051842.r55IgifW098256@svn.freebsd.org> From: Alexander Motin Date: Wed, 5 Jun 2013 18:42:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251427 - stable/9/sys/dev/sound/pci X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Jun 2013 18:42:45 -0000 Author: mav Date: Wed Jun 5 18:42:44 2013 New Revision: 251427 URL: http://svnweb.freebsd.org/changeset/base/251427 Log: MFC r250286: Some fixes to snd_envy24ht(4) driver: - Allow DMA addresses anywhere in the lower 4GB; Envy24HT has a 32-bit DMA engine, not 28-bit like Envy24. - Mark interrupt handler as MPSAFE, seems to be correctly synchronized. PR: kern/152378 Submitted by: Jason Harmening Modified: stable/9/sys/dev/sound/pci/envy24ht.c stable/9/sys/dev/sound/pci/envy24ht.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/sound/pci/envy24ht.c ============================================================================== --- stable/9/sys/dev/sound/pci/envy24ht.c Wed Jun 5 17:37:59 2013 (r251426) +++ stable/9/sys/dev/sound/pci/envy24ht.c Wed Jun 5 18:42:44 2013 (r251427) @@ -2080,7 +2080,7 @@ envy24ht_pci_probe(device_t dev) static void envy24ht_dmapsetmap(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - /* struct sc_info *sc = (struct sc_info *)arg; */ + struct sc_info *sc = arg; #if(0) device_printf(sc->dev, "envy24ht_dmapsetmap()\n"); @@ -2088,15 +2088,16 @@ envy24ht_dmapsetmap(void *arg, bus_dma_s printf("envy24ht(play): setmap %lx, %lx; ", (unsigned long)segs->ds_addr, (unsigned long)segs->ds_len); - printf("%p -> %lx\n", sc->pmap, (unsigned long)vtophys(sc->pmap)); } #endif + envy24ht_wrmt(sc, ENVY24HT_MT_PADDR, (uint32_t)segs->ds_addr, 4); + envy24ht_wrmt(sc, ENVY24HT_MT_PCNT, (uint32_t)(segs->ds_len / 4 - 1), 2); } static void envy24ht_dmarsetmap(void *arg, bus_dma_segment_t *segs, int nseg, int error) { - /* struct sc_info *sc = (struct sc_info *)arg; */ + struct sc_info *sc = arg; #if(0) device_printf(sc->dev, "envy24ht_dmarsetmap()\n"); @@ -2104,9 +2105,10 @@ envy24ht_dmarsetmap(void *arg, bus_dma_s printf("envy24ht(record): setmap %lx, %lx; ", (unsigned long)segs->ds_addr, (unsigned long)segs->ds_len); - printf("%p -> %lx\n", sc->rmap, (unsigned long)vtophys(sc->pmap)); } #endif + envy24ht_wrmt(sc, ENVY24HT_MT_RADDR, (uint32_t)segs->ds_addr, 4); + envy24ht_wrmt(sc, ENVY24HT_MT_RCNT, (uint32_t)(segs->ds_len / 4 - 1), 2); } static void @@ -2149,7 +2151,6 @@ envy24ht_dmafree(struct sc_info *sc) static int envy24ht_dmainit(struct sc_info *sc) { - u_int32_t addr; #if(0) device_printf(sc->dev, "envy24ht_dmainit()\n"); @@ -2176,34 +2177,16 @@ envy24ht_dmainit(struct sc_info *sc) #if(0) device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_load(): sc->pmap\n"); #endif - if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->psize, envy24ht_dmapsetmap, sc, 0)) + if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->psize, envy24ht_dmapsetmap, sc, BUS_DMA_NOWAIT)) goto bad; #if(0) device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_load(): sc->rmap\n"); #endif - if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->rsize, envy24ht_dmarsetmap, sc, 0)) + if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->rsize, envy24ht_dmarsetmap, sc, BUS_DMA_NOWAIT)) goto bad; bzero(sc->pbuf, sc->psize); bzero(sc->rbuf, sc->rsize); - /* set values to register */ - addr = vtophys(sc->pbuf); -#if(0) - device_printf(sc->dev, "pbuf(0x%08x)\n", addr); -#endif - envy24ht_wrmt(sc, ENVY24HT_MT_PADDR, addr, 4); -#if(0) - device_printf(sc->dev, "PADDR-->(0x%08x)\n", envy24ht_rdmt(sc, ENVY24HT_MT_PADDR, 4)); - device_printf(sc->dev, "psize(%ld)\n", sc->psize / 4 - 1); -#endif - envy24ht_wrmt(sc, ENVY24HT_MT_PCNT, sc->psize / 4 - 1, 2); -#if(0) - device_printf(sc->dev, "PCNT-->(%ld)\n", envy24ht_rdmt(sc, ENVY24HT_MT_PCNT, 2)); -#endif - addr = vtophys(sc->rbuf); - envy24ht_wrmt(sc, ENVY24HT_MT_RADDR, addr, 4); - envy24ht_wrmt(sc, ENVY24HT_MT_RCNT, sc->rsize / 4 - 1, 2); - return 0; bad: envy24ht_dmafree(sc); @@ -2441,7 +2424,7 @@ envy24ht_alloc_resource(struct sc_info * sc->irq = bus_alloc_resource(sc->dev, SYS_RES_IRQ, &sc->irqid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); if (!sc->irq || - snd_setup_intr(sc->dev, sc->irq, 0, envy24ht_intr, sc, &sc->ih)) { + snd_setup_intr(sc->dev, sc->irq, INTR_MPSAFE, envy24ht_intr, sc, &sc->ih)) { device_printf(sc->dev, "unable to map interrupt\n"); return ENXIO; } @@ -2450,13 +2433,13 @@ envy24ht_alloc_resource(struct sc_info * if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(sc->dev), /*alignment*/4, /*boundary*/0, - /*lowaddr*/BUS_SPACE_MAXADDR_ENVY24, - /*highaddr*/BUS_SPACE_MAXADDR_ENVY24, + /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, + /*highaddr*/BUS_SPACE_MAXADDR, /*filter*/NULL, /*filterarg*/NULL, /*maxsize*/BUS_SPACE_MAXSIZE_ENVY24, /*nsegments*/1, /*maxsegsz*/0x3ffff, - /*flags*/0, /*lockfunc*/busdma_lock_mutex, - /*lockarg*/&Giant, &sc->dmat) != 0) { + /*flags*/0, /*lockfunc*/NULL, + /*lockarg*/NULL, &sc->dmat) != 0) { device_printf(sc->dev, "unable to create dma tag\n"); return ENXIO; } Modified: stable/9/sys/dev/sound/pci/envy24ht.h ============================================================================== --- stable/9/sys/dev/sound/pci/envy24ht.h Wed Jun 5 17:37:59 2013 (r251426) +++ stable/9/sys/dev/sound/pci/envy24ht.h Wed Jun 5 18:42:44 2013 (r251427) @@ -176,8 +176,6 @@ #define ENVY24HT_VOL_MIN 96 /* -144db(negate) */ #define ENVY24HT_VOL_MUTE 127 /* mute */ -#define BUS_SPACE_MAXADDR_ENVY24 0x0fffffff /* Address space beyond 256MB is not - supported */ #define BUS_SPACE_MAXSIZE_ENVY24 0x3fffc /* 64k x 4byte(1dword) */ #define ENVY24HT_CCS_GPIO_HDATA 0x1E From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 6 03:18:09 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0823FD47; Thu, 6 Jun 2013 03:18:09 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DE7901283; Thu, 6 Jun 2013 03:18:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r563I8Ps061725; Thu, 6 Jun 2013 03:18:08 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r563I8Dt061719; Thu, 6 Jun 2013 03:18:08 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201306060318.r563I8Dt061719@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Thu, 6 Jun 2013 03:18:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251447 - stable/9/sys/fs/ext2fs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 03:18:09 -0000 Author: pfg Date: Thu Jun 6 03:18:07 2013 New Revision: 251447 URL: http://svnweb.freebsd.org/changeset/base/251447 Log: MFC r251336, r251344, r251346: ext2fs: update Block Group Descriptor struct plus cosmetic fixes. Modified: stable/9/sys/fs/ext2fs/ext2_bmap.c stable/9/sys/fs/ext2fs/ext2_dinode.h stable/9/sys/fs/ext2fs/ext2_inode_cnv.c stable/9/sys/fs/ext2fs/ext2fs.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/fs/ (props changed) Modified: stable/9/sys/fs/ext2fs/ext2_bmap.c ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_bmap.c Wed Jun 5 23:53:00 2013 (r251446) +++ stable/9/sys/fs/ext2fs/ext2_bmap.c Thu Jun 6 03:18:07 2013 (r251447) @@ -47,8 +47,8 @@ #include #include -#include #include +#include /* * Bmap converts the logical block number of a file to its physical block Modified: stable/9/sys/fs/ext2fs/ext2_dinode.h ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_dinode.h Wed Jun 5 23:53:00 2013 (r251446) +++ stable/9/sys/fs/ext2fs/ext2_dinode.h Thu Jun 6 03:18:07 2013 (r251447) @@ -77,7 +77,8 @@ #define EXT3_EPOCH_MASK ((1 << EXT3_EPOCH_BITS) - 1) #define EXT3_NSEC_MASK (~0UL << EXT3_EPOCH_BITS) -#define E2DI_HAS_XTIME(ip) (EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, EXT2F_ROCOMPAT_EXTRA_ISIZE)) +#define E2DI_HAS_XTIME(ip) (EXT2_HAS_RO_COMPAT_FEATURE(ip->i_e2fs, \ + EXT2F_ROCOMPAT_EXTRA_ISIZE)) /* * Structure of an inode on the disk Modified: stable/9/sys/fs/ext2fs/ext2_inode_cnv.c ============================================================================== --- stable/9/sys/fs/ext2fs/ext2_inode_cnv.c Wed Jun 5 23:53:00 2013 (r251446) +++ stable/9/sys/fs/ext2fs/ext2_inode_cnv.c Thu Jun 6 03:18:07 2013 (r251447) @@ -115,7 +115,7 @@ ext2_i2ei(struct inode *ip, struct ext2f int i; ei->e2di_mode = ip->i_mode; - ei->e2di_nlink = ip->i_nlink; + ei->e2di_nlink = ip->i_nlink; /* Godmar thinks: if dtime is nonzero, ext2 says this inode has been deleted, this would correspond to a zero link count Modified: stable/9/sys/fs/ext2fs/ext2fs.h ============================================================================== --- stable/9/sys/fs/ext2fs/ext2fs.h Wed Jun 5 23:53:00 2013 (r251446) +++ stable/9/sys/fs/ext2fs/ext2fs.h Thu Jun 6 03:18:07 2013 (r251447) @@ -281,9 +281,13 @@ struct ext2_gd { uint32_t ext2bgd_i_tables; /* inodes table block */ uint16_t ext2bgd_nbfree; /* number of free blocks */ uint16_t ext2bgd_nifree; /* number of free inodes */ - uint16_t ext2bgd_ndirs; /* number of directories */ - uint16_t reserved; - uint32_t reserved2[3]; + uint16_t ext2bgd_ndirs; /* number of directories */ + uint16_t ext2bgd_flags; /* block group flags */ + uint32_t ext2bgd_x_bitmap; /* snapshot exclusion bitmap loc. */ + uint16_t ext2bgd_b_bmap_csum; /* block bitmap checksum */ + uint16_t ext2bgd_i_bmap_csum; /* inode bitmap checksum */ + uint16_t ext2bgd_i_unused; /* unused inode count */ + uint16_t ext2bgd_csum; /* group descriptor checksum */ }; /* cluster summary information */ From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 6 05:28:29 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4FEA02C3; Thu, 6 Jun 2013 05:28:29 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 41B2F182A; Thu, 6 Jun 2013 05:28:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r565STfU002042; Thu, 6 Jun 2013 05:28:29 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r565STNu002041; Thu, 6 Jun 2013 05:28:29 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201306060528.r565STNu002041@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 6 Jun 2013 05:28:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251450 - stable/9/sys/vm X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 05:28:29 -0000 Author: kib Date: Thu Jun 6 05:28:28 2013 New Revision: 251450 URL: http://svnweb.freebsd.org/changeset/base/251450 Log: MFC r251318: Remove irrelevant comments. Modified: stable/9/sys/vm/vm_page.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/vm/vm_page.c ============================================================================== --- stable/9/sys/vm/vm_page.c Thu Jun 6 05:20:05 2013 (r251449) +++ stable/9/sys/vm/vm_page.c Thu Jun 6 05:28:28 2013 (r251450) @@ -902,11 +902,6 @@ vm_page_splay(vm_pindex_t pindex, vm_pag * * Inserts the given mem entry into the object and object list. * - * The pagetables are not updated but will presumably fault the page - * in if necessary, or if a kernel page the caller will at some point - * enter the page into the kernel's pmap. We are not allowed to sleep - * here so we *can't* do this anyway. - * * The object must be locked. */ void @@ -976,8 +971,6 @@ vm_page_insert(vm_page_t m, vm_object_t * table and the object page list, but do not invalidate/terminate * the backing store. * - * The underlying pmap entry (if any) is NOT removed here. - * * The object must be locked. The page must be locked if it is managed. */ void From owner-svn-src-stable-9@FreeBSD.ORG Thu Jun 6 13:47:37 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 3886C240; Thu, 6 Jun 2013 13:47:37 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 28F0E1294; Thu, 6 Jun 2013 13:47:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r56DlbUR062968; Thu, 6 Jun 2013 13:47:37 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r56Dlb7B062967; Thu, 6 Jun 2013 13:47:37 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201306061347.r56Dlb7B062967@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Thu, 6 Jun 2013 13:47:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251469 - stable/9/usr.sbin/rtadvd X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Jun 2013 13:47:37 -0000 Author: des Date: Thu Jun 6 13:47:36 2013 New Revision: 251469 URL: http://svnweb.freebsd.org/changeset/base/251469 Log: MFH (r247863): fix occasional SIGSEGV when an interface was added. Modified: stable/9/usr.sbin/rtadvd/rtadvd.c Directory Properties: stable/9/usr.sbin/rtadvd/ (props changed) Modified: stable/9/usr.sbin/rtadvd/rtadvd.c ============================================================================== --- stable/9/usr.sbin/rtadvd/rtadvd.c Thu Jun 6 11:59:38 2013 (r251468) +++ stable/9/usr.sbin/rtadvd/rtadvd.c Thu Jun 6 13:47:36 2013 (r251469) @@ -1008,6 +1008,8 @@ set_short_delay(struct ifinfo *ifi) long delay; /* must not be greater than 1000000 */ struct timeval interval, now, min_delay, tm_tmp, *rest; + if (ifi->ifi_ra_timer == NULL) + return; /* * Compute a random delay. If the computed value * corresponds to a time later than the time the next From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 7 14:10:19 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3390DACC; Fri, 7 Jun 2013 14:10:19 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1677C1147; Fri, 7 Jun 2013 14:10:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r57EAJmY028427; Fri, 7 Jun 2013 14:10:19 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r57EAIgt028422; Fri, 7 Jun 2013 14:10:18 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306071410.r57EAIgt028422@svn.freebsd.org> From: Steven Hartland Date: Fri, 7 Jun 2013 14:10:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251497 - in stable/9: sbin/camcontrol sys/sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2013 14:10:19 -0000 Author: smh Date: Fri Jun 7 14:10:18 2013 New Revision: 251497 URL: http://svnweb.freebsd.org/changeset/base/251497 Log: MFC r249115: Adds security command to camcontrol which provides the ability to secure erase SSD's MFC r249153: (included in r251494) mdoc: remove superfluous paragraph macro. Modified: stable/9/sbin/camcontrol/camcontrol.8 stable/9/sbin/camcontrol/camcontrol.c stable/9/sys/sys/ata.h Directory Properties: stable/9/sbin/camcontrol/ (props changed) stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 7 13:59:41 2013 (r251496) +++ stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 7 14:10:18 2013 (r251497) @@ -228,6 +228,21 @@ .Op Fl y .Op Fl s .Nm +.Ic security +.Op device id +.Op generic args +.Op Fl d Ar pwd +.Op Fl e Ar pwd +.Op Fl f +.Op Fl h Ar pwd +.Op Fl k Ar pwd +.Op Fl l Ar high|maximum +.Op Fl q +.Op Fl s Ar pwd +.Op Fl T Ar timeout +.Op Fl U Ar user|master +.Op Fl y +.Nm .Ic help .Sh DESCRIPTION The @@ -1072,6 +1087,123 @@ specifies automatic standby timer value .It Ic sleep Put ATA device into SLEEP state. Note that the only way get device out of this state may be reset. +.It Ic security +Update or report security settings, using an ATA identify command (0xec). +By default, +.Nm +will print out the security support and associated settings of the device. +The +.Ic security +command takes several arguments: +.Bl -tag -width 0n +.It Fl d Ar pwd +.Pp +Disable device security using the given password for the selected user according +to the devices configured security level. +.It Fl e Ar pwd +.Pp +Erase the device using the given password for the selected user. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +Issuing a secure erase will +.Em ERASE ALL +user data on the device and may take several hours to complete. +.Pp +When this command is used against an SSD drive all its cells will be marked as +empty, restoring it to factory default write performance. For SSD's this action +usually takes just a few seconds. +.It Fl f +.Pp +Freeze the security configuration of the specified device. +.Pp +After command completion any other commands that update the device lock mode +shall be command aborted. Frozen mode is disabled by power-off or hardware reset. +.It Fl h Ar pwd +.Pp +Enhanced erase the device using the given password for the selected user. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +Issuing an enhanced secure erase will +.Em ERASE ALL +user data on the device and may take several hours to complete. +.Pp +An enhanced erase writes predetermined data patterns to all user data areas, +all previously written user data shall be overwritten, including sectors that +are no longer in use due to reallocation. +.It Fl k Ar pwd +.Pp +Unlock the device using the given password for the selected user according to +the devices configured security level. +.It Fl l Ar high|maximum +.Pp +Specifies which security level to set when issuing a +.Fl s Ar pwd +command. The security level determines device behavior when the master +password is used to unlock the device. When the security level is set to high +the device requires the unlock command and the master password to unlock. +When the security level is set to maximum the device requires a secure erase +with the master password to unlock. +.Pp +This option must be used in conjunction with one of the security action commands. +.Pp +Defaults to +.Em high +.It Fl q +.Pp +Be quiet, do not print any status messages. +This option will not disable the questions, however. +To disable questions, use the +.Fl y +argument, below. +.It Fl s Ar pwd +.Pp +Password the device (enable security) using the given password for the selected +user. This option can be combined with other options such as +.Fl e Em pwd +.Pp +A master password may be set in a addition to the user password. The purpose of +the master password is to allow an administrator to establish a password that +is kept secret from the user, and which may be used to unlock the device if the +user password is lost. +.Pp +.Em Note: +Setting the master password does not enable device security. +.Pp +If the master password is set and the drive supports a Master Revision Code +feature the Master Password Revision Code will be decremented. +.It Fl T Ar timeout +.Pp +Overrides the default timeout, specified in seconds, used for both +.Fl e +and +.Fl h +this is useful if your system has problems processing long timeouts correctly. +.Pp +Usually the timeout is calculated from the information stored on the drive if +present, otherwise it defaults to 2 hours. +.It Fl U Ar user|master +.Pp +Specifies which user to set / use for the running action command, valid values +are user or master and defaults to master if not set. +.Pp +This option must be used in conjunction with one of the security action commands. +.Pp +Defaults to +.Em master +.It Fl y +.Pp +Confirm yes to dangerous options such as +.Fl e +without prompting for confirmation. +.Pp +.El +If the password specified for any action commands doesn't match the configured +password for the specified user the command will fail. +.Pp +The password in all cases is limited to 32 characters, longer passwords will +fail. .It Ic fwdownload Program firmware of the named SCSI device using the image file provided. .Pp @@ -1240,6 +1372,30 @@ camcontrol smpcmd ses0 -v -r 4 "40 0 00 Send the SMP REPORT GENERAL command to ses0, and display the number of PHYs it contains. Display SMP errors if the command fails. +.Bd -literal -offset indent +camcontrol security ada0 +.Ed +.Pp +Report security support and settings for ada0 +.Bd -literal -offset indent +camcontrol security ada0 -u user -s MyPass +.Ed +.Pp +Enable security on device ada0 with the password MyPass +.Bd -literal -offset indent +camcontrol security ada0 -u user -e MyPass +.Ed +.Pp +Secure erase ada0 which has had security enabled with user password MyPass +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +This will +.Em ERASE ALL +data from the device, so backup your data before using! +.Pp +This command can be used used against an SSD drive to restoring it to +factory default write performance. .Sh SEE ALSO .Xr cam 3 , .Xr cam_cdbparse 3 , Modified: stable/9/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.c Fri Jun 7 13:59:41 2013 (r251496) +++ stable/9/sbin/camcontrol/camcontrol.c Fri Jun 7 14:10:18 2013 (r251497) @@ -87,7 +87,8 @@ typedef enum { CAM_CMD_SMP_PC = 0x00000019, CAM_CMD_SMP_PHYLIST = 0x0000001a, CAM_CMD_SMP_MANINFO = 0x0000001b, - CAM_CMD_DOWNLOAD_FW = 0x0000001c + CAM_CMD_DOWNLOAD_FW = 0x0000001c, + CAM_CMD_SECURITY = 0x0000001d } cam_cmdmask; typedef enum { @@ -140,6 +141,7 @@ static const char negotiate_opts[] = "ac static const char smprg_opts[] = "l"; static const char smppc_opts[] = "a:A:d:lm:M:o:p:s:S:T:"; static const char smpphylist_opts[] = "lq"; +static char pwd_opt; #endif static struct camcontrol_opts option_table[] = { @@ -183,6 +185,7 @@ static struct camcontrol_opts option_tab {"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"}, {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:ys"}, + {"security", CAM_CMD_SECURITY, CAM_ARG_NONE, "d:e:fh:k:l:qs:T:U:y"}, #endif /* MINIMALISTIC */ {"help", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, {"-?", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, @@ -274,7 +277,10 @@ static int scsireportluns(struct cam_dev static int scsireadcapacity(struct cam_device *device, int argc, char **argv, char *combinedopt, int retry_count, int timeout); static int atapm(struct cam_device *device, int argc, char **argv, - char *combinedopt, int retry_count, int timeout); + char *combinedopt, int retry_count, int timeout); +static int atasecurity(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt); + #endif /* MINIMALISTIC */ #ifndef min #define min(a,b) (((a)<(b))?(a):(b)) @@ -1328,55 +1334,93 @@ atacapprint(struct ata_params *parm) printf("free-fall %s %s\n", parm->support2 & ATA_SUPPORT_FREEFALL ? "yes" : "no", parm->enabled2 & ATA_SUPPORT_FREEFALL ? "yes" : "no"); - printf("data set management (TRIM) %s\n", - parm->support_dsm & ATA_SUPPORT_DSM_TRIM ? "yes" : "no"); + printf("Data Set Management (DSM/TRIM) "); + if (parm->support_dsm & ATA_SUPPORT_DSM_TRIM) { + printf("yes\n"); + printf("DSM - max 512byte blocks "); + if (parm->max_dsm_blocks == 0x00) + printf("yes not specified\n"); + else + printf("yes %d\n", + parm->max_dsm_blocks); + + printf("DSM - deterministic read "); + if (parm->support3 & ATA_SUPPORT_DRAT) { + if (parm->support3 & ATA_SUPPORT_RZAT) + printf("yes zeroed\n"); + else + printf("yes any value\n"); + } else { + printf("no\n"); + } + } else { + printf("no\n"); + } } static int -ataidentify(struct cam_device *device, int retry_count, int timeout) +scsi_cam_pass_16_send(struct cam_device *device, union ccb *ccb, int quiet) { - union ccb *ccb; - struct ata_params *ident_buf; - struct ccb_getdev cgd; - u_int i, error = 0; - int16_t *ptr; + struct ata_pass_16 *ata_pass_16; + struct ata_cmd ata_cmd; - if (get_cgd(device, &cgd) != 0) { - warnx("couldn't get CGD"); - return(1); - } - ccb = cam_getccb(device); + ata_pass_16 = (struct ata_pass_16 *)ccb->csio.cdb_io.cdb_bytes; + ata_cmd.command = ata_pass_16->command; + ata_cmd.control = ata_pass_16->control; + ata_cmd.features = ata_pass_16->features; - if (ccb == NULL) { - warnx("couldn't allocate CCB"); - return(1); + if (arglist & CAM_ARG_VERBOSE) { + warnx("sending ATA %s via pass_16 with timeout of %u msecs", + ata_op_string(&ata_cmd), + ccb->csio.ccb_h.timeout); } - /* cam_getccb cleans up the header, caller has to zero the payload */ - bzero(&(&ccb->ccb_h)[1], - sizeof(struct ccb_ataio) - sizeof(struct ccb_hdr)); + /* Disable freezing the device queue */ + ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; - ptr = (uint16_t *)malloc(sizeof(struct ata_params)); + if (arglist & CAM_ARG_ERR_RECOVER) + ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; - if (ptr == NULL) { - cam_freeccb(ccb); - warnx("can't malloc memory for identify\n"); - return(1); + if (cam_send_ccb(device, ccb) < 0) { + if (quiet != 1 || arglist & CAM_ARG_VERBOSE) { + warn("error sending ATA %s via pass_16", + ata_op_string(&ata_cmd)); + } + + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + + return (1); } - bzero(ptr, sizeof(struct ata_params)); - cam_fill_ataio(&ccb->ataio, - retry_count, - NULL, - /*flags*/CAM_DIR_IN, - MSG_SIMPLE_Q_TAG, - /*data_ptr*/(u_int8_t *)ptr, - /*dxfer_len*/sizeof(struct ata_params), - timeout ? timeout : 30 * 1000); - if (cgd.protocol == PROTO_ATA) - ata_28bit_cmd(&ccb->ataio, ATA_ATA_IDENTIFY, 0, 0, 0); - else - ata_28bit_cmd(&ccb->ataio, ATA_ATAPI_IDENTIFY, 0, 0, 0); + if (!(ata_pass_16->flags & AP_FLAG_CHK_COND) && + (ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { + if (quiet != 1 || arglist & CAM_ARG_VERBOSE) { + warnx("ATA %s via pass_16 failed", + ata_op_string(&ata_cmd)); + } + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + } + + return (1); + } + + return (0); +} + + +static int +ata_cam_send(struct cam_device *device, union ccb *ccb, int quiet) +{ + if (arglist & CAM_ARG_VERBOSE) { + warnx("sending ATA %s with timeout of %u msecs", + ata_op_string(&(ccb->ataio.cmd)), + ccb->ataio.ccb_h.timeout); + } /* Disable freezing the device queue */ ccb->ccb_h.flags |= CAM_DEV_QFRZDIS; @@ -1385,47 +1429,247 @@ ataidentify(struct cam_device *device, i ccb->ccb_h.flags |= CAM_PASS_ERR_RECOVER; if (cam_send_ccb(device, ccb) < 0) { - perror("error sending ATA identify"); + if (quiet != 1 || arglist & CAM_ARG_VERBOSE) { + warn("error sending ATA %s", + ata_op_string(&(ccb->ataio.cmd))); + } if (arglist & CAM_ARG_VERBOSE) { cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); } - free(ptr); - cam_freeccb(ccb); - return(1); + return (1); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { - error = 1; + if (quiet != 1 || arglist & CAM_ARG_VERBOSE) { + warnx("ATA %s failed: %d", + ata_op_string(&(ccb->ataio.cmd)), quiet); + } if (arglist & CAM_ARG_VERBOSE) { cam_error_print(device, ccb, CAM_ESF_ALL, CAM_EPF_ALL, stderr); } + + return (1); } - cam_freeccb(ccb); + return (0); +} + +static int +ata_do_pass_16(struct cam_device *device, union ccb *ccb, int retries, + u_int32_t flags, u_int8_t protocol, u_int8_t ata_flags, + u_int8_t tag_action, u_int8_t command, u_int8_t features, + u_int64_t lba, u_int8_t sector_count, u_int8_t *data_ptr, + u_int16_t dxfer_len, int timeout, int quiet) +{ + if (data_ptr != NULL) { + ata_flags |= AP_FLAG_BYT_BLOK_BYTES | + AP_FLAG_TLEN_SECT_CNT; + if (flags & CAM_DIR_OUT) + ata_flags |= AP_FLAG_TDIR_TO_DEV; + else + ata_flags |= AP_FLAG_TDIR_FROM_DEV; + } else { + ata_flags |= AP_FLAG_TLEN_NO_DATA; + } + + bzero(&(&ccb->ccb_h)[1], + sizeof(struct ccb_scsiio) - sizeof(struct ccb_hdr)); + + scsi_ata_pass_16(&ccb->csio, + retries, + NULL, + flags, + tag_action, + protocol, + ata_flags, + features, + sector_count, + lba, + command, + /*control*/0, + data_ptr, + dxfer_len, + /*sense_len*/SSD_FULL_SIZE, + timeout); + + return scsi_cam_pass_16_send(device, ccb, quiet); +} + +static int +ata_try_pass_16(struct cam_device *device) +{ + struct ccb_pathinq cpi; + + if (get_cpi(device, &cpi) != 0) { + warnx("couldn't get CPI"); + return (-1); + } + + if (cpi.protocol == PROTO_SCSI) { + /* possibly compatible with pass_16 */ + return (1); + } + + /* likely not compatible with pass_16 */ + return (0); +} + +static int +ata_do_28bit_cmd(struct cam_device *device, union ccb *ccb, int retries, + u_int32_t flags, u_int8_t protocol, u_int8_t tag_action, + u_int8_t command, u_int8_t features, u_int32_t lba, + u_int8_t sector_count, u_int8_t *data_ptr, u_int16_t dxfer_len, + int timeout, int quiet) +{ + + + switch (ata_try_pass_16(device)) { + case -1: + return (1); + case 1: + /* Try using SCSI Passthrough */ + return ata_do_pass_16(device, ccb, retries, flags, protocol, + 0, tag_action, command, features, lba, + sector_count, data_ptr, dxfer_len, + timeout, quiet); + } + + bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_ataio) - + sizeof(struct ccb_hdr)); + cam_fill_ataio(&ccb->ataio, + retries, + NULL, + flags, + tag_action, + data_ptr, + dxfer_len, + timeout); + + ata_28bit_cmd(&ccb->ataio, command, features, lba, sector_count); + return ata_cam_send(device, ccb, quiet); +} + +static void +dump_data(uint16_t *ptr, uint32_t len) +{ + u_int i; + + for (i = 0; i < len / 2; i++) { + if ((i % 8) == 0) + printf(" %3d: ", i); + printf("%04hx ", ptr[i]); + if ((i % 8) == 7) + printf("\n"); + } + if ((i % 8) != 7) + printf("\n"); +} + +static int +ata_do_identify(struct cam_device *device, int retry_count, int timeout, + union ccb *ccb, struct ata_params** ident_bufp) +{ + struct ata_params *ident_buf; + struct ccb_pathinq cpi; + struct ccb_getdev cgd; + u_int i, error; + int16_t *ptr; + u_int8_t command, retry_command; + + if (get_cpi(device, &cpi) != 0) { + warnx("couldn't get CPI"); + return (-1); + } + + /* Neither PROTO_ATAPI or PROTO_SATAPM are used in cpi.protocol */ + if (cpi.protocol == PROTO_ATA) { + if (get_cgd(device, &cgd) != 0) { + warnx("couldn't get CGD"); + return (-1); + } + + command = (cgd.protocol == PROTO_ATA) ? + ATA_ATA_IDENTIFY : ATA_ATAPI_IDENTIFY; + retry_command = 0; + } else { + /* We don't know which for sure so try both */ + command = ATA_ATA_IDENTIFY; + retry_command = ATA_ATAPI_IDENTIFY; + } + + ptr = (uint16_t *)calloc(1, sizeof(struct ata_params)); + if (ptr == NULL) { + warnx("can't calloc memory for identify\n"); + return (1); + } + + error = ata_do_28bit_cmd(device, + ccb, + /*retries*/retry_count, + /*flags*/CAM_DIR_IN, + /*protocol*/AP_PROTO_PIO_IN, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/command, + /*features*/0, + /*lba*/0, + /*sector_count*/(u_int8_t)sizeof(struct ata_params), + /*data_ptr*/(u_int8_t *)ptr, + /*dxfer_len*/sizeof(struct ata_params), + /*timeout*/timeout ? timeout : 30 * 1000, + /*quiet*/1); if (error != 0) { - free(ptr); - return(error); + if (retry_command == 0) { + free(ptr); + return (1); + } + error = ata_do_28bit_cmd(device, + ccb, + /*retries*/retry_count, + /*flags*/CAM_DIR_IN, + /*protocol*/AP_PROTO_PIO_IN, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/retry_command, + /*features*/0, + /*lba*/0, + /*sector_count*/(u_int8_t) + sizeof(struct ata_params), + /*data_ptr*/(u_int8_t *)ptr, + /*dxfer_len*/sizeof(struct ata_params), + /*timeout*/timeout ? timeout : 30 * 1000, + /*quiet*/0); + + if (error != 0) { + free(ptr); + return (1); + } } - for (i = 0; i < sizeof(struct ata_params) / 2; i++) + error = 1; + for (i = 0; i < sizeof(struct ata_params) / 2; i++) { ptr[i] = le16toh(ptr[i]); + if (ptr[i] != 0) + error = 0; + } + if (arglist & CAM_ARG_VERBOSE) { fprintf(stdout, "%s%d: Raw identify data:\n", device->device_name, device->dev_unit_num); - for (i = 0; i < sizeof(struct ata_params) / 2; i++) { - if ((i % 8) == 0) - fprintf(stdout, " %3d: ", i); - fprintf(stdout, "%04x ", (uint16_t)ptr[i]); - if ((i % 8) == 7) - fprintf(stdout, "\n"); - } + dump_data(ptr, sizeof(struct ata_params)); } + + /* check for invalid (all zero) response */ + if (error != 0) { + warnx("Invalid identify response detected"); + free(ptr); + return (error); + } + ident_buf = (struct ata_params *)ptr; if (strncmp(ident_buf->model, "FX", 2) && strncmp(ident_buf->model, "NEC", 3) && @@ -1446,15 +1690,636 @@ ataidentify(struct cam_device *device, i ata_bpack(ident_buf->media_serial, ident_buf->media_serial, sizeof(ident_buf->media_serial)); - fprintf(stdout, "%s%d: ", device->device_name, - device->dev_unit_num); + *ident_bufp = ident_buf; + + return (0); +} + + +static int +ataidentify(struct cam_device *device, int retry_count, int timeout) +{ + union ccb *ccb; + struct ata_params *ident_buf; + + if ((ccb = cam_getccb(device)) == NULL) { + warnx("couldn't allocate CCB"); + return (1); + } + + if (ata_do_identify(device, retry_count, timeout, ccb, &ident_buf) != 0) { + cam_freeccb(ccb); + return (1); + } + + printf("%s%d: ", device->device_name, device->dev_unit_num); ata_print_ident(ident_buf); camxferrate(device); atacapprint(ident_buf); free(ident_buf); + cam_freeccb(ccb); - return(0); + return (0); +} +#endif /* MINIMALISTIC */ + + +#ifndef MINIMALISTIC +enum { + ATA_SECURITY_ACTION_PRINT, + ATA_SECURITY_ACTION_FREEZE, + ATA_SECURITY_ACTION_UNLOCK, + ATA_SECURITY_ACTION_DISABLE, + ATA_SECURITY_ACTION_ERASE, + ATA_SECURITY_ACTION_ERASE_ENHANCED, + ATA_SECURITY_ACTION_SET_PASSWORD +} atasecurity_action; + +static void +atasecurity_print_time(u_int16_t tw) +{ + + if (tw == 0) + printf("unspecified"); + else if (tw >= 255) + printf("> 508 min"); + else + printf("%i min", 2 * tw); +} + +static u_int32_t +atasecurity_erase_timeout_msecs(u_int16_t timeout) +{ + + if (timeout == 0) + return 2 * 3600 * 1000; /* default: two hours */ + else if (timeout > 255) + return (508 + 60) * 60 * 1000; /* spec says > 508 minutes */ + + return ((2 * timeout) + 5) * 60 * 1000; /* add a 5min margin */ +} + + +static void +atasecurity_notify(u_int8_t command, struct ata_security_password *pwd) +{ + struct ata_cmd cmd; + + bzero(&cmd, sizeof(cmd)); + cmd.command = command; + printf("Issuing %s", ata_op_string(&cmd)); + + if (pwd != NULL) { + char pass[sizeof(pwd->password)+1]; + + /* pwd->password may not be null terminated */ + pass[sizeof(pwd->password)] = '\0'; + strncpy(pass, pwd->password, sizeof(pwd->password)); + printf(" password='%s', user='%s'", + pass, + (pwd->ctrl & ATA_SECURITY_PASSWORD_MASTER) ? + "master" : "user"); + + if (command == ATA_SECURITY_SET_PASSWORD) { + printf(", mode='%s'", + (pwd->ctrl & ATA_SECURITY_LEVEL_MAXIMUM) ? + "maximum" : "high"); + } + } + + printf("\n"); +} + +static int +atasecurity_freeze(struct cam_device *device, union ccb *ccb, + int retry_count, u_int32_t timeout, int quiet) +{ + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_FREEZE_LOCK, NULL); + + return ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_FREEZE_LOCK, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + /*timeout*/timeout, + /*quiet*/0); +} + +static int +atasecurity_unlock(struct cam_device *device, union ccb *ccb, + int retry_count, u_int32_t timeout, + struct ata_security_password *pwd, int quiet) +{ + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_UNLOCK, pwd); + + return ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/AP_PROTO_PIO_OUT, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_UNLOCK, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t *)pwd, + /*dxfer_len*/sizeof(*pwd), + /*timeout*/timeout, + /*quiet*/0); +} + +static int +atasecurity_disable(struct cam_device *device, union ccb *ccb, + int retry_count, u_int32_t timeout, + struct ata_security_password *pwd, int quiet) +{ + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_DISABLE_PASSWORD, pwd); + return ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/AP_PROTO_PIO_OUT, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_DISABLE_PASSWORD, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t *)pwd, + /*dxfer_len*/sizeof(*pwd), + /*timeout*/timeout, + /*quiet*/0); +} + + +static int +atasecurity_erase_confirm(struct cam_device *device, + struct ata_params* ident_buf) +{ + + printf("\nYou are about to ERASE ALL DATA from the following" + " device:\n%s%d,%s%d: ", device->device_name, + device->dev_unit_num, device->given_dev_name, + device->given_unit_number); + ata_print_ident(ident_buf); + + for(;;) { + char str[50]; + printf("\nAre you SURE you want to ERASE ALL DATA? (yes/no) "); + + if (fgets(str, sizeof(str), stdin) != NULL) { + if (strncasecmp(str, "yes", 3) == 0) { + return (1); + } else if (strncasecmp(str, "no", 2) == 0) { + return (0); + } else { + printf("Please answer \"yes\" or " + "\"no\"\n"); + } + } + } + + /* NOTREACHED */ + return (0); +} + +static int +atasecurity_erase(struct cam_device *device, union ccb *ccb, + int retry_count, u_int32_t timeout, + u_int32_t erase_timeout, + struct ata_security_password *pwd, int quiet) +{ + int error; + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_ERASE_PREPARE, NULL); + + error = ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_NONE, + /*protocol*/AP_PROTO_NON_DATA, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_ERASE_PREPARE, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + /*timeout*/timeout, + /*quiet*/0); + + if (error != 0) + return error; + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_ERASE_UNIT, pwd); + + error = ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/AP_PROTO_PIO_OUT, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_ERASE_UNIT, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t *)pwd, + /*dxfer_len*/sizeof(*pwd), + /*timeout*/erase_timeout, + /*quiet*/0); + + if (error == 0 && quiet == 0) + printf("\nErase Complete\n"); + + return error; +} + +static int +atasecurity_set_password(struct cam_device *device, union ccb *ccb, + int retry_count, u_int32_t timeout, + struct ata_security_password *pwd, int quiet) +{ + + if (quiet == 0) + atasecurity_notify(ATA_SECURITY_SET_PASSWORD, pwd); + + return ata_do_28bit_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/AP_PROTO_PIO_OUT, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/ATA_SECURITY_SET_PASSWORD, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t *)pwd, + /*dxfer_len*/sizeof(*pwd), + /*timeout*/timeout, + /*quiet*/0); +} + +static void +atasecurity_print(struct ata_params *parm) +{ + + printf("\nSecurity Option Value\n"); + if (arglist & CAM_ARG_VERBOSE) { + printf("status %04x\n", + parm->security_status); + } + printf("supported %s\n", + parm->security_status & ATA_SECURITY_SUPPORTED ? "yes" : "no"); + if (!(parm->security_status & ATA_SECURITY_SUPPORTED)) + return; + printf("enabled %s\n", + parm->security_status & ATA_SECURITY_ENABLED ? "yes" : "no"); + printf("drive locked %s\n", + parm->security_status & ATA_SECURITY_LOCKED ? "yes" : "no"); + printf("security config frozen %s\n", + parm->security_status & ATA_SECURITY_FROZEN ? "yes" : "no"); + printf("count expired %s\n", + parm->security_status & ATA_SECURITY_COUNT_EXP ? "yes" : "no"); + printf("security level %s\n", + parm->security_status & ATA_SECURITY_LEVEL ? "maximum" : "high"); + printf("enhanced erase supported %s\n", + parm->security_status & ATA_SECURITY_ENH_SUPP ? "yes" : "no"); + printf("erase time "); + atasecurity_print_time(parm->erase_time); + printf("\n"); + printf("enhanced erase time "); + atasecurity_print_time(parm->enhanced_erase_time); + printf("\n"); + printf("master password rev %04x%s\n", + parm->master_passwd_revision, + parm->master_passwd_revision == 0x0000 || + parm->master_passwd_revision == 0xFFFF ? " (unsupported)" : ""); +} + +/* + * Validates and copies the password in optarg to the passed buffer. + * If the password in optarg is the same length as the buffer then + * the data will still be copied but no null termination will occur. + */ +static int +ata_getpwd(u_int8_t *passwd, int max, char opt) +{ + int len; + + len = strlen(optarg); + if (len > max) { + warnx("-%c password is too long", opt); + return (1); + } else if (len == 0) { + warnx("-%c password is missing", opt); + return (1); + } else if (optarg[0] == '-'){ + warnx("-%c password starts with '-' (generic arg?)", opt); + return (1); + } else if (strlen(passwd) != 0 && strcmp(passwd, optarg) != 0) { + warnx("-%c password conflicts with existing password from -%c", + opt, pwd_opt); + return (1); + } + + /* Callers pass in a buffer which does NOT need to be terminated */ + strncpy(passwd, optarg, max); + pwd_opt = opt; + + return (0); +} + +static int +atasecurity(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt) +{ + union ccb *ccb; + struct ata_params *ident_buf; + int error, confirm, quiet, c, action, actions, setpwd; + int security_enabled, erase_timeout, pwdsize; + struct ata_security_password pwd; + + actions = 0; + setpwd = 0; + erase_timeout = 0; + confirm = 0; + quiet = 0; + + memset(&pwd, 0, sizeof(pwd)); + + /* default action is to print security information */ + action = ATA_SECURITY_ACTION_PRINT; + + /* user is master by default as its safer that way */ + pwd.ctrl |= ATA_SECURITY_PASSWORD_MASTER; + pwdsize = sizeof(pwd.password); + *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 7 14:23:12 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2031AF26; Fri, 7 Jun 2013 14:23:12 +0000 (UTC) (envelope-from smh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 028E211E9; Fri, 7 Jun 2013 14:23:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r57ENBKT032513; Fri, 7 Jun 2013 14:23:12 GMT (envelope-from smh@svn.freebsd.org) Received: (from smh@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r57ENB0h032509; Fri, 7 Jun 2013 14:23:11 GMT (envelope-from smh@svn.freebsd.org) Message-Id: <201306071423.r57ENB0h032509@svn.freebsd.org> From: Steven Hartland Date: Fri, 7 Jun 2013 14:23:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251498 - in stable/9: sbin/camcontrol sys/sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2013 14:23:12 -0000 Author: smh Date: Fri Jun 7 14:23:11 2013 New Revision: 251498 URL: http://svnweb.freebsd.org/changeset/base/251498 Log: MFC r249895: Add Host Protected Area (HPA) support to camcontrol MFC r249904: mdoc: remove superfluous paragraph macro. Modified: stable/9/sbin/camcontrol/camcontrol.8 stable/9/sbin/camcontrol/camcontrol.c stable/9/sys/sys/ata.h Directory Properties: stable/9/sbin/camcontrol/ (props changed) stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 7 14:10:18 2013 (r251497) +++ stable/9/sbin/camcontrol/camcontrol.8 Fri Jun 7 14:23:11 2013 (r251498) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 4, 2012 +.Dd April 24, 2013 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -243,6 +243,18 @@ .Op Fl U Ar user|master .Op Fl y .Nm +.Ic hpa +.Op device id +.Op generic args +.Op Fl f +.Op Fl l +.Op Fl P +.Op Fl p Ar pwd +.Op Fl q +.Op Fl s Ar max_sectors +.Op Fl U Ar pwd +.Op Fl y +.Nm .Ic help .Sh DESCRIPTION The @@ -1204,6 +1216,73 @@ password for the specified user the comm .Pp The password in all cases is limited to 32 characters, longer passwords will fail. +.It Ic hpa +Update or report Host Protected Area details. +By default +.Nm +will print out the HPA support and associated settings of the device. +The +.Ic hpa +command takes several optional arguments: +.Bl -tag -width 0n +.It Fl f +.Pp +Freeze the HPA configuration of the specified device. +.Pp +After command completion any other commands that update the HPA configuration +shall be command aborted. +Frozen mode is disabled by power-off or hardware reset. +.It Fl l +.Pp +Lock the HPA configuration of the device until a successful call to unlock or +the next power-on reset occurs. +.It Fl P +.Pp +Make the HPA max sectors persist across power-on reset or a hardware reset. +This must be used in combination with +.Fl s Ar max_sectors +. +.It Fl p Ar pwd +.Pp +Set the HPA configuration password required for unlock calls. +.It Fl q +.Pp +Be quiet, do not print any status messages. +This option will not disable the questions. +To disable questions, use the +.Fl y +argument, below. +.It Fl s Ar max_sectors +.Pp +Configures the maximum user accessible sectors of the device. +This will change the number of sectors the device reports. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +Changing the max sectors of a device using this option will make the data on +the device beyond the specified value inaccessible. +.Pp +Only one successful +.Fl s Ar max_sectors +call can be made without a power-on reset or a hardware reset of the device. +.It Fl U Ar pwd +.Pp +Unlock the HPA configuration of the specified device using the given password. +If the password specified doesn't match the password configured via +.Fl p Ar pwd +the command will fail. +.Pp +After 5 failed unlock calls, due to password miss-match, the device will refuse +additional unlock calls until after a power-on reset. +.It Fl y +.Pp +Confirm yes to dangerous options such as +.Fl e +without prompting for confirmation +.Pp +.El +The password for all HPA commands is limited to 32 characters, longer passwords +will fail. .It Ic fwdownload Program firmware of the named SCSI device using the image file provided. .Pp @@ -1396,6 +1475,28 @@ data from the device, so backup your dat .Pp This command can be used used against an SSD drive to restoring it to factory default write performance. +.Bd -literal -offset indent +camcontrol hpa ada0 +.Ed +.Pp +Report HPA support and settings for ada0 (also reported via +identify). +.Bd -literal -offset indent +camcontrol hpa ada0 -s 10240 +.Ed +.Pp +Enables HPA on ada0 setting the maximum reported sectors to 10240. +.Pp +.Em WARNING! WARNING! WARNING! +.Pp +This will +.Em PREVENT ACCESS +to all data on the device beyond this limit until HPA is disabled by setting +HPA to native max sectors of the device, which can only be done after a +power-on or hardware reset! +.Pp +.Em DO NOT +use this on a device which has an active filesystem! .Sh SEE ALSO .Xr cam 3 , .Xr cam_cdbparse 3 , Modified: stable/9/sbin/camcontrol/camcontrol.c ============================================================================== --- stable/9/sbin/camcontrol/camcontrol.c Fri Jun 7 14:10:18 2013 (r251497) +++ stable/9/sbin/camcontrol/camcontrol.c Fri Jun 7 14:23:11 2013 (r251498) @@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifndef MINIMALISTIC +#include +#include +#endif #include #include @@ -88,7 +92,8 @@ typedef enum { CAM_CMD_SMP_PHYLIST = 0x0000001a, CAM_CMD_SMP_MANINFO = 0x0000001b, CAM_CMD_DOWNLOAD_FW = 0x0000001c, - CAM_CMD_SECURITY = 0x0000001d + CAM_CMD_SECURITY = 0x0000001d, + CAM_CMD_HPA = 0x0000001e } cam_cmdmask; typedef enum { @@ -135,6 +140,29 @@ struct camcontrol_opts { }; #ifndef MINIMALISTIC +struct ata_res_pass16 { + u_int16_t reserved[5]; + u_int8_t flags; + u_int8_t error; + u_int8_t sector_count_exp; + u_int8_t sector_count; + u_int8_t lba_low_exp; + u_int8_t lba_low; + u_int8_t lba_mid_exp; + u_int8_t lba_mid; + u_int8_t lba_high_exp; + u_int8_t lba_high; + u_int8_t device; + u_int8_t status; +}; + +struct ata_set_max_pwd +{ + u_int16_t reserved1; + u_int8_t password[32]; + u_int16_t reserved2[239]; +}; + static const char scsicmd_opts[] = "a:c:dfi:o:r"; static const char readdefect_opts[] = "f:GP"; static const char negotiate_opts[] = "acD:M:O:qR:T:UW:"; @@ -186,6 +214,7 @@ static struct camcontrol_opts option_tab {"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""}, {"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:ys"}, {"security", CAM_CMD_SECURITY, CAM_ARG_NONE, "d:e:fh:k:l:qs:T:U:y"}, + {"hpa", CAM_CMD_HPA, CAM_ARG_NONE, "Pflp:qs:U:y"}, #endif /* MINIMALISTIC */ {"help", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, {"-?", CAM_CMD_USAGE, CAM_ARG_NONE, NULL}, @@ -280,6 +309,8 @@ static int atapm(struct cam_device *devi char *combinedopt, int retry_count, int timeout); static int atasecurity(struct cam_device *device, int retry_count, int timeout, int argc, char **argv, char *combinedopt); +static int atahpa(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt); #endif /* MINIMALISTIC */ #ifndef min @@ -1128,6 +1159,38 @@ xferrate_bailout: } static void +atahpa_print(struct ata_params *parm, u_int64_t hpasize, int header) +{ + u_int32_t lbasize = (u_int32_t)parm->lba_size_1 | + ((u_int32_t)parm->lba_size_2 << 16); + + u_int64_t lbasize48 = ((u_int64_t)parm->lba_size48_1) | + ((u_int64_t)parm->lba_size48_2 << 16) | + ((u_int64_t)parm->lba_size48_3 << 32) | + ((u_int64_t)parm->lba_size48_4 << 48); + + if (header) { + printf("\nFeature " + "Support Enabled Value\n"); + } + + printf("Host Protected Area (HPA) "); + if (parm->support.command1 & ATA_SUPPORT_PROTECTED) { + u_int64_t lba = lbasize48 ? lbasize48 : lbasize; + printf("yes %s %ju/%ju\n", (hpasize > lba) ? "yes" : "no ", + lba, hpasize); + + printf("HPA - Security "); + if (parm->support.command1 & ATA_SUPPORT_MAXSECURITY) + printf("yes\n"); + else + printf("no\n"); + } else { + printf("no\n"); + } +} + +static void atacapprint(struct ata_params *parm) { u_int32_t lbasize = (u_int32_t)parm->lba_size_1 | @@ -1554,6 +1617,83 @@ ata_do_28bit_cmd(struct cam_device *devi return ata_cam_send(device, ccb, quiet); } +static int +ata_do_cmd(struct cam_device *device, union ccb *ccb, int retries, + u_int32_t flags, u_int8_t protocol, u_int8_t ata_flags, + u_int8_t tag_action, u_int8_t command, u_int8_t features, + u_int64_t lba, u_int8_t sector_count, u_int8_t *data_ptr, + u_int16_t dxfer_len, int timeout, int force48bit) +{ + int retval; + + retval = ata_try_pass_16(device); + if (retval == -1) + return (1); + + if (retval == 1) { + int error; + + /* Try using SCSI Passthrough */ + error = ata_do_pass_16(device, ccb, retries, flags, protocol, + ata_flags, tag_action, command, features, + lba, sector_count, data_ptr, dxfer_len, + timeout, 0); + + if (ata_flags & AP_FLAG_CHK_COND) { + /* Decode ata_res from sense data */ + struct ata_res_pass16 *res_pass16; + struct ata_res *res; + u_int i; + u_int16_t *ptr; + + /* sense_data is 4 byte aligned */ + ptr = (uint16_t*)(uintptr_t)&ccb->csio.sense_data; + for (i = 0; i < sizeof(*res_pass16) / 2; i++) + ptr[i] = le16toh(ptr[i]); + + /* sense_data is 4 byte aligned */ + res_pass16 = (struct ata_res_pass16 *)(uintptr_t) + &ccb->csio.sense_data; + res = &ccb->ataio.res; + res->flags = res_pass16->flags; + res->status = res_pass16->status; + res->error = res_pass16->error; + res->lba_low = res_pass16->lba_low; + res->lba_mid = res_pass16->lba_mid; + res->lba_high = res_pass16->lba_high; + res->device = res_pass16->device; + res->lba_low_exp = res_pass16->lba_low_exp; + res->lba_mid_exp = res_pass16->lba_mid_exp; + res->lba_high_exp = res_pass16->lba_high_exp; + res->sector_count = res_pass16->sector_count; + res->sector_count_exp = res_pass16->sector_count_exp; + } + + return (error); + } + + bzero(&(&ccb->ccb_h)[1], sizeof(struct ccb_ataio) - + sizeof(struct ccb_hdr)); + cam_fill_ataio(&ccb->ataio, + retries, + NULL, + flags, + tag_action, + data_ptr, + dxfer_len, + timeout); + + if (force48bit || lba > ATA_MAX_28BIT_LBA) + ata_48bit_cmd(&ccb->ataio, command, features, lba, sector_count); + else + ata_28bit_cmd(&ccb->ataio, command, features, lba, sector_count); + + if (ata_flags & AP_FLAG_CHK_COND) + ccb->ataio.cmd.flags |= CAM_ATAIO_NEEDRESULT; + + return ata_cam_send(device, ccb, 0); +} + static void dump_data(uint16_t *ptr, uint32_t len) { @@ -1571,6 +1711,278 @@ dump_data(uint16_t *ptr, uint32_t len) } static int +atahpa_proc_resp(struct cam_device *device, union ccb *ccb, + int is48bit, u_int64_t *hpasize) +{ + struct ata_res *res; + + res = &ccb->ataio.res; + if (res->status & ATA_STATUS_ERROR) { + if (arglist & CAM_ARG_VERBOSE) { + cam_error_print(device, ccb, CAM_ESF_ALL, + CAM_EPF_ALL, stderr); + printf("error = 0x%02x, sector_count = 0x%04x, " + "device = 0x%02x, status = 0x%02x\n", + res->error, res->sector_count, + res->device, res->status); + } + + if (res->error & ATA_ERROR_ID_NOT_FOUND) { + warnx("Max address has already been set since " + "last power-on or hardware reset"); + } + + return (1); + } + + if (arglist & CAM_ARG_VERBOSE) { + fprintf(stdout, "%s%d: Raw native max data:\n", + device->device_name, device->dev_unit_num); + /* res is 4 byte aligned */ + dump_data((uint16_t*)(uintptr_t)res, sizeof(struct ata_res)); + + printf("error = 0x%02x, sector_count = 0x%04x, device = 0x%02x, " + "status = 0x%02x\n", res->error, res->sector_count, + res->device, res->status); + } + + if (hpasize != NULL) { + if (is48bit) { + *hpasize = (((u_int64_t)((res->lba_high_exp << 16) | + (res->lba_mid_exp << 8) | res->lba_low_exp) << 24) | + ((res->lba_high << 16) | (res->lba_mid << 8) | + res->lba_low)) + 1; + } else { + *hpasize = (((res->device & 0x0f) << 24) | + (res->lba_high << 16) | (res->lba_mid << 8) | + res->lba_low) + 1; + } + } + + return (0); +} + +static int +ata_read_native_max(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, + struct ata_params *parm, u_int64_t *hpasize) +{ + int error; + u_int cmd, is48bit; + u_int8_t protocol; + + is48bit = parm->support.command2 & ATA_SUPPORT_ADDRESS48; + protocol = AP_PROTO_NON_DATA; + + if (is48bit) { + cmd = ATA_READ_NATIVE_MAX_ADDRESS48; + protocol |= AP_EXTEND; + } else { + cmd = ATA_READ_NATIVE_MAX_ADDRESS; + } + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_IN, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/0, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, hpasize); +} + +static int +atahpa_set_max(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, + int is48bit, u_int64_t maxsize, int persist) +{ + int error; + u_int cmd; + u_int8_t protocol; + + protocol = AP_PROTO_NON_DATA; + + if (is48bit) { + cmd = ATA_SET_MAX_ADDRESS48; + protocol |= AP_EXTEND; + } else { + cmd = ATA_SET_MAX_ADDRESS; + } + + /* lba's are zero indexed so the max lba is requested max - 1 */ + if (maxsize) + maxsize--; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/ATA_HPA_FEAT_MAX_ADDR, + /*lba*/maxsize, + /*sector_count*/persist, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, NULL); +} + +static int +atahpa_password(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, + int is48bit, struct ata_set_max_pwd *pwd) +{ + int error; + u_int cmd; + u_int8_t protocol; + + protocol = AP_PROTO_PIO_OUT; + cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/ATA_HPA_FEAT_SET_PWD, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t*)pwd, + /*dxfer_len*/sizeof(struct ata_set_max_pwd), + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, NULL); +} + +static int +atahpa_lock(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, int is48bit) +{ + int error; + u_int cmd; + u_int8_t protocol; + + protocol = AP_PROTO_NON_DATA; + cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/ATA_HPA_FEAT_LOCK, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, NULL); +} + +static int +atahpa_unlock(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, + int is48bit, struct ata_set_max_pwd *pwd) +{ + int error; + u_int cmd; + u_int8_t protocol; + + protocol = AP_PROTO_PIO_OUT; + cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/ATA_HPA_FEAT_UNLOCK, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/(u_int8_t*)pwd, + /*dxfer_len*/sizeof(struct ata_set_max_pwd), + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, NULL); +} + +static int +atahpa_freeze_lock(struct cam_device *device, int retry_count, + u_int32_t timeout, union ccb *ccb, int is48bit) +{ + int error; + u_int cmd; + u_int8_t protocol; + + protocol = AP_PROTO_NON_DATA; + cmd = (is48bit) ? ATA_SET_MAX_ADDRESS48 : ATA_SET_MAX_ADDRESS; + + error = ata_do_cmd(device, + ccb, + retry_count, + /*flags*/CAM_DIR_OUT, + /*protocol*/protocol, + /*ata_flags*/AP_FLAG_CHK_COND, + /*tag_action*/MSG_SIMPLE_Q_TAG, + /*command*/cmd, + /*features*/ATA_HPA_FEAT_FREEZE, + /*lba*/0, + /*sector_count*/0, + /*data_ptr*/NULL, + /*dxfer_len*/0, + timeout ? timeout : 1000, + is48bit); + + if (error) + return (error); + + return atahpa_proc_resp(device, ccb, is48bit, NULL); +} + + +static int ata_do_identify(struct cam_device *device, int retry_count, int timeout, union ccb *ccb, struct ata_params** ident_bufp) { @@ -1701,6 +2113,7 @@ ataidentify(struct cam_device *device, i { union ccb *ccb; struct ata_params *ident_buf; + u_int64_t hpasize; if ((ccb = cam_getccb(device)) == NULL) { warnx("couldn't allocate CCB"); @@ -1712,10 +2125,21 @@ ataidentify(struct cam_device *device, i return (1); } + if (ident_buf->support.command1 & ATA_SUPPORT_PROTECTED) { + if (ata_read_native_max(device, retry_count, timeout, ccb, + ident_buf, &hpasize) != 0) { + cam_freeccb(ccb); + return (1); + } + } else { + hpasize = 0; + } + printf("%s%d: ", device->device_name, device->dev_unit_num); ata_print_ident(ident_buf); camxferrate(device); atacapprint(ident_buf); + atahpa_print(ident_buf, hpasize, 0); free(ident_buf); cam_freeccb(ccb); @@ -2044,6 +2468,245 @@ ata_getpwd(u_int8_t *passwd, int max, ch return (0); } +enum { + ATA_HPA_ACTION_PRINT, + ATA_HPA_ACTION_SET_MAX, + ATA_HPA_ACTION_SET_PWD, + ATA_HPA_ACTION_LOCK, + ATA_HPA_ACTION_UNLOCK, + ATA_HPA_ACTION_FREEZE_LOCK +}; + +static int +atahpa_set_confirm(struct cam_device *device, struct ata_params* ident_buf, + u_int64_t maxsize, int persist) +{ + printf("\nYou are about to configure HPA to limit the user accessible\n" + "sectors to %ju %s on the device:\n%s%d,%s%d: ", maxsize, + persist ? "persistently" : "temporarily", + device->device_name, device->dev_unit_num, + device->given_dev_name, device->given_unit_number); + ata_print_ident(ident_buf); + + for(;;) { + char str[50]; + printf("\nAre you SURE you want to configure HPA? (yes/no) "); + + if (NULL != fgets(str, sizeof(str), stdin)) { + if (0 == strncasecmp(str, "yes", 3)) { + return (1); + } else if (0 == strncasecmp(str, "no", 2)) { + return (0); + } else { + printf("Please answer \"yes\" or " + "\"no\"\n"); + } + } + } + + /* NOTREACHED */ + return (0); +} + +static int +atahpa(struct cam_device *device, int retry_count, int timeout, + int argc, char **argv, char *combinedopt) +{ + union ccb *ccb; + struct ata_params *ident_buf; + struct ccb_getdev cgd; + struct ata_set_max_pwd pwd; + int error, confirm, quiet, c, action, actions, setpwd, persist; + int security, is48bit, pwdsize; + u_int64_t hpasize, maxsize; + + actions = 0; + setpwd = 0; + confirm = 0; + quiet = 0; + maxsize = 0; + persist = 0; + security = 0; + + memset(&pwd, 0, sizeof(pwd)); + + /* default action is to print hpa information */ + action = ATA_HPA_ACTION_PRINT; + pwdsize = sizeof(pwd.password); + + while ((c = getopt(argc, argv, combinedopt)) != -1) { + switch(c){ + case 's': + action = ATA_HPA_ACTION_SET_MAX; + maxsize = strtoumax(optarg, NULL, 0); + actions++; + break; + + case 'p': + if (ata_getpwd(pwd.password, pwdsize, c) != 0) + return (1); + action = ATA_HPA_ACTION_SET_PWD; + security = 1; + actions++; + break; + + case 'l': + action = ATA_HPA_ACTION_LOCK; + security = 1; + actions++; + break; + + case 'U': + if (ata_getpwd(pwd.password, pwdsize, c) != 0) + return (1); + action = ATA_HPA_ACTION_UNLOCK; + security = 1; + actions++; + break; + + case 'f': + action = ATA_HPA_ACTION_FREEZE_LOCK; + security = 1; + actions++; + break; + + case 'P': + persist = 1; + break; + + case 'y': + confirm++; + break; + + case 'q': + quiet++; + break; + } + } + + if (actions > 1) { + warnx("too many hpa actions specified"); + return (1); + } + + if (get_cgd(device, &cgd) != 0) { + warnx("couldn't get CGD"); + return (1); + } + + ccb = cam_getccb(device); + if (ccb == NULL) { + warnx("couldn't allocate CCB"); + return (1); + } + + error = ata_do_identify(device, retry_count, timeout, ccb, &ident_buf); + if (error != 0) { + cam_freeccb(ccb); + return (1); + } + + if (quiet == 0) { + printf("%s%d: ", device->device_name, device->dev_unit_num); + ata_print_ident(ident_buf); + camxferrate(device); + } + + if (action == ATA_HPA_ACTION_PRINT) { + error = ata_read_native_max(device, retry_count, timeout, ccb, + ident_buf, &hpasize); + if (error == 0) + atahpa_print(ident_buf, hpasize, 1); + + cam_freeccb(ccb); + free(ident_buf); + return (error); + } + + if (!(ident_buf->support.command1 & ATA_SUPPORT_PROTECTED)) { + warnx("HPA is not supported by this device"); + cam_freeccb(ccb); + free(ident_buf); + return (1); + } + + if (security && !(ident_buf->support.command1 & ATA_SUPPORT_MAXSECURITY)) { + warnx("HPA Security is not supported by this device"); + cam_freeccb(ccb); + free(ident_buf); + return (1); + } + + is48bit = ident_buf->support.command2 & ATA_SUPPORT_ADDRESS48; + + /* + * The ATA spec requires: + * 1. Read native max addr is called directly before set max addr + * 2. Read native max addr is NOT called before any other set max call + */ + switch(action) { + case ATA_HPA_ACTION_SET_MAX: + if (confirm == 0 && + atahpa_set_confirm(device, ident_buf, maxsize, + persist) == 0) { + cam_freeccb(ccb); + free(ident_buf); + return (1); + } + + error = ata_read_native_max(device, retry_count, timeout, + ccb, ident_buf, &hpasize); + if (error == 0) { + error = atahpa_set_max(device, retry_count, timeout, + ccb, is48bit, maxsize, persist); + if (error == 0) { + /* redo identify to get new lba values */ + error = ata_do_identify(device, retry_count, + timeout, ccb, + &ident_buf); + atahpa_print(ident_buf, hpasize, 1); + } + } + break; + + case ATA_HPA_ACTION_SET_PWD: + error = atahpa_password(device, retry_count, timeout, + ccb, is48bit, &pwd); + if (error == 0) + printf("HPA password has been set\n"); + break; + + case ATA_HPA_ACTION_LOCK: + error = atahpa_lock(device, retry_count, timeout, + ccb, is48bit); + if (error == 0) + printf("HPA has been locked\n"); + break; + + case ATA_HPA_ACTION_UNLOCK: + error = atahpa_unlock(device, retry_count, timeout, + ccb, is48bit, &pwd); + if (error == 0) + printf("HPA has been unlocked\n"); + break; + + case ATA_HPA_ACTION_FREEZE_LOCK: + error = atahpa_freeze_lock(device, retry_count, timeout, + ccb, is48bit); + if (error == 0) + printf("HPA has been frozen\n"); + break; + + default: + errx(1, "Option currently not supported"); + } + + cam_freeccb(ccb); + free(ident_buf); + + return (error); +} + static int atasecurity(struct cam_device *device, int retry_count, int timeout, int argc, char **argv, char *combinedopt) @@ -6701,6 +7364,8 @@ usage(int printlong) " <-d pwd | -e pwd | -f | -h pwd | -k pwd>\n" " [-l ] [-q] [-s pwd] [-T timeout]\n" " [-U ] [-y]\n" +" camcontrol hpa [dev_id][generic args] [-f] [-l] [-P] [-p pwd]\n" +" [-q] [-s max_sectors] [-U pwd] [-y]\n" #endif /* MINIMALISTIC */ " camcontrol help\n"); if (!printlong) @@ -6851,6 +7516,17 @@ usage(int printlong) "-T timeout overrides the timeout (seconds) used for erase operation\n" "-U specifies which user to set: user or master\n" "-y don't ask any questions\n" +"hpa arguments:\n" +"-f freeze the HPA configuration of the device\n" +"-l lock the HPA configuration of the device\n" +"-P make the HPA max sectors persist\n" +"-p pwd Set the HPA configuration password required for unlock\n" +" calls\n" +"-q be quiet, do not print any status messages\n" +"-s sectors configures the maximum user accessible sectors of the\n" +" device\n" +"-U pwd unlock the HPA configuration of the device\n" +"-y don't ask any questions\n" ); #endif /* MINIMALISTIC */ } @@ -7075,6 +7751,10 @@ main(int argc, char **argv) case CAM_CMD_DEVLIST: error = getdevlist(cam_dev); break; + case CAM_CMD_HPA: + error = atahpa(cam_dev, retry_count, timeout, + argc, argv, combinedopt); + break; #endif /* MINIMALISTIC */ case CAM_CMD_DEVTREE: error = getdevtree(); Modified: stable/9/sys/sys/ata.h ============================================================================== --- stable/9/sys/sys/ata.h Fri Jun 7 14:10:18 2013 (r251497) +++ stable/9/sys/sys/ata.h Fri Jun 7 14:23:11 2013 (r251498) @@ -289,6 +289,23 @@ struct ata_params { #define ATA_DEV_SLAVE 0x10 #define ATA_DEV_LBA 0x40 +/* ATA limits */ +#define ATA_MAX_28BIT_LBA 268435455UL + +/* ATA Status Register */ +#define ATA_STATUS_ERROR 0x01 +#define ATA_STATUS_DEVICE_FAULT 0x20 + +/* ATA Error Register */ +#define ATA_ERROR_ABORT 0x04 +#define ATA_ERROR_ID_NOT_FOUND 0x10 + +/* ATA HPA Features */ +#define ATA_HPA_FEAT_MAX_ADDR 0x00 +#define ATA_HPA_FEAT_SET_PWD 0x01 +#define ATA_HPA_FEAT_LOCK 0x02 +#define ATA_HPA_FEAT_UNLOCK 0x03 +#define ATA_HPA_FEAT_FREEZE 0x04 /* ATA transfer modes */ #define ATA_MODE_MASK 0x0f From owner-svn-src-stable-9@FreeBSD.ORG Fri Jun 7 19:02:34 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 8A0FE6E1; Fri, 7 Jun 2013 19:02:34 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7B3441F70; Fri, 7 Jun 2013 19:02:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r57J2Y9g021492; Fri, 7 Jun 2013 19:02:34 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r57J2Xso021485; Fri, 7 Jun 2013 19:02:33 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201306071902.r57J2Xso021485@svn.freebsd.org> From: "David E. O'Brien" Date: Fri, 7 Jun 2013 19:02:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251504 - in stable/9: sys/dev/filemon sys/modules/filemon tools/regression/filemon X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Jun 2013 19:02:34 -0000 Author: obrien Date: Fri Jun 7 19:02:32 2013 New Revision: 251504 URL: http://svnweb.freebsd.org/changeset/base/251504 Log: MFC: r251368, r251382: Match the options of the kernel. Modified: stable/9/sys/dev/filemon/filemon.c stable/9/sys/dev/filemon/filemon_wrapper.c stable/9/sys/modules/filemon/Makefile stable/9/tools/regression/filemon/Makefile stable/9/tools/regression/filemon/filemontest.c stable/9/tools/regression/filemon/test_script.sh Directory Properties: stable/9/ (props changed) stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/modules/ (props changed) stable/9/tools/ (props changed) stable/9/tools/regression/ (props changed) Modified: stable/9/sys/dev/filemon/filemon.c ============================================================================== --- stable/9/sys/dev/filemon/filemon.c Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/sys/dev/filemon/filemon.c Fri Jun 7 19:02:32 2013 (r251504) @@ -28,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" + #include #include #include Modified: stable/9/sys/dev/filemon/filemon_wrapper.c ============================================================================== --- stable/9/sys/dev/filemon/filemon_wrapper.c Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/sys/dev/filemon/filemon_wrapper.c Fri Jun 7 19:02:32 2013 (r251504) @@ -28,6 +28,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_compat.h" + #if __FreeBSD_version > 800032 #define FILEMON_HAS_LINKAT #endif Modified: stable/9/sys/modules/filemon/Makefile ============================================================================== --- stable/9/sys/modules/filemon/Makefile Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/sys/modules/filemon/Makefile Fri Jun 7 19:02:32 2013 (r251504) @@ -4,6 +4,6 @@ KMOD= filemon SRCS= ${KMOD}.c -SRCS+= vnode_if.h opt_compat.h opt_capsicum.h +SRCS+= opt_compat.h .include Modified: stable/9/tools/regression/filemon/Makefile ============================================================================== --- stable/9/tools/regression/filemon/Makefile Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/tools/regression/filemon/Makefile Fri Jun 7 19:02:32 2013 (r251504) @@ -1,10 +1,20 @@ # $FreeBSD$ -BINS= \ +.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" +BI_BITS= +.endif + +_BINS= \ filemontest \ - timed-forkb + timed-forkb \ + sizeof_long + +BINS= ${_BINS} +.if defined(BI_BITS) +BINS+= ${_BINS:C/$/32/g} +.endif -bins: filemontest timed-forkb +bins: ${BINS} all: bins NO_MAN= @@ -18,16 +28,25 @@ WITHOUT_CDDL= CLEANFILES+= ${BINS} -tests: bins + +.for f32 in ${BINS} +${f32}32: ${f32}.c + ${CC} -m32 -DBIT=\"32\" -o ${.TARGET} ${CFLAGS} ${.ALLSRC} +.endfor + +tests: kldstat | grep filemon - ${MAKE} test - ./timed-forkb + @echo "" + ${MAKE} test01 + ${MAKE} test02 +.if defined(BI_BITS) + ${MAKE} test32 +.endif @echo "filemon(4) tests passed." # Cannot use .OBJDIR -- 'filemontest' expects 'test_script.sh' in . -#FILEMONTEST32= filemontest32 -test: filemontest clean-test -.for BIN in filemontest ${FILEMONTEST32} +test01: ${BINS:Mfilemontest*} ${BINS:Msizeof_long*} clean-test +.for BIN in ${BINS:Mfilemontest} cd ${.CURDIR} ; \ for A in 1 2 3 4 5 6 7 8 9 0; do \ for B in 1 2 3 4 5 6 7 8 9 0; do \ @@ -37,10 +56,31 @@ test: filemontest clean-test done ;\ done @cd ${.CURDIR} ; set +e ; egrep '(Start|Stop) .*\.' filemon_log.* | \ - grep -q -v '\.[0-9][0-9][0-9][0-9][0-9][0-9]$$' || echo "Time stamp format OK" + grep -q -v '\.[0-9][0-9][0-9][0-9][0-9][0-9]$$' || printf "Time stamp format OK\n\n" .endfor + @cd ${.CURDIR} ; set +e ; for F in filemon_log.* ; do \ + tail -1 $$F | grep -q '# Bye bye' || echo "$$F missing filemon bye-bye" ; \ + NL=`wc -l $$F | awk '{print $$1}'` ; \ + if [ "$${NL}" != 97 ]; then echo "$$F BAD, contains $${NL} lines" ; exit 1 ; fi ; done + +test02: ${BINS:Mtimed-forkb*} + @echo "Without filemon(4) active:" + ./timed-forkb + @echo "With filemon(4) active:" + script -f typescript-timed-forkb ./timed-forkb + ls -l typescript-timed-forkb.filemon + +test32: ${BINS:M*32*} + script -f typescript.${.TARGET} ./sizeof_long32 >/dev/null + @tail -1 typescript.test32.filemon | grep -q '# Bye bye' || (echo '32-bit comapt filemon Missing "bye-bye"' ; exit 1) + @egrep -q '^X [0-9]+ 0$$' typescript.test32.filemon || (echo "32-bit binary exit ERROR" ; exit 1) + @printf "filemon(4) 32bit FreeBSD support passed.\n\n" + +CLEANFILES+= typescript-timed-forkb typescript-timed-forkb.filemon clean-test: - cd ${.CURDIR} ; rm -f filemon_log.* + cd ${.CURDIR} ; rm -f filemon_log*.* + +clean-tests: clean-test .include Modified: stable/9/tools/regression/filemon/filemontest.c ============================================================================== --- stable/9/tools/regression/filemon/filemontest.c Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/tools/regression/filemon/filemontest.c Fri Jun 7 19:02:32 2013 (r251504) @@ -43,9 +43,13 @@ __FBSDID("$FreeBSD$"); * "test_script.sh" in the cwd. */ +#ifndef BIT +#define BIT "" +#endif + int main(void) { - char log_name[] = "filemon_log.XXXXXX"; + char log_name[] = "filemon_log" BIT ".XXXXXX"; pid_t child; int fm_fd, fm_log; @@ -66,7 +70,7 @@ main(void) { child = getpid(); if (ioctl(fm_fd, FILEMON_SET_PID, &child) == -1) err(1, "Cannot set filemon PID to %d", child); - system("./test_script.sh"); + system("env BIT=" BIT " ./test_script.sh"); break; case -1: err(1, "Cannot fork"); Modified: stable/9/tools/regression/filemon/test_script.sh ============================================================================== --- stable/9/tools/regression/filemon/test_script.sh Fri Jun 7 18:46:47 2013 (r251503) +++ stable/9/tools/regression/filemon/test_script.sh Fri Jun 7 19:02:32 2013 (r251504) @@ -41,3 +41,4 @@ ed -s $f1 < $f2 #w" | ed -s $f1 #rm $f1 $f2 uptime > /dev/null +sizeof_long${BIT} > /dev/null From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 8 15:45:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 2BA6E6B5; Sat, 8 Jun 2013 15:45:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1DAFB1208; Sat, 8 Jun 2013 15:45:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r58Fj18m008016; Sat, 8 Jun 2013 15:45:01 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r58Fj1Y9008015; Sat, 8 Jun 2013 15:45:01 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201306081545.r58Fj1Y9008015@svn.freebsd.org> From: Mark Johnston Date: Sat, 8 Jun 2013 15:45:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251532 - stable/9/usr.sbin/newsyslog X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jun 2013 15:45:02 -0000 Author: markj Date: Sat Jun 8 15:45:01 2013 New Revision: 251532 URL: http://svnweb.freebsd.org/changeset/base/251532 Log: MFC r235647 for newsyslog (by gleb): Hide DIR definition by making it an opaque struct typedef. Introduce dirfd() libc exported symbol replacing macro with same name, preserve _dirfd() macro for internal use. Replace dirp->dd_fd with dirfd() call. Avoid using dirfd as variable name to prevent shadowing global symbol. MFC r250545: Some filesystems (NFS in particular) do not fill out the d_type field when returning directory entries through readdir(3). In this case we need to obtain the file type ourselves; otherwise newsyslog -t will not be able to find archived log files and will fail to both delete old log files and to do interval-based rotations properly. MFC r251240: We want to stat the archived log file rather than the logfile itself. Modified: stable/9/usr.sbin/newsyslog/newsyslog.c Directory Properties: stable/9/usr.sbin/newsyslog/ (props changed) Modified: stable/9/usr.sbin/newsyslog/newsyslog.c ============================================================================== --- stable/9/usr.sbin/newsyslog/newsyslog.c Sat Jun 8 13:48:27 2013 (r251531) +++ stable/9/usr.sbin/newsyslog/newsyslog.c Sat Jun 8 15:45:01 2013 (r251532) @@ -1450,16 +1450,27 @@ oldlog_entry_compare(const void *a, cons * tm if this is the case; otherwise return false. */ static int -validate_old_timelog(const struct dirent *dp, const char *logfname, struct tm *tm) +validate_old_timelog(int fd, const struct dirent *dp, const char *logfname, + struct tm *tm) { + struct stat sb; size_t logfname_len; char *s; int c; logfname_len = strlen(logfname); - if (dp->d_type != DT_REG) - return (0); + if (dp->d_type != DT_REG) { + /* + * Some filesystems (e.g. NFS) don't fill out the d_type field + * and leave it set to DT_UNKNOWN; in this case we must obtain + * the file type ourselves. + */ + if (dp->d_type != DT_UNKNOWN || + fstatat(fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW) != 0 || + !S_ISREG(sb.st_mode)) + return (0); + } /* Ignore everything but files with our logfile prefix. */ if (strncmp(dp->d_name, logfname, logfname_len) != 0) return (0); @@ -1511,7 +1522,7 @@ static void delete_oldest_timelog(const struct conf_entry *ent, const char *archive_dir) { char *logfname, *s, *dir, errbuf[80]; - int dirfd, i, logcnt, max_logcnt; + int dir_fd, i, logcnt, max_logcnt; struct oldlog_entry *oldlogs; struct dirent *dp; const char *cdir; @@ -1543,9 +1554,9 @@ delete_oldest_timelog(const struct conf_ /* First we create a 'list' of all archived logfiles */ if ((dirp = opendir(dir)) == NULL) err(1, "Cannot open log directory '%s'", dir); - dirfd = dirfd(dirp); + dir_fd = dirfd(dirp); while ((dp = readdir(dirp)) != NULL) { - if (validate_old_timelog(dp, logfname, &tm) == 0) + if (validate_old_timelog(dir_fd, dp, logfname, &tm) == 0) continue; /* @@ -1593,7 +1604,7 @@ delete_oldest_timelog(const struct conf_ if (noaction) printf("\trm -f %s/%s\n", dir, oldlogs[i].fname); - else if (unlinkat(dirfd, oldlogs[i].fname, 0) != 0) { + else if (unlinkat(dir_fd, oldlogs[i].fname, 0) != 0) { snprintf(errbuf, sizeof(errbuf), "Could not delete old logfile '%s'", oldlogs[i].fname); @@ -2310,10 +2321,10 @@ mtime_old_timelog(const char *file) dir_fd = dirfd(dirp); /* Open the archive dir and find the most recent archive of logfname. */ while ((dp = readdir(dirp)) != NULL) { - if (validate_old_timelog(dp, logfname, &tm) == 0) + if (validate_old_timelog(dir_fd, dp, logfname, &tm) == 0) continue; - if (fstatat(dir_fd, logfname, &sb, 0) == -1) { + if (fstatat(dir_fd, dp->d_name, &sb, AT_SYMLINK_NOFOLLOW) == -1) { warn("Cannot stat '%s'", file); continue; } From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 8 15:46:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 33F49B01; Sat, 8 Jun 2013 15:46:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 261CC1222; Sat, 8 Jun 2013 15:46:43 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r58FkhcZ008408; Sat, 8 Jun 2013 15:46:43 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r58FkhGE008407; Sat, 8 Jun 2013 15:46:43 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201306081546.r58FkhGE008407@svn.freebsd.org> From: Mark Johnston Date: Sat, 8 Jun 2013 15:46:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251534 - stable/9/usr.sbin/ndp X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jun 2013 15:46:43 -0000 Author: markj Date: Sat Jun 8 15:46:42 2013 New Revision: 251534 URL: http://svnweb.freebsd.org/changeset/base/251534 Log: MFC r250941: Include descriptions of the flags and fields printed when dumping the IPv6 prefix list. Modified: stable/9/usr.sbin/ndp/ndp.8 Directory Properties: stable/9/usr.sbin/ndp/ (props changed) Modified: stable/9/usr.sbin/ndp/ndp.8 ============================================================================== --- stable/9/usr.sbin/ndp/ndp.8 Sat Jun 8 15:46:09 2013 (r251533) +++ stable/9/usr.sbin/ndp/ndp.8 Sat Jun 8 15:46:42 2013 (r251534) @@ -231,6 +231,36 @@ Specify the Cur Hop Limit on the interfa Do not try to resolve numeric addresses to hostnames. .It Fl p Show prefix list. +The following information will be printed: +.Bl -tag -width indent +.It Cm if +The network interface associated with this prefix. +.It Cm flags +The status of the prefix, expressed by a combination of the following +letters: +.Pp +.Bl -tag -width indent -compact +.It Cm A +This prefix can be used for stateless address autoconfiguration. +.It Cm L, Cm O +This prefix can be used for on-link determination; that is, it can be +used to determine whether a given destination address is on-link. +.It Cm D +There are no reachable routers advertising this prefix. +.El +.It Cm vltime +Valid lifetime; the length of time for which the prefix and a stateless +autoconfigured address generated from this prefix can be used for the +source or destination address of a packet. +.It Cm pltime +Preferred lifetime; the length of time for which the prefix and a stateless +autoconfigured address generated from this prefix can be used by upper-layer +protocols unrestrictedly. +.It Cm expire +This is the remaining time that the prefix is in the valid state. +.It Cm ref +The number of kernel references held for this prefix. +.El .It Fl P Flush all the entries in the prefix list. .It Fl r From owner-svn-src-stable-9@FreeBSD.ORG Sat Jun 8 15:48:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3C33AEA1; Sat, 8 Jun 2013 15:48:02 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2DB2F1244; Sat, 8 Jun 2013 15:48:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r58Fm2Ma008679; Sat, 8 Jun 2013 15:48:02 GMT (envelope-from markj@svn.freebsd.org) Received: (from markj@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r58Fm20F008678; Sat, 8 Jun 2013 15:48:02 GMT (envelope-from markj@svn.freebsd.org) Message-Id: <201306081548.r58Fm20F008678@svn.freebsd.org> From: Mark Johnston Date: Sat, 8 Jun 2013 15:48:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r251536 - stable/9/usr.sbin/rtsold X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jun 2013 15:48:02 -0000 Author: markj Date: Sat Jun 8 15:48:01 2013 New Revision: 251536 URL: http://svnweb.freebsd.org/changeset/base/251536 Log: MFC r250939: Correct the description of the -a option: rtsol(d) -a will in fact send out router solicitations on multiple interfaces. MFC r251059: - Fix wording. - Improve the descriptions in the FILES section. Modified: stable/9/usr.sbin/rtsold/rtsold.8 Directory Properties: stable/9/usr.sbin/rtsold/ (props changed) Modified: stable/9/usr.sbin/rtsold/rtsold.8 ============================================================================== --- stable/9/usr.sbin/rtsold/rtsold.8 Sat Jun 8 15:47:18 2013 (r251535) +++ stable/9/usr.sbin/rtsold/rtsold.8 Sat Jun 8 15:48:01 2013 (r251536) @@ -161,15 +161,10 @@ will dump the current internal state int The options are as follows: .Bl -tag -width indent .It Fl a -Autoprobe outgoing interface. +Autoprobe outgoing interfaces. .Nm -will try to find a non-loopback, non-point-to-point, IPv6-capable interface. -If -.Nm -finds multiple interfaces, -.Nm -will exit with error. -.\" +will try to find any non-loopback, non-point-to-point, IPv6-capable interfaces +and send router solicitation messages on all of them. .It Fl d Enable debugging. .It Fl D @@ -261,10 +256,10 @@ If not, it will be .Sh FILES .Bl -tag -width /var/run/rtsold.dump -compact .It Pa /var/run/rtsold.pid -the pid of the currently running +The PID of the currently running .Nm . .It Pa /var/run/rtsold.dump -dumps internal state on. +Internal state dump file. .El .\" .Sh EXIT STATUS