Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Nov 2017 21:10:50 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326290 - head/usr.sbin/diskinfo
Message-ID:  <201711272110.vARLAo0F070021@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Mon Nov 27 21:10:50 2017
New Revision: 326290
URL: https://svnweb.freebsd.org/changeset/base/326290

Log:
  diskinfo(8): Delete dead code in slog test
  
  Reported by:	Coverity
  CID:		1377556
  Reviewed by:	mav
  MFC after:	3 weeks
  Sponsored by:	Spectra Logic Corp
  Differential Revision:	https://reviews.freebsd.org/D13275

Modified:
  head/usr.sbin/diskinfo/diskinfo.c

Modified: head/usr.sbin/diskinfo/diskinfo.c
==============================================================================
--- head/usr.sbin/diskinfo/diskinfo.c	Mon Nov 27 20:01:58 2017	(r326289)
+++ head/usr.sbin/diskinfo/diskinfo.c	Mon Nov 27 21:10:50 2017	(r326290)
@@ -646,22 +646,22 @@ parwrite(int fd, size_t size, off_t off)
 {
 	struct aiocb aios[MAXIOS];
 	off_t o;
-	size_t s;
 	int n, error;
 	struct aiocb *aiop;
 
-	for (n = 0, o = 0; size > MAXIO; n++, size -= s, o += s) {
-		s = (size >= MAXIO) ? MAXIO : size;
+	// if size > MAXIO, use AIO to write n - 1 pieces in parallel
+	for (n = 0, o = 0; size > MAXIO; n++, size -= MAXIO, o += MAXIO) {
 		aiop = &aios[n];
 		bzero(aiop, sizeof(*aiop));
 		aiop->aio_buf = &buf[o];
 		aiop->aio_fildes = fd;
 		aiop->aio_offset = off + o;
-		aiop->aio_nbytes = s;
+		aiop->aio_nbytes = MAXIO;
 		error = aio_write(aiop);
 		if (error != 0)
 			err(EX_IOERR, "AIO write submit error");
 	}
+	// Use synchronous writes for the runt of size <= MAXIO
 	error = pwrite(fd, &buf[o], size, off + o);
 	if (error < 0)
 		err(EX_IOERR, "Sync write error");



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711272110.vARLAo0F070021>