From owner-svn-src-all@freebsd.org Sat Dec 15 11:36:21 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ECE971343352; Sat, 15 Dec 2018 11:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89C346C6CC; Sat, 15 Dec 2018 11:36:20 +0000 (UTC) (envelope-from trasz@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7B5CDEF62; Sat, 15 Dec 2018 11:36:20 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBFBaKO6058237; Sat, 15 Dec 2018 11:36:20 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBFBaKV3058236; Sat, 15 Dec 2018 11:36:20 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201812151136.wBFBaKV3058236@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sat, 15 Dec 2018 11:36:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342115 - head/sbin/fsck_ffs X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/sbin/fsck_ffs X-SVN-Commit-Revision: 342115 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 89C346C6CC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.85 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-0.99)[-0.989,0]; NEURAL_HAM_SHORT(-0.98)[-0.978,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-0.88)[-0.883,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Dec 2018 11:36:21 -0000 Author: trasz Date: Sat Dec 15 11:36:20 2018 New Revision: 342115 URL: https://svnweb.freebsd.org/changeset/base/342115 Log: Make fsck(8) use pread(2). This cuts the number of syscalls by half. Reviewed by: kib, mckusick MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17586 Modified: head/sbin/fsck_ffs/fsutil.c Modified: head/sbin/fsck_ffs/fsutil.c ============================================================================== --- head/sbin/fsck_ffs/fsutil.c Sat Dec 15 11:32:11 2018 (r342114) +++ head/sbin/fsck_ffs/fsutil.c Sat Dec 15 11:36:20 2018 (r342115) @@ -576,9 +576,7 @@ blread(int fd, char *buf, ufs2_daddr_t blk, long size) slowio_start(); totalreads++; diskreads++; - if (lseek(fd, offset, 0) < 0) - rwerror("SEEK BLK", blk); - else if (read(fd, buf, (int)size) == size) { + if (pread(fd, buf, (int)size, offset) == size) { if (bkgrdflag) slowio_end(); return (0); @@ -595,14 +593,11 @@ blread(int fd, char *buf, ufs2_daddr_t blk, long size) } else rwerror("READ BLK", blk); - if (lseek(fd, offset, 0) < 0) - rwerror("SEEK BLK", blk); errs = 0; memset(buf, 0, (size_t)size); printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:"); for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) { - if (read(fd, cp, (int)secsize) != secsize) { - (void)lseek(fd, offset + i + secsize, 0); + if (pread(fd, cp, (int)secsize, offset + i) != secsize) { if (secsize != dev_bsize && dev_bsize != 1) printf(" %jd (%jd),", (intmax_t)(blk * dev_bsize + i) / secsize, @@ -629,22 +624,16 @@ blwrite(int fd, char *buf, ufs2_daddr_t blk, ssize_t s return; offset = blk; offset *= dev_bsize; - if (lseek(fd, offset, 0) < 0) - rwerror("SEEK BLK", blk); - else if (write(fd, buf, size) == size) { + if (pwrite(fd, buf, size, offset) == size) { fsmodified = 1; return; } resolved = 0; rwerror("WRITE BLK", blk); - if (lseek(fd, offset, 0) < 0) - rwerror("SEEK BLK", blk); printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:"); for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize) - if (write(fd, cp, dev_bsize) != dev_bsize) { - (void)lseek(fd, offset + i + dev_bsize, 0); + if (pwrite(fd, cp, dev_bsize, offset + i) != dev_bsize) printf(" %jd,", (intmax_t)blk + i / dev_bsize); - } printf("\n"); return; }