Commit Graph

680 Commits

Author SHA1 Message Date
Theodore Ts'o
9660ba3b66 Merge branch 'maint' into next 2019-01-29 23:17:08 -05:00
Theodore Ts'o
8775809399 tests: generate test_data.tmp file from a script
Even if the debugfs executable is not sparse, it might contain a 1k
aligned block which is all zeros, which when written into a 1k block
file system by a test like d_loaddump will result in a sparse file and
causing one or more test failures.

Google-Bug-Id: 122085761
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2019-01-03 14:10:32 -05:00
Theodore Ts'o
e500f69c2b Merge branch 'maint' into next 2018-12-16 00:46:24 -05:00
Theodore Ts'o
ce75cf5459 e2fsck: use "Optimize?" prompt for PR_1E_CAN_{COLLAPSE,NARROW}_EXTENT_TREE
If e2fsck can optimize an inode's extent tree, it should ask for
permission to optimize it, not to "fix" it.  This was causing some
confusion, since some users interpreted this prompt as an indication
that the file system was inconsistent.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-12-15 22:37:53 -05:00
Theodore Ts'o
75da667779 Merge branch 'maint' into next 2018-11-26 12:37:41 -05:00
Theodore Ts'o
0eeb17d061 tune2fs: fix false warning that a UUID change will take a long time
If the file system only has the flex_bg feature enabled (with out the
metadata_csum feature enabled), it won't take a long time time fix up
the checksums after changing the UUID.  While it does need to
recalculate all of the checksums in the block group descriptors, that
doesn't take a long time.

Also, if the ea_data feature is enabled, changing the UUID will also
take a long time, and we weren't warning the user about that case.

Fix up the warning message so it doesn't mislead people, and is more
accurate.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-11-23 22:47:08 -05:00
Li Dongyang
4a11f49957 e2fsck: check xattr 'system.data' before setting inline_data feature
ext2fs_inline_data_size will happy return 0 and set size to
EXT4_MIN_INLINE_DATA_SIZE even when inode doesn't have
xattr 'system.data', a corrupted i_flags could make e2fsck
enable the inline_data on the superblock.

We should only offer to enable inline_data when i_flags is set
and xattr 'system.data' can be found.

Also use correct prompt for PR_1_INLINE_DATA_FEATURE.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
2018-11-15 13:02:34 -05:00
Theodore Ts'o
0869943714 Merge branch 'maint' into next 2018-10-21 07:53:16 -04:00
Theodore Ts'o
8d24eeb71a tests: move inode and its interior extent tree block
Add a test case for the bug fixed in 4b3038134b: "resize2fs: update
checksums in the extent tree's relocated block"

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-10-20 10:11:21 -04:00
Theodore Ts'o
cf5587db3e Merge branch 'maint' into next 2018-10-11 10:28:42 -04:00
Theodore Ts'o
03fdf30663 test_one: make sure the tmpfile is cleaned up if the test script exits
f_detect_junk will skip the test by exiting; and in that case we need
to make sure the test's tmpfile gets cleaned up.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-10-10 22:56:12 -04:00
Theodore Ts'o
62dfbc0fb2 Merge branch 'maint' into next 2018-10-04 10:39:50 -04:00
Lukas Czerner
b0ec76d623 libe2p: avoid segfault when s_nr_users is too high
Currently in e2fsprogs tools it's possible to access out of bounds
memory when reading list of ids sharing a journal log
(journal_superblock_t->s_users[]) in case where s_nr_users is too high.

This is because we never check whether the s_nr_users fits into the
restriction of JFS_USERS_MAX. Fix it by checking that nr_users is not
bigger than JFS_USERS_MAX and error out when possiblem.

Also add test for dumpe2fs. The rest would require involving external
journal which is not possible to test with e2fsprogs test suite at the
moment.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-10-02 21:47:10 -04:00
Theodore Ts'o
f56db533fc Merge branch 'maint' into next 2018-08-23 11:33:22 -04:00
Artem Blagodarenko
8aa8f063de e2image: copy mmp block when create metadata only image
e2image in modes without data blocks copy (-r, -Q) doesn't copy
mmp block that leads to fsck error:

Superblock has invalid MMP magic.  Fix? no

This patch adds coping this block if mmp is enabled.

Change-Id: I66035ee394a0ff53b9959e82b3e47050f3bf1593
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-22 00:37:54 -04:00
Theodore Ts'o
6ac81e4526 Merge branch 'maint' into next 2018-08-18 23:22:53 -04:00
Lukas Czerner
80a55276b3 tests: mke2fs must not create fs with resize_inode and meta_bg
Test that mke2fs does not allow to create file system with both
resize_inode and meta_bg features enabled.

This was fixes with commit 42e77d5d ("libext2fs: don't create
filesystems with meta_bg and resize_inode").

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-14 13:06:19 -04:00
Lukas Czerner
99a0dffcd3 tests: e2fsck must be able fix fs with resize_inode and meta_bg
Test if the e2fsck can fix file system with resize_inode and meta_bg
features enabled simultaneously.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-14 10:04:42 -04:00
Theodore Ts'o
2fcbcb1b9e Fix function declarations for ss commands to fix LTO warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-08-08 19:59:40 -04:00
Andreas Dilger
6e2863e445 tests: make generated test scripts read-only
Make generated test scripts read-only, to avoid errors by developers
editing the generated test scripts and then having them accidentally
clobbered when "make" is run again.

Change-Id: I60d417b816b7c559b5e05baf4167fc2cf2a871cf
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-07-02 17:28:25 -04:00
Lukas Czerner
cabde4999d e2fsck: do not allow initialized blocks pass i_size
We do not allow initialized blocks to exist past i_size as this could
lead to stale data exposure.

Remove test f_pgsize_gt_blksize because it is testing for the scenario
that not allowed. f_eofblocks is already testing for this.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-28 17:22:06 -04:00
Theodore Ts'o
8cec4acdc0 tests, mke2fs: add option to suppress xattr copying to fix f_extent_htree
If the developer is running with SELinux enabled on /tmp, the
f_extent_htree regression test will fail because mke2fs by default
copies the extended attributes into the newly created file system (if
a directory hierarchy is specified via the -d option).

Fix this by adding a new extended option to mke2fs, -E no_copy_xattrs
and using it in f_extent_htree's test script.

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-26 15:21:28 -04:00
Theodore Ts'o
74430052bc tests: explicitly force resize2fs's use of lazy (or not)
Resize2fs will not enable lazy_itable if the kernel apparently does
not support that feature.  This will cause spurious test failures when
the tests are running on such a system (or where sysfs is not
mounted).

So for the purposes of the regression test we need to force the use of
lazy_itable so that the results conform to expected golden output.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-26 09:59:19 -04:00
Theodore Ts'o
574b714d58 Update Makefile.in files using "make depend"
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-25 10:10:39 -04:00
Theodore Ts'o
579e9ae1dd tests: fix up f_detect_junk and f_detect_xfs
The golden output files for these two tests were out of date.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-25 09:43:18 -04:00
Theodore Ts'o
51a3b0b3dc e2fsck: only retry to open the file system when the superblock is corrupt
Previously we were always retrying the ext2fs_open2() call with the
EXT2_FLAG_IGNORE_SB_ERRORS flag.  It only makes sense to do this if
the superblock is reported as corrupt.  Otherwise, it's a waste of
time, and results in printing an extra set of error messages to annoy
the user.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-24 21:09:59 -04:00
Theodore Ts'o
0790bf05a2 tests: fix i_qcow test to properly test e2image's qcow-to-raw functionality
The test script was not properly checking e2image's ability to convert
a qcow2 image back to a raw image.  Fix this, and also change it to
use /tmp for the temporary files to speed things up systems with a
ramdisk for /tmp.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-24 18:30:50 -04:00
Theodore Ts'o
ac3256fd31 Fix gcc and clang warnings
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 23:00:50 -04:00
Theodore Ts'o
0d5c1d7ff1 tests: fix f_bigalloc_orphan_list so it is not dependant on umask
Reported-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 17:54:28 -04:00
Andreas Dilger
9302bda131 e2fsck: mark device inodes with EXT4_EXTENTS_FL bad
Mark device inodes bad if they have the EXT4_EXTENTS_FL set, since
this should never happen and likely shows the inode is corrupt.

Change-Id: I85ab667b39ff57c658a779e59f692a080217690e
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 17:54:01 -04:00
Andreas Dilger
42d3e8cc4b tests: PAGE_SIZE larger than blocksize with hole
Verify correct operation in the case of writing files with allocated
blocks at the end of the file beyond i_size.  This can happen for
PAGE_SIZE > blocksize, or through fallocate().

The f_eofblocks thest checks quite the same situation, but for broken
file system. This test is about correct file.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 17:23:57 -04:00
Andreas Dilger
8d541f641e e2fsck: handle preallocation for large PAGE_SIZE
Fix handling of block preallocation support in cases where the kernel
PAGE_SIZE is larger than the filesystem blocksize.

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-23 17:23:57 -04:00
Shuichi Ihara
32b8802aa5 misc: add e2mmpstatus utility via dumpe2fs
e2mmpstatus is a Multi-Mount Protection (MMP) helper utility to read
an MMP block to see if it is being updated.  It can also output the
latest update time, nodename, and device from the MMP block.

This is useful for HA and other maintenance scripts to determine if
the filesystem is in use on another node, and which node it is.

Signed-off-by: Shuichi Ihara <sihara@ddn.com>
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>

Moved e2mmpstatus checking/dumping code to be part of dumpe2fs rather
than a standalone program, using the "-m" option to check MMP status,
and "-i" to dump info.  If dumpe2fs is called as "e2mmpstatus" (and
also "mmpstatus" for compatibility reasons), assume "-m" is specified.

Re-use the existing MMP block handing routines (with some changes) to
check and dump the MMP block, rather than adding duplicate versions.

Modify dumpe2fs to exit with a non-zero error code if there is an
error while reading the filesystem metadata or MMP block, or if
"-m" is used with the "mmp" feature and is in use by another node.

Add a configure check for gethostname() rather than depending on
_BSD_SOURCE or _XOPEN_SOURCE to be set.

Update the f_mmp, m_mmp, m_mmp_bad_csum, and m_mmp_bad_magic tests
to use e2mmpstatus to check and dump the MMP state before and after
e2fsck is run to verify that the tool is working correctly.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 18:22:37 -04:00
Andreas Dilger
1a8015773a e2fsck: set dir_nlink feature if large dir exists
If there is a directory with more than EXT2_LINK_MAX (65000)
subdirectories, but the DIR_NLINK feature is not set in the
superblock, the feature should be set before continuing on
to change the on-disk directory link count to 1.

While most filesystems should have DIR_NLINK set (it was set
by default for all ext4 filesystems, and all kernels between
2.6.23 and 4.12 automatically set it if the directory link
count grew too large), it is possible that this flag is lost
due to disk corruption or for an upgraded filesystem.  We no
longer want kernels to automatically enable features.

Addresses: https://bugzilla.kernel.org/show_bug.cgi?id=196405
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 18:08:54 -04:00
Andreas Dilger
c759616b87 tests: remove pre-generated f_extent_htree image
The f_extent_htree test depends on the "mke2fs -d" functionality
that did not exist in the maint branch when the patch was landed.
On master this functionality exists and should be used instead of
a pre-generated image.  That exercises the "mke2fs -d" functionality
as well as e2fsck better.

[ Fixed to add missing expect.pre.? files --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 17:59:48 -04:00
Andreas Dilger
c5d9d3ce5f tests: don't run sed multiple times on test output
Don't call sed multiple times on the output, and avoid the use
of temporary files, or if possible.  It would be convenient to
use "sed -i" to only update the output file once, but this is
not portable to all platforms.

[ Fixed a few test regression failures --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 17:59:35 -04:00
Andreas Dilger
b7454eb8ee tests: remove redundant sed filtering
Now that the majority of device name filtering is in filter.sed,
it does not need to be specified explicitly for every test.

Fix the error message printed in debugfs when opening the device
to match that used in other tools.  This simplifies the filtering,
and will be helpful if debugfs messages are internationalized.

[ Fixed up some test failures in m_hugefile t_uninit_bg_rm --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 14:06:53 -04:00
Andreas Dilger
3819bff4cf tests: clean up $DEBUGFS_EXE usage in scripts
Instead of putting the entire test script under an implicit
"if test -x $DEBUGFS_EXE" conditional (sometimes indenting
the code, and sometimes not), rather check for the reverse
and exit the test script early if $DEBUGFS_EXE is missing.

In some places, tests were running $DEBUGFS_EXE directly,
when they should be running $DEBUGFS (which will run with
Fortify, or other options).

[ Fixed up missing exit statement in f_detect_junk. --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 12:31:42 -04:00
Andreas Dilger
0647f84998 tests: don't unlink test image if SKIP_UNLINK set
Don't register a trap to unlink $TMPFILE at the test exit if
SKIP_UNLINK is set.  Otherwise, this makes it difficult to
debug a failing test.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 11:42:41 -04:00
Andreas Dilger
5cf8bb1100 tests: don't use a sparse test file
If the TEST_BITS file is sparse, then the "debugfs -R write"
command may skip holes in the file when copying it into the
test image (depending on whether SEEK_HOLE/SEEK_DATA and/or
FIEMAP are available in the copy_file() function).

This was causing test failures on MacOS in the f_dup_resize
and d_loaddump tests because the TEST_BITS file was the
compiled "debugfs" binary, which apparently has holes when
built on MacOS, and the number of blocks allocated in the
test image was reduced as a result.  This caused the expect
output to differ in the summary line and resulted in failure.

Instead of using the debugfs binary for TEST_BITS, generate
a temporary file using /dev/urandom, if available.  If not,
fall back to the old behaviour or using debugfs.

[ Fixed up use of non-POSIX /bin/sh constructs and add test_data.tmp to
  .gitignore and files to be deleted on a make clean. --tytso ]

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-22 11:42:14 -04:00
David Anderson
bf1609036a AOSP: e2fsck: imply -f when using -E unshare_blocks
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Google-Bug-Id: 64109868
Test: e2fsck -E unshare_blocks does a full scan
Change-Id: Idc36ceba3bf24e1fb1487feedefe9a68f9acc7f3
From AOSP commit: 7c180d6598363722de6195d142d7677bbc2b0161
2018-06-21 10:14:47 -04:00
David Anderson
91327df457 AOSP: e2fsck: Add an extended option for unsharing blocks.
Add an -E unshare_blocks flag for unsharing blocks that were created for
a filesystem with block sharing enabled. If the filesystem does not have
this feature enabled, the flag has no effect. If the filesystem does not
have free space, e2fsck will error.

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

Google-Bug-Id: 64109868
Test: f_unshare_blocks_no_space, f_unshare_blocks_ok
Change-Id: I8821353e9e6200c6c0c71dd22f4f43d796fc720c
From AOSP commit: 8ba190e3135d61501d3a694b6960c2fbee98e7a6
2018-06-21 09:56:30 -04:00
David Anderson
9c5413b1ae AOSP: e2fsck: Skip duplicate blocks when RO_COMPAT_SHARED_BLOCKS is set.
If RO_COMPAT_SHARED_BLOCKS is set, the duplicate block pass is skipped
entirely.

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

Google-Bug-Id: 64109868
Test: f_shared_blocks_ok
Change-Id: I49a9d6c5012d5e76c9a47578a45cae7484df4c4a
From AOSP commit: 93d12bc16bffd39a56b1e08aefbc641eba298077
2018-06-21 09:47:57 -04:00
Jan Kara
35b459ffd7 e2fsck: allow to fix some superblock corruptions
Add a flag to ext2fs_open() which allows to open a filesystem even if
superblock is somewhat inconsistent. Use this flag from e2fsck as a last
resort to try to fix the superblok.

Currently, the flag does nothing. We'll relax checks in ext2fs_open()
once e2fsck is able to handle corresponding corruption gracefully.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-06-19 11:27:27 -04:00
Theodore Ts'o
2bb826370c tests: don't leave temp files behind after running i_bitmaps
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-04-09 16:20:53 -04:00
Theodore Ts'o
b46fbf3d52 tests: add new test f_ea_inode_self_ref
Make sure we can handle a maliciously created file system containing
an inode containing an extended attribute whose e_value_inum points
back at itself.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-04-07 01:12:00 -04:00
Ingo Brückl
c52d7eff8c tests: don't use "debugfs -f /dev/stdin"
Don't use "debugfs -f /dev/stdin" for portability reasons --- not all
systems have /dev/stdin. Simply dropping "-f /dev/stdin" works just
fine.

Signed-off-by: Ingo Brückl <ib@wupperonline.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-03-31 16:59:48 -04:00
Theodore Ts'o
79284d3992 tests: use mke2fs and debugfs from the build tree
The tests f_bigalloc_badinode and f_bigalloc_orphan_list were not
using the version of mke2fs and debugfs from the build tree, and if
mke2fs and debugfs are not in the user's PATH, these tests would fail.
Fix this.

Reported-by: Somchai Smythe <buraphalinuxserver@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-03-31 16:38:48 -04:00
Darrick J. Wong
7d79b40bb3 e2fsck: adjust quota counters when clearing orphaned inodes
If e2fsck encounters a filesystem that supports internal quotas, it is
responsible for adjusting the quota counters if it decides to clear any
orphaned inodes.  Therefore, we must read the quota files, adjust the
counters, and write the quota files back out when we are done.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-03-29 23:37:32 -04:00
Theodore Ts'o
07d5857e53 tests: explicitly specify 1k block sizes when creating test file systems
On the Hurd, mke2fs will force the use of 4k block sizes by default
because the Hurd's implemntation of ext2 doesn't support any other
block sizes.  This causes spurious test failures.  Since these test
are testing e2fsprogs functionality, force the use of 1k block sizes
so the test output matches the expected output.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2018-03-24 11:39:09 -04:00