git: bc6860ca7cfa - stable/13 - ffs_use_bwrite: make the superblock snapshot more consistent

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 16 May 2022 22:48:21 UTC
The branch stable/13 has been updated by kib:

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

commit bc6860ca7cfa4f3d317dd6380b3852a9db99bb16
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-05-08 14:00:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-05-16 22:32:55 +0000

    ffs_use_bwrite: make the superblock snapshot more consistent
    
    PR:     263765
    
    (cherry picked from commit 4ac2df8f4cd91017c000543224204f823008f699)
---
 sys/ufs/ffs/ffs_vfsops.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 3997c026859c..c749ecbcded9 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -2267,7 +2267,9 @@ ffs_use_bwrite(void *devfd, off_t loc, void *buf, int size)
 	}
 	if (MOUNTEDSOFTDEP(ump->um_mountp))
 		softdep_setup_sbupdate(ump, (struct fs *)bp->b_data, bp);
+	UFS_LOCK(ump);
 	bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
+	UFS_UNLOCK(ump);
 	fs = (struct fs *)bp->b_data;
 	ffs_oldfscompat_write(fs, ump);
 	fs->fs_si = NULL;