aboutsummaryrefslogtreecommitdiffstats
path: root/sbin/dumpfs
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2018-02-08 23:06:58 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2018-02-08 23:06:58 +0000
commit068beacf21ea3ca33dd07741bb23939e24d84bef (patch)
treefe4dcad1f441eebb6296166140e4afbecc041914 /sbin/dumpfs
parent11421c37f0de8e96d350a5a00223ea6110bc0517 (diff)
downloadsrc-068beacf21ea3ca33dd07741bb23939e24d84bef.tar.gz
src-068beacf21ea3ca33dd07741bb23939e24d84bef.zip
The goal of this change is to prevent accidental foot shooting by
folks running filesystems created on check-hash enabled kernels (which I will call "new") on a non-check-hash enabled kernels (which I will call "old). The idea here is to detect when a filesystem is run on an old kernel and flag the filesystem so that when it gets moved back to a new kernel, it will not start getting a slew of check-hash errors. Back when the UFS version 2 filesystem was created, it added a file flag FS_INDEXDIRS that was to be set on any filesystem that kept some sort of on-disk indexing for directories. The idea was precisely to solve the issue we have today. Specifically that a newer kernel that supported indexing would be able to tell that the filesystem had been run on an older non-indexing kernel and that the indexes should not be used until they had been rebuilt. Since we have never implemented on-disk directory indicies, the FS_INDEXDIRS flag is cleared every time any UFS version 2 filesystem ever created is mounted for writing. This commit repurposes the FS_INDEXDIRS flag as the FS_METACKHASH flag. Thus, the FS_METACKHASH is definitively known to have always been cleared. The FS_INDEXDIRS flag has been moved to a new block of flags that will always be cleared starting with this commit (until they get used to implement some future feature which needs to detect that the filesystem was mounted on a kernel that predates the new feature). If a filesystem with check-hashes enabled is mounted on an old kernel the FS_METACKHASH flag is cleared. When that filesystem is mounted on a new kernel it will see that the FS_METACKHASH has been cleared and clears all of the fs_metackhash flags. To get them re-enabled the user must run fsck (in interactive mode without the -y flag) which will ask for each supported check hash whether it should be rebuilt and enabled. When fsck is run in its default preen mode, it will just ignore the check hashes so they will remain disabled. The kernel has always disabled any check hash functions that it does not support, so as more types of check hashes are added, we will get a non-surprising result. Specifically if filesystems get moved to kernels supporting fewer of the check hashes, those that are not supported will be disabled. If the filesystem is moved back to a kernel with more of the check-hashes available and fsck is run interactively to rebuild them, then their checking will resume. Otherwise just the smaller subset will be checked. A side effect of this commit is that filesystems running with cylinder-group check hashes will stop having them checked until fsck is run to re-enable them (since none of them currently have the FS_METACKHASH flag set). So, if you want check hashes enabled on your filesystems after booting a kernel with these changes, you need to run fsck to enable them. Any newly created filesystems will have check hashes enabled. If in doubt as to whether you have check hashes emabled, run dumpfs and look at the list of enabled flags at the end of the superblock details.
Notes
Notes: svn path=/head/; revision=329051
Diffstat (limited to 'sbin/dumpfs')
-rw-r--r--sbin/dumpfs/dumpfs.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/sbin/dumpfs/dumpfs.c b/sbin/dumpfs/dumpfs.c
index 87e28366a1a0..d1ba635f9f26 100644
--- a/sbin/dumpfs/dumpfs.c
+++ b/sbin/dumpfs/dumpfs.c
@@ -257,9 +257,9 @@ dumpfs(const char *name)
if (fsflags & FS_DOSOFTDEP)
printf("soft-updates%s ", (fsflags & FS_SUJ) ? "+journal" : "");
if (fsflags & FS_NEEDSFSCK)
- printf("needs fsck run ");
+ printf("needs-fsck-run ");
if (fsflags & FS_INDEXDIRS)
- printf("indexed directories ");
+ printf("indexed-directories ");
if (fsflags & FS_ACLS)
printf("acls ");
if (fsflags & FS_MULTILABEL)
@@ -267,31 +267,33 @@ dumpfs(const char *name)
if (fsflags & FS_GJOURNAL)
printf("gjournal ");
if (fsflags & FS_FLAGS_UPDATED)
- printf("fs_flags expanded ");
+ printf("fs_flags-expanded ");
if (fsflags & FS_NFS4ACLS)
printf("nfsv4acls ");
if (fsflags & FS_TRIM)
printf("trim ");
- fsflags &= ~(FS_UNCLEAN | FS_DOSOFTDEP | FS_NEEDSFSCK | FS_INDEXDIRS |
+ fsflags &= ~(FS_UNCLEAN | FS_DOSOFTDEP | FS_NEEDSFSCK | FS_METACKHASH |
FS_ACLS | FS_MULTILABEL | FS_GJOURNAL | FS_FLAGS_UPDATED |
- FS_NFS4ACLS | FS_SUJ | FS_TRIM);
+ FS_NFS4ACLS | FS_SUJ | FS_TRIM | FS_INDEXDIRS);
if (fsflags != 0)
- printf("unknown flags (%#x)", fsflags);
+ printf("unknown-flags (%#x)", fsflags);
putchar('\n');
- printf("check hashes\t");
- fsflags = afs.fs_metackhash;
- if (fsflags == 0)
- printf("none");
- if (fsflags & CK_SUPERBLOCK)
- printf("superblock ");
- if (fsflags & CK_CYLGRP)
- printf("cylinder-groups ");
- if (fsflags & CK_INODE)
- printf("inodes ");
- if (fsflags & CK_INDIR)
- printf("indirect-blocks ");
- if (fsflags & CK_DIR)
- printf("directories ");
+ if (afs.fs_flags & FS_METACKHASH) {
+ printf("check hashes\t");
+ fsflags = afs.fs_metackhash;
+ if (fsflags == 0)
+ printf("none");
+ if (fsflags & CK_SUPERBLOCK)
+ printf("superblock ");
+ if (fsflags & CK_CYLGRP)
+ printf("cylinder-groups ");
+ if (fsflags & CK_INODE)
+ printf("inodes ");
+ if (fsflags & CK_INDIR)
+ printf("indirect-blocks ");
+ if (fsflags & CK_DIR)
+ printf("directories ");
+ }
fsflags &= ~(CK_SUPERBLOCK | CK_CYLGRP | CK_INODE | CK_INDIR | CK_DIR);
if (fsflags != 0)
printf("unknown flags (%#x)", fsflags);