diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-01-11 02:34:00 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-01-31 17:50:03 +0000 |
| commit | 929ef0d36c6c80981c11dae0f51f6ab839a58c06 (patch) | |
| tree | 4635b8f849ba3d8c1c6f64985e6d2f280ba25e6c | |
| parent | e58f90157c9b947c13e205fb0062411168fdab11 (diff) | |
newfs: Add an option to disable soft updates
A previous commit turned soft updates on by default for UFS2 without
providing a way to turn them off. This corrects that by adding a new -u
flag which forces soft updates (and soft updates journaling) off.
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: NetApp, Inc.
Fixes: 61dece6d27fb ("Enable soft updates by default for UFS2 filesystems.")
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D54576
(cherry picked from commit 68562f8145e8154e7e276897a546995f0d8f3428)
newfs: Add -u to getopt string
Fixes: 68562f8145e8 ("newfs: Add an option to disable soft updates")
(cherry picked from commit 717ae163919e48f000b94f85dc188e0d92261929)
| -rw-r--r-- | sbin/newfs/newfs.8 | 24 | ||||
| -rw-r--r-- | sbin/newfs/newfs.c | 11 |
2 files changed, 25 insertions, 10 deletions
diff --git a/sbin/newfs/newfs.8 b/sbin/newfs/newfs.8 index 9b70643ee646..7336dbbc6e23 100644 --- a/sbin/newfs/newfs.8 +++ b/sbin/newfs/newfs.8 @@ -27,7 +27,7 @@ .\" .\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 .\" -.Dd November 19, 2024 +.Dd January 7, 2026 .Dt NEWFS 8 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd construct a new UFS1/UFS2 file system .Sh SYNOPSIS .Nm -.Op Fl EJNUjlnt +.Op Fl EJNUjlntu .Op Fl L Ar volname .Op Fl O Ar filesystem-type .Op Fl S Ar sector-size @@ -100,10 +100,20 @@ 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. +If neither +.Fl U +nor +.Fl u +is specified, soft updates are enabled by default for UFS2 format file +systems and disabled otherwise. +.It Fl u +Do not enable soft updates on the new file system. +If neither +.Fl U +nor +.Fl u +is specified, soft updates are enabled by default for UFS2 format file +systems and disabled otherwise. .It Fl a Ar maxcontig Specify the maximum number of contiguous blocks that will be laid out before forcing a rotational delay. @@ -168,6 +178,8 @@ One inode is required for each distinct file, so this value effectively specifies the average file size on the file system. .It Fl j Enable soft updates journaling on the new file system. +This implies +.Fl U . This flag is implemented by running the .Xr tunefs 8 utility found in the user's diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c index c96e414b85dd..754606707178 100644 --- a/sbin/newfs/newfs.c +++ b/sbin/newfs/newfs.c @@ -88,7 +88,7 @@ int Lflag; /* add a volume label */ int Nflag; /* run without writing file system */ int Oflag = 2; /* file system format (1 => UFS1, 2 => UFS2) */ int Rflag; /* regression test */ -int Uflag; /* enable soft updates for file system */ +int Uflag = -1; /* enable soft updates for file system */ int jflag; /* enable soft updates journaling for filesys */ int Xflag = 0; /* exit in middle of newfs for testing */ int Jflag; /* enable gjournal for file system */ @@ -142,7 +142,7 @@ main(int argc, char *argv[]) part_name = 'c'; reserved = 0; while ((ch = getopt(argc, argv, - "EJL:NO:RS:T:UXa:b:c:d:e:f:g:h:i:jk:lm:no:p:r:s:t")) != -1) + "EJL:NO:RS:T:UXa:b:c:d:e:f:g:h:i:jk:lm:no:p:r:s:tu")) != -1) switch (ch) { case 'E': Eflag = 1; @@ -192,6 +192,9 @@ main(int argc, char *argv[]) case 'U': Uflag = 1; break; + case 'u': + Uflag = 0; + break; case 'X': Xflag++; break; @@ -396,8 +399,8 @@ main(int argc, char *argv[]) opt = FS_OPTSPACE; } /* Use soft updates by default for UFS2 and above */ - if (Oflag > 1) - Uflag = 1; + if (Uflag < 0) + Uflag = Oflag > 1; realsectorsize = sectorsize; if (sectorsize != DEV_BSIZE) { /* XXX */ int secperblk = sectorsize / DEV_BSIZE; |
