git: 378d18d96deb - stable/13 - Update standard superblock when successful using an alternate superblock.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sun, 11 Dec 2022 00:38:12 UTC
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=378d18d96debe60bb051c5df47b195d6d450c693

commit 378d18d96debe60bb051c5df47b195d6d450c693
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-08-24 06:28:30 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-12-11 00:37:17 +0000

    Update standard superblock when successful using an alternate superblock.
    
    (cherry picked from commit be639cc8eef01a2b8849939eb07cfde476146794)
    
    Sponsored by: The FreeBSD Foundation
---
 sbin/fsck_ffs/fsutil.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c
index 711c9bb63549..dfe472ab17fb 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -681,14 +681,17 @@ ckfini(int markclean)
 	if (debug)
 		printf("Flush the superblock\n");
 	flush(fswritefd, &sblk);
-	if (havesb && cursnapshot == 0 && sblock.fs_magic == FS_UFS2_MAGIC &&
-	    sblk.b_bno != sblock.fs_sblockloc / dev_bsize &&
-	    !preen && reply("UPDATE STANDARD SUPERBLOCK")) {
-		/* Change the write destination to standard superblock */
-		sblock.fs_sblockactualloc = sblock.fs_sblockloc;
-		sblk.b_bno = sblock.fs_sblockloc / dev_bsize;
-		sbdirty();
-		flush(fswritefd, &sblk);
+	if (havesb && cursnapshot == 0 &&
+	    sblk.b_bno != sblock.fs_sblockloc / dev_bsize) {
+		if (preen || reply("UPDATE STANDARD SUPERBLOCK")) {
+			/* Change write destination to standard superblock */
+			sblock.fs_sblockactualloc = sblock.fs_sblockloc;
+			sblk.b_bno = sblock.fs_sblockloc / dev_bsize;
+			sbdirty();
+			flush(fswritefd, &sblk);
+		} else {
+			markclean = 0;
+		}
 	}
 	if (cursnapshot == 0 && sblock.fs_clean != markclean) {
 		if ((sblock.fs_clean = markclean) != 0) {