git: be639cc8eef0 - main - Update standard superblock when successful using an alternate superblock.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Aug 2022 06:29:42 UTC
The branch main has been updated by mckusick:
URL: https://cgit.FreeBSD.org/src/commit/?id=be639cc8eef01a2b8849939eb07cfde476146794
commit be639cc8eef01a2b8849939eb07cfde476146794
Author: Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-08-24 06:28:30 +0000
Commit: Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-08-24 06:29:17 +0000
Update standard superblock when successful using an alternate superblock.
Historically fsck_ffs(8) would only use alternate superblocks when
running in manual mode. When the standard superblock fails, it now
tries to find and use a backup superblocks even when running in `preen'
mode. If an alternate superblock is found and the filesystem is
successfully cleaned up using it, write the alternate superblock
back to the standard superblock so that the filesystem can be
subsequently mounted and used.
Reported by: Peter Holm
Tested by: Peter Holm
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 424f8d9794f6..57853abe5442 100644
--- a/sbin/fsck_ffs/fsutil.c
+++ b/sbin/fsck_ffs/fsutil.c
@@ -682,14 +682,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) {