From owner-svn-src-head@freebsd.org Fri Aug 18 04:07:27 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23D8BDC77DB; Fri, 18 Aug 2017 04:07:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7BAF721F3; Fri, 18 Aug 2017 04:07:26 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7I47QA7011621; Fri, 18 Aug 2017 04:07:26 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7I47Qhd011620; Fri, 18 Aug 2017 04:07:26 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201708180407.v7I47Qhd011620@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 18 Aug 2017 04:07:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322646 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 322646 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Aug 2017 04:07:27 -0000 Author: markj Date: Fri Aug 18 04:07:25 2017 New Revision: 322646 URL: https://svnweb.freebsd.org/changeset/base/322646 Log: Remove some unneeded subroutines for padding writes to dump devices. Right now we only need to pad when writing kernel dump headers, so flatten three related subroutines into one. The encrypted kernel dump code already writes out its key in a dumper.blocksize-sized block. No functional change intended. Reviewed by: cem, def Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11647 Modified: head/sys/kern/kern_shutdown.c Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Fri Aug 18 04:04:09 2017 (r322645) +++ head/sys/kern/kern_shutdown.c Fri Aug 18 04:07:25 2017 (r322646) @@ -1152,51 +1152,25 @@ dump_write(struct dumperinfo *di, void *virtual, vm_of } static int -dump_pad(struct dumperinfo *di, void *virtual, size_t length, void **buf, - size_t *size) +dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + vm_offset_t physical, off_t offset) { + void *buf; + size_t hdrsz; - if (length > di->blocksize) + hdrsz = sizeof(*kdh); + if (hdrsz > di->blocksize) return (ENOMEM); - *size = di->blocksize; - if (length == di->blocksize) { - *buf = virtual; - } else { - *buf = di->blockbuf; - memcpy(*buf, virtual, length); - memset((uint8_t *)*buf + length, 0, di->blocksize - length); + if (hdrsz == di->blocksize) + buf = kdh; + else { + buf = di->blockbuf; + memset(buf, 0, di->blocksize); + memcpy(buf, kdh, hdrsz); } - return (0); -} - -static int -dump_raw_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, - off_t offset, size_t length, size_t *size) -{ - void *buf; - int error; - - error = dump_pad(di, virtual, length, &buf, size); - if (error != 0) - return (error); - - return (dump_raw_write(di, buf, physical, offset, *size)); -} - -static int -dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, - vm_offset_t physical, off_t offset) -{ - size_t size; - int ret; - - ret = dump_raw_write_pad(di, kdh, physical, offset, sizeof(*kdh), - &size); - if (ret == 0 && size != di->blocksize) - ret = EINVAL; - return (ret); + return (dump_raw_write(di, buf, physical, offset, di->blocksize)); } /*