git: 61dece6d27fb - main - Enable soft updates by default for UFS2 filesystems.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Wed, 15 May 2024 05:40:14 UTC
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=61dece6d27fb2436928ca93d65667b358e05aa7b

commit 61dece6d27fb2436928ca93d65667b358e05aa7b
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2024-05-15 05:38:35 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2024-05-15 05:40:01 +0000

    Enable soft updates by default for UFS2 filesystems.
    
    Soft updates dramatically improve the performance of UFS filesystems.
    The newfs(8) utility currently does not enable them by default. The
    FreeBSD installer enables soft updates by default. However custom
    built installations that do not specify the -U option to newfs(8)
    and the prebuilt UFS system images get filesystems without soft
    updates enabled.
    
    There are several testing sites that run benchmarks comparing the
    performance of Linux distributions versus BSD distributions. When
    they run filesystem comparison benchmarks they use newfs(8) to
    create the UFS filesystem. Because it does not have soft updates
    enabled it runs poorly versus the Linux ext4 filesystem. When I
    have suggested to them that they should enable soft updates on the
    UFS filesystem in their testing their response is that they expect
    the utility that creates the filesystem to use optimal defaults and
    that they cannot be expected to fiddle with various option settings.
    
    The purpose of this change is to give a filesystem created with
    newfs(8) reasonably optimal settings. For UFS2 this means enabling
    soft updates. For UFS1 which tends to be used on small systems with
    minimal memory and CPU speed, the lower memory footprint of running
    without soft updates is a more sensible default.
    
    This change adds a note in the section of the newfs(8) manual page
    that describes the -U option for enabling soft updates that they
    are enabled by default for UFS2 filesystems and that they can be
    disabled by using tunefs(8).
    
    Reviewed-by: Warner Losh, kib
    MFC after:   1 week
    Differential Revision: https://reviews.freebsd.org/D45201
---
 sbin/newfs/newfs.8 | 6 +++++-
 sbin/newfs/newfs.c | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8
index 05d2413a44e4..a7f792635aa9 100644
--- a/sbin/newfs/newfs.8
+++ b/sbin/newfs/newfs.8
@@ -25,7 +25,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 21, 2022
+.Dd May 18, 2024
 .Dt NEWFS 8
 .Os
 .Sh NAME
@@ -98,6 +98,10 @@ The default format is UFS2.
 For backward compatibility.
 .It Fl U
 Enable soft updates on the new file system.
+Soft updates are enabled by default for UFS2 format file systems.
+Use
+.Xr tunefs 8
+to disable soft updates if they are not wanted.
 .It Fl a Ar maxcontig
 Specify the maximum number of contiguous blocks that will be
 laid out before forcing a rotational delay.
diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 38781368e8ca..49bd8b7dc4b6 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -383,6 +383,9 @@ main(int argc, char *argv[])
 		fprintf(stderr, "because minfree is less than %d%%\n", MINFREE);
 		opt = FS_OPTSPACE;
 	}
+	/* Use soft updates by default for UFS2 and above */
+	if (Oflag > 1)
+		Uflag = 1;
 	realsectorsize = sectorsize;
 	if (sectorsize != DEV_BSIZE) {		/* XXX */
 		int secperblk = sectorsize / DEV_BSIZE;