[Ocfs2-tools-commits] zab commits r371 - trunk/fsck.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Sun Nov 7 17:48:08 CST 2004
Author: zab
Date: 2004-11-07 17:48:06 -0600 (Sun, 07 Nov 2004)
New Revision: 371
Modified:
trunk/fsck.ocfs2/dirblocks.c
trunk/fsck.ocfs2/dirparents.c
trunk/fsck.ocfs2/fsck.c
trunk/fsck.ocfs2/icount.c
trunk/fsck.ocfs2/journal.c
trunk/fsck.ocfs2/pass0.c
trunk/fsck.ocfs2/pass1.c
trunk/fsck.ocfs2/pass2.c
trunk/fsck.ocfs2/pass3.c
trunk/fsck.ocfs2/pass4.c
trunk/fsck.ocfs2/problem.c
trunk/fsck.ocfs2/strings.c
trunk/fsck.ocfs2/util.c
Log:
o go nuts updating comments
o tiny clean-up of checking the super block
Modified: trunk/fsck.ocfs2/dirblocks.c
===================================================================
--- trunk/fsck.ocfs2/dirblocks.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/dirblocks.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,12 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * icount.c
- *
- * As always, we let e2fsck lead the way. A bitmap for
- * inodes with a single i_count (the vast majority), and a
- * tree of inode numbers with a greater count.
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +17,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * Just a simple rbtree wrapper to record directory blocks and the inodes
+ * that own them.
*/
#include <unistd.h>
#include <stdlib.h>
Modified: trunk/fsck.ocfs2/dirparents.c
===================================================================
--- trunk/fsck.ocfs2/dirparents.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/dirparents.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,12 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * dirparents.c
- *
- * As always, we let e2fsck lead the way. A bitmap for
- * inodes with a single i_count (the vast majority), and a
- * tree of inode numbers with a greater count.
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +17,12 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * An rbtree to record a directory's parent information. _dirent records
+ * the inode who had a directory entry that points to the directory in
+ * question. _dot_dot records the inode that the directory's ".." points to;
+ * who it thinks its parent is.
*/
#include <unistd.h>
#include <stdlib.h>
Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/fsck.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * fsck.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -24,34 +20,24 @@
* --
* Roughly o2fsck performs the following operations. Each pass' file has
* more details.
- *
- * - pass0: clean up the inode allocators
- * - kill loops, chains can't share groups
- * - move local allocs back to the global or something?
- * - verify just enough of the fields to make iterating work
*
- * - pass1: walk inodes
- * - record all valid clusters that inodes point to
- * - make sure extent trees in inodes are consistent
- * - inconsistencies mark inodes for deletion
- * - update cluster bitmap
- * - have bits reflect our set of referenced clusters
- * - again, how to resolve local/global?
- * * from this point on the library can trust the cluster bitmap
+ * journal.c: try and replay the journal for each node
+ * pass0.c: make sure the inode allocators are consistent
+ * pass1.c: walk allocated inodes and verify them
+ * reflect valid inodes in the inode allocator bitmaps
+ * pass2.c: verify directory entries, record some linkage metadata
+ * pass3.c: make sure all dirs are reachable
+ * pass4.c: resolve inode's link counts, move disconnected inodes to lost+found
*
- * - update the inode allocators
- * - make sure our set of valid inodes matches the bits
- * - make sure all the bit totals add up
- * * from this point on the library can trust the inode allocators
+ * When hacking on this keep the following in mind:
*
- * This makes it so only these early passes need to have global
- * allocation goo in memory. The rest can use the library as
- * usual.
- *
- * so what do we do about the extent metadata allocators? track them in
- * the same way we track inodes in the inode suballocators, I guess. store
- * with whatever key they have. do the suballocators only allocate extent
- * list blocks that are only owned by a tree? that'd make it pretty easy.
+ * - fsck -n is a good read-only on-site diagnostic tool. This means that fsck
+ * _should not_ write to the file system unless it has asked prompt() to do
+ * so. It should also not exit if prompt() returns 0. prompt() shold give
+ * as much detail as possible as it becomes an error log.
+ * - to make life simpler, memory allocation is a fatal error. We shouldn't
+ * have unreasonable memory demands in relation to the size of the fs.
+ * - I'm still of mixed opinions about IO errors. thoughts?
*/
#include <getopt.h>
#include <limits.h>
@@ -159,24 +145,27 @@
return 0;
}
-static void check_superblock(char *whoami, o2fsck_state *ost)
+static errcode_t check_superblock(char *whoami, o2fsck_state *ost)
{
ocfs2_super_block *sb = OCFS2_RAW_SB(ost->ost_fs->fs_super);
+ errcode_t ret = 0;
if (sb->s_max_nodes == 0) {
- printf("The superblock max_nodes field is set to 0. fsck "
- "doesn't know how to repair this.\n");
- exit(FSCK_ERROR);
+ printf("The superblock max_nodes field is set to 0.\n");
+ ret = OCFS2_ET_CORRUPT_SUPERBLOCK;
}
/* ocfs2_open() already checked _incompat and _ro_compat */
if (sb->s_feature_compat & ~OCFS2_FEATURE_COMPAT_SUPP) {
- com_err(whoami, OCFS2_ET_UNSUPP_FEATURE,
- "while checking _compat flags");
- exit(FSCK_ERROR);
+ if (ret == 0)
+ ret = OCFS2_ET_UNSUPP_FEATURE;
+ com_err(whoami, ret, "while checking the super block's compat "
+ "flags");
}
/* XXX do we want checking for different revisions of ocfs2? */
+
+ return ret;
}
static void exit_if_skipping(o2fsck_state *ost)
@@ -325,15 +314,6 @@
filename = argv[optind];
-#if 0 /* irritating, and e2fsck doesn't do it. what do others think? */
- struct stat st;
- if (stat(filename, &st) == 0 && !S_ISBLK(st.st_mode) &&
- !prompt(ost, PY, "%s isn't a special block device. Proceed "
- "anyway?", filename)) {
- exit(FSCK_ERROR);
- }
-#endif
-
/* XXX we'll decide on a policy for using o_direct in the future.
* for now we want to test against loopback files in ext3, say. */
ret = ocfs2_open(filename, rw | OCFS2_FLAG_BUFFERED, blkno,
@@ -349,9 +329,13 @@
return 1;
}
+ ret = check_superblock(argv[0], ost);
+ if (ret) {
+ printf("fsck saw unrecoverable errors in the super block and "
+ "will not continue.\n");
+ exit(FSCK_ERROR);
+ }
- check_superblock(argv[0], ost);
-
exit_if_skipping(ost);
/* XXX we don't use the bad blocks inode, do we? */
Modified: trunk/fsck.ocfs2/icount.c
===================================================================
--- trunk/fsck.ocfs2/icount.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/icount.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,12 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * icount.c
- *
- * As always, we let e2fsck lead the way. A bitmap for
- * inodes with a single i_count (the vast majority), and a
- * tree of inode numbers with a greater count.
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +17,10 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * A trivial rbtree that stores a u16 icount indexed by an inode's block
+ * number.
*/
#include <unistd.h>
#include <stdlib.h>
Modified: trunk/fsck.ocfs2/journal.c
===================================================================
--- trunk/fsck.ocfs2/journal.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/journal.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * journal.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -610,7 +606,6 @@
printf("Node %d's journal replayed successfully.\n", i);
}
- /* XXX make sure we maintain journal_trouble in all cases */
if (journal_trouble &&
!prompt(ost, PN, "There were problems replaying journals. This "
"means that the file system is almost certainly badly "
Modified: trunk/fsck.ocfs2/pass0.c
===================================================================
--- trunk/fsck.ocfs2/pass0.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/pass0.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * pass0.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -21,6 +17,8 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
+ * --
+ *
* Pass 0 verifies that the inode suballocators can be iterated over by later
* passes without risk of running into corruption. This is so the passes can
* build up state without having to worry about tearing it down half way
Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/pass1.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -17,8 +17,31 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
+ * --
+ *
+ * Pass 1 is arguably where the greatest concentration of special rules
+ * in fsck live. It walks through all the inodes that it can get its hands
+ * on and verifies them. For now it only walks the inode allocator groups
+ * that pass 0 was able to verify. One can imagine it getting other potential
+ * inodes from other places.
+ *
+ * The complexity comes in deciding that inodes are valid. There are different
+ * critera for system inodes, allocator inodes, and the usual different
+ * unix inode file types.
+ *
+ * Pass 1 build up in-memory copies of the inode allocators that are written
+ * back as the real inode allocators if inconsistencies are found between
+ * the bitmaps and the inodes. It also builds up many inode-dependent data
+ * structures that are used by future passes:
+ * - icount map of inodes to what their current on-disk i_link_count is
+ * - bitmap of which inodes are directories or regular files
+ * - directory blocks that it finds off of directory inodes
+ *
* XXX
+ * check many, many, more i_ fields for each inode type
* make sure the inode's dtime/count/valid match in update_inode_alloc
+ * clean up the extent records that hang off inodes
+ * more carefully track cluster use in conjunction with pass 0
*/
#include <string.h>
#include <inttypes.h>
@@ -152,10 +175,7 @@
/* Check the basics of the ocfs2_dinode itself. If we find problems
* we clear the VALID flag and the caller will see that and update
- * inode allocations and write the inode to disk.
- *
- * XXX should walk down all the i_fields to make sure we're veryfying
- * those that we can this early */
+ * inode allocations and write the inode to disk. */
static void o2fsck_verify_inode_fields(ocfs2_filesys *fs, o2fsck_state *ost,
uint64_t blkno, ocfs2_dinode *di)
{
Modified: trunk/fsck.ocfs2/pass2.c
===================================================================
--- trunk/fsck.ocfs2/pass2.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/pass2.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * pass2.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +17,22 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ * Pass 2 iterates through the directory blocks that pass 1 found under
+ * directory inodes. The basic dirent structures are made consistent
+ * in each block. Directory entries much point to active inodes. "dot dot"
+ * must be in the first blocks of the dir and nowhere else. Duplicate entries
+ * are detected but little more. Slashes and nulls in names are replaced
+ * with dots. The file type in the entry is synced with the type found in
+ * the inode it points to. Throughout this invalid entries are cleared
+ * by simply setting their inode field to 0 so that the fs will reuse them.
+ *
+ * Pass 2 builds up the parent dir linkage as it scans the directory entries
+ * so that pass 3 can walk the directory trees to find disconnected inodes.
+ *
+ * XXX
+ * do something about duplicate entries?
+ *
*/
#include <string.h>
#include <inttypes.h>
Modified: trunk/fsck.ocfs2/pass3.c
===================================================================
--- trunk/fsck.ocfs2/pass3.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/pass3.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * pass3.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +17,16 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ * Pass 3 makes sure that all directories are connected to the file system
+ * tree and that their are no cycles in the tree. It starts by marking
+ * the root and system directories in the filesystem as connected. It then
+ * iterates through the directories found in pass 1. For each directory
+ * it ascends to the root of the file system via the chain of parent dir
+ * entries as built up by pass 2. If a directory is found which doesn't have
+ * a parent it is connected to lost+found. connect_directory() is careful
+ * to stop before following a parent that it has already seen. This lets it
+ * connect to lost+found instead and break cycles.
*/
#include <inttypes.h>
#include <string.h>
Modified: trunk/fsck.ocfs2/pass4.c
===================================================================
--- trunk/fsck.ocfs2/pass4.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/pass4.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -17,6 +17,13 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
+ * --
+ *
+ * Pass 4 walks all the active inodes and makes sure that they are reachable
+ * via directory entries, just like pass 3 did for directories. It also
+ * makes sure each inode's link_count reflects the number of entries that
+ * refer to it. Inodes that aren't referred to by any entries are moved
+ * to lost+found.
*/
#include <inttypes.h>
Modified: trunk/fsck.ocfs2/problem.c
===================================================================
--- trunk/fsck.ocfs2/problem.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/problem.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * problem.c
- *
- * These routines serve the same purpose as e2fsck's "fix_problem()"
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +17,15 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * prompt() asks the user whether a given problem should be fixed or not.
+ * "problem.c" is derived from the baroque e2fsck origins for this concept.
+ *
+ * XXX
+ * The significant gap here is in persistent answers. Often one wants
+ * to tell fsck to stop asking the same freaking question over and over
+ * until a different question is asked.
*/
#include <unistd.h>
#include <stdlib.h>
Modified: trunk/fsck.ocfs2/strings.c
===================================================================
--- trunk/fsck.ocfs2/strings.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/strings.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,12 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * strings.c
- *
- * As always, we let e2fsck lead the way. A bitmap for
- * inodes with a single i_count (the vast majority), and a
- * tree of inode numbers with a greater count.
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -23,7 +17,11 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * A light wrapper around rbtree to store strings with the sole purpose of
+ * detecting dupliates.
+ *
*/
#include <unistd.h>
#include <stdlib.h>
Modified: trunk/fsck.ocfs2/util.c
===================================================================
--- trunk/fsck.ocfs2/util.c 2004-11-07 22:08:45 UTC (rev 370)
+++ trunk/fsck.ocfs2/util.c 2004-11-07 23:48:06 UTC (rev 371)
@@ -1,10 +1,6 @@
/* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
- * util.c
- *
- * file system checker for OCFS2
- *
* Copyright (C) 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
@@ -21,7 +17,13 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*
- * Authors: Zach Brown
+ * --
+ *
+ * Little helpers that are used by all passes.
+ *
+ * XXX
+ * pull more in here.. look in include/pass?.h for incongruities
+ *
*/
#include <inttypes.h>
#include "ocfs2.h"
More information about the Ocfs2-tools-commits
mailing list