aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/boot/common/ufsread.c2
-rw-r--r--sys/ufs/ffs/ffs_snapshot.c8
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c23
-rw-r--r--sys/ufs/ffs/fs.h8
4 files changed, 25 insertions, 16 deletions
diff --git a/sys/boot/common/ufsread.c b/sys/boot/common/ufsread.c
index f2b7ba78aa1d..6173fd9e69e6 100644
--- a/sys/boot/common/ufsread.c
+++ b/sys/boot/common/ufsread.c
@@ -243,7 +243,7 @@ fsread(ino_t inode, void *buf, size_t nbyte)
return -1;
if ((fs->fs_magic == FS_UFS1_MAGIC ||
(fs->fs_magic == FS_UFS2_MAGIC &&
- fs->fs_sblockloc == numfrags(fs, sblock_try[n]))) &&
+ fs->fs_sblockloc == sblock_try[n])) &&
fs->fs_bsize <= MAXBSIZE &&
fs->fs_bsize >= sizeof(struct fs))
break;
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index c2538a6af185..667b93785430 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -235,8 +235,8 @@ restart:
/*
* Allocate copies for the superblock and its summary information.
*/
- error = UFS_BALLOC(vp, lfragtosize(fs, fs->fs_sblockloc),
- fs->fs_sbsize, KERNCRED, 0, &nbp);
+ error = UFS_BALLOC(vp, fs->fs_sblockloc, fs->fs_sbsize, KERNCRED,
+ 0, &nbp);
if (error)
goto out;
bawrite(nbp);
@@ -339,14 +339,14 @@ restart:
* Grab a copy of the superblock and its summary information.
* We delay writing it until the suspension is released below.
*/
- error = bread(vp, fragstoblks(fs, fs->fs_sblockloc), fs->fs_bsize,
+ error = bread(vp, lblkno(fs, fs->fs_sblockloc), fs->fs_bsize,
KERNCRED, &sbp);
if (error) {
brelse(sbp);
sbp = NULL;
goto out1;
}
- loc = blkoff(fs, lfragtosize(fs, fs->fs_sblockloc));
+ loc = blkoff(fs, fs->fs_sblockloc);
copy_fs = (struct fs *)(sbp->b_data + loc);
bcopy(fs, copy_fs, fs->fs_sbsize);
if ((fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0)
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 91d396bf5798..9567bd084cc2 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -426,7 +426,7 @@ ffs_reload(mp, cred, td)
* Step 2: re-read superblock from disk.
*/
fs = VFSTOUFS(mp)->um_fs;
- if ((error = bread(devvp, fsbtodb(fs, fs->fs_sblockloc), fs->fs_sbsize,
+ if ((error = bread(devvp, btodb(fs->fs_sblockloc), fs->fs_sbsize,
NOCRED, &bp)) != 0)
return (error);
newfs = (struct fs *)bp->b_data;
@@ -624,10 +624,11 @@ ffs_mountfs(devvp, mp, td, malloctype)
cred, &bp)) != 0)
goto out;
fs = (struct fs *)bp->b_data;
- sblockloc = numfrags(fs, sblock_try[i]);
+ sblockloc = sblock_try[i];
if ((fs->fs_magic == FS_UFS1_MAGIC ||
(fs->fs_magic == FS_UFS2_MAGIC &&
- fs->fs_sblockloc == sblockloc)) &&
+ (fs->fs_sblockloc == sblockloc ||
+ (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0))) &&
fs->fs_bsize <= MAXBSIZE &&
fs->fs_bsize >= sizeof(struct fs))
break;
@@ -848,12 +849,18 @@ ffs_oldfscompat_read(fs, ump, sblockloc)
off_t maxfilesize;
/*
+ * If not yet done, update fs_flags location and value of fs_sblockloc.
+ */
+ if ((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) {
+ fs->fs_flags = fs->fs_old_flags;
+ fs->fs_old_flags |= FS_FLAGS_UPDATED;
+ fs->fs_sblockloc = sblockloc;
+ }
+ /*
* If not yet done, update UFS1 superblock with new wider fields.
*/
- if (fs->fs_magic == FS_UFS1_MAGIC &&
- fs->fs_sblockloc != sblockloc) {
+ if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_size != fs->fs_old_size) {
fs->fs_maxbsize = fs->fs_bsize;
- fs->fs_sblockloc = sblockloc;
fs->fs_time = fs->fs_old_time;
fs->fs_size = fs->fs_old_size;
fs->fs_dsize = fs->fs_old_dsize;
@@ -1471,8 +1478,8 @@ ffs_sbupdate(mp, waitfor)
*/
if (allerror)
return (allerror);
- bp = getblk(mp->um_devvp, fsbtodb(fs, fs->fs_sblockloc),
- (int)fs->fs_sbsize, 0, 0);
+ bp = getblk(mp->um_devvp, btodb(fs->fs_sblockloc), (int)fs->fs_sbsize,
+ 0, 0);
fs->fs_fmod = 0;
fs->fs_time = time_second;
bcopy((caddr_t)fs, bp->b_data, (u_int)fs->fs_sbsize);
diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h
index 44d92f2e8c8f..0dc495eebc69 100644
--- a/sys/ufs/ffs/fs.h
+++ b/sys/ufs/ffs/fs.h
@@ -302,7 +302,7 @@ struct fs {
int8_t fs_fmod; /* super block modified flag */
int8_t fs_clean; /* filesystem is clean flag */
int8_t fs_ronly; /* mounted read-only flag */
- int8_t fs_flags; /* see FS_ flags below */
+ int8_t fs_old_flags; /* old FS_ flags */
u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
/* these fields retain the current block allocation info */
int32_t fs_cgrotor; /* last cg searched */
@@ -314,7 +314,7 @@ struct fs {
int32_t fs_old_cpc; /* cyl per cycle in postbl */
int32_t fs_maxbsize; /* maximum blocking factor permitted */
int64_t fs_sparecon64[17]; /* old rotation block list head */
- int64_t fs_sblockloc; /* location of standard superblock */
+ int64_t fs_sblockloc; /* byte offset of standard superblock */
struct csum_total fs_cstotal; /* cylinder summary information */
ufs_time_t fs_time; /* last time written */
int64_t fs_size; /* number of blocks in fs */
@@ -326,7 +326,8 @@ struct fs {
int32_t fs_avgfilesize; /* expected average file size */
int32_t fs_avgfpdir; /* expected # of files per directory */
int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */
- int32_t fs_sparecon32[27]; /* reserved for future constants */
+ int32_t fs_sparecon32[26]; /* reserved for future constants */
+ int32_t fs_flags; /* see FS_ flags below */
int32_t fs_contigsumsize; /* size of cluster summary array */
int32_t fs_maxsymlinklen; /* max length of an internal symlink */
int32_t fs_old_inodefmt; /* format of on-disk inodes */
@@ -389,6 +390,7 @@ struct fs {
#define FS_INDEXDIRS 0x08 /* kernel supports indexed directories */
#define FS_ACLS 0x10 /* file system has ACLs enabled */
#define FS_MULTILABEL 0x20 /* file system is MAC multi-label */
+#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */
/*
* Macros to access bits in the fs_active array.