Commit Graph

572 Commits (master)

Author SHA1 Message Date
Darrick J. Wong b0295237b9 tests: test recovery from an external journal
Add a couple of tests to verify that writing to and recovering from
an external journal work properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:40 -04:00
Darrick J. Wong cdac96a8e1 tests: test e2fsck recovery with broken commit blocks
Test e2fsck' recovery of commit blocks with (a) only a corrupt
checksum and (b) an obviously incorrect tid.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:40 -04:00
Darrick J. Wong eb266fc5d2 tests: test e2fsck recovery of corrupt revoke blocks
Test e2fsck' ability to deal with (a) revoke blocks with a bad
checksum and (b) revoke blocks with an obviously bad block number.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:40 -04:00
Darrick J. Wong ddde6a059a tests: test how e2fsck recovers from corrupt journal superblocks
Test e2fsck' ability to deal with corrupt journal superblock checksum
and a bad magic.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:40 -04:00
Darrick J. Wong 821fc8ca32 tests: test recovery of 32 and 64-bit journals with the v2 checksum
Add tests to ensure that we know how to recover journals with the
csum_v2 feature set.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:40 -04:00
Darrick J. Wong 490e1f5201 tests: write and replay blocks with the old journal checksum
Test that we can write and replay transactions with the old journal
checksum algorithm.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:39 -04:00
Darrick J. Wong c452914469 tests: test writing and recovering 32bit csum_v3 journals
Simple tests for the 32bit journal transaction creation code when
journal and metadata_csum are enabled.  We test the following:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:39 -04:00
Darrick J. Wong 20466c8045 tests: test writing and recovering 64bit csum_v3 journals
Simple tests for the 64bit journal transaction creation code when
journal and metadata_csum are enabled.   We test writing (bad) block
bitmaps out through the journal and replaying them via fsck, with a
few twists:

(a) All bitmaps are committed (fs errors reported)
(b) All the bitmap blocks are revoked (no errors)
(c) The transaction is never committed (no errors)
(d) Same as (a), but debugfs gets to do the replay.

We also test:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:39 -04:00
Darrick J. Wong 9ce517d43e tests: test writing and recovering checksum-free 32/64bit journals
Simple tests for the journal transaction creation code.   We test
writing (bad) block bitmaps out through the journal and replaying them
via fsck, with a few twists:

(a) All bitmaps are committed (fs errors reported)
(b) All the bitmap blocks are revoked (no errors)
(c) The transaction is never committed (no errors)
(d) Same as (a), but debugfs gets to do the replay.

We also test:

(a) writing and replaying transactions with multiple
    descriptor blocks
(b) same, but with multiple revoke blocks.
(c) adding the 64bit flag to a journal

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 16:52:39 -04:00
Darrick J. Wong 3727a0e745 dumpe2fs: display external journal feature flags
Display the feature flags of an external journal.

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-09-11 12:40:55 -04:00
Darrick J. Wong 811bccef89 tune2fs: explicitly disallow tuning of journal devices
Spit out a more specific error if someone tries to modify an
external journal device.

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-09-11 12:40:55 -04:00
Darrick J. Wong 6aabb75493 e2fsck: detect and repair external journal superblock checksum errors
Verify the (ext4) superblock checksum of an external journal device
and prompt to correct the checksum if nothing else is wrong with the
superblock.

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-09-11 12:40:55 -04:00
Darrick J. Wong 7a8f497356 mke2fs: allow creation of journal device with superblock checksum
Enable mke2fs to create an external journal device with a superblock
checksum.

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-09-11 12:40:55 -04:00
Darrick J. Wong fc06f25a10 libext2fs: write_journal_inode should check iterate return value
When creating a journal inode, check the return value from
block_iterate3() because otherwise we fail to capture errors such as
being unable to allocate an extent tree block, which leads to e2fsck
creating broken journals.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-09-11 12:40:54 -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 d9eab8e2f0 tests/d_inline_dump: remove version dependency in the expected output
Also add the convenience macro $CLEAN_OUTPUT in test_config which can
be used to run the "sed -e $cmd_dir/filter.sed" command to clean up
e2fsprogs command output before comparing with the expected golden
output.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-25 18:04:42 -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
Darrick J. Wong 8a17df7195 libext2fs: create inlinedata symlinks
Add to ext2fs_symlink the ability to create inline data symlinks.

[ Modified by tytso to add more logging to the test script ]

Suggested-by: Pu Hou <houpu.hp@alibaba-inc.com>
Cc: Pu Hou <houpu.hp@alibaba-inc.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-24 12:21:16 -04:00
Theodore Ts'o aef977196a Merge branch 'maint' into next 2014-08-15 19:01:24 -04:00
Theodore Ts'o 6197c10c58 tests: convert use of md5sum to crcsum
The following tests were using md5sum: i_e2image, u_mke2fs, and
u_tune2fs.  Convert them to use crcsum for better portability (not all
environments have md5sum; some might have sha1sum instead :-)

For our purposes crcsum is quite sufficient.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-12 14:37:19 -04:00
Darrick J. Wong ab2cd4a4d2 e2fsck: don't flush the FS unless it's actually dirty
ext2fs_flush2() unconditionally writes the block group descriptors to
disk even if the underlying FS isn't marked dirty.  This causes the
following error message on a fsck -n run:

e2fsck 1.43-WIP (09-Jul-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Error writing block 2 (Attempt to write block to filesystem resulted in short write).  Ignore error? no

Error writing block 2 (Attempt to write block to filesystem resulted in short write).  Ignore error? no

Error writing file system info: Attempt to write block to filesystem resulted in short write

Since ext2fs_close2() only calls flush if the dirty flag is set,
modify e2fsck to exhibit the same behavior so that we don't spit out
write errors for a read only check.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-12 14:19:42 -04:00
Theodore Ts'o 68083287ae Merge branch 'maint' into next
Conflicts:
	e2fsck/unix.c
2014-08-10 19:33:31 -04:00
Darrick J. Wong 19c5d41d5c tests: add regression tests for inlinedata fixes
Add a regression test to ensure that previous patches' fixes to e2fsck
do not revert.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:51:32 -04:00
Darrick J. Wong fa441f91f1 e2fsck: fix conflicting extents|inlinedata inode flags
If we come across an inode with the inline data and extents inode flag
set, try to figure out the correct flag settings from the contents of
i_block and i_size.  If i_blocks looks like an extent tree head, we'll
make it an extent inode; if it's small enough for inline data, set it
to that.  This leaves the weird gray area where there's no extent
tree but it's too big for the inode -- if /could/ be a block map,
change it to that; otherwise, just clear the inode.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:43:24 -04:00
Darrick J. Wong 8dae07fb55 e2fsck: clear extents and inline_data flags from fifo/socket/device inodes
Since fifo, socket, and device inodes cannot have inline data or
extents, strip off these flags if we find them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:41:07 -04:00
Darrick J. Wong 78c666b832 e2fsck: check ea-in-inode regions for overlap
Ensure that the various blobs in the in-inode EA region do not overlap.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:34:43 -04:00
Darrick J. Wong 996999a1a4 libext2fs: don't fail inline data operations if there's no EA
Fix up the rest of the inline data code not to complain if there's no
EA, since it's possible that there's no EA because we're in the
process of creating an inline data file.  Also, don't return an error
code when removing a nonexistent EA, because there's no reason to.

Furthermore, if we write less than 60 bytes of inline data, remove the
EA to avoid wasting space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:31:04 -04:00
Darrick J. Wong d5da89e868 e2fsck: convert 'delete files' warning to a proper fix_problem error
In pass 3, convert the "delete files and re-run e2fsck" message to a
proper error code for more consistent error reporting and to make
translation easier.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:21:15 -04:00
Theodore Ts'o 84d6dd7858 tests: add the r_meta_bg_shrink test
This test checks to make sure resize2fs can properly handle a file
system which started life as a normal ext4 file system and then was
grown to a size where meta_bg was enabled, and then shrunk back below
the point where the meta_bg format is still needed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 18:11:54 -04:00
Theodore Ts'o 755e077181 tests: add f_first_meta_bg_too_big test
The test verifies that e2fsck can properly fix a file system where the
value of s_first_meta_bg in the superblock is larger than the number
of block group descriptors in the file system.  E2fsck will fix this
by clearing the meta_bg feature.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 16:21:31 -04:00
Theodore Ts'o 9974f8c2be tests: make sure MKE2FS_FIRST_META_BG is unset while running tests
If the developer has set the MKE2FS_FIRST_META_BG environment
variable, this can cause test failures.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-10 16:21:31 -04:00
Theodore Ts'o 489ff4a2c7 Merge branch 'maint' into next
Conflicts:
	configure
2014-08-08 17:02:34 -04:00
Theodore Ts'o b1988056fb libext2fs: place metadata blocks in the last flex_bg so they are contiguous
Place the allocation bitmaps and inode table blocks so they are
adjacent, even in the last flexbg.

Previously, after running "mke2fs -t ext4 DEV 286720", the layout of
the last few block groups would look like this:

Group 32: (Blocks 262145-270336) [INODE_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262145 (+0), Inode bitmap at 262161 (+16)
  Inode table at 262177-262432 (+32)
Group 33: (Blocks 270337-278528) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262146 (bg #32 + 1), Inode bitmap at 262162 (bg #32 + 17)
  Inode table at 262433-262688 (bg #32 + 288)
Group 34: (Blocks 278529-286719) [INODE_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262147 (bg #32 + 2), Inode bitmap at 262163 (bg #32 + 18)
  Inode table at 262689-262944 (bg #32 + 544)

Now, they look like this:

Group 32: (Blocks 262145-270336) [INODE_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262145 (+0), Inode bitmap at 262148 (+3)
  Inode table at 262151-262406 (+6)
Group 33: (Blocks 270337-278528) [INODE_UNINIT, BLOCK_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262146 (bg #32 + 1), Inode bitmap at 262149 (bg #32 + 4)
  Inode table at 262407-262662 (bg #32 + 262)
Group 34: (Blocks 278529-286719) [INODE_UNINIT, ITABLE_ZEROED]
  Block bitmap at 262147 (bg #32 + 2), Inode bitmap at 262150 (bg #32 + 5)
  Inode table at 262663-262918 (bg #32 + 518)

This reduces the free space fragmentation in a freshly created file
system.  It also allows the following mke2fs command to succeed:

mke2fs -t ext4 -b 4096 -O ^resize_inode -G $((2**20)) DEV 2130483

(Note that while this allows people to run mke2fs with insanely large
flexbg sizes, this is not a recommended practice, as the kernel may
refuse to resize such a file system while mounted, since it currently
tries to allocate an in-memory data structure based on the size of the
flexbg, and so a file system with a very large flexbg size will cause
the memory allocation to fail.  This will hopefully be fixed in a
future kernel release, but if the goal is to force all of the metadata
blocks to be at the beginning of the file system, it's better to use
the packed_meta_blocks configuration parameter in mke2fs.conf.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-04 18:58:23 -04:00
Darrick J. Wong 1a27630fcf tests: add regression tests for inodes with bad checksums
Add regression tests to e2fsck to examine how it deals with inode
table blocks which (a) have been zero'd; (b) have been one'd; (c) have
corrupt inodes with obvious problems; and (d) have inodes with
non-obvious problems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:51:31 -04:00
Darrick J. Wong f093caf15e tests: add regression tests for group descriptors with bad checksums
Add tests to examine how e2fsck deals with (a) the block bitmap being
corrupt; (b) the inode bitmap being corrupt; (c) the bitmap checksums
being incorrect (but the bitmaps are fine); and (d) the group
descriptor checksum itself is incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:50:52 -04:00
Darrick J. Wong f882feb3bb tests: add regression tests for superblocks with bad checksums
Add regression tests to examine how e2fsck deals with random
superblock corruption such as obviously wrong fields and the checksum
itself being incorrect.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:50:34 -04:00
Darrick J. Wong a8a1ee1255 tests: add regression tests for MMP blocks with bad checksums
Add regression tests to examine how e2fsck deals with MMP blocks with
(a) a bad magic number; and (b) an incorrect checksum.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:49:41 -04:00
Darrick J. Wong 8e203507b3 tests: add tests for directory entry blocks with checksum errors
Add some regression tests to examine how e2fsck handles directory
entry blocks and htree blocks with (a) malformed directory entries;
(b) incorrect checksums; or (c) obviously garbage entries.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:48:58 -04:00
Darrick J. Wong f6204f9d86 tests: add tests for handling of corrupt extents
Add some regression tests to examine how e2fsck deals with (a) extent
blocks with only a bad checksum; (b) extent blocks with a bad magic
number; and (c) extent entries with corruption.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:46:15 -04:00
Darrick J. Wong b46e247776 tests: add regression tests for EA blocks with bad checksums
Add regression tests for e2fsck dealing with (a) EA block with a bad
checksum; (b) EA block with a bad magic number; and (c) EA block with
damage that isn't otherwise noticeable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 23:18:37 -04:00
Darrick J. Wong 6e3c3b7552 e2fsck: always ask to fix an inode that fails checksum verification
If an inode fails checksum verification during pass 1 and the user
doesn't fix or clear the inode as part of the regular inode checks,
ensure that e2fsck remembers to ask the user if he simply wants to
correct the checksum.

We weren't capturing all the ways out of an interation of the inode
scanning loop, which means that not all errors were caught.  Also,
we might as well clear the 'failed csum' flag if we write the inode
directly from the inode scanning loop.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 22:52:29 -04:00
Darrick J. Wong b9f95911e9 libext2fs: don't cache inodes that fail checksum verification
If an inode fails checksum verification, don't stuff a copy of it in
the inode cache, because this can cause the library to fail to return
the "corrupt inode" error code.

In general, this happens if ext2fs_read_inode_full() is called twice
on an inode with an incorrect checksum.  If fs->flags has
EXT2_FLAG_IGNORE_CSUM_ERRORS set during the first call and *unset*
during the second call, the cache hit during the second call fails to
return EXT2_ET_INODE_CSUM_INVALID as you'd expect.  This happens
during fsck because the first read_inode call happens as part of
check_blocks and the second call happens during inode checksum
revalidation.  A file system with a slightly corrupt non-extent inode
will trigger this.

While we're at it, make the inode read function consistent with the
rest of libext2fs -- copy the metadata object into the caller's buffer
even if it fails checksum verification.  This will help e2fsck avoid a
double re-read later on down the line.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 22:49:23 -04:00
Darrick J. Wong 0991896720 e2fsck: use root dir for lost+found when really desperate
If we're totally unable to allocate a lost+found directory, ask the
user if he would like to dump orphaned files in the root directory.
Hopefully this enables the user to delete enough files so that a
subsequent run of e2fsck will make more progress.  Better to cram lost
files in the rootdir than the current behavior, which is to fail at
linking them in, thereby leaving them as lost files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-02 22:18:30 -04:00
Theodore Ts'o 14207cf60e Merge branch 'maint' into next
Conflicts:
	configure
	misc/Makefile.in
2014-08-02 22:05:03 -04:00
Andreas Dilger a1363e6ad2 tests: fix f_badcluster output formatting
The f_badcluster output format depends on how libreadline formats
and outputs the commands read from stdin.  Instead of trying to
handle these differences, use an input command file, which does
not depend on external components to be consistent.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-08-01 21:40:47 -04:00
Theodore Ts'o 8f5e2b6045 Merge branch 'maint' into next 2014-07-28 16:03:55 -04:00
Darrick J. Wong d230dc4a3e tests: add the f_badcluster test
This should have been part of commit 9a1d614df2 ("e2fsck: fix
rule-violating lblk->pblk mappings on bigalloc filesystems") but it
accidentally got dropped when the patch was applied.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-28 15:37:03 -04:00
Darrick J. Wong d3eb1502fd e2fsck: make insert_dirent_tail more robust
Fix the routine that adds dirent checksum structures to the directory
block to handle oddball situations a bit more robustly.

First, when we're walking the entry array, we might encounter an
entry that ends exactly one byte before where the checksum entry needs
to start, i.e. there's space for the tail entry, but it needs to be
reinitialized.  When that happens, we should proceed until d points to
that space so that the tail entry can be initialized.

Second, it's possible that we've been fed a directory block where the
entries end just short of the end of the block.  In this case, we need
to adjust the size of the last entry to point exactly to where the
dirent tail starts.  The current code requires that entries end
exactly on the block boundary, but this is not always the case with
damaged filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-27 19:46:15 -04:00
Darrick J. Wong eb89a6287d e2fsck: write dir blocks after new inode when reconstructing root/lost+found
If we trash the root directory block, e2fsck will find inode 11 (the
old lost+found) and try to attach it to l+f.  The lost+found checker
also fails to find l+f and tries to add one to the root dir.  The root
dir is not found but is recreated with incorrect checksums, so linking
in the l+f dir fails and the l+f '..' entry isn't set.  Since both
dirs now fail checksum verification, they're both referred to rehash
to have that fixed, but because l+f doesn't have a '..' entry, rehash
crashes because l+f has < 2 entries.

On a checksumming filesystem, the routines in e2fsck that recreate
/lost+found and / must write the new directory block *after* the inode
has been written to disk because the checksum depends on i_generation.
Add a regression test while we're at it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 17:14:40 -04:00
Theodore Ts'o 22302aa320 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
	e2fsck/pass1.c
2014-07-26 15:57:42 -04:00
Darrick J. Wong b729b7dfab e2fsck: reserve blocks for root/lost+found directory repair
If we think we're going to need to repair either the root directory or
the lost+found directory, reserve a block at the end of pass 1 to
reduce the likelihood of an e2fsck abort while reconstructing
root/lost+found during pass 3.

If / and/or /lost+found are corrupt and duplicate processing in pass
1b allocates all the free blocks in the FS, fsck aborts with an
unusable FS since pass 3 can't recreate / or /lost+found.  If either
of those directories are missing, an admin can't easily mount the FS
and access the directory tree to move files off the injured FS and
free up space; this in turn prevents subsequent runs of e2fsck from
being able to continue repairs of the FS.

(One could migrate files manually with debugfs without the help of
path names, but it seems easier if users can simply mount the FS and
use regular FS management tools.)

[ Fixed up an obvious C trap: const char * and const char [] are not
  the same thing when you are taking the size of the parameter.
  People, run your regression tests!  Like spinach, it's good for you.  :-)
  -- tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 15:45:42 -04:00
Darrick J. Wong 97c607b1a2 libext2fs: provide a function to set inode size
Provide an API to set i_size in an inode and take care of all required
feature flag modifications.  Refactor the code to use this new
function.

[ Moved the function to lib/ext2fs/blk_num.c, which is the rest of
  these sorts of functions live, and renamed it to be
  ext2fs_inode_size_set() instead of ext2fs_inode_set_size() to be
  consistent with the other functions in in blk_num.c -- tytso ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 14:34:56 -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 a30a4e93f3 libext2fs: fix free block accounting for 64-bit file systems
We rely on a nasty hack to adjust the free block count where we pass
signed value into ext2fs_free_blocks_count_add(), which takes an
64-bit unsigned value, and relies on overflow and C's signed->unsigned
semantics to do the subtraction.  This works, so long as a 64-bit
signed value is used.

Unfortunately, ext2fs_block_alloc_stats2() and
ext2fs_block_alloc_stats_range(), this is not true, so on a 64-bit
file system, the free blocks accounting can get screwed up.

A simple way to demonstrate the problem is:

mke2fs -F -t ext4 -O 64bit /tmp/foo.img 1M
e2fsck -fy /tmp/foo.img

... which will result in the following e2fsck complaint:

Pass 5: Checking group summary information
Free blocks count wrong (4294968278, counted=982).
Fix? yes

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 09:25:40 -04:00
Theodore Ts'o 188949d7ce tests: use e2fsck -f instead of -p for resize tests
Using e2sck -f provides better debugging information if things go
wrong.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-26 00:48:29 -04:00
Darrick J. Wong cd32129d89 mke2fs: set error behavior at initialization time
Port tune2fs' -e flag to mke2fs so that we can set error behavior at
format time, and introduce the equivalent errors= setting into
mke2fs.conf.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:58:29 -04:00
Theodore Ts'o e05a05630a Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
	e2fsck/problem.h
2014-07-25 08:58:10 -04:00
Darrick J. Wong 57b7fabc2e e2fsck: clear uninit flag on directory extents
Directories can't have uninitialized extents, so offer to clear the
uninit flag when we find this situation.  The actual directory blocks
will be checked in pass 2 and 3 regardless of the uninit flag.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:50:23 -04:00
Darrick J. Wong c28c2741ba e2fsck: pass2 should not process directory blocks that are impossibly large
Currently, directories cannot be fallocated, which means that the only
way they get bigger is for the kernel to append blocks one by one.
Therefore, if we encounter a logical block offset that is too big, we
needn't bother adding it to the dblist for pass2 processing, because
it's unlikely to contain a valid directory block.  The code that
handles extent based directories also does not add toobig blocks to
the dblist.

Note that we can easily cause e2fsck to fail with ENOMEM if we start
feeding it really large logical block offsets, as the dblist
implementation will try to realloc() an array big enough to hold it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:41:11 -04:00
Darrick J. Wong 0733835bf7 e2fsck: always submit logical block 0 of a directory for pass 2
Always iterate logical block 0 in a directory, even if no physical
block has been allocated.  Pass 2 will notice the lack of mapping and
offer to allocate a new directory block; this enables us to link the
directory into lost+found.

Previously, if there were no logical blocks mapped, we would fail to
pick up even block 0 of the directory for processing in pass 2.  This
meant that e2fsck never allocated a block 0 and therefore wouldn't fix
the missing . and .. entries for the directory; subsequent e2fsck runs
would complain about (yet never fix) the problem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:39:45 -04:00
Theodore Ts'o 60203cb171 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2014-07-25 08:38:39 -04:00
Darrick J. Wong 9f005a90f8 e2fsck: collapse holes in extent-based directories
If we notice a hole in the block map of an extent-based directory,
offer to collapse the hole by decreasing the logical block # of the
extent.  This saves us from pass 3's inefficient strategy, which fills
the holes by mapping in a lot of empty directory blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 08:30:11 -04:00
Darrick J. Wong 203e13cf9c libext2fs: fix bounds check of the bitmap test range in get_free_blocks2
In the loop in ext2fs_get_free_blocks2, we ask the bitmap if there's a
range of free blocks starting at "b" and ending at "b + num - 1".
That quantity is the number of the last block in the range.  Since
ext2fs_blocks_count() returns the number of blocks and not the number
of the last block in the filesystem, the check is incorrect.

Put in a shortcut to exit the loop if finish > start, because in that
case it's obvious that we don't need to reset to the beginning of the
FS to continue the search for blocks.  This is needed to terminate the
loop because the broken test meant that b could get large enough to
equal finish, which would end the while loop.

The attached testcase shows that with the off by one error, it is
possible to throw e2fsck into an infinite loop while it tries to
find space for the inode table even though there's no space for one.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-25 07:11:57 -04:00
Darrick J. Wong 35c8faaffc e2fsck: don't clobber critical metadata during check_blocks
If we encounter an inode with IND/DIND/TIND blocks or internal extent
tree blocks that point into critical FS metadata such as the
superblock, the group descriptors, the bitmaps, or the inode table,
it's quite possible that the validation code for those blocks is not
going to like what it finds, and it'll ask to try to fix the block.
Unfortunately, this happens before duplicate block processing (pass
1b), which means that we can end up doing stupid things like writing
extent blocks into the inode table, which multiplies e2fsck'
destructive effect and can render a filesystem unfixable.

To solve this, create a bitmap of all the critical FS metadata.  If
before pass1b runs (basically check_blocks) we find a metadata block
that points into these critical regions, continue processing that
block, but avoid making any modifications, because we could be
misinterpreting inodes as block maps.  Pass 1b will find the
multiply-owned blocks and fix that situation, which means that we can
then restart e2fsck from the beginning and actually fix whatever
problems we find.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-23 12:11:23 -04:00
Darrick J. Wong 7ba5cc744b debugfs: fix printing of inline data during symlink inode dump
When we're dumping a fast symlink inode, we print some odd things to
stdout.  To clean this up, first don't print inline data EA, since the
inode dump doesn't display file and directory contents.  Then, teach
the inode dump function how to print out either an inline data fast
symlink or a non-inline data fast symlink.

(This is a follow-up to the earlier patch "debugfs: Only print the
first 60 bytes from i_block on a fast symlink")

[ Modified by tytso so that the d_inline_dump test works when build
  directory is different from the source directory --- i.e., when
  doing a VPATH build. ]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-22 18:44:33 -04:00
Theodore Ts'o 7f7d1cb462 Merge branch 'maint' into next
Conflicts:
	debugfs/set_fields.c
	tests/f_mmp/script
	tests/f_mmp_garbage/script
	tests/m_mmp/script
	tests/t_mmp_1on/script
	tests/t_mmp_2off/script
2014-07-06 00:09:27 -04:00
Theodore Ts'o bdeb2dba29 tests: avoid using mktemp -t
The -t option is documented as deprecated in GNU's mktemp, and
FreeBSD's mktemp doesn't support it at all.

Replace it with the construct "mktemp ${TMPDIR:-/tmp}/foo.XXXXXX"

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:49 -04:00
Theodore Ts'o 0b5610e0fa tests: clean up the temp file if test_one is interrupted
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:49 -04:00
Theodore Ts'o 358c94ab33 tests: fix left-over e2fsprogs-tmp files not getting clean up
In addition, incorporate the test name into the e2fsprogs-tmp to make
it easier to debug left-over temp files in the future.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:49 -04:00
Benno Schulenberg 9e9e7b4a02 tests: for mktemp the exes must be the final characters of the name
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-07-04 16:39:49 -04:00
Benno Schulenberg 1301def84c e2fsck: make a prompt message simpler and thus translatable
It can be made simpler because there is no need to differentiate between
having an internal journal inode and having an external journal device.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-06-03 22:04:28 -04:00
Theodore Ts'o 6bb8845953 Merge branch 'maint' into next
Conflicts:
	debugfs/debugfs.c
2014-05-27 12:38:23 -04:00
Eric Sandeen 2eb0ed09d9 e2fsprogs: don't run quota test if quota is not enabled
The default configuration still has quota disabled, but
runs the f_quota test unconditionally, so we fail by
default.

Fix that...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-27 12:12:05 -04:00
Andreas Dilger 90c5b4c9de debugfs: fix string_to_time for MacOS strptime()
The strptime() function does not update fields in struct tm that are
not specified in the input format.  The glibc implementation sets the
tm_yday field (%j) when any of the year (%Y), month (%m), or day (%d)
fields are changed, but the MacOS strptime() does not set tm_yday in
this case.  This caused string_to_time() to calculate the wrong Unix
epoch on MacOS. If tm_yday is unset, compute it in string_to_time().

This also fixes test regression failures for FreeBSD.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-22 17:52:23 -04:00
Theodore Ts'o ba08cb996a Merge branch 'maint' into next
Conflicts:
	debugfs/Makefile.in
	debugfs/debug_cmds.ct
	debugfs/debugfs.c
	debugfs/debugfs.h
	e2fsck/Makefile.in
	misc/Makefile.in
	misc/mke2fs.c
2014-05-13 11:01:07 -04:00
Theodore Ts'o 1c358e6e12 quota: remove mke2fs's and tune2fs's warning messages regarding quota
We no longer need to reference https://ext4.wiki.kernel.org/index.php/Quota
since we've fixed the nasty bugs associated with e2fsck and the quota
feature.  The wiki page will be updated once we've done a release that
includes these fixes indicated the verison which these problems have
been fixed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
2014-05-13 10:13:33 -04:00
Theodore Ts'o 133d9fbff3 tests: add basic e2fsck regression test for fixing the quota inode
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
2014-05-13 10:13:26 -04:00
Darrick J. Wong a1ff15f83b debugfs: teach logdump to deal with 64bit revoke tables
The logdump command doesn't know how to deal with revoke tables in
64bit journals, so teach it to do this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 21:04:17 -04:00
Darrick J. Wong a46300fe70 misc: create better-packaged static analysis reports
Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-05-11 18:32:07 -04:00
Theodore Ts'o c9bc7484cc Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2014-05-11 18:30:11 -04:00
Theodore Ts'o 45a78b88db resize2fs: refine minimum required blocks for flex_bg file systems
The previous commit exposed bugs in the calculation for flex_bg file
systems.  The problem is that since (by default) we keep the metadata
blocks for the flex_bg in the first block group of the flex_bg, and
because we don't want to overwrite metadata blocks used by the
original file system with data blocks make life easier in case the
resize is aborted for some reason, we need to treat all of the
metadata blocks in the existing flex_bg has in use for the purposes of
calculate_minimum_resize_size().

Even though this means we need to reserve more data blocks to avoid
running out of space, the net result of these two commits is a net
savings in how much we can shrink a file system.

Using the following test sequence:

	mke2fs -F -t ext4 /tmp/foo.img 2T
	resize2fs -M /tmp/foo.img
	resize2fs -M /tmp/foo.img
	resize2fs -M /tmp/foo.img

Here is the comparison in the resulting file systems between the old
and new resize2fs (units are in 4k blocks):

                resize #1  resize #2   resize #3
old resize2fs    1117186     45679       43536
new resize2fs      48784     37413       37392

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 23:15:49 -04:00
Theodore Ts'o 6d82e1f4c7 mke2fs: only print the low-level file system stats in verbose mode
Also print the file system UUID if it is non-NULL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-05-04 23:15:29 -04:00
Theodore Ts'o 71715a5a9a Merge branch 'maint' into next 2014-04-20 08:31:24 -04:00
Andreas Dilger 5bb66e37d6 tests: fix resize test tmpfs max-file-size checking
Old distros may not have the "truncate" tool, so use "dd" instead.

If tmpfs cannot handle a 2GB temp file (e.g. old RHEL5 and SLES 11
kernels) then skip the test instead of failing it.  If this fails,
try to report better error messages instead of failing silently.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-04-14 13:51:24 -04:00
Darrick J. Wong 28b966d7c6 e2fsck: print runs of duplicate blocks instead of all of them
When pass1 finds blocks that are mapped to multiple files, it will
print every duplicated block.  If there are long sequences of
duplicate blocks (e.g. the e_pblk field is wrong in an extent), this
can cause a gigantic flood of output when a range could convey the
same information.  Therefore, teach pass1b to print ranges when
possible.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-15 12:12:37 -04:00
Darrick J. Wong f1605243a4 all: Introduce cppcheck static checking for make C=1
Introduce more static checking via cppcheck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-14 09:32:50 -04:00
Darrick J. Wong 227239b10b debugfs: create commands to edit extended attributes
Enhance debugfs to be able to display and modify extended attributes, and
create some simple tests for the extended attribute editing functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-11 23:50:08 -04:00
Zheng Liu 356b448701 tests: change result in f_bad_disconnected_inode
In this test, inode flag is some random data, and after we apply inline
data patch set we should need to handle it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-03-04 08:46:15 -05:00
Darrick J. Wong 5beff1c0cf debugfs: dump all extended attributes
Use the new extended attribute APIs to display all extended attributes
(current code does not look in the EA block) and display full names
(current code ignores name index too).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-23 23:08:48 -05:00
Theodore Ts'o 3ba59bf649 Merge branch 'maint' into next 2014-02-23 23:07:38 -05:00
Theodore Ts'o fedfb27fe5 Add coverage testing using gcov
To check the coverage of e2fsprogs's regression test, do the
following:

	configure --enable-gcov
	make -j8 ; make -j8 check ; make coverage.txt

The coverage information will be the coverage.txt and *.gcov files in
the build directories.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-23 00:17:09 -05:00
Theodore Ts'o dc084ab7b1 Merge branch 'maint' into next 2014-02-20 21:39:29 -05:00
Andreas Dilger 3b97799c74 tests: skip unsupported tests on MacOS systems
The "mkswap" program is not available on MacOS, so just use the
existing swap0.img.bz2 and swap1.img.bz2 files directly.

Because MacOS HFS+ doesn't support sparse files (welcome to the 80's)
the m_bigjournal test takes forever to zero out the whole 42GB test
filesystem.  Skip this test for Darwin kernels for now.

Unfortunately, neither "df -T" nor "stat -f -c %T" is available on
MacOS to directly determine the filesystem type, and I'm too lazy
to parse the output of "mount" and match it to the path of the test
directory in shell, so it just checks the kernel type and assumes
the filesystem type is HFS and skips the test.

Since this test runs on Linux the majority of the time, the loss of
test coverage is minimal.  If MacOS should ever get a real filesystem,
this can be revisited.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-02-18 18:30:00 -05:00
Theodore Ts'o f0996c12d5 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/alloc.c
	misc/mke2fs.c
2014-01-30 19:05:16 -05:00
Darrick J. Wong 454e6e0c74 tests: adjust test output to reflect block_uninit calculated block bitmaps
Now that libext2fs marks group metadata in the fs block bitmap, adjust
the expected test output to reflect expanded use of block_uninit and
the fact debugfs no longer prints block bitmap data that fails to
account for group data blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2014-01-11 14:15:52 -05:00
Theodore Ts'o bc82f39437 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
	lib/ext2fs/csum.c
2014-01-09 12:25:37 -05:00
Theodore Ts'o 5a1d25a7b2 Fix up workarounds for dietlibc breakage
The dietlibc doesn't support the TZ environment variable, which is
required by the standard.  Work around this so that we can run the
regression test suite when building with dietlibc.  (This is useful
for finding problems.)

With this change, the only thing which doesn't work as far as dietlibc
is concerned is the posix_memalign test, and the MMP support tests
(because posix_memalign isn't provided by dietlibc, sigh.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-09 12:22:03 -05:00
Theodore Ts'o d2dce124dd Merge branch 'maint' into next
Conflicts:
	debian/changelog
	e2fsck/Makefile.in
2014-01-06 06:58:58 -05:00
Theodore Ts'o 6c59a665da configure: fix --with-diet-libc
Newer versions of autoconf pull in AC_PROG_GCC as part of
AC_CANONICAL_HOST.  So we need check for WITH_DIET_LIBC earlier in
configure.in.

Also, e2fsprogs now needs functions which are found in diet libc's
compat library.  So add support for autoconf's LIBS function, and
automatically set libs to include -lcompat.

Finally, disable compiling e4defrag by deault if --with-diet-libc is
specified because the program has too many glibc dependencies.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-05 22:58:16 -05:00
Theodore Ts'o c32409aec6 e2fsck: improve the "superblock corrupt" message
Previously, this message used 8193 as the example alternate
superblock.  But for most file systems, the backup superblock is
located at 32768 (since most file systems have a block size of 4k, and
not 1k).

Addresses-Debian-Bug: #719185

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2014-01-04 19:11:30 -05:00
Theodore Ts'o 9c846766fd Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	debian/changelog
	version.h
2013-12-28 23:27:39 -05:00
Theodore Ts'o 9f90b2e632 tests: fix stray newline printed when running r_min_itable
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:37:09 -05:00
Theodore Ts'o 2ffccc82c4 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/csum.c
2013-12-26 00:30:56 -05:00
Phillip Susi 22b83f6280 e2image: perform in-place move
If given at least one offset and only one file, assume source
and dest are the same, and do an in place move.

Signed-off-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-26 00:20:40 -05:00
Theodore Ts'o aafd361550 tests: use the in-tree binaries in the test f_extent_oobounds
Fix the f_extent_oobounds test so that it uses binaries built in the
tree, instead of the binaries in the system PATH (which might not
exist in a chroot environment) when creating the test image.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:23 -05:00
Andreas Dilger 2bc3041754 debugfs, e2fsck: fix s_desc_size handling
The s_desc_size in the superblock specifies the group descriptor
size in bytes, but in various places the EXT4_FEATURE_INCOMPAT_64BIT
flag implies that the descriptor size is EXT2_MIN_DESC_SIZE_64BIT
(64 bytes) instead of checking the actual size.  In other places,
the s_desc_size field is used without checking for INCOMPAT_64BIT.

In the case of ext2fs_group_desc() the s_desc_size was being ignored,
and assumed to be sizeof(struct ext4_group_desc), which would result
in garbage for any but the first group descriptor.  Similarly, in
ext2fs_group_desc_csum() and print_csum() they assumed that the
maximum group descriptor size was sizeof(struct ext4_group_desc).
Fix these functions to use the actual superblock s_desc_size if
INCOMPAT_64BIT.

Conversely, in ext2fs_swap_group_desc2() s_desc_size was used
without checking for INCOMPAT_64BIT being set.

The e2fsprogs behaviour is different than that of the kernel,
which always checks INCOMPAT_64BIT, and only uses s_desc_size to
determine the offset of group descriptors and what range of bytes
to checksum.

Allow specifying the s_desc_size field at mke2fs time with the
"-E desc_size=NNN" option.  Allow a power-of-two s_desc_size
value up to s_blocksize if INCOMPAT_64BIT is specified.  This
is not expected to be used by regular users at this time, so it
is not currently documented in the mke2fs usage or man page.

Add m_desc_size_128, f_desc_size_128, and f_desc_bad test cases to
verify mke2fs and e2fsck handling of larger group descriptor sizes.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-24 22:50:19 -05:00
Andreas Dilger fd5e00e1d0 tests: delete temporary resize test files
Since commit 5ad07acad if $TMP cannot hold large test filesystems
for resize testing the resize_test creates temporary test files
in the local working directory.  Since it overrides TMPFILE locally
the calling program does not delete the generated file correctly.

Delete the large $TMPFILE within resize_test if it passes, but leave
it for debugging if the test failed.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-12-23 16:01:56 -05:00
Theodore Ts'o 2fae17697a Merge branch 'maint' into next
Conflicts:
	e2fsck/pass2.c
	e2fsck/pass3.c
2013-12-03 00:24:39 -05:00
Andreas Dilger 5ad07acadc tests: check backing filesystem can handle large file
The new resize tests create 2TB test files, but tmpfs in kernels
before 3.1 have a max file size of 256GB.  Ext3 may also have
a size limit for smaller blocksize filesystems.

Fix the resize_test script to verify that $TMPFILE can be resized
to the final test size, and if that fails try creating the file on
the local filesystem instead of in $TMPDIR.  If that cannot hold
the large filesystem, skip the test.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Tested-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-12-03 00:11:55 -05:00
Theodore Ts'o 1586850bcd Merge branch 'maint' into next 2013-10-14 09:57:23 -04:00
Niu Yawei 43075b42bd quota: fix disabling quota, add quota tests
Update all superblock copies when disabling the quota feature.

Added basic tests for the quota feature.

Signed-off-by: Niu Yawei <niu@whamcloud.com>
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-14 09:54:28 -04:00
Theodore Ts'o e7619b71c0 tests: add new test t_uninit_bg_rm
This test checks tune2fs's support for removing the uninit_bg feature
flag.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-12 23:08:02 -04:00
Theodore Ts'o e337e7fad8 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/rehash.c
	e2fsck/super.c
2013-10-12 22:26:28 -04:00
Theodore Ts'o 128c943ef2 tests: remove version number dependency in r_min_itable
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-12 22:25:29 -04:00
Darrick J. Wong 832cb612f8 e2fsprogs: add (optional) sparse checking to the build
Run sparse against source files when building e2fsprogs with 'make C=1'.  If
instead C=2, it configures basic ext2 types for bitwise checking with sparse,
which can help find the (many many) spots where conversion errors are
(possibly) happening.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-10-11 23:12:40 -04:00
Theodore Ts'o 7447da02f0 tests: add test for resize2fs -M with inode table in middle of block group
Eric Sandeen reported that Fedora's mke2fs when compiled for ppc was
creating a file system which caused problems with resize2fs -M.
Closer examination showed that the problem was file system which
looked like this:

Filesystem features:      ext_attr dir_index filetype sparse_super
Inode count:              512
Block count:              1247
   ...

Group 0: (Blocks 1-1024)
  Primary superblock at 1, Group descriptors at 2-2
  Block bitmap at 66 (+65), Inode bitmap at 67 (+66)
  Inode table at 68-99 (+67)

Group 1: (Blocks 1025-1246)
  Backup superblock at 1025, Group descriptors at 1026-1026
  Block bitmap at 1090 (+65), Inode bitmap at 1091 (+66)
  Inode table at 1092-1123 (+67)

It's not obvious to me why Fedora's ppc mke2fs is creating file
systems like this (I can't reproduce this on debian ppc systems), but
resize2fs -M should be able to deal with such file systems, which is
what this test is designed to check.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-09-30 23:07:27 -04:00
Eric Whitney d45170717a tests: add another test for uninit extents past eof
Commit d3f32c2db8 was intended to detect extents found outside their
proper location in the extent tree, including invalid extents at the
end of an extent block.  However, it incorrectly reported legal
uninitialized extents created by fallocate() at the end of file with
the FALLOC_FL_KEEP_SIZE flag as false positives.  xfstests
generic/263 (among others) caught this problem, while the e2fsprogs
test f_uninit_ext_past_eof did not.  The latter test failed to
detect the problem in part because it uses a test file whose i_size
is 0.

Add a test derived from the fsx-based test case in xfstests
generic/263 consisting of a file with non-zero length, more than
four extents total, and two uninitialized extents past EOF to
reliably reproduce commit d3f32c2db8's false positive behavior.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-09-26 20:17:09 -04:00
Theodore Ts'o fc9f162eea Merge branch 'maint' into next 2013-09-09 20:49:49 -04:00
Theodore Ts'o c8ec2bad18 e2fsck: correctly deallocate invalid extent-mapped symlinks
The function deallocate_inode() in e2fsck/pass2.c was buggy in that it
would clear out the inode's mode and flags fields before trying to
deallocate any blocks which might belong to the inode.

The good news is that deallocate_inode() is mostly used to free inodes
which do not have blocks: device inodes, FIFO's, Unix-domain sockets.

The bad news is that if deallocate_inode() tried to free an invalid
extent-mapped inode, it would try to interpret the root of the extent
node as block numbers, and would therefore mark various file system
metadata blocks (the superblock, block group descriptors, the root
directory, etc.) as free and available for allocation.  This was
unfortunate.

(Try running an older e2fsck against the test file system image in the
new test f_invalid_extent_symlink, and then run e2fsck a second time
on the fs image, and weep.)

Fortunately, this kind of file system image corruption appears to be
fairly rare in actual practice, since it would require a very unlucky
set of bits to be flipped, or a buggy file system implementation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-07-28 22:03:01 -04:00
Theodore Ts'o dd50ef8743 e2fsck: check extent-mapped directories with really large logical blocks
E2fsck was missing a check for directories with logical blocks so
large that i_size > 2GB.  Without this check the test image found in
the new test f_toobig_extent_dir will cause e2fsck to die with a
memory allocation failure:

Error storing directory block information (inode=12, block=0, num=475218819): Memory allocation failed
e2fsck: aborted

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Andrey Melnikov <temnota.am@gmail.com>
2013-07-28 21:03:00 -04:00
Theodore Ts'o 38cc555a5f Merge branch 'maint' into next 2013-07-08 12:14:45 -04:00
Theodore Ts'o 42b61c50e5 libext2fs, tests: allow /etc/mtab file to be missing
The environment variable EXT2FS_NO_MTAB_OK will suppress the error
code EXT2_NO_MTAB_FILE when the /etc/mtab file can not be found.  This
allows the e2fsprogs regression test suite to be run in chroots which
might not have an /etc/mtab file.

By default will still want to complain if the /etc/mtab file is
missing, since we really don't want to discourage distributions and
purveyors of embedded systems from running without an /etc/mtab file.
But if it's missing it only results in a missing sanity check that
might cause file system corruption if the file system is mounted when
programs such as e2fsck, tune2fs, or resize2fs is running, so there is
no potential security problems that might result if this environment
variable is set inappropriately.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-07-08 12:08:44 -04:00
Theodore Ts'o 8b9eb12807 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	e2fsck/Makefile.in
	lib/config.h.in
	version.h
2013-06-16 18:54:01 -04:00
Andreas Dilger dc9cc7006a mke2fs: don't set root dir UID/GID automatically
Don't change the root directory's UID/GID automatically just because
mke2fs was run as a non-root user.  This can be confusing for users,
and is not flexible for non-root installation tools that need to
create a filesystem with different ownership from the current user.

Add the "-E root_owner[=uid:gid]" option to mke2fs so that the user
and group can be explicitly specified for the root directory.  If
the "=uid:gid" argument is not specified, the current UID and GID
are extracted from the running process, as was done in the past.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-15 21:51:33 -04:00
Andreas Dilger 2a83b3c374 mke2fs: sort option parsing, deprecate "-R"
A minor cleanup to order the command-line option parsing in
alphabetical order, except for "-E" and "-R", which need to
be co-located.

Print a message that the "-R" option is deprecated.  It has
been deprecated since 2005 (commit c6a44136b9).

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-15 18:47:30 -04:00
Andreas Dilger f9fd342e56 tests: clean up sed filtering of test output
The sed filters for test outputs that are used to remove build and
test specific information (such as version strings, dates, times,
UUIDs) were unconditionally deleting the first line of output.  This
would normally contain the tool version string, but in some cases
contained other information that was being lost.  This can lead to
difficulty debugging test failures.

The sed filtering has been changed to only remove the actual version
strings.  As well, similar filter strings were duplicated throughout
many scripts, and "sed" and "tr" were often called multiple times in
a pipeline.  These have been consolidated into a single filter.sed
file to avoid having to maintain these filters in multiple places.

In a few cases, accidentally deleted messages have been restored to
the expect output for the tests.  In other cases, trivial whitespace
has been changed in the expect files.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2013-06-15 18:44:09 -04:00
Theodore Ts'o e07b71f294 Merge branch 'maint' 2013-06-08 17:02:54 -04:00
Theodore Ts'o e2e389a1d5 tests: add new test f_extent_oobounds
This tests creates a file system where the last entry in one leaf
block overlaps with logical block range in the first entry of the next
leaf block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-06-06 23:53:31 -04:00
Theodore Ts'o 29f6dfea52 Merge branch 'maint' into next 2013-05-16 11:05:37 -04:00
Theodore Ts'o 5dfd5ef88d tests: add new test f_zero_xattr
E2fsck previously was complaining with zero-length extended attributes
if they appeared in the in-inode xattr space.  Test to make sure
e2fsck is now happy with such xattrs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-25 00:29:09 -04:00
Theodore Ts'o 07bcd90f3d Merge branch 'maint' into next 2013-04-22 00:07:08 -04:00
Theodore Ts'o 9bd95a472c crcsum: remove the -b option since ext2fs_crc32c_be is dropped in 1.43.x
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-04-22 00:04:36 -04:00
Theodore Ts'o e79a9395b3 tests: add more tests for off-line resizing
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:23 -04:00
Theodore Ts'o 28e6662403 tests: create crcsum progam to support resizing tests
The only checksum program which we can reliably count upon being
installed on all systems is "sum", which is not a particular robust
checksum.  The problem with using md5sum or sha1sum is it hat it may
not be installed on all systems.  So create a crcsum program which is
used so we can validate that a data file on a resized file system has
not been corrupted.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-03-31 20:41:23 -04:00
Theodore Ts'o 7b68fa38b8 Merge branch 'maint' into next
Conflicts:
	RELEASE-NOTES
	lib/ext2fs/ext2_err.et.in
	version.h
2013-01-16 14:14:09 -05:00
Theodore Ts'o 390e49aab7 tests: create test for debugfs creating special files
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2013-01-16 14:09:20 -05:00
Theodore Ts'o ab83252174 Merge branch 'maint' into next
Conflicts:
	e2fsck/problem.c
	e2fsck/problem.h
2012-12-24 10:50:20 -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 2f2a048b1d Merge branch 'maint' into next 2012-09-22 21:35:46 -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 43c67c4f73 Merge branch 'maint' into next
Conflicts:
	debian/changelog
	version.h
2012-09-21 12:55:45 -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 32dd6cdbe5 Merge branch 'maint' into next
Conflicts:
	resize/resize2fs.c
2012-09-16 22:06:29 -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
Andreas Dilger 03b10639e7 tests: remove unused temporary files for MMP tests
The MMP tests need to be run on a real disk instead of tmpfs, since
the MMP block access is using O_DIRECT.  As such, they create their
own test files in the local testing directory instead of using the
temporary file created in /tmp by the test_one script.  Delete the
tempfs file before clobbering TMPFILE, otherwise it will leave the
unused file in /tmp after the test is completed.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-08-15 16:44:59 -04:00
Andreas Dilger ff07d436fc tests: allow e2fsck tests to run on OS/X
The "mktemp" program requires a template on OS/X.  Allow the test
TMPFILE to be created in the local /tmp directory for both OS/X
and Linux.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2012-06-12 13:59:56 -04:00
Theodore Ts'o e130a16e83 tests: add two more tests of orphaned inode handling
Add two tests, f_orphan_indirect_inode, and f_orphan_extents_inode,
which tests the bug fixes in the two previous commits:

e2fsck: update global free blocks/inodes count when truncating orphan inodes
libext2fs: fix block iterator for extents when truncating inodes

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2012-06-12 01:38:57 -04:00