]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
AOSP: support the stable_inodes feature
authorEric Biggers <ebiggers@google.com>
Mon, 21 Oct 2019 23:30:43 +0000 (16:30 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 31 Oct 2019 23:32:27 +0000 (19:32 -0400)
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

lib/e2p/feature.c
lib/ext2fs/ext2_fs.h
lib/ext2fs/ext2fs.h
misc/mke2fs.c
misc/tune2fs.c
resize/main.c

index ae7f7f0aac20e610d22b1877217e2c5ce9b698d0..ad0d7f821dc0cb7d8ede0cb66ded6278fc04d8f7 100644 (file)
@@ -47,6 +47,8 @@ static struct feature feature_list[] = {
                        "sparse_super2" },
        {       E2P_FEATURE_COMPAT, EXT4_FEATURE_COMPAT_FAST_COMMIT,
                        "fast_commit" },
+       {       E2P_FEATURE_COMPAT, EXT4_FEATURE_COMPAT_STABLE_INODES,
+                       "stable_inodes" },
 
        {       E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER,
                        "sparse_super" },
index febcb476a996b497dea0122aa26a055d6e3cce31..3165b3895222228b72f14c77baf905456877d175 100644 (file)
@@ -811,6 +811,7 @@ struct ext2_super_block {
 #define EXT2_FEATURE_COMPAT_EXCLUDE_BITMAP     0x0100
 #define EXT4_FEATURE_COMPAT_SPARSE_SUPER2      0x0200
 #define EXT4_FEATURE_COMPAT_FAST_COMMIT                0x0400
+#define EXT4_FEATURE_COMPAT_STABLE_INODES      0x0800
 
 
 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER    0x0001
@@ -913,6 +914,7 @@ EXT4_FEATURE_COMPAT_FUNCS(lazy_bg,          2, LAZY_BG)
 EXT4_FEATURE_COMPAT_FUNCS(exclude_bitmap,      2, EXCLUDE_BITMAP)
 EXT4_FEATURE_COMPAT_FUNCS(sparse_super2,       4, SPARSE_SUPER2)
 EXT4_FEATURE_COMPAT_FUNCS(fast_commit,         4, FAST_COMMIT)
+EXT4_FEATURE_COMPAT_FUNCS(stable_inodes,       4, STABLE_INODES)
 
 EXT4_FEATURE_RO_COMPAT_FUNCS(sparse_super,     2, SPARSE_SUPER)
 EXT4_FEATURE_RO_COMPAT_FUNCS(large_file,       2, LARGE_FILE)
index 334944d9b0e12b9dd47153c3bfc2242aab721eae..a5ed10fc6cf5ef5029d19bf12ec84ccd2b1bfb33 100644 (file)
@@ -612,7 +612,8 @@ typedef struct ext2_icount *ext2_icount_t;
                                         EXT2_FEATURE_COMPAT_DIR_INDEX|\
                                         EXT2_FEATURE_COMPAT_EXT_ATTR|\
                                         EXT4_FEATURE_COMPAT_SPARSE_SUPER2|\
-                                        EXT4_FEATURE_COMPAT_FAST_COMMIT)
+                                        EXT4_FEATURE_COMPAT_FAST_COMMIT|\
+                                        EXT4_FEATURE_COMPAT_STABLE_INODES)
 
 #ifdef CONFIG_MMP
 #define EXT4_LIB_INCOMPAT_MMP          EXT4_FEATURE_INCOMPAT_MMP
index fe4958441bb013fd264eaa296a2d1e333a4803d2..ffea8233bd6d5db5c6712728c79f1c70c596a15e 100644 (file)
@@ -1144,7 +1144,8 @@ static __u32 ok_features[3] = {
                EXT2_FEATURE_COMPAT_DIR_INDEX |
                EXT2_FEATURE_COMPAT_EXT_ATTR |
                EXT4_FEATURE_COMPAT_SPARSE_SUPER2 |
-               EXT4_FEATURE_COMPAT_FAST_COMMIT,
+               EXT4_FEATURE_COMPAT_FAST_COMMIT |
+               EXT4_FEATURE_COMPAT_STABLE_INODES,
        /* Incompat */
        EXT2_FEATURE_INCOMPAT_FILETYPE|
                EXT3_FEATURE_INCOMPAT_EXTENTS|
index 77a45875b0f3defab7e166c2d27b9ce0499df2be..8368a73384d98a06c9baf8f0fb603ac67b5ff961 100644 (file)
@@ -150,7 +150,8 @@ static __u32 ok_features[3] = {
        /* Compat */
        EXT3_FEATURE_COMPAT_HAS_JOURNAL |
                EXT2_FEATURE_COMPAT_DIR_INDEX |
-               EXT4_FEATURE_COMPAT_FAST_COMMIT,
+               EXT4_FEATURE_COMPAT_FAST_COMMIT |
+               EXT4_FEATURE_COMPAT_STABLE_INODES,
        /* Incompat */
        EXT2_FEATURE_INCOMPAT_FILETYPE |
                EXT3_FEATURE_INCOMPAT_EXTENTS |
@@ -180,7 +181,8 @@ static __u32 clear_ok_features[3] = {
        EXT3_FEATURE_COMPAT_HAS_JOURNAL |
                EXT2_FEATURE_COMPAT_RESIZE_INODE |
                EXT2_FEATURE_COMPAT_DIR_INDEX |
-               EXT4_FEATURE_COMPAT_FAST_COMMIT,
+               EXT4_FEATURE_COMPAT_FAST_COMMIT |
+               EXT4_FEATURE_COMPAT_STABLE_INODES,
        /* Incompat */
        EXT2_FEATURE_INCOMPAT_FILETYPE |
                EXT4_FEATURE_INCOMPAT_FLEX_BG |
index a0c31c069f3c71ca9764cf7a9949fb0979bf1dae..cb0bf6a0d271822109637e6294e290f958079e52 100644 (file)
@@ -605,6 +605,12 @@ int main (int argc, char ** argv)
                fprintf(stderr, _("The filesystem is already 32-bit.\n"));
                exit(0);
        }
+       if (new_size < ext2fs_blocks_count(fs->super) &&
+           ext2fs_has_feature_stable_inodes(fs->super)) {
+               fprintf(stderr, _("Cannot shrink this filesystem "
+                       "because it has the stable_inodes feature flag.\n"));
+               exit(1);
+       }
        if (mount_flags & EXT2_MF_MOUNTED) {
                retval = online_resize_fs(fs, mtpt, &new_size, flags);
        } else {