Commit Graph

89 Commits (a3efe4842054175d01b465fbe0b29b9be8b800a1)

Author SHA1 Message Date
Theodore Ts'o a3efe48420 e2fsck: fix mysterious "FILE SYSTEM WAS MODIFIED" with no changes
Commit 2a77a784a3 (firest released in e2fsprogs 1.33) compared
superblock summary free blocks and inode counts with the allocation
bitmap counts before starting the file system check proper, and if
they differed, set the superblock and marked it as dirty.  If no other
file systme changes were required, this would cause a "*** FILE SYSTEM
WAS MODIFIED ***" message without any explanation of what e2fsck had
changed.

We fix this by only setting the superblock summary free block/inodes
counts if we are skipping a full check, and in non-preen mode, e2fsck
will now print an explicit message stating how the superblock had been
updated.

In a full check, any updates to the superblock free blocks/inodes
fields will be noted in pass5.

This change requires changing a few test results (essentially
reversing the changes made in commit 2a77a784a3).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16 01:22:02 -04:00
Theodore Ts'o 44fe08f1fa e2fsck: add basic bigalloc support to check (but not yet repair) file systems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:58:16 -04:00
Theodore Ts'o a6217f5ae2 e2fsck: Fix a number of problems that were inappropriately using PROMPT_ABORT
There were a number of problems that were prompting the user whether
or not to ABORT, but then would abort regardless of whether the user
answered yes or no.  Change those to be PROMPT_NONE, PR_FATAL.

Also, fix PR_1_RESIZE_INODE_CREATE so that it recovers appropriately
after failing to create the resize inode.  This problem now uses
PROMPT_CONTINUE instead of PROMPT_ABORT, and if the user says, "no",
the code will abort.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-12 18:58:53 -04:00
Theodore Ts'o 2291fbb035 e2fsck: Check for cases where EOFBLOCKS_FL is unnecessarily set
Some kernels will crash if EOFBLOCKS_FL is set when it is it not
needed, and this if it is left set when it isn't needed, it is a sign
of a kernel bug.

Addresses-Google-Bug: #2604224

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-10 10:29:14 -04:00
Theodore Ts'o 6013915487 e2fsck: Add a global latch question for bad group descriptor checksums
Very often all the block group descriptors will have bad checksums, so
don't force the user answer 'yes' many, many times.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-19 01:06:50 -04:00
Theodore Ts'o 26ea4899d1 e2fsck: Fix superblock times in the future even if buggy_init_scripts=1
Unfortunately, distributions like Ubuntu seem to have buggy init
scripts that run e2fsck and mount the root filesystem before making
sure the system time and time zone is correctly set.  As a result, a
filesystem's last write and last mounted time can be set in future.
The buggy_init_scripts configuration option will stop e2fsck from
aborting the boot process, but it also inhibits the superblock times
from getting fixed.  This causes resize2fs to refuse to resize the
filesystem, even after running e2fsck on the file system.  To deal
with this, we need to fix the superblock write times unconditionally.

Addresses-Launchpad-bug: #373409

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-16 23:44:50 -04:00
Andreas Dilger ae33f578c0 e2fsck: cleanup whitespace in problem.c and problem.h
Cleanup whitespace in the problem.h and problem.c files.  Removes a
bunch of places where tabs follow spaces, whitespace on empty lines, etc.
I didn't reformat the indenting of the entire problem.h error codes,
but there is some room for doing this...

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:45 -04:00
Andreas Dilger 7494cbfd59 e2fsck: Add test code in problem.c to verify problem codes
We've hit a number of cases where the error codes in problem.h have
been assigned duplicate values compared to problems in our own e2fsck
patches, and this can lead to confusing and difficult to find bugs
in e2fsck (e.g. wrong problem messages, incorrect repair action, etc).

Attached is a test case for the problem.c file to ensure that the
problem table is sorted and does not contain any duplicate values.
Having the problem table sorted allows the correctness checking to be
very simple, and if it ever became important for performance we could
use binary searching of the problem table for the specific problem code.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-02 21:10:44 -04:00
Theodore Ts'o 911ec62615 e2fsck: On a 32-bit filesystem, make sure i_file_acl_high is zero
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-23 21:31:16 -04:00
Theodore Ts'o 7518c17686 e2fsck: Fix an unhandled corruption case in scan_extent_node()
A corrupted interior node in an extent tree would cause e2fsck to
crash with the error message:

Error1: Corrupt extent header on inode 107192
Aborted (core dumped)

Handle this and related failures when scanning an inode's extent tree
more robustly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-12-25 22:42:38 -05:00
Theodore Ts'o 80875db58a e2fsck: Offer to clear the test_fs flag if ext4 is available
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-12 23:12:23 -04:00
Theodore Ts'o 185c4aeaf2 e2fsck: Add support to check journal checksums
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-06 23:38:38 -04:00
Theodore Ts'o d5a8f9a9f2 e2fsck: Detect unordered extents in an extent node
The logical block numbers must be monotonically increasing, and there
must not be any overlapping extents.  If any are found, report them as
filesystem corruption.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-02 20:33:30 -04:00
Theodore Ts'o db0691b555 Fix trailing whitespace in e2fsck/problem.[ch]
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:38 -04:00
Andreas Dilger 0d5439c8e0 e2fsck: Add check to enforce a valid block bitmap in last block group
Add a check for the UNINIT_BLOCKS flag set in the last group.  The kernel
patch doesn't handle this gracefully, because it assumes there are a full
set of blocks in each group marked UNINIT_BLOCKS.  The kernel should be
fixed up, but in the meantime this avoids hitting the problem, and is
more consistent with lazy_bg not marking the last group UNINIT.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-31 14:28:38 -04:00
Jose R. Santos 49a7360ba6 Make e2fsck uninit block group aware
This patch has all the necesary pieces to open and fix filesystems created
with the uninit block group feature.

Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-20 15:33:12 -04:00
Theodore Ts'o ee19c902e6 e2fsck: Check for fast symlinks that have EXTENTS_FL set
These shouldn't show up in the wild, but if they do, e2fsck will offer
to clear them.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-13 23:13:18 -04:00
Theodore Ts'o a040a99b6c Merge branch 'maint'
Conflicts:

	lib/ext2fs/ext2_err.et.in
2008-03-13 10:53:26 -04:00
Theodore Ts'o d45edec0fb e2fsck: Handle a pass 2 "should never happen" error gracefully
Turns out a "should never happen" error can indeed happen very easily
if a directory with an htree index has an incorrect, and too-large,
i_size field.  This patch fixes this so that we handle this situation
gracefully, allowing filesystems with this error to be fixed.

In another patch I will clean up the specific problem which caused the
internal "should never happen" error from happening at all, but patch
will prevent e2fsck from crashing, and prompt the user to remove the
htree index, so it can be rebuilt again after pass 3.

Thanks to Bas van Schaik at Tetra for giving me access to his system
so this problem could be debugged.

Addresses-Launchpad-Bug: #129395

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-03-12 16:10:48 -04:00
Theodore Ts'o 15d482ba6e e2fsck: Add support for extents
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-02-18 20:06:18 -05:00
Theodore Ts'o 1a191d6648 e2fsck: Detect recursive loops in @-expansions
The Turkish translation has a bug in it where it has the translation
of "E@e '%Dn' in %p (%i)" to "E@E".  This causes @E to be expanded at
@E, recursively, forever, until the stack fills up e2fsck core dumps.

Fix it by stopping after a recursive depth of 10, which is far more
than we need.

Addresses-Sourceforge-Bug: 1646081

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-07-02 19:04:31 -04:00
Kalpak Shah 5107d0d196 Recreate journal that had been removed previously due to corruption
If the journal had been removed because it was corrupt, the
E2F_FLAG_JOURNAL_INODE flag will be set.  If this flag is set, then
recreate the filesystem after checking the filesystem.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
2007-06-21 11:59:06 -04:00
Theodore Ts'o fbc3f90194 e2fsck: Recover a special file which looks an awful lot like a directory
This is probably only useful in artificial test cases, but it will be
useful if we ever do the "inodes in directory" idea for ext4.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2007-04-02 10:08:59 -04:00
Theodore Ts'o f77704e416 Add directory hashed signed/unsigned hint to superblock
The e2fsprogs and kernel implementation of directory hash tree has a
bug which causes the implementation to be dependent on whether
characters are signed or unsigned.  Platforms such as the PowerPC,
Arm, and S/390 have signed characters by default, which means that
hash directories on those systems are incompatible with hash
directories on other systems, such as the x86.

To fix this we add a new flags field to the superblock, and define two
new bits in that field to indicate whether or not the directory should
be signed or unsigned.  If the bits are not set, e2fsck and fixed
kernels will set them to the signed/unsigned value of the currently
running platform, and then respect those bits when calculating the
directory hash.  This allows compatibility with current filesystems,
as well as allowing cross-architectural compatibility.

Addresses Debian Bug: #389772

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 22:32:35 -05:00
Theodore Ts'o 5d17119d14 On-disk format definition for huge files
- EXT4_FEATURE_RO_COMPAT_HUGE_FILE (0x0008) - change i_blocks to be
  in units of s_blocksize units instead of 512-byte sectors, use
  l_i_frag and l_i_fsize as i_blocks_hi (could also be part of 64BIT).

E2fsck and debugfs changed to support i_blocks_hi instead of l_i_frag and
l_i_fsize.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-11-11 06:32:03 -05:00
Theodore Ts'o b1c52b26a4 Enhance e2fsck so it can fix external journal hint in the superblock
Check to see if the superblock hint for the external journal needs to
be updated, and if so, offer to update it.  (Addresses Debian Bug:
#355644)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-03-10 15:25:59 -05:00
Theodore Ts'o 8dceb92407 E2fsck: fix future times in the superblock's last mount or last write fields
Detect if the superblock's last mount field or last write field is in
the future, and offer to fix if so.  (Addresses Debian Bug #327580)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2005-09-24 21:59:45 -04:00
Theodore Ts'o cebe48a1ec Integrate code from Alex Thomas at Clusterfs to check extended attributes
stored in inodes into e2fsck.

There are a number of bug fixes and enhancements over the original lustre fsck
BK repository.  The biggest one is that this extended attribute values must
be aligned on 4-byte boundaries.
2005-03-21 13:15:45 -05:00
Theodore Ts'o 33db8f80f2 Remove support for --enable-clear-htree; this was
only needed during the early development of the htree patch.
2005-02-05 10:28:15 -05:00
Theodore Ts'o c3ffaf833b Add support to detect corrupted resize_inode's to e2fsck. 2004-12-24 01:42:22 -05:00
Theodore Ts'o e75cfc5da8 Fix e2fsck so that it will clean up filesystesm that have the
resize_inode capability disabled, but which still have the
s_reserved_gdt_blocks field set in the superblock, or which 
still have blocks in the inode #7 (the resize inode).
2004-12-16 20:13:45 -05:00
Theodore Ts'o 000ba4046f pass1.c (e2fsck_pass1), problem.h (PR_1_BB_FS_BLOCK),
problem.c (PR_1_BB_FS_BLOCK, PR_1_BBINODE_BAD_METABLOCK_PROMPT): 
	Fix up the handling of corrupted indirect blocks in the 
	bad block.  We now correctly handle the case where there
	is an overlap between a block group descriptor or
	a superblock and a bad block indirect block.  In the case
	where the indirect block is corrupted, we now suggest
	"e2fsck -c".
2003-11-21 10:41:58 -05:00
Theodore Ts'o a435ec3449 Add support for backing up the journal inode location in the
superblock.  E2fsck will automatically save the journal information
in the superblock if it is not there already, and will use it if the
journal inode appears to be corrupted.  ext2fs_add_journal_inode() 
will also save the backup information, so that new filesystems
created by mke2fs and filesystems that have journals added via
tune2fs will also have journal location written to the superblock as
well.  Debugfs's logdump command has been enhanced so that it can
use the journal information in the superblock.

The debugfs man page has been improved to more fully describe the
logdump command.

Added two new functions, ext2fs_file_open2() and 
ext2fs_inode_io_intern2() which take a pointer to an inode structure;
this is needed so that e2fsck and debugfs can synthesize a
fake journal inode and use it to access the journal.
2003-08-21 00:40:26 -04:00
Theodore Ts'o 0926668d3a e2fsck/pass2.c (check_dir_block): Check for duplicate filenames within
a single directory block (because this is the easy case;
	we don't currently check for duplicates that span
	directory blocks, for now.  Eventually for htree
	directories we can do this by searching for all directory
	blocks that have a hash overflow, and then searching the
	adjacent blocks to find all other potential duplicates.)
2003-03-14 22:19:10 -05:00
Theodore Ts'o b0700a1b60 Change e2fsck to detect and offer to delete or rename duplicate
filenames in directories when rebuilding directories using
"e2fsck -fD /dev/XXX"
2003-03-14 01:43:56 -05:00
Theodore Ts'o ad4fa46604 Avoid counting directory entries during a directory salvage.
Add additional checks to HTREE directories.  We now check the count
and limit fields in the htree header, as well as assuring that the
hash table in each interior node is in ascending order.  We also
check to make sure all leaf nodes are have the expected depth in 
the tree.

Updated test cases to deal with all of the above.
2002-09-30 11:19:19 -04:00
Theodore Ts'o ea1959f015 Fix a bug which caused e2fsck to fail to correctly check filesystems
using a non-zero hash version (i.e., half MD4 or TEA hash).

The hash version wasn't getting copied into dx_dir->hashversion and
this caused the kernel to treat all directories if they were using the 
legacy hash, which was Bad.
2002-08-31 02:32:41 -04:00
Theodore Ts'o 0684a4f33b Overhaul extended attribute handling. Should now be correct with
respect to the latest V2 bestbits ACL code.
2002-08-17 10:19:44 -04:00
Theodore Ts'o 850d05e9aa Add e2fsck -D option which optimizes/compresses directories.
General cleanup of rehash code.  (Fixed a few bugs, reformatted
code to make it more maintainable, etc.)
2002-07-25 00:00:08 -04:00
Theodore Ts'o b7a00563b2 Add support to e2fsck to reindex directories to use hash trees. 2002-07-20 00:28:07 -04:00
Theodore Ts'o 503f9e7f6e Add support for the half-MD4 HTREE hash.
Add HTREE root node tests.
2002-06-26 16:52:10 -04:00
Theodore Ts'o 8fdc9985c1 Add initial support for htree directories. 2002-06-25 23:26:34 -04:00
Theodore Ts'o da307041e7 Check for inodes which are too big (either too many blocks, or
would cause i_size to be too big), and offer to truncate the inode.
Remove old bogus i_size checks.

Add test case which tests e2fsck's handling of large sparse files.
Older e2fsck with the old(er) bogus i_size checks didn't handle
this correctly.
2002-05-21 21:19:14 -04:00
Theodore Ts'o bcf9c5d401 Fix up Andreas' changeset. Avoid use of dynamic automatic arrays,
and check for EXT2_INDEX_FL for special devices, and consider them to
be invalid if they are set.
2002-05-21 09:14:17 -04:00
Andreas Dilger b94a052a25 Add more complete tests for symlinks: nul termination of long links and length
Improve the f_badsymlinks test case for these new tests.
2002-05-18 13:16:30 -06:00
Theodore Ts'o f122632e6b E2fsck now prints ranges in pass 5 when printing deltas in
the block and inode bitmaps.
2002-03-07 02:47:07 -05:00
Theodore Ts'o d37066a9fa Give the opportunity for e2fsck to run the journal even if
recovery flag is cleared.  If we're using a backup
superblock, run the journal by default.
2001-12-21 23:28:54 -05:00
Theodore Ts'o 62e3e7fe4f journal.c (clear_v2_journal_fields, e2fsck_journal_load): If the
V2 fields are set on a V1 journal superblock, or an
	internal V2 journal has s_nr_users is non-zero, clear the
	entire journal superblock beyond the V1 superblock.  This
	fixes botched V1->V2 updates.

problem.c, problem.h (PR_0_CLEAR_V2_JOURNAL): Add new problem code.

f_bad_local_jnl: New test which tests for a V2 journal with bad 
	fields caused by a botched V1->V2 upgrade.
2001-10-07 02:13:30 -04:00
Theodore Ts'o 773fd8a1d4 e2fsck.h, journal.c (e2fsck_move_ext3_journal): Add new function
which will automatically relocate the ext3 journal from a
	visible file to an invisible journal file if the
	filesystem has been opened read/write.

super.c (check_super_block): Add call to e2fsck_move_ext3_journal

problem.c, problem.h (PR_0_MOVE_JOURNAL, PR_0_ERR_MOVE_JOURNAL):
	Add new problem codes.
2001-10-06 21:26:27 -04:00
Theodore Ts'o a474269147 pass1.c, pass2.c, problem.c, problem.h: Fix bug introduced by
Andreas's symlink code; check_blocks() was unconditionally testing
	inode_bad_map without checking to see if it existed first.  Fixed
	problem a different way; we now no longer check inode_bad_map at all,
	since the file might not get deleted in pass 2 anyway.  We move the
	large file feature reconciliation code to to e2fsck_pass2(), and in
	deallocate_inode() in pass2.c, we decrement the large files counter if
	we're about to delete a large file.
2001-08-09 04:14:04 -04:00