From owner-svn-src-head@FreeBSD.ORG Mon Oct 3 21:48:11 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 407EB106564A; Mon, 3 Oct 2011 21:48:11 +0000 (UTC) (envelope-from ivoras@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 30A128FC12; Mon, 3 Oct 2011 21:48:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p93LmB5j029164; Mon, 3 Oct 2011 21:48:11 GMT (envelope-from ivoras@svn.freebsd.org) Received: (from ivoras@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p93LmBnp029162; Mon, 3 Oct 2011 21:48:11 GMT (envelope-from ivoras@svn.freebsd.org) Message-Id: <201110032148.p93LmBnp029162@svn.freebsd.org> From: Ivan Voras Date: Mon, 3 Oct 2011 21:48:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225954 - head/bin/mv X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 03 Oct 2011 21:48:11 -0000 Author: ivoras Date: Mon Oct 3 21:48:10 2011 New Revision: 225954 URL: http://svn.freebsd.org/changeset/base/225954 Log: Don't chop IO into small pieces, follow cp(1) and just use MAXPHYS. Modified: head/bin/mv/mv.c Modified: head/bin/mv/mv.c ============================================================================== --- head/bin/mv/mv.c Mon Oct 3 21:19:15 2011 (r225953) +++ head/bin/mv/mv.c Mon Oct 3 21:48:10 2011 (r225954) @@ -260,40 +260,34 @@ static int fastcopy(const char *from, const char *to, struct stat *sbp) { struct timeval tval[2]; - static u_int blen; - static char *bp; + static u_int blen = MAXPHYS; + static char *bp = NULL; mode_t oldmode; int nread, from_fd, to_fd; if ((from_fd = open(from, O_RDONLY, 0)) < 0) { - warn("%s", from); + warn("fastcopy: open() failed (from): %s", from); return (1); } - if (blen < sbp->st_blksize) { - if (bp != NULL) - free(bp); - if ((bp = malloc((size_t)sbp->st_blksize)) == NULL) { - blen = 0; - warnx("malloc failed"); - return (1); - } - blen = sbp->st_blksize; + if (bp == NULL && (bp = malloc((size_t)blen)) == NULL) { + warnx("malloc(%u) failed", blen); + return (1); } while ((to_fd = open(to, O_CREAT | O_EXCL | O_TRUNC | O_WRONLY, 0)) < 0) { if (errno == EEXIST && unlink(to) == 0) continue; - warn("%s", to); + warn("fastcopy: open() failed (to): %s", to); (void)close(from_fd); return (1); } while ((nread = read(from_fd, bp, (size_t)blen)) > 0) if (write(to_fd, bp, (size_t)nread) != nread) { - warn("%s", to); + warn("fastcopy: write() failed: %s", to); goto err; } if (nread < 0) { - warn("%s", from); + warn("fastcopy: read() failed: %s", from); err: if (unlink(to)) warn("%s: remove", to); (void)close(from_fd);