Commit Graph

4154 Commits (4718395120454ad7c193c76258ef5359f2ab3f2f)

Author SHA1 Message Date
Filipe Brandenburger a8ffb5c2c4 debian: add make variable to prevent building e2fsck.static package
Setting BUILD_E2FSCK_STATIC=no in rules.custom will prevent the
debian/rules makefile from building a statically-linked e2fsck and
from creating a deb package for it.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-28 13:15:13 -05:00
Theodore Ts'o ba75d9e208 debugfs: add the commands "zap_block" and "block_dump"
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Darren Hart e329f67ba5 libext2fs: fix spelling typo in texinfo docs
Signed-off-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Dilger <adilger@dilger.ca>
2012-12-24 10:49:45 -05:00
Theodore Ts'o 37cdbee0c0 configure.in: require at least autoconf 2.54
AC_PROG_EGREP requires autoconf 2.54, so bump up the AC_PREREQ
accordingly.

Reported-by: g.esp@free.fr
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o 068136c31e libext2fs: link the test programs with static libraries
Force the use of the static libraries when linking the test program so
that "make check" works when the shared libraries have not been
installed, and so that we test against the version of the libraries in
the source tree.

Reported-by: g.esp@free.fr
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o 2168df757a debugfs: add a makefile rule to build debugfs.static
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:45 -05:00
Theodore Ts'o bee7b67ce9 debugfs: add the ability to manipulate the extent tree directly
This commit adds the functionality which had previously only been in
the tst_extents command to debugfs.  The debugfs command extent_open
will open extent tree of a particular inode, and enables a series of
commands which will allow the user to interact with the extent tree
directly.  Once the extent tree is closed via extent_open(), these
additional commands will be disabled again.

This commit exports two new functions from lib/ext2fs/extent.c which
had previously been statically defined: ext2fs_extent_node_split() and
ext2fs_extent_goto2().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-24 10:49:41 -05:00
Theodore Ts'o b4944f654c tests: add test of an incorrect interior node in an extent tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-20 21:48:08 -05:00
Theodore Ts'o 29e8e74e02 e2fsck: make sure the extent tree is consistent after bogus node in the tree
Commit 789bd401c3 ("e2fsck: fix incorrect interior node logical start
values") surfaced a bug where if e2fsck finds and removed an invalid
node in the extent tree, i.e.:

Inode 12 has an invalid extent node (blk 22, lblk 0)
Clear? yes

It was possible for starting logical blocks found in the interior
nodes of the extent tree.  Commit 789bd401c3 added the ability for
e2fsck to discover this problem, which resulted in the test
f_extent_bad_node to fail when the second pass of e2fsck reported the
following complaint:

Interior extent node level 0 of inode 12:
Logical start 0 does not match logical start 3 at next level.  Fix? yes

This patch fixes this by adding a call to ext2fs_extent_fix_parents()
after deleting the bogus node in the extent tree.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-20 18:37:01 -05:00
Theodore Ts'o eacf6a0878 libext2fs: ext2fs_extents_fix_parents() should not modify the handle location
Previously, ext2fs_extent_fix_parents() would only avoid modifying the
cursor location associated with the extent handle the cursor was
pointed at a leaf node in the extent tree.  This is because it saved
the starting logical block number of the current extent, but not the
"level" of the extent (where level 0 is the leaf node, level 1 is the
interior node which points at blocks containing leaf nodes, etc.)

Fix ext2fs_extent_fix_parents() so it is guaranteed to not change the
current extent in the handle even if the current extent is not at the
bottom of the tree.

Also add a fix_extent command to the tst_extents program to make it
easier to test this function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-20 18:27:33 -05:00
Eric Sandeen 789bd401c3 e2fsck: fix incorrect interior node logical start values
An index node's logical start (ei_block) should
match the logical start of the first node (index
or leaf) below it.  If we find a node whose start
does not match its parent, fix all of its parents
accordingly.

If it finds such a problem, we'll see:

Pass 1: Checking inodes, blocks, and sizes
Interior extent node level 0 of inode 274258:
Logical start 3666 does not match logical start 4093 at next level.  Fix<y>?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-20 14:07:56 -05:00
Mikael Pettersson dbe5c43b2e libext2fs: remove m68k-specific bitops code
The current m68k code was buggy for multiple reasons; first the bfset,
et. al commands interpret the bit number as a signed number, not an
unsigned number.  Secondly, there were missing memory clobbers.  Since
there is no real benefit in using explicit asm's at this point (gcc is
smart enough to optimize the generic C code to use the set/clear/test
bit m68k instruction) fix this bug by removing the m68k specific asm
versions of these functions.

Tested on m68k-linux with e2fsprogs-1.42.6 and gcc-4.6.3 as before.
All tests pass and the debug output looks sane.

I compared the e2fsck binaries from the previous build with this
one.  They had identical .text sizes, and almost the same number
of bit field instructions (obviously compiler-generated), so this
change should have no serious performance implications.

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Andreas Schwab <schwab@linux-m68k.org>
2012-12-17 09:46:33 -05:00
Theodore Ts'o 4e0bb5eb74 libext2fs: fix memory and fd leak in error path of unix_open()
Fix a potential memory leak reported by Li Xi.  In addition, there
were possible error cases where the file descriptor would not be
properly closed, so fix those as well while we're at it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by:  Li Xi <pkuelelixi@gmail.com>
2012-12-16 20:14:20 -05:00
Gregoire Pichon 1564150d31 mke2fs: fix handling of mmp_update_interval option
Make sure the s_mmp_update_interval super block field is set
from the file system parameters block which is passed into the
ext2fs_initialize() function.

Addresses-Lustre-Bug: LU-1888

Signed-off-by: Gregoire Pichon <gregoire.pichon@bull.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-12-15 22:36:37 -05:00
Theodore Ts'o c7e293251f e2fsck: fix pass5 optimization for bigalloc file systems
Commit 53e3120c18 introduced a regression which would case e2fsck to
overrun an array boundary for bigalloc file systems, and most likely
crash.  Fix this by correctly using blocks instead of clusters when
incrementing the loop counter in the fast path optimization case.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-15 22:32:23 -05:00
Theodore Ts'o d3de1a714f configure: clarify message regarding checking if we can link with -static
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-15 22:11:31 -05:00
Theodore Ts'o 2658b9616f contrib/fallocate: add support for punch functionality
Also fix the -o option so it works correctly (instead of core
dumping).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-12-06 11:21:44 -05:00
Theodore Ts'o 5e27a274d3 resize2fs: fix gcc -Wall nits and valgrind complaints
One of these fixes was triggering failures when running:

./test_scripts --valgrind r_move_itable r_inline_xattr r_resize_inode

It should be a false positive, but it fixing this makes it easier to
see real problems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-11-29 19:52:39 -05:00
Theodore Ts'o 0f8186598c tune2fs: fix a compile-time bug if quota is not enabled
Commit 44a2cca35e introduced a compile-time failure if --enable-quota
is not passed to the configure script.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-11-29 14:58:29 -05:00
Eric Sandeen 44a2cca35e tune2fs: respect quota config option
If we haven't turned --enable-quota on at config time,
I don't think tune2fs should know about the feature either.

Today we can actually tune2fs -O quota even if not
configured on, and then the rest of the tools will
refuse to touch it:

# tune2fs -O quota /dev/sda1
# tune2fs -O ^quota /dev/whatever complains
tune2fs 1.42.3 (14-May-2012)
tune2fs: Filesystem has unsupported read-only feature(s) while trying to open /dev/sda1
# fsck /dev/sda1
fsck from util-linux 2.21.2
e2fsck 1.42.3 (14-May-2012)
/dev/sda1 has unsupported feature(s): quota
e2fsck: Get a newer version of e2fsck!

Ok, so turn it off?
# tune2fs -O ^quota /dev/whatever complains
tune2fs 1.42.3 (14-May-2012)
tune2fs: Filesystem has unsupported read-only feature(s) while trying to open /dev/sda1

Nope.  Debugfs?  Nope.

# debugfs -w /dev/sda1
debugfs 1.42.3 (14-May-2012)
/dev/sda1: Filesystem has unsupported read-only feature(s) while opening filesystem

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Bert DeKnuydt <Bert.Deknuydt@esat.kuleuven.be>
Addresses-Red-Hat-Bugzilla: #880596
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-11-28 22:52:52 -05:00
Eric Sandeen 7b8912eaab e2fsprogs: fix configure help text for quota
It's --enable-quota, not --enable-libquota.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-11-28 22:51:19 -05:00
Theodore Ts'o 53e3120c18 e2fsck: optimize pass 5 for CPU utilization
Add a fast path optimization in e2fsck's pass 5 for the common case
where the block bitmap is correct.  The optimization works by
extracting each block group's block allocation bitmap into a memory
buffer, and comparing it with the expected allocation bitmap using
memcmp().  If it matches, then we can just update the free block
counts and be on our way, and skip checking each bit individually.

Addresses-Google-Bug: #7534813

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-28 19:01:51 -05:00
Theodore Ts'o b65ccfc7a4 libext2fs: optimize rb_get_bmap_range() for mostly allocated bmaps
This optimizies the CPU utilization of the rb_get_bmap_range()
function when most of the bitmap is allocated.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-28 19:01:51 -05:00
Theodore Ts'o c3f9641eaf libext2fs: optimize rb_get_bmap_range()
This simplifies the rb_get_bmap_range() function and speeds it up for
the case where most of the bitmap is zero.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-28 19:01:51 -05:00
Theodore Ts'o c6b006ea6c libext2fs: add ext2fs_bitcount() function
This function efficiently counts the number of bits in a block of
memory.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-28 19:01:43 -05:00
Theodore Ts'o 2ae49fd0cc e2fsck: optimize pass1 for CPU time
Optimize e2fsck pass 1 by marking entire extents as being in use at a
time, instead of block by block.  This optimization only works for
non-bigalloc file systems for now (it's tricky to handle bigalloc file
systems since this code is also responsible for dealing with blocks
that are not correctly aligned within a cluster).  When the
optimization works, the CPU savings can be significant: ove a full CPU
minute for a mostly full 4T disk.

Addresses-Google-Bug: #7534813

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-27 12:37:49 -05:00
Theodore Ts'o fc8ea52033 libext2fs: optimize rb_set_bmap_range()
This speeds up reading bitmaps from disk for very large (and full)
disks by significant amounts (i.e., up to two CPU minutes for a 4T
file system).

Addresses-Google-Bug: #7534813

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-11-27 12:37:34 -05:00
Andreas Dilger 3e554cc116 ext2fs, blkid: localize environment-specific variables
Restructure the ext2fs_get_device_size() and blkid_get_dev_size()
code to localize the variables used for different device probing
methods.  This at least reduces the #ifdef mess to only one part
of the code for each method, and avoids "unused variable" compiler
warnings added when variables are declared without being #ifdef'd.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-11-26 09:34:20 -05:00
Andreas Dilger ab00fdac7c libext2fs: change mmp.c to LGPL to match other files
Change the license of the mmp.c file to LGPL to match the license
of other files in the libext2fs library.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-11-26 09:32:52 -05:00
Theodore Ts'o e6575ce308 debugfs: fix htree command so that all printf's go through the pager
The "Reading directory block XXX..." message was not being sent
through the pager, which would result in confusing output.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-14 04:54:20 -04:00
Theodore Ts'o dd0c9a3c9c e2fsck: only consult inode_dir_map if needed in pass4
In e2fsck_pass4(), we were consulting inode_dir_map using
ext2fs_test_inode_bitmap2() for every single inode in the file system.
However, there were many cases where we never needed the result of the
test --- most notably if the inode is not in use.

I was a bit surprised that GCC 4.7 with CFLAGS set to "-g -O2" wasn't
able to optimize this out for us, but here is the pass 4 timing for an
empty 3T file system before this patch:

Pass 4: Memory used: 672k/772k (422k/251k), time:  3.67/ 3.66/ 0.00

and afterwards, we see a 43% improvement:

Pass 4: Memory used: 672k/772k (422k/251k), time:  2.09/ 2.08/ 0.00

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-11 07:36:09 -04:00
Theodore Ts'o 51fb43dd27 Fix makefiles to compile e2freefrag with profiling
Also fix a bug caused by a stray continuation backslash which caused
the e2fsck/Makefile to fail when profiling is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2012-10-11 07:35:58 -04:00
Theodore Ts'o fb129bba73 libext2fs: further optimize rb_test_bit
Profiling shows that rb_test_bit() is now calling ext2fs_rb_next() a
lot, and this function is now the hot spot when running e2freefrag.
If we cache the results of ext2fs_rb_next(), we can eliminate those
extra calls, which further speeds up both e2freefrag and e2fsck by
reducing the amount of CPU time spent in userspace.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-11 06:30:35 -04:00
Theodore Ts'o 0bcba36f3f libext2fs: remove pointless indirection in rbtree bitmaps
The code was previously allocating a single 4 or 8 byte pointer for
the rcursor and wcursor fields in the ext2fs_rb_private structure;
this added two extra memory allocations (which could fail), and extra
indirections, for no good reason.  Removing the extra indirection also
makes the code more readable, so it's all upside and no downside.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
2012-10-11 06:30:34 -04:00
Theodore Ts'o 547a59a821 libext2fs: optimize rb_test_bit
Optimize testing for a bit in an rbtree-based bitmap for the case
where the calling application is scanning through the bitmap
sequentially.  Previously, we did this for a set of bits which were
inside an allocated extent, but we did not optimize the case where
there was a large number of bits after an allocated extents which were
not in use.

             1111111111111110000000000000000000
             ^ optimized    ^not optimized

In my tests of a roughly half-filled file system, the run time of
e2freefrag was halved, and the cpu time spent in userspace was during
e2fsck's pass 5 was reduced by a factor of 30%.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
2012-10-11 06:30:16 -04:00
Theodore Ts'o ea2d378862 e2freefrag: use 64-bit rbtree bitmaps
Enable the use of 64-bit bitmaps, so e2freefrag will work on file
systems with the 64-bit feature enabled.  In addition, enable the
rbtree-based bitmaps, which significantly saves the amount of memory
required (from 97 megs to 1.7 megs for an empty 3T file system) at the
cost of additional CPU overhead (but we will claw back some of the
additional CPU overhead in the next commit).

Addresses-Google-Bug: 7269948

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-10-04 23:30:23 -04:00
Theodore Ts'o c498cb11d3 mke2fs: fix progress suppression to make regression tests reliable
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-22 21:26:48 -04:00
Theodore Ts'o 11e5292266 Update Release Notes, Changelogs, version.h, etc. for 1.42.6 release 2012-09-21 12:53:14 -04:00
Theodore Ts'o bbcd91bb0d Fix wordwrap.pl so it is more portable
Needed so that wordwrap.pl works with perl 5.14.2

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-21 12:50:04 -04:00
Theodore Ts'o b2f5ce5516 mke2fs: throttle allocating groups progress as well
Throttle updates for the "Allocating Groups" progress updates to once
a second as well.  We now do this throttling in libext2fs, so we don't
have to do this for each of mke2fs's progress updates, and because the
updates from ext2fs_allocate_tables() come from within libext2fs
anyway.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-21 12:50:04 -04:00
Theodore Ts'o 802f46783c mke2fs.8: use extents vs extent in the man page
We print "extents" for the feature, so we should document "extents" in
the mke2fs's man page, even though we accept both "extent" and
"extents".

Addresses-Sourceforge-Bug: #3559210

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-21 12:50:04 -04:00
Theodore Ts'o a92037f261 debian: adjust build dependencies
Remove dc from the list of dependencies, since it's not used during
the build anymore.

Addresses-Debian-Bug: #677497

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-21 12:49:48 -04:00
Andreas Dilger 12f48b0caa tests: kill debugfs on interrupted MMP test
If the f_mmp test is interrupted during its test run, then it can
leave debugfs busy-looping in the background.  Since f_mmp is a
relatively long-running test, and is likely to be running during
a parallel test run, this can happen fairly often.

Set a signal trap for the f_mmp test script being killed, so that
the background debugfs command will always be killed by the test.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-09-16 22:05:21 -04:00
Theodore Ts'o a3e87bcc32 mke2fs: disable progress reporting in mke2fs.conf for regression tests
Add a configuration knob so the regression tests can disable progress
reporting.  This fixes a potential lack of predictability since the
progress reports are now time based (once a second) which is
problematic for regression tests which are comparing the expected
output of mke2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-16 20:43:07 -04:00
Theodore Ts'o 03237de00a mke2fs: throttle progress updates to once a second
With lazy itable initialization, the progress updates for writing the
inode table happens so quickly that on a serial console, the time to
write the progress updates can be the bottleneck.  Fix this by only
updating the progress indicator once a second.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-14 00:11:07 -04:00
Theodore Ts'o 2d8c0c8a4f resize2fs: grow uninit_bg file systems more efficiently
If the uninit_bg feature is enabled and the kernel supports
lazy_itable_init, skip zeroing the inode table so that the resize
operation can go much more quickly.  Also set the itable_unused fields
so that the first e2fsck after the resize will run faster.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-13 23:09:54 -04:00
Theodore Ts'o 06ca8da745 resize2fs: enforce restrictions if the kernel doesn't do meta_bg resizing
Enhance the online resizing code to be more nuanced about resizing
restrictions.  If the kernel supports meta_bg resizing, then we can
skip all of the restrictions.  If the kernel does not support meta_bg
resizing, check more carefully to make sure there are enough reserved
gdt blocks, so that the user gets a clearer error message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-13 23:09:49 -04:00
Theodore Ts'o a4b738c0bf resize2fs: allow meta_bg/64-bit file systems to be online resized
Resize2fs can't handle resizing flex_bg file systems that do not have
the resize inode, but when the kernel adds support for resizing using
the meta_bg layout, we should allow it be able to resize the file
system.

So move the flex_bg/resize_inode check to the just before we start
doing the off-line resize, instead of doing it earlier where it would
prohibit these file systems for both on-line and off-line resizes.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-13 23:05:32 -04:00
Theodore Ts'o 7f82034438 resize2fs: fix overhead calculation for meta_bg file systems
The file system overhead calculation in calculate_minimum_resize_size
was incorrect meta_bg file systems.  This caused the minimum size to
underflow for very large file systems, which threw resize2fs into a
loop generally lasted longer than the user's patience.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-13 23:05:32 -04:00
Theodore Ts'o ea38e50307 resize2fs: enforce the 16TB limit on 32-bit file systems correctly
The 16TB limit must be enforced regardless of whether the new size is
specified on the command line or implied by the size of the device,
but only if the file system does not support 64-bit block sizes, or
the kernel does not advertise support of meta_bg resizing.

Previously we were unconditionally enforcing it when it was implied by
the device size, but not if the new size was specified on the command
line.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-09-13 23:04:44 -04:00