summaryrefslogtreecommitdiff
path: root/misc/tune2fs.c
Commit message (Collapse)AuthorAgeFilesLines
* misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel()Eric Biggers2023-01-271-2/+3
| | | | | | | | | | These warnings show up in non-Linux builds. To fix them, only declare local variables when they are needed. While we're here, also make handle_fslabel() static. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* misc/tune2fs: fix setting fsuuid::fsu_lenEric Biggers2023-01-271-1/+1
| | | | | | | | | | | | | | | | | Minus does not mean equals. Besides fixing an obvious bug, this avoids the following compiler warning with clang -Wall: tune2fs.c:3625:20: warning: expression result unused [-Wunused-value] fsuuid->fsu_len - UUID_SIZE; ~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ Fixes: a83e199da0ca ("tune2fs: Add support for get/set UUID ioctls.") Reviewed-by: Jeremy Bongio <bongiojp@gmail.com> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Merge branch 'maint' into nextTheodore Ts'o2023-01-271-6/+25
|\
| * tune2fs: check return value of ext2fs_mmp_update2 in rewrite_metadata_checksumslihaoxiang (F)2023-01-251-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Tune2fs hasn't consider about the result of executing ext2fs_mmp_update2 when it try to rewrite_metadata_checksums. If the ext2fs_mmp_update2 failed, multi-mount protection couldn't guard there has the only node (i.e. this program) accessing this device in the meantime. We solve this problem to verify the return value of ext2fs_mmp_update2. It terminate rewrite_metadata_checksums and exit immediately if the wrong error code returned. Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| * tune2fs: print error message when closing the fs failsLubomir Rintel2023-01-181-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I encountered an I/O error on writing the superblock on a drive: ... pwrite64(3, ..., 114688, 97844727808) = 114688 fsync(3) = -1 EIO (Input/output error) close(3) = 0 ... The error was silently ignored, only indicated by the exit value. Let's print an error message. The error message was taken from mke2fs in order to reuse the translations. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| * tune2fs: fix an error messageLubomir Rintel2022-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | $ tune2fs -O ^has_journal -ff /dev/sdh2 Recovering journal. tune2fs: Unknown code ____ 251 while recovering journal. Before: Please run e2fsck -fy -O. After: Please run e2fsck -fy /dev/sdh2. Note this doesn't fix the "Unknown code" message, just the "Please run e2fsck" one. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| * tune2fs: exit directly when fs freed in ext2fs_run_ext3_journalLi Jinlin2022-10-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | In ext2fs_run_ext3_journal(), fs will be freed and reallocated. However, the reallocation by ext2fs_open() may fail in some cases --- for example, when the device becomes offline. To avoid a segfault, exit if fs is NULL. [ Simplified the patch by by simply exiting if fs is NULL -TYT ] Signed-off-by: Li Jinlin <lijinlin3@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2022-09-131-3/+2
|\ \ | |/
| * tune2fs: tune2fs_main() should return rc when some error, occursZhiqiang Liu2022-09-121-1/+2
| | | | | | | | | | | | | | | | | | | | If some error occurs, tune2fs_main() will go to closefs tag for releasing resource, and it should return correct value (rc) instead of 0 when ext2fs_close_free(&fs) successes. Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Reviewed-by: Artem Blagodarenko <artem.blagodarenko@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
| * tune2fs: fix tune2fs segfault when ext2fs_run_ext3_journal() failsZhiqiang Liu2022-09-121-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When ext2fs_run_ext3_journal() fails, tune2fs cmd will occur one segfault problem as follows. (gdb) bt #0 0x00007fdadad69917 in ext2fs_mmp_stop (fs=0x0) at mmp.c:405 #1 0x0000558fa5a9365a in main (argc=<optimized out>, argv=<optimized out>) at tune2fs.c:3440 misc/tune2fs.c: main() -> ext2fs_open2(&fs) -> ext2fs_mmp_start ...... -> retval = ext2fs_run_ext3_journal(&fs) -> if (retval) // if ext2fs_run_ext3_journal fails, close and free fs. -> ext2fs_close_free(&fs) -> rc = 1 -> goto closefs ...... closefs: -> if (rc) -> ext2fs_mmp_stop(fs) // fs has been set to NULL, boom!! -> (ext2fs_close_free(&fs) ? 1 : 0); // close and free fs In main() of tune2fs cmd, if ext2fs_run_ext3_journal() fails, we should set rc=1 and goto closefs tag, in which will release fs resource. Fix: a2292f8a5108 ("tune2fs: reset MMP state on error exit") Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com> Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | misc: fix test for unavailable mountpoint in tune2fsTheodore Ts'o2022-08-311-1/+1
| | | | | | | | | | | | Addresses-Coverity-Bug: 1510127 Fixes: a83e199da0ca ("tune2fs: Add support for get/set UUID ioctls") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: Add support for get/set UUID ioctls.Jeremy Bongio2022-08-231-20/+83
| | | | | | | | | | | | | | | | | | | | When mounted, there is a race condition between changing the filesystem UUID and changing other aspects of the filesystem, like mounting, resizing, changing features, etc. Using these ioctls to get/set the UUID ensures the filesystem is not being resized. Signed-off-by: Jeremy Bongio <bongiojp@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: allow disabling casefold featureSlava Bacherikov2022-08-121-1/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Casefold can be safely disabled if there are no directories with +F attribute ( EXT4_CASEFOLD_FL ). This checks all inodes for that flag and in case there isn't any, it disables casefold FS feature. When FS has directories with +F attributes, user could convert these directories, probably by mounting FS and executing some script or by doing it manually. Afterwards, it would be possible to disable casefold FS flag via tune2fs. Link: https://lore.kernel.org/r/20220708122658.17907-1-slava@bacher09.org Signed-off-by: Slava Bacherikov <slava@bacher09.org> Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2022-08-121-2/+3
|\ \ | |/
| * e2fsprogs: fix device name parsing to resolve names containing '='Lukas Czerner2022-08-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently in varisous e2fsprogs tools, most notably tune2fs and e2fsck we will get the device name by passing the user provided string into blkid_get_devname(). This library function however is primarily intended for parsing "NAME=value" tokens. It will return the device matching the specified token, NULL if nothing is found, or copy of the string if it's not in "NAME=value" format. However in case where we're passing in a file name that contains an equal sign blkid_get_devname() will treat it as a token and will attempt to find the device with the match. Likely finding nothing. Fix it by checking existence of the file first and then attempt to call blkid_get_devname(). In case of a collision, notify the user and automatically prefer the one returned by blkid_get_devname(). Otherwise return either the existing file, or NULL. We do it this way to avoid some existing file in working directory (for example LABEL=volume-name) masking an actual device containing the matchin LABEL. User can specify full, or relative path (e.g. ./LABEL=volume-name) to make sure the file is used instead. Link: https://lore.kernel.org/r/20220812130122.69468-1-lczerner@redhat.com Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reported-by: Daniel Ng <danielng@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2022-08-111-0/+2
|\ \ | |/
| * Avoid potential NULL dereference when argv[0]Theodore Ts'o2022-08-111-0/+2
| | | | | | | | | | | | | | | | | | Addresses-Coverity-Bug: 1500772 Addresses-Coverity-Bug: 1500769 Addresses-Coverity-Bug: 1500767 Addresses-Coverity-Bug: 1500758 Addresses-Coverity-Bug: 1500756 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: implement support for set/get label ioctsLukas Czerner2021-12-311-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement support for FS_IOC_SETFSLABEL and FS_IOC_GETFSLABEL ioctls. Try to use the ioctls if possible even before we open the file system since we don't need it. Only fall back to the old method in the case the file system is not mounted, is mounted read only in the set label case, or the ioctls are not suppported by the kernel. The new ioctls can also be supported by file system drivers other than ext4. As a result tune2fs and e2label will work for those file systems as well as long as the file system is mounted. Note that we still truncate the label exceeds the supported lenghth on extN file system family, while we keep the label intact for others. Update tune2fs and e2label as well. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: Add support for orphan_file featureJan Kara2021-09-301-2/+88
|/ | | | | Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: Fix conversion of quota filesJan Kara2021-09-031-1/+1
| | | | | | | | | | | | | | | When tune2fs is enabling quota feature, it looks for old-style quota files and tries to transfer limits stored in these files into newly created hidded quota files. However the code doing the transfer setups the quota scan wrongly and instead of transferring limits we transfer usage. So not only quota limits are lost (at least they can still be recovered from the old quota files) but also usage information may be wrong if the accounting in e2fsprogs does not exactly match the accounting in quota-tools (which is actually the case). Fix the setup of the quota scan. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* quota: Rename quota_update_limits() to quota_read_all_dquots()Jan Kara2021-09-031-2/+3
| | | | | | | | | | | quota_update_limits() is a misnomer because what it actually does is that it updates 'usage' counters and leaves 'limit' counters intact. Rename quota_update_limits() to quota_read_all_dquots() and while changing prototype also add a flags argument so that callers can control which quota information is actually updated from the disk. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: update overhead when toggling journal featureJan Kara2021-07-061-2/+8
| | | | | | | | | | | | | When adding or removing journal from a filesystem, we also need to add / remove journal blocks from overhead stored in the superblock. Otherwise total number of blocks in the filesystem as reported by statfs(2) need not match reality and could lead to odd results like negative number of used blocks reported by df(1). Fixes: 9046b4dfd0ce ("mke2fs: set overhead in super block") Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* tune2fs: teach tune2fs to use a random value for "-c random"Theodore Ts'o2021-02-141-3/+11
| | | | | Addresses-Debian-Bug: #926293 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Fix clang warnings on architectures with a 64-bit longTheodore Ts'o2021-02-111-3/+4
| | | | | | | | | | | | On most systems where we compile e2fsprogs, the u64 type is an unsigned long long. However, there are platforms (such as the PowerPC) where a long 64-bits and so u64 is typedef'ed to be unsigned long instead of a unsigned long long. Fix this by using explicit casts in printf statements. For scanf calls, we need to receive the value into a unsigned long long, and then assign it to a u64, after doing range checks. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* Merge branch 'maint' into nextTheodore Ts'o2021-01-281-24/+77
|\
| * AOSP: ANDROID: tune2fs: Support encrypt+casefoldDaniel Rosenberg2021-01-271-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | In preparation for upcoming kernel changes that will make the kernel support both encryption and casefolding at the same time, allow tune2fs to enable both features at the same time. Signed-off-by: Daniel Rosenberg <drosen@google.com> Google-Bug-Id: 138322712 Test: Create fs with casefold and encryption enabled via tune2fs Change-Id: I36537a8b6dc5e2997b7016212f9b574c76673067 From AOSP commit: 44ac9dccd9853cc9807f0d6ce952bdcdeb93954a
| * AOSP: ANDROID: tune2fs: Allow setting the casefold featureDaniel Rosenberg2021-01-271-7/+90
| | | | | | | | | | | | | | | | | | | | | | This allows tune2fs to enable casefolding on an existing filesystem. At the moment, casefolding is incompatible with encryption. Signed-off-by: Daniel Rosenberg <drosen@google.com> Google-Bug-Id: 138322712 Test: Create fs without casefold and enable it via tune2fs Change-Id: Ic9ed63180ef28c36e083cee85ade432e4bfcc654 From AOSP commit: eb5b168decac07058e90ead191350be80c75aff4
* | tune2fs: fix casefold+encrypt error messageGabriel Krisman Bertazi2021-01-271-1/+1
| | | | | | | | | | | | | | | | | | Refering to EXT4_INCOMPAT_CASEFOLD as encoding is not as meaningful as saying casefold. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: allow enabling casefold feature after fs creationGabriel Krisman Bertazi2021-01-271-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main reason we didn't allow this before was because !CASEFOLDED directories were expected to be normalized(). Since this is no longer the case, and as long as the encrypt feature is not enabled, it should be safe to enable this feature. Disabling the feature is trickier, since we need to make sure there are no existing +F directories in the filesystem. Leave that for a future patch. Also, enabling strict mode requires some filesystem-wide verification, so ignore that for now. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2021-01-231-2/+4
|\ \ | |/
| * tune2fs: fix resource leak in handle_quota_options()Theodore Ts'o2021-01-211-2/+4
| | | | | | | | | | Addresses-Coverity-Bug: 1467672 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: abort clearing the dir_index when the fs needs to be fsck'ed firstTheodore Ts'o2021-01-211-2/+3
| | | | | | | | | | | | | | | | | | | | We were not checking the return value of check_fsck_needed() when checking to clear the dir_index feature. As a result, tune2fs would print that the file system needed to be checked first, but then go ahead and clear the dir_index flag. Addresses-Coverity-Bug: 1467671 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Make userspace tools number of fast commits blocks awareHarshad Shirwadkar2021-01-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes number of fast commit blocks configurable. Also, the number of fast commit blocks can now be seen in dumpe2fs output. $ ./misc/mke2fs -O fast_commit -t ext4 image mke2fs 1.46-WIP (20-Mar-2020) Discarding device blocks: done Creating filesystem with 5120 1k blocks and 1280 inodes Allocating group tables: done Writing inode tables: done Creating journal (1040 blocks): done Writing superblocks and filesystem accounting information: done $ ./misc/dumpe2fs image dumpe2fs 1.46-WIP (20-Mar-2020) ... Journal features: (none) Total journal size: 1040k Total journal blocks: 1040 Max transaction length: 1024 Fast commit length: 16 Journal sequence: 0x00000001 Journal start: 0 $ ./misc/mke2fs -O fast_commit -t ext4 image -J fast_commit_size=256,size=1 mke2fs 1.46-WIP (20-Mar-2020) Creating filesystem with 5120 1k blocks and 1280 inodes Allocating group tables: done Writing inode tables: done Creating journal (1280 blocks): done Writing superblocks and filesystem accounting information: done $ ./misc/dumpe2fs image dumpe2fs 1.46-WIP (20-Mar-2020) ... Journal features: (none) Total journal size: 1280k Total journal blocks: 1280 Max transaction length: 1024 Fast commit length: 256 Journal sequence: 0x00000001 Journal start: 0 This patch also adds information about fast commit feature in mke2fs and tune2fs man pages. Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | ext2fs: move calculate_summary_stats to ext2fs libHarshad Shirwadkar2021-01-211-58/+1
| | | | | | | | | | | | | | | | | | | | | | | | The function calculate_summary_stats sets the global metadata of the file system. Tune2fs had this function defined statically in tune2fs.c. Fast commit replay needs this function to set global metadata at the end of the replay phase. So, move this function to libext2fs. Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Reviewed-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Enable threaded support for e2fsprogs' applications.Theodore Ts'o2021-01-211-1/+2
| | | | | | | | Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2020-10-011-36/+48
|\ \ | |/
| * tune2fs: reset MMP state on error exitAndreas Dilger2020-10-011-36/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If tune2fs cannot perform the requested change, ensure that the MMP block is reset to the unused state before exiting. Otherwise, the filesystem will be left with mmp_seq = EXT4_MMP_SEQ_FSCK set, which prevents it from being mounted afterward: EXT4-fs warning (device dm-9): ext4_multi_mount_protect:311: fsck is running on the filesystem Add a test to try some failed tune2fs operations and verify that the MMP block is left in a clean state afterward. Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13672 Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: prevent stable_inodes feature from being clearedEric Biggers2020-04-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | Similar to encrypt and verity, once the stable_inodes feature has been enabled there may be files anywhere on the filesystem that require this feature. Therefore, in general it's unsafe to allow clearing it. Don't allow tune2fs to do so. Like encrypt and verity, it can still be cleared with debugfs if someone really knows what they're doing. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: prevent changing UUID of fs with stable_inodes featureEric Biggers2020-04-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The stable_inodes feature is intended to indicate that it's safe to use IV_INO_LBLK_64 encryption policies, where the encryption depends on the inode numbers and thus filesystem shrinking is not allowed. However since inode numbers are not unique across filesystems, the encryption also depends on the filesystem UUID, and I missed that there is a supported way to change the filesystem UUID (tune2fs -U). So, make 'tune2fs -U' report an error if stable_inodes is set. We could add a separate stable_uuid feature flag, but it seems unlikely it would be useful enough on its own to warrant another flag. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | tune2fs: update dir checksums when clearing dir_index featureJan Kara2020-03-151-48/+95
| | | | | | | | | | | | | | | | | | When clearing dir_index feature while metadata_csum is enabled, we have to rewrite checksums of all indexed directories to update checksums of internal tree nodes. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2020-03-071-1/+1
|\ \ | |/
| * e2fsck: use proper types for variablesAndreas Dilger2020-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Use ext2_ino_t instead of ino_t for referencing inode numbers. Use loff_t for for file offsets, and dgrp_t for group numbers. Cast products to ssize_t before multiplication to avoid overflow. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Reviewed-by: Shilong Wang <wshilong@ddn.com> Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2020-01-251-2/+1
|\ \ | |/
| * mmp: abstract out repeated 'sizeof(buf), buf' usageAndreas Dilger2020-01-241-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The printf("%.*s") format requires both the buffer size and buffer pointer to be specified for each use. Since this is repeatedly given as "(int)sizeof(buf), (char *)buf" for mmp_nodename and mmp_bdevname fields, with typecasts to avoid compiler warnings. Add a helper macro EXT2_LEN_STR() to avoid repeated boilerplate code. This can also be used for other superblock buffer fields that may not have NUL-terminated strings (e.g. s_volume_name, s_last_mounted, s_{first,last}_error_func, s_mount_opts) to simplify code and avoid the need for temporary buffers for NUL-termination. Annotate the superblock string fields that may not be NUL-terminated. Signed-off-by: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Merge branch 'maint' into nextTheodore Ts'o2019-11-221-0/+12
|\ \ | |/
| * tune2fs: prohibit toggling uninit_bg on live filesystemsDarrick J. Wong2019-11-201-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An internal customer followed an erroneous AskUbuntu article[1] to try to change the UUID of a live ext4 filesystem. The article claims that you can work around tune2fs' "cannot change UUID on live fs" error by disabling uninit_bg, changing the UUID, and re-enabling the feature. This led to metadata corruption because tune2fs' journal descriptor rewrite races with regular filesystem writes. Therefore, prevent administrators from turning on or off uninit_bg on a mounted fs. [1] https://askubuntu.com/questions/132079/how-do-i-change-uuid-of-a-disk-to-whatever-i-want/195839#459097 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | Rename functions, types, constants to reflect jbd2 usageTheodore Ts'o2019-11-091-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We had previously stuck to using the names from ext3/jbd kernel files, and used a script in contrib/jbd2-resync.sh to convert the kernel files to use the ext3/jbd conventions so we could keep the files e2fsck/recovery.c and e2fsck/revoke.c in sync with jbd2/recovery.c and jbd2/revoke.c, respectively. This has been getting harder and harder, so let's make a global sweep through e2fsprogs to use the jbd2 names. Fortunately none of the ext3/jbd names had leaked out into publically exported header files, so this is only an internal change. Which looks scary, but it's basically a search and replace, so if it compiles it's going to be correct. Signed-off-by: Theodore Ts'o <tytso@mit.edu>
* | AOSP: support the stable_inodes featureEric Biggers2019-10-311-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reserve the codepoint for EXT4_FEATURE_COMPAT_STABLE_INODES, allow it to be set and cleared, and teach resize2fs to forbid shrinking the filesystem if it is set. This feature will allow the use of encryption policies where the inode number is included in the IVs (initialization vectors) for encryption, so data would be corrupted if the inodes were to be renumbered. For more details, see the kernel patchset: https://lkml.kernel.org/linux-fsdevel/20191021230355.23136-1-ebiggers@kernel.org/T/#u Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Theodore Ts'o <tytso@mit.edu> From AOSP commit: 9aa30c254dd57df54f00c5d520b7ac867ad7ca68
* | Teach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flagTheodore Ts'o2019-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Opening the file system with EXT2_FLAG_SUPER_ONLY will leave fs->group_desc to be NULL and modify "dumpe2fs -h" and tune2fs when it is emulating e2label to use this flag. This speeds up "dumpe2fs -h" and "e2label" when operating on very large file systems. To allow other libext2fs functions to work without too many surprises, ext2fs_group_desc() will read in the block group descriptors on demand. This allows "dumpe2fs -h" to be able to read the journal inode, for example. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cray-bug-id: LUS-5777
* | Enable support for the fast_commit compat featureTheodore Ts'o2019-10-031-2/+4
|/ | | | Signed-off-by: Theodore Ts'o <tytso@mit.edu>