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>
If multiple blocks of a block group's inode table overlaps with other
file system blocks, only ask once for each block group.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If the filesystem feature FLEX_BG is enabled, the inode table and
bitmap blocks can be located anywhere in the inode table. So for
FLEX_BG filesystems, new_table_block() now tries allocate in the block
group's flex_bg first, and if there is no space in the local flex_bg,
then try to allocate from the whole filesystem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fixed a bug where e2fsck would report that last mount time was in the
future when it was really the last write time that was in the future.
Also, since people can't seem to believe that (a) their distribution
has buggy init scripts, or (b) their CMOS/RTC clock or backup battery
is dead, print the incorrect time and the current system time.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
check_block_bitmap() calculates the block number of superblock in the current
block group but it's not used.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If unused range of the bitmap has an unmarked bit, check_[inode/block]_end()
marks all bits in the range. However, we know that the checked bits are marked.
So this patch fixes loop counter to mark from the unmarked bit.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Remove the continue statement because it calls at the end of the loop.
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want. Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.
(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.
Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.
Addresses-Sourceforge-Patches: #2813809
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536. The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.
We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The new ext2fs_super_and_bgd_loc2() function has some changes aside
from just blk64_t support. Lets make sure that the interfaces are
sane by adding libext2fs support early to get the new API tested here.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck_pass5() checks whether the inode and block allocation bitmaps
are consistent. However, if EXT2_BG_[INODE/BLOCK]_BITMAP is set to a
ext4's block group, most of its bitmap is uninitialized (0). In that
case, we can optimize e2fsck's pass 5 by checking the entire range of
an uninitalized block group instead of checking bit by bit.
This can speed up e2fsck pass 5 by up to 80%:
+-----+--------------------+--------------------+
| | old e2fsck | new e2fsck |
|Pass | time(s) | time(s) |
| | real | user |system| real | user |system|
+-----+------+------+------+------+------+------+
| 1 | 5.70| 3.29| 0.50| 5.66| 3.21| 0.54|
| 2 | 3.33| 0.80| 0.19| 3.40| 0.82| 0.23|
| 3 | 0.01| 0.00| 0.00| 0.01| 0.00| 0.00|
| 4 | 1.04| 1.04| 0.00| 1.05| 1.04| 0.00|
| 5 | 19.60| 17.27| 0.06| 3.53| 1.21| 0.05|
+-----+------+------+------+------+------+------+
|Total| 29.94| 22.57| 0.80| 13.90| 6.47| 0.86|
+-----+------+------+------+------+------+------+
Comparison of e2fsck time on an ext4 500GB partition (20% blocks used)
Machine environment:
CPU: Intel(R) Xeon(TM) CPU 3.00GHz
Memory: 1GB
Kernel: linux-2.6.29-git2
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The e2fsprogs programs have historically just said that they operate
on ext2 and ext3 file system in their man pages. Update them to say
that they also operate on ext4 file systems.
Addresses-Launchpad-bug: #381854
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
In the case where the block group descriptors appear corrupt, e2fsck
will try to use the backup superblock. However, it could be that the
backup superblock itself is completely corrupted, in which e2fsck
should go back to the original superblock instead of refusing to fix
the file system.
Addresses-Debian-Bug: #516820
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Ext3 filesystems don't care if i_file_acl_hi is non-zero in some
inode, and newer kernels should ignore this field (although 2.6.29 and
older kernels will not). So e2fsck should fix this without aborting
an e2fsck preen operation.
Addresses-Debian-Bug: #526524
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The patch below adds a function, ext2fs_extent_open2(), that behaves
as ext2fs_extent_open(), but will use the user-supplied inode
structure when opening an extent instead of reading the inode from
disk. It also changes several of the calls to extent_open() to use
this enhancement.
Signed-off-by: Nic Case <number9652@yahoo.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
in the case of ! defined RESOURCE_TRACK, so that we can clean up #ifdef
throughout e2fsck source.
Signed-off-by: Ken Chen <kenchen@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
On ext2, time tracking for pass1 includes both error detection and
specific type of fs fix-up phase (e.g. block referenced by multiple
inodes). The multi-reference fix-up phase some time take significant
amount of time to complete. We would like to track time spent in sub
component of pass1 by having a finer granularity during pass1b through
pass1d phase.
Signed-off-by: Ken Chen <kenchen@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Use unsigned values for printing memory tracking to avoid overflows.
The mallinfo() data is currently signed ints, but it might change in
the future so we may as well compute/print unsigned longs.
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Restart e2fsck only once in case of multiple inodes in uninit range.
Display correct inode number during BG_INO_UNINIT and INOREF_IN_USED errors.
Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix a regression in e2fsprogs 1.41.5 which would undo updates to the
block group descriptors after a journal replay, caused by commit
b7c5b403. We now use ext2fs_free() instead of ext2fs_close() to make
sure we the library will never try to write out superblock or block
group descriptors.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
One of our customers hit a temporary IO error during an e2fsck run during
the read from the journal. It seems that the read error resulted in
e2fsck automatically discarding the journals and recreating them on several
filesystems on this node without any prompting from the user:
end_request: I/O error, dev sdg, sector 484832
Buffer I/O error on device sdg, logical block 60604
fsck-sdg[8276]: ls2-OST024c: Superblock has an invalid ext3 journal (inode 8).
fsck-sdg[8276]: CLEARED.
fsck-sdg[8276]: *** ext3 journal has been deleted - filesystem is now ext2
only ***
fsck-sdg[8276]: ls2-OST024c was not cleanly unmounted, check forced.
fsck-sdg[8276]: ls2-OST024c: Journal inode is not in use, but contains data.
CLEARED.
fsck-sdg[8276]: ls2-OST024c: Recreate journal to make the filesystem ext3
again?
fsck-sdg[8276]: FIXED.
fsck-sdg[8276]: Creating journal (32768 blocks): Done.
fsck-sdg[8276]:
fsck-sdg[8276]: *** journal has been re-created - filesystem is now ext3 again
***
fsck-sdg[8276]: ls2-OST024c: 39818/20183248 files (8.2% non-contiguous), 222122257/779902976 blocks
fsck-sdg[8276]: exit code 1 (file system errors corrected)
The following patch moves the e2fsck error handler initialization earlier
in the e2fsck startup code before the journal is processed, so that the
user will be prompted for an action. This is the first IO that is not
part of ext2fs_open() where fs->io is first initialized.
It doesn't seem possible to initialize the error handlers for the initial
filesystem open without changing the prototype for ext2fs_open2(). If we
are getting a new ext2fs_open3() prototype for 64-bit it might make sense
to add at least "read_error" as a parameter ("write_error" is not strictly
necessary for the open and could be set afterward).
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
If ext2fs_extent_open() fails due to a corrupt extent header, and the
user declines to clear the inode, check_blocks_extents() should bail
out; otherwise, it will cause a core dump due a null pointer
dereference.
Addresses-Sourceforge-Bug: #2791794
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
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>
If we are checking a mounted filesystem (typically the root
filesystem, mounted read/only) and the NEEDS_RECOVERY flag is not set,
skip all of the checks associated with making sure the journal is
consistent. There is the very slight possibility we could lose if the
NEEDS_RECOVERY flag was somehow cleared even though there was data in
the journal, but this has practically never happend in practice, and
it reduces the number of reads required at boot-time, which is a big
deal when trying to reduce boot times with HDD's.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
E2fsck needs to check to see if the backup superblock differs from the
primary superblock. Previously it was doing so by calling
ext2fs_open(), which does a lot of unnecessary work, including reading
all of the backup block group descriptors. Avoid this by reading in
the backup superblock directly.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Move check_resize_inode() out of check_super_block(), since we only
need to test the resize_inode for correctness only if the filesystem
requires checking. This change avoids a lot of I/O operations which
slows down a 1 second boot.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Fixed a potential bug where by partial returns from the write(2)
system call could lost characters to be sent to external progress bar
display program.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Running e2fsck against a 14.5TB filesystem with -tt it reported
-200904kB for RAM usage in pass3 instead of the correct 2300773kB.
The RAM usage statistics were being printed with %d instead of %u.
Also fix a few places using %ld for inode numbers instead of %lu.
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
When we resize online, the primary superblock gets copied to all
the backups, and of course since we're mounted the NEEDS_RECOVERY
flag is set. A subsequent fsck will find the backups have the
NEEDS_RECOVERY flag set while the primary does not, and this
forces a full fsck pass.
I think this flag can be safely ignored in the flag comparisons.
Addresses-Red-Hat-Bugzilla: #471925
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The coverity scanner found this one.
If a line in modules.dep has a ":" but no "/" then:
if ((cp = strchr(buf, ':')) != NULL)
*cp = 0;
else
continue;
if ((cp = strrchr(buf, '/')) != NULL)
cp++;
/* XXX else cp is still null */
i = strlen(cp);
... we will deref a null pointer (cp). This can be
demonstrated by putting a line like:
foo.ko:
into modules.dep. The below change just says that if no "/" is
found, treat the whole string as the module name.
Addresses-Red-Hat-Bugzilla: #486997
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The other problem codes associated with failing to create the
lost+found directory are non-fatal, and this one should be non-fatal
as well. The two places which call e2fsck_get_lost_and_found()
already deal with a failure to create the directory, so there's no
point making this be a fatal error.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
An deliberately corrupted filesystem with an insanely large
s_first_ino field could cause e2fsck to crash with a seg fault.
Thanks to Eric Sesterhenn for supplying test cases which demonstrated
this issue.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
E2fsck was using a fixed-size 8k buffer for replaying blocks from the
journal. So attempts to replay a journal on filesystems greater than
8k would cause e2fsck to crash with a segfault.
Thanks to Miao Xie <miaox@cn.fujitsu.com> for reporting this problem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
The ext4 filesystem uses journals too, so remove "ext3" from the
problem descriptions involving journals.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
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>
If the directory is packed with no slack space, as soon as any new
directory entries are added, leaf nodes end up getting split and
directory ends up getting very inefficient.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Report whether a fragmented inode is a directory or a file, as this is
highly useful for determining what is going on with an ext4 filesystem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Track the number of non-contiguous files and directories so we can
give more detailed information in verbose mode.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>