From owner-svn-src-head@freebsd.org Sun Aug 19 17:19:21 2018 Return-Path: Delivered-To: svn-src-head@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 1A4E0107127D; Sun, 19 Aug 2018 17:19:21 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B267081048; Sun, 19 Aug 2018 17:19:20 +0000 (UTC) (envelope-from mckusick@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 72BE51442; Sun, 19 Aug 2018 17:19:20 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w7JHJKRI041994; Sun, 19 Aug 2018 17:19:20 GMT (envelope-from mckusick@FreeBSD.org) Received: (from mckusick@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7JHJKaN041993; Sun, 19 Aug 2018 17:19:20 GMT (envelope-from mckusick@FreeBSD.org) Message-Id: <201808191719.w7JHJKaN041993@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mckusick set sender to mckusick@FreeBSD.org using -f From: Kirk McKusick Date: Sun, 19 Aug 2018 17:19:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338057 - head/sys/ufs/ffs X-SVN-Group: head X-SVN-Commit-Author: mckusick X-SVN-Commit-Paths: head/sys/ufs/ffs X-SVN-Commit-Revision: 338057 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.27 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: Sun, 19 Aug 2018 17:19:21 -0000 Author: mckusick Date: Sun Aug 19 17:19:20 2018 New Revision: 338057 URL: https://svnweb.freebsd.org/changeset/base/338057 Log: For traditional disks, the filesystem attempts to allocate the blocks of a file as contiguously as possible. Since the filesystem does not know how large a file will grow when it is first being written, it initially places the file in a set of blocks in which it currently fits. As it grows, it is relocated to areas with larger contiguous blocks. In this way it saves its large contiguous sets of blocks for the files that need them and thus avoids unnecessaily fragmenting its disk space. We used to skip reallocating the blocks of a file into a contiguous sequence if the underlying flash device requested BIO_DELETE notifications, because devices that benefit from BIO_DELETE also benefit from not moving the data. However, in the algorithm described above that reallocates the blocks, the destination for the data is usually moved before the data is written to the initially allocated location. So we rarely suffer the penalty of extra writes. With the addition of the consolodation of contiguous blocks into single BIO_DELETE operations, having fewer but larger contiguous blocks reduces the number of (slow and expensive) BIO_DELETE operations. So when doing BIO_DELETE consolodation, we do block reallocation. Reviewed by: kib Tested by: Peter Holm Sponsored by: Netflix Modified: head/sys/ufs/ffs/ffs_alloc.c Modified: head/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- head/sys/ufs/ffs/ffs_alloc.c Sun Aug 19 16:56:42 2018 (r338056) +++ head/sys/ufs/ffs/ffs_alloc.c Sun Aug 19 17:19:20 2018 (r338057) @@ -506,14 +506,23 @@ ffs_reallocblks(ap) struct ufsmount *ump; /* - * If the underlying device can do deletes, then skip reallocating - * the blocks of this file into contiguous sequences. Devices that - * benefit from BIO_DELETE also benefit from not moving the data. - * These devices are flash and therefore work less well with this - * optimization. Also skip if reallocblks has been disabled globally. + * We used to skip reallocating the blocks of a file into a + * contiguous sequence if the underlying flash device requested + * BIO_DELETE notifications, because devices that benefit from + * BIO_DELETE also benefit from not moving the data. However, + * the destination for the data is usually moved before the data + * is written to the initially allocated location, so we rarely + * suffer the penalty of extra writes. With the addition of the + * consolodation of contiguous blocks into single BIO_DELETE + * operations, having fewer but larger contiguous blocks reduces + * the number of (slow and expensive) BIO_DELETE operations. So + * when doing BIO_DELETE consolodation, we do block reallocation. + * + * Skip if reallocblks has been disabled globally. */ ump = ap->a_vp->v_mount->mnt_data; - if (((ump->um_flags) & UM_CANDELETE) != 0 || doreallocblks == 0) + if ((((ump->um_flags) & UM_CANDELETE) != 0 && dotrimcons == 0) || + doreallocblks == 0) return (ENOSPC); /*