Allow the administrator to mark the filesystem's error bit to force a
fsck at the next mount.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
In the case where the UUID has changed and the user wants to turn off
the csum_seed feature, it's important that file system be freshly
checked. That's also the only case when it's necessary to recalculate
all of the metadata file systems.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Also change the t_replay_and_set test so that we do something more
innocuous, such as setting the file system label, instead of something
much more dangerous such as removing metadata_csum feature (which
requires rewriting the metadat checksums, and this will fail
catastrophically after the test corrupts the inode bitmaps and we
perform the journal replay correctly).
Reported-by: NeilBrown <neilb@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
tune2fs currently replays the journal if it needs
recovery and the filesystem isn't mounted.
The test for "is the filesystem mounted" isn't completely robust.
Lustre makes use of ext4 filesystems in a way that they are mounted
without being visible in /proc/mounts or similar.
This usage can easily be detected by attempting to open the device
with O_EXCL. tune2fs already does this and the EXT2_MF_BUSY flag
is set if open(O_EXCL) fails.
Several uses other than lustre mounts could cause O_EXCL to fail,
but in any case it seems unwise to recover the journal when something
else is keeping the device busy.
So add an extra test to avoid journal recovery when the device
is busy. This fixes some problems with lustre usage.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
badblocks.c: Add -B and -X to usage text.
chattr.1.in: Add P to list of settable attributes.
e2image.8.in, e2image.c: Remove superfluous mention of -r option.
e2undo.8.in, e2undo.c: Add description for -z to man page and add -o and
-z to synopsis and usage text.
e4crypt.8.in: Add -p pad option to relevant command descriptions.
lsattr.1.in: Fix typo.
mke2fs.8.in: Add -C to synopsis. Add MKE2FS_DEVICE_PHYS_SECTSIZE
description and update MKE2FS_DEVICE_SECTSIZE description.
mke2fs.conf.5.in: Add devices stanza summary. Remove base_features and
default_features descriptions from defaults section, as they are
already described in fs_types section. Move enable_periodic_fsck and
force_undo to fs_types section, as they can be set per filesystem
type. Add missing lazy_journal_init and hugefiles_dir descriptions.
tune2fs.8.in: Remove unsupported -p option and deprecated -s option.
Add 64bit, ea_inode, large_dir, and metadata_csum_seed descriptions.
tune2fs.c: Remove unsupported -p option from usage text.
Add mmp_update_interval to extended option usage text.
resize/main.c: Add -S option to usage text.
Signed-off-by: Tyson Nottingham <tgnottingham@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The ext2fs_run_ext3_journal() function is in debugfs/journal.c, and in
some error conditions cases may close the passed-in file system handle.
Clean up the both the function so that it reliably clears the file
system handle if it has been freed, and its callers so that they do
not crash by dereferencing a null pointer if it has been freed.
Reported-by: Erkki Ruohtula <eru@netti.fi>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Currently tune2fs just says without any explanation, "run fsck -f".
Add a short explanation that a freshly checked file system is required
to reduce user confusion. (We could add even more details, but
hopefully this is enough.)
Addresses-Debian-Bug: #857336
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Extended attribute inodes maintain a crc32c hash that is used for
deduplication. The crc seed derives from uuid so ea_inode hashes
must be updated when uuid changes.
The ea_inode hash is also incorporated into the xattr entry e_hash
so the entries that reference the inode also must be updated.
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Disabling ea_inode feature would require inlining all the existing
xattr values that are currently stored in external inodes. This is
not always possible. Just disallow it.
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Add support for the INCOMPAT_EA_INODE feature, which stores large
extended attributes into an external inode instead of data blocks.
The inode is referenced by the e_value_inum field (formerly the
unused e_value_block field) from the extent header, and stores the
xattr data starting at byte offset 0 in the inode data block.
The xattr inode stores the referring inode number in its i_mtime,
and the parent i_generation in its own i_generation, so that there
is a solid linkage between the two that e2fsck can verify. The
xattr inode is itself marked with EXT4_EA_INODE_FL as well.
Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
There are several problems for project quota enable/disable:
tune2fs -O ^project did not work, because @clear_ok_features
did not include @EXT4_FEATURE_RO_COMPAT_PROJECT.
update_feature_set() works for -O option, but tune2fs -Q prj/^prj
did not work well, because function handle_quota_options()
did not set and clear @EXT4_FEATURE_RO_COMPAT_PROJECT feature very well.
one warning message is removed, because with project feature
enabled, quota feature will be enabled automatically.
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The INCOMPAT_LARGEDIR feature allows larger directories to
be created, both with directory sizes over 2GB and and a
maximum htree depth of 3 instead of the current limit of 2.
These features are needed in order to exceed the currently
limit of approximately 10M entries in a single directory
for 4KB blocksize (~100k for 1KB).
debugfs, e2fsck, ext2fs, mke2fs and tune2fs support is
added.
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@seagate.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@seagate.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Commit 5c2a665afa (Avoid dereferencing beyond allocated memory in quota
handling) induced a quota enablement regression in tune2fs. Attempts
to enable a particular quota type (tune2fs -O project <dev>, for
example) set the appropriate feature flag in the superblock but the
quota file for the type is not initialized.
The regression prevents the current version of xfstests from running
generic/383, 384, 385, and 386 (all project quota tests) with e2fsprogs
1.43.4. These tests exit with the message "Installed kernel does not
support project quotas", but the actual problem is that the project
quota file is not present.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The quota support code must must not try to handle the project quota
if the the project feature is not enabled.
Problem detected by ASAN.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The message requesting that the user run e2fsck doesn't include the -f
option, and this is needed to force a file system check.
Addresses-Debian-Bug: #828022
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The s_creator_os field was a mistake, given how Hurd has been
ab(using) certain file system fields. We should skip support for
certain advanced features (64-bit support, metadata checksums) for
file systems created on the Hurd OS only, instead of only supporting
them for file systems created on Linux. This fixes various regression
test failures for FreeBSD.
(The regression tests are probably mostly hopeless for Hurd anyway,
but given the HURD abuse's of various file system fields, the HURD is
going to have to be given second-class treatment in any case, given
what they decided to do with ext2 support, which locks them out of the
more advanced file system features, anyway.)
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
If the journal needs to be recovered to avoid clobbering whatever
changes tune2fs makes, do so.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Give admins a short amount of time to confirm that they want to
proceed with a dangerous operation. Refuse to perform the op
unless the filesystem is freshly checked.
Cc: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch adds project quota support. An new quota type PRJQUOTA(2)
is added. EXT4_PRJ_QUOTA_INO(11) is reserved for project quota inode.
The super block reservers an field s_prj_quota_inum for saving
project quota inode. And each inode adds an internal field i_projid
for saving its project ID.
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This patch add project feature flag EXT4_FEATURE_RO_COMPAT_PROJECT.
Project feature is a read-only compat feature. Thus, an ext4 file
system with project feature enabled could only be read by ext4
kernel module without project feature support.
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Project quota related fields are reserved in Linux kernel.
As a preparation for it, this patch cleans up quota codes
of e2fsprogs so as to make it easier to add new quota type(s).
Signed-off-by: Li Xi <lixi@ddn.com>
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Running tune2fs on a filesystem with an unrecovered journal can
cause the tune2fs settings changes in the superblock to be reverted
when the journal is replayed if it contains an uncommitted copy of
the superblock. Print a warning if this is detected so that the
user isn't surprised if it happens.
Signed-off-by: Jim Garlick <garlick@llnl.gov>
Updated message printed to include steps to replay journal.
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Create separate predicate functions to test/set/clear feature flags,
thereby replacing the wordy old macros. Furthermore, clean out the
places where we open-coded feature tests.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
There are times when it is necessary to update the UUID on a mounted
root file system (for example). So when we add this this safety check
to e2fsprogs 1.43, we will likely break some scripts. Allow the -f
option to force an override of this safety check.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Also change ext2fs_symlink() so that the target parameter is a const
char *, thus promising that we will never change the incoming string.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
The check_plausibility() function is now used all over the place, so
we should move the plausible.c file to lib/support and remove the
special case handling for that file that had been in the build system.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
We will be using libsupport.a for e2fsprogs's internal support
functions. It will contain the quota support functions, but we will
also be moving code such as profile.c and plausible.c to libsupport.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
For the 1.43 release, quota support will be the default. It's much
simpler if we don't try to make quota support optional. This was done
originally because the quota feature wasn't fully tested. It is now,
so we can remove this as an option.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Some temporary char buffers allocated on the stack are not properly
aligned when typecast to a structure containing __u32 or __u64 types,
and this can cause alignment warnings on ARM and other alignment
sensitive architectures, and potential slowdowns to do fixups.
Fix the buffer alignment to avoid such issues.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=680090
Reported-by: Gordan Bobic <gordan.bobic@gmail.com>
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Having multiple versions of jfs_user.h was confusing the Android
build. Clean up things by removing the lib/ext2fs/jfs_user.h and
misc/jfs_user.h and simplifying how we emulate the kernel
infrastructure needed by journal replay code and removing the
kernel-specific lines from kernel-jbd.h.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Fix Coverity bugs 1297094-1297101 by fixing all the mutations in the
*_setup_tdb() functions, fixing buffer overflows, and checking
return values.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>