summaryrefslogtreecommitdiffstats
path: root/sys/ufs
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2002-11-27 02:18:58 +0000
committermckusick <mckusick@FreeBSD.org>2002-11-27 02:18:58 +0000
commit9251693096205ec24c8f8eec7bd9f516b3bb70e5 (patch)
treed1928be6bf74e88babe007808d7eaa98444918f3 /sys/ufs
parent4b6c4bf70dda32c0c61b5380253299edaff0df5b (diff)
downloadFreeBSD-src-9251693096205ec24c8f8eec7bd9f516b3bb70e5.zip
FreeBSD-src-9251693096205ec24c8f8eec7bd9f516b3bb70e5.tar.gz
Create a new 32-bit fs_flags word in the superblock. Add code to move
the old 8-bit fs_old_flags to the new location the first time that the filesystem is mounted by a new kernel. One of the unused flags in fs_old_flags is used to indicate that the flags have been moved. Leave the fs_old_flags word intact so that it will work properly if used on an old kernel. Change the fs_sblockloc superblock location field to be in units of bytes instead of in units of filesystem fragments. The old units did not work properly when the fragment size exceeeded the superblock size (8192). Update old fs_sblockloc values at the same time that the flags are moved. Suggested by: BOUWSMA Barry <freebsd-misuser@netscum.dyndns.dk> Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/ufs')
-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
3 files changed, 24 insertions, 15 deletions
diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index c2538a6..667b937 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 91d396b..9567bd0 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 44d92f2..0dc495e 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.
OpenPOWER on IntegriCloud