Date: Sun, 19 Aug 2018 17:19:20 +0000 (UTC) From: Kirk McKusick <mckusick@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338057 - head/sys/ufs/ffs Message-ID: <201808191719.w7JHJKaN041993@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808191719.w7JHJKaN041993>