svn commit: r340924 - head/sys/ufs/ffs
Kirk McKusick
mckusick at FreeBSD.org
Sun Nov 25 18:01:17 UTC 2018
Author: mckusick
Date: Sun Nov 25 18:01:15 2018
New Revision: 340924
URL: https://svnweb.freebsd.org/changeset/base/340924
Log:
Calculate updated superblock check-hash before writing it into the snapshot.
This corrects a bug that prevented snapshots from being mounted due to a
superblock check-hash failure.
Reported by: Brennan Vincent <brennan at umanwizard.com>
Tested by: Peter Holm (pho@)
Sponsored by: Netflix
Modified:
head/sys/ufs/ffs/ffs_extern.h
head/sys/ufs/ffs/ffs_snapshot.c
head/sys/ufs/ffs/ffs_subr.c
Modified: head/sys/ufs/ffs/ffs_extern.h
==============================================================================
--- head/sys/ufs/ffs/ffs_extern.h Sun Nov 25 18:00:50 2018 (r340923)
+++ head/sys/ufs/ffs/ffs_extern.h Sun Nov 25 18:01:15 2018 (r340924)
@@ -68,6 +68,7 @@ ufs2_daddr_t ffs_blkpref_ufs1(struct inode *, ufs_lbn_
ufs2_daddr_t ffs_blkpref_ufs2(struct inode *, ufs_lbn_t, int, ufs2_daddr_t *);
void ffs_blkrelease_finish(struct ufsmount *, u_long);
u_long ffs_blkrelease_start(struct ufsmount *, struct vnode *, ino_t);
+uint32_t ffs_calc_sbhash(struct fs *);
int ffs_checkfreefile(struct fs *, struct vnode *, ino_t);
void ffs_clrblock(struct fs *, u_char *, ufs1_daddr_t);
void ffs_clusteracct(struct fs *, struct cg *, ufs1_daddr_t, int);
Modified: head/sys/ufs/ffs/ffs_snapshot.c
==============================================================================
--- head/sys/ufs/ffs/ffs_snapshot.c Sun Nov 25 18:00:50 2018 (r340923)
+++ head/sys/ufs/ffs/ffs_snapshot.c Sun Nov 25 18:01:15 2018 (r340924)
@@ -795,6 +795,7 @@ out1:
brelse(nbp);
} else {
loc = blkoff(fs, fs->fs_sblockloc);
+ copy_fs->fs_ckhash = ffs_calc_sbhash(copy_fs);
bcopy((char *)copy_fs, &nbp->b_data[loc], (u_int)fs->fs_sbsize);
bawrite(nbp);
}
Modified: head/sys/ufs/ffs/ffs_subr.c
==============================================================================
--- head/sys/ufs/ffs/ffs_subr.c Sun Nov 25 18:00:50 2018 (r340923)
+++ head/sys/ufs/ffs/ffs_subr.c Sun Nov 25 18:01:15 2018 (r340924)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <ufs/ffs/fs.h>
uint32_t calculate_crc32c(uint32_t, const void *, size_t);
+uint32_t ffs_calc_sbhash(struct fs *);
struct malloc_type;
#define UFS_MALLOC(size, type, flags) malloc(size)
#define UFS_FREE(ptr, type) free(ptr)
@@ -147,7 +148,6 @@ ffs_load_inode(struct buf *bp, struct inode *ip, struc
static off_t sblock_try[] = SBLOCKSEARCH;
static int readsuper(void *, struct fs **, off_t, int,
int (*)(void *, off_t, void **, int));
-static uint32_t calc_sbhash(struct fs *);
/*
* Read a superblock from the devfd device.
@@ -276,7 +276,7 @@ readsuper(void *devfd, struct fs **fsp, off_t sblocklo
fs->fs_bsize <= MAXBSIZE &&
fs->fs_bsize >= roundup(sizeof(struct fs), DEV_BSIZE) &&
fs->fs_sbsize <= SBLOCKSIZE) {
- if (fs->fs_ckhash != (ckhash = calc_sbhash(fs))) {
+ if (fs->fs_ckhash != (ckhash = ffs_calc_sbhash(fs))) {
#ifdef _KERNEL
res = uprintf("Superblock check-hash failed: recorded "
"check-hash 0x%x != computed check-hash 0x%x\n",
@@ -339,7 +339,7 @@ ffs_sbput(void *devfd, struct fs *fs, off_t loc,
}
fs->fs_fmod = 0;
fs->fs_time = UFS_TIME;
- fs->fs_ckhash = calc_sbhash(fs);
+ fs->fs_ckhash = ffs_calc_sbhash(fs);
if ((error = (*writefunc)(devfd, loc, fs, fs->fs_sbsize)) != 0)
return (error);
return (0);
@@ -348,8 +348,8 @@ ffs_sbput(void *devfd, struct fs *fs, off_t loc,
/*
* Calculate the check-hash for a superblock.
*/
-static uint32_t
-calc_sbhash(struct fs *fs)
+uint32_t
+ffs_calc_sbhash(struct fs *fs)
{
uint32_t ckhash, save_ckhash;
More information about the svn-src-all
mailing list