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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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
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
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>
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>
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>
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>
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>
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>