Commit Graph

379 Commits (master)

Author SHA1 Message Date
Vitaliy Filippov 6e4fa6e281 Fix ea remapping 2016-09-29 01:51:04 +03:00
Vitaliy Filippov b331d80fba Fix itable_unused adjustment - fixes shrink FS + shrink inode tables and some other cases 2016-09-27 23:53:58 +03:00
Vitaliy Filippov f99c7a2e12 One way to fix non-contiguous inode table allocations... 2016-09-26 00:02:00 +03:00
Vitaliy Filippov b9b963d427 Fix the rest of block bitmap differences 2016-09-26 00:02:00 +03:00
Vitaliy Filippov f58c260dc4 Remap blocks before moving inode tables (fixes big flex_bg extend),
check blocks to move even when shrinking inode tables (fixes big flex_bg shrink),
mark inode tables during allocation (fixes bigalloc shrink)
2016-09-25 23:48:01 +03:00
Vitaliy Filippov 152890aa45 Split inode_scan_and_fix into two parts.
- Basic extend and shrink works
- Extend on bigalloc fs works
- Shrink on bigalloc fs gives errors
- Extend on big flex_bg gives errors
2016-09-25 23:48:01 +03:00
Vitaliy Filippov 63039f4bac Implement inode table resizing (not done yet, should split inode_scan_and_fix()) 2016-09-25 23:47:54 +03:00
Vitaliy Filippov 7e0136332c Add patch_io manager support to resize2fs and e2fsck 2016-09-25 23:47:26 +03:00
Theodore Ts'o 3d6fc97483 resize2fs: fix crash when there is an ea block and no blocks to migrate
This fixes a bug introduced in 1.43 by commit fb47b94fffc: "resize2fs:
rewrite extent/dir/ea block checksums when migrating".  If there is an
extended attribute block and there are no blocks that need to migrate,
we will crash.

The bug was caused by a botched De Morgan's transformation.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-08-10 16:00:17 -04:00
Theodore Ts'o 81f965a04d tune2fs,resize2fs: special case HURD only when testing s_creator_os
The s_creator_os field was a mistake, given how Hurd has been
ab(using) certain file system fields.  We should skip support for
certain advanced features (64-bit support, metadata checksums) for
file systems created on the Hurd OS only, instead of only supporting
them for file systems created on Linux.  This fixes various regression
test failures for FreeBSD.

(The regression tests are probably mostly hopeless for Hurd anyway,
but given the HURD abuse's of various file system fields, the HURD is
going to have to be given second-class treatment in any case, given
what they decided to do with ext2 support, which locks them out of the
more advanced file system features, anyway.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-06-07 11:47:40 -04:00
Theodore Ts'o 97b7a94679 Add clarifications to the e4defrag and resize2fs man pages
Addresses-Debian-Bug: #761144
Addresses-Debian-Bug: #770750

Signed-off-by: Theodore Ts'o <tytso@mit.edu>

by 1 commit.
2016-06-03 23:28:33 -04:00
Theodore Ts'o 62f9bd0e4f e2fsck,resize2fs: fix gcc -Wall nits
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-29 13:36:20 -04:00
Theodore Ts'o fd1677e801 Add --enable-hardening which builds e2fsprogs with security hardening
Enable the following security features: stack protection, fortify,
read-only relocation tables, immediate dynamic symbol binding, and
text segment ASLR by enabling position independent executable
(PIE).

Special handling is provided for shared library and statically linked
executables.  For all the gory details please see:

   https://lists.debian.org/debian-devel/2016/05/msg00302.html

Distributions who want to do their own special thing can set CFLAGS,
CFLAGS_SHLIB, CLFAGS_STLIB, LDFLAGS, LDFLAGS_SHLIB and LDFLAGS_STATIC
as appropriate.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-22 01:58:09 -04:00
Theodore Ts'o aaa1ae0856 resize2fs, libext2fs: fix bugs in sparse_super2 support
Fix resize2fs so that the location of the backup superblocks when the
sparse_super2 feature is enabled is properly set when growing the file
system from a single block group to larger file system sizes.

Also fix a bug where the block group summary statistics in some cases
when exapnding a sparse_super2 file system.

Finally, accurately calculate the file system metadata overhead of the
last block group in sparse_super2 file systems.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-05-10 21:06:15 -04:00
Alex Deymo 205593f65b Android.mk: Replace _host suffix with more standard -host suffix
Most libraries use the "-host" suffix when building for the host. This
patch renames all the libraries to use -host instead of _host.

Addresses-Google-Bug: #24619596
TEST=make dist

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-15 01:25:11 -04:00
Eric Sandeen f3745728bc resize2fs: clear uninit BG if allocating from new group
If resize2fs_get_alloc_block() allocates from a BLOCK_UNINIT group, we
need to make sure that the UNINIT flag is cleared on both file system
structures which are maintained by resize2fs.  This causes the
modified bitmaps to not get written out, which leads to post-resize2fs
e2fsck errors; used blocks in UNINIT groups, not marked in the block
bitmap.  This was seen on r_ext4_small_bg.

This patch uses clear_block_uninit() to clear the flag,
and my problem goes away.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 21:51:23 -05:00
Theodore Ts'o 6d4bb11487 Merge branch 'maint' into next 2016-03-06 21:30:07 -05:00
Andreas Dilger 539d3ae3da misc: replace comparison macros with inline functions
Replace the EXT2FS_RB_EMPTY_ROOT(), EXT2FS_RB_EMPTY_NODE(),
EXT2FS_RB_CLEAR_NODE(), IS_BLOCK_BM(), IS_INODE_BM(), and
IS_INODE_TB() macros with static inline functions to avoid
suprious compiler warnings with clang:

	pass1.c:618:28: warning: equality comparison with extraneous
		parentheses [-Wparentheses-equality]
	if ((*((__u32 *)(entry)) == 0UL)) {
             ~~~~~~~~~~~~~~~~~~~~^~~~~~
	pass1.c:618:28: note: remove extraneous parentheses
		around the comparison to silence this warning
	if ((*((__u32 *)(entry)) == 0UL)) {
				 ^~
	pass1.c:618:28: note: use '=' to turn this equality
		comparison into an assignment
	if ((*((__u32 *)(entry)) == 0UL)) {
				 ^~
				 =

The static inline functions should compile identically, and allow
some extra compile-time checking for the arguments over macros.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2016-03-06 21:23:40 -05:00
Darrick J. Wong 21e37be65b resize2fs: clean up feature test macros with predicate functions
Create separate predicate functions to test/set/clear feature flags,
thereby replacing the wordy old macros.  Furthermore, clean out the
places where we open-coded feature tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-10-24 01:23:30 -04:00
Theodore Ts'o 25f291c9b3 Eliminate unused parameter warnings from Android build
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-13 09:12:23 -04:00
Theodore Ts'o f1644c324b Eliminate doubly defined _LARGEFILE_SOURCE warning
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-07-12 22:54:37 -04:00
Darrick J. Wong b085139224 misc: fix undo file setup
Fix Coverity bugs 1297094-1297101 by fixing all the mutations in the
*_setup_tdb() functions, fixing buffer overflows, and checking
return values.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-16 20:19:52 -04:00
Darrick J. Wong 03f9fd2ad9 resize2fs: optionally create undo file
Provide the user with an option to create an undo file so that they
can roll back a failed resize operation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-05-05 10:41:05 -04:00
Theodore Ts'o 4fb758aa4b Clean up and fix Android build files
Add missing new lib/ext2fs source files that were added for encryption
support.  Also move configuration #define's from individual Android.mk
to the android_config.h file, since we've moved away from specifying
configuration #define's on the command-line upstream.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-03-30 14:50:55 -04:00
Theodore Ts'o 321f3446f3 Add files to build on Android
The Android.mk files were taken from the Android AOSP sources, and
updated for the 1.43 next branch.  The intention is that this will
allow the repository which is currently located in external/e2fsprogs
with one which is based off of the upstream e2fsprogs.  Right now
external/e2fsprogs was not created using "git clone", so it means that
git merges don't work.  After the external/e2fsprogs Android
repository is replaced, with one based off the upstream repository,
Android will be able to synchronize with the upstream repository by
pulling and merging from upstream, and then running the script
"./util/gen-android-files" to update any generated files.  (This is
necessary because in the Android build system, the Android.mk files
are rather stylized and don't make it easy to run arbitrary shell
scripts during the build phase.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2015-03-01 15:45:11 -05:00
Darrick J. Wong f21c30d90c resize2fs: fix regression test to not depend on ext4.ko being loaded
The behavior of the r_fixup_lastbg_big test varies depending on
whether or not ext4.ko is loaded and supports lazy_itable_init.  This
makes checking the bg flags after resize2fs hard to predict, so put in
a way to force resize2fs to zero the inode tables, and compare the
output based on lazy_itable_init == 0.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-01-27 13:10:58 -05:00
Theodore Ts'o 560080272f Merge branch 'maint' into next 2015-01-19 16:37:04 -05:00
Darrick J. Wong c916e5248b Fix clang warning and a resource leak
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2015-01-19 16:31:49 -05:00
Darrick J. Wong fe12931f8f resize2fs: convert fs to and from 64bit mode
resize2fs does its magic by loading a filesystem, duplicating the
in-memory image of that fs, moving relevant blocks out of the way of
whatever new metadata get created, and finally writing everything back
out to disk.  Enabling 64bit mode enlarges the group descriptors,
which makes resize2fs a reasonable vehicle for taking care of the rest
of the bookkeeping requirements, so add to resize2fs the ability to
convert a filesystem to 64bit mode and back.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Cc: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-15 12:45:05 -05:00
Darrick J. Wong 538ef36326 resize2fs: don't play stupid games with the block count
While it may be true that playing games with old_fs' block count
during a grow operation shuts up a bunch of warnings, resize2fs
doesn't actually expand the group descriptor array to match the size
we're artificially stuffing into old_fs, which means that if we
actually need to allocate a block out of the larger fs (i.e. we're in
desperation mode), ext2fs_block_alloc_stats2() scribbles on the heap,
leading to crashes if you're lucky and FS corruption if not.

So, rip that piece out and turn off com_err warnings properly and add
a test case to deal with growing a nearly full filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-14 22:13:09 -05:00
Darrick J. Wong 1862ef7200 resize2fs: set bg flags and unused inode count when resizing
Recalculate the unused inode count and the block/inode uninit flags
when resizing a filesystem.  This can speed up future e2fsck runs
considerably and will reduce mount times.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-14 21:12:37 -05:00
Darrick J. Wong 2273a17ae8 resize2fs: don't interpret bitmap shift while crossing flexbg as raid stride
resize2fs tries to infer the RAID stride by observing differences
between the locations of adjacent block groups' block and inode
bitmaps within the block group.  If the two block groups being
compared belong to different flexbgs, however, it'll be fooled by the
large offset into thinking that the FS has an abnormally large RAID
stride.

Therefore, teach it not to get confused by crossing a flexbg.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reported-by: TR Reardon <thomas_reardon@hotmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-14 21:10:42 -05:00
Darrick J. Wong 8e98899b2f resize2fs: use old_fs to detect per-bg metadata blocks to free
When shrinking a filesystem, resize2fs wants to free per-bg metadata
blocks that are no longer needed.  This behavior is gated on whether
there's a superblock in the group as told by new_fs.  The check really
should be against old_fs, since we're effectively freeing blocks out
of old_fs in the transition to new_fs, but prior to sparse_super2 this
didn't matter since superblocks didn't move, so it didn't matter.

Under sparse_super2, however, there's a superblock in the last group,
so now we need to change the test to use old_fs as it should.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-14 21:09:29 -05:00
Theodore Ts'o 0698ecc1e2 Merge branch 'maint' into next 2014-12-14 20:57:09 -05:00
Eric Sandeen 0462fd6db5 resize2fs: don't require fsck to print min size
My previous change ended up requiring that the filesystem
be fsck'd after the last mount, even if we are only querying
the minimum size.  This is a bit draconian, and it burned
the Fedora installer, which wants to calculate minimum size
for every filesystem in the box at install time, which in turn
requires a full fsck of every filesystem.

Try this one more time, and separate out the tests to make things
a bit more clear.  If we're only printing the min size, don't
require the fsck, as this is a bit less dangerous/critical.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-14 19:12:01 -05:00
Darrick J. Wong fb30384777 resize2fs: quickly rewrite extent blocks when moving an inode w/ metadata_csum
When we're moving an inode on a metadata_csum filesystem, we need to
rewrite the checksum of all interior nodes of the extent tree.  The
current code does this inefficiently via set_bmap, but we can do this
more efficiently through direct iteration of the extent tree.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-13 22:08:18 -05:00
Darrick J. Wong 4495c5a0eb resize2fs: don't exit if shrinking sparse_super2 fs to one bg
If we're shrinking a sparse_super2 filesystem to a single block group,
the superblock will be in block 0.  This is perfectly valid (for block
group 0 with a blocksize > 1024) so don't exit.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-12-13 22:06:15 -05:00
Darrick J. Wong 180f376b04 misc: fix compiler warnings and minor build errors
Fix some gcc-4.8 warnings and other problems that broke the build.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-11-07 21:23:41 -05:00
Darrick J. Wong 08c8e319e3 libext2fs/e2fsck: refactor everyone who writes zero blocks to disk
Convert all call sites that write zero blocks to disk to use
ext2fs_zero_blocks2() since it can use Linux's zero out feature to do
the writes more quickly.  Reclaim the zero buffer at freefs time and
make the write-zeroes fallback use a larger buffer.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-13 04:31:17 -04:00
Theodore Ts'o 6a0f113535 Merge branch 'maint' into next 2014-10-11 19:26:55 -04:00
Theodore Ts'o deae5e809b resize2fs: fix fs->blocksize dereference after fs has been freed
Commit 77255cf369 introduced a use after free bug.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-10-08 12:09:35 -04:00
Theodore Ts'o 330cebc0e9 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/Makefile.in
	lib/ext2fs/Makefile.in
	tests/test_config
2014-09-11 12:40:43 -04:00
Michael Forney 60abcd7394 tests: Add to LD_LIBRARY_PATH instead of overriding
Signed-off-by: Michael Forney <forney@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-08 18:55:42 -04:00
Theodore Ts'o c1c8800b71 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2014-08-25 18:37:37 -04:00
Theodore Ts'o 77255cf369 resize2fs: clarify the size of blocks in resize2fs's messages
Addresses-Debian-Bug: #758029

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-24 23:23:41 -04:00
Theodore Ts'o 061c566eaa resize2fs.8.in: clarify when on-line resizing is supported
Addresses-Debian-Bug: #726760

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-24 22:40:43 -04:00
Theodore Ts'o 68083287ae Merge branch 'maint' into next
Conflicts:
	e2fsck/unix.c
2014-08-10 19:33:31 -04:00
Theodore Ts'o c82815e509 resize2fs: disable the meta_bg feature if necessary
When shrinking a file system, if the number block groups drops below
the point where we started using the meta_bg layout, disable the
meta_bg feature and set s_first_meta_bg to zero.  This is necessary to
avoid creating an invalid/corrupted file system after the shrink.

Addresses-Debian-Bug: #756922

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reported-by: Marcin Wolcendorf <antymat+debian@chelmska.waw.pl>
Tested-by: Marcin Wolcendorf <antymat+debian@chelmska.waw.pl>
2014-08-10 16:21:08 -04:00
Theodore Ts'o 50972e1f7d Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/pass5.c
2014-07-26 09:46:50 -04:00
Theodore Ts'o 1e33a8b408 Fix 32/64-bit overflow when multiplying by blocks/clusters per group
There are a number of places where we need convert groups to blocks or
clusters by multiply the groups by blocks/clusters per group.
Unfortunately, both quantities are 32-bit, but the result needs to be
64-bit, and very often the cast to 64-bit gets lost.

Fix this by adding new macros, EXT2_GROUPS_TO_BLOCKS() and
EXT2_GROUPS_TO_CLUSTERS().

This should fix a bug where resizing a 64bit file system can result in
calculate_minimum_resize_size() looping forever.

Addresses-Launchpad-Bug: #1321958

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 07:40:36 -04:00