git: 17207eae668b - stable/13 - Write out corrected superblock when creating a UFS/FFS snapshot.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sat, 22 Jul 2023 00:22:44 UTC
The branch stable/13 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=17207eae668b80561c98fe18a9a5e18409d47c58

commit 17207eae668b80561c98fe18a9a5e18409d47c58
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2023-06-13 07:21:43 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2023-07-22 00:22:10 +0000

    Write out corrected superblock when creating a UFS/FFS snapshot.
    
    PR:           271352
    Tested-by:    Peter Holm
    Sponsored-by: The FreeBSD Foundation
    (cherry picked from commit f1549d7d522995bf5d821ae08cc2f500ba545285)
---
 sys/ufs/ffs/ffs_snapshot.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index 709038db071f..a23f0ad502a9 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -207,7 +207,7 @@ ffs_snapshot(struct mount *mp, char *snapfile)
 	long snaplistsize = 0;
 	int32_t *lp;
 	void *space;
-	struct fs *copy_fs = NULL, *fs;
+	struct fs *copy_fs = NULL, *fs, *bpfs;
 	struct thread *td = curthread;
 	struct inode *ip, *xp;
 	struct buf *bp, *nbp, *ibp;
@@ -828,8 +828,10 @@ resumefs:
 	} else {
 		loc = blkoff(fs, fs->fs_sblockloc);
 		copy_fs->fs_fmod = 0;
-		copy_fs->fs_ckhash = ffs_calc_sbhash(copy_fs);
-		bcopy((char *)copy_fs, &nbp->b_data[loc], (u_int)fs->fs_sbsize);
+		bpfs = (struct fs *)&nbp->b_data[loc];
+		bcopy((caddr_t)copy_fs, (caddr_t)bpfs, (u_int)fs->fs_sbsize);
+		ffs_oldfscompat_write(bpfs, ump);
+		bpfs->fs_ckhash = ffs_calc_sbhash(bpfs);
 		bawrite(nbp);
 	}
 	/*