mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
PATCH v2 1/1 mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
From: Darrick J. Wong <[email protected]>
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
First, change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, then add a warning to mke2fs itself if someone is trying to make us format an ext4 filesystem with 128-byte inodes.
Note that we /don't/ warn about these things if the user has signalled that they want an old format such as ext2, ext3, or hurd. Everyone should know by now that those are legacy.
---
v2: fix the comments
--- misc/mke2fs.c | 39 +++++++++++++++++++++++++++++++++++++++ misc/mke2fs.conf.in | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-)
misc/mke2fs.c +39 -0
@@ -1537,6 +1537,35 @@ static int get_device_geometry(const char *file, }#endif +/* +* Decide if the user is formatting with an old feature set (e.g. ext2, ext3). +* +* If there is no fs_types list, assume that the user's getting ext4 and return +* 0. If we find 'ext4' anywhere in the fs_types list, take that as a sign +* that the user will get ext4 and return 0. Any other case returns 1. +* +* Normally, 'ext4' will be the first item in fs_types, but the user can +* combine argv[0], -t, and -T options in such a way that fs_types will start +* with some other word and the 'ext4' will end up in a non-zero slot. A +* simple way to do this is "mke2fs -T ext4 /dev/XXX". The user is supposed to +* use -t for the fs type and not -T, but we've never enforced that. +*/ +static inline int +old_format_forced (char **fs_types) +{ +int found_ext4 =0 ; +int i; + +if (!fs_types) +return 0 ; + +for (i =0 ; fs_types[i]; i++) +if (!strcmp (fs_types[i],"ext4" )) + found_ext4 =1 ; + +return !found_ext4; +} +static void PRS (int argc,char *argv[]) {int b, c, flags;
@@ -2603,6 +2632,16 @@ static void PRS(int argc, char *argv[])exit (1 ); } +/* +* If we're formatting with an ext4 feature set (and not an old ondisk +* format), warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. +*/ +if (!old_format_forced (fs_types) && + inode_size ==EXT2_GOOD_OLD_INODE_SIZE ) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;
misc/mke2fs.conf.in +2 -2
@@ -16,12 +16,12 @@ } small = { blocksize = 1024 - inode_size = 128 + inode_size = 256 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 + inode_size = 256 inode_ratio = 8192 } big = {
Quoted 3 lines · Darrick J. Wong
Note that we /don't/ warn about these things if the user has signalled that they want an old format such as ext2, ext3, or hurd. Everyone should know by now that those are legacy.
So I took a closer look, and it turns out that we changed the default inode size for ext2 and ext3 file systems in 2008 (see commit b1631cce648e ("Create new filesystems with 256-byte inodes by default"), in e2fsprogs 1.40.4. Even a positively antedeluvian distro such as RHEL 7 uses e2fsprogs 1.42.9, and RHEL 6 EOL'ed November 30th, 2020.
There were only two cases where we created file systems with 128 byte inodes --- "small" and "floppy" sized file systems, and for the GNU Hurd, which only supports the original 128 byte inode. What will GNU Hurd do in 16.5 years? ¯\_(ツ)_/¯
Given that, I think we can simplify the patch a little, and just use a mke2fs.conf boolean to disable the warning message.
What do folks think?
- Ted
commit f569fe86caddf964973ed35cdf36ed520ef23a0c
Author: Darrick J. Wong <[email protected]> Date: Thu Aug 12 16:22:22 2021 -0700
mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
(Note that even for ext2 and ext3, we changed the default for non-small file systems in 2008 in commit commit b1631cce648e ("Create new filesystems with 256-byte inodes by default").)
So change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, and then add a warning to mke2fs itself if someone is trying to make us format a file system with 128-byte inodes. This can be suppressed by setting the boolean option warn_y2038_dates in the mke2fs.conf file to false, which we do in the case of GNU Hurd, since it only supports 128 byte inodes as of this writing.
[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
the default for ext2/ext3 was changed for all but small file systems in 2008. ]
misc/mke2fs.c +11 -0
@@ -2603,6 +2603,17 @@ profile_error:exit (1 ); } +/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for ext2, ext3, and hurd file systems. +*/ +if (inode_size ==EXT2_GOOD_OLD_INODE_SIZE && +get_bool_from_profile (fs_types,"warn_y2038_dates" ,1 )) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;
misc/mke2fs.conf.5.in +7 -0
@@ -505,6 +505,13 @@ This relation specifies the base file name for the huge files. This relation specifies the (zero-padded) width of the field for the huge file number. .TP +.I warn_y2038_dates +This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038. The default value is true, +except for file systems created for the GNU Hurd, which does not support +inodes larger than 128 bytes. +.TP .I zero_hugefiles This boolean relation specifies whether or not zero blocks will be written to the hugefiles while
misc/mke2fs.conf.in +1 -3
@@ -12,16 +12,13 @@ } ext4 = { features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize - inode_size = 256 } small = { blocksize = 1024 - inode_size = 128 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 inode_ratio = 8192 } big = {
@@ -44,4 +41,5 @@ hurd = { blocksize = 4096 inode_size = 128 + warn_y2038_dates = 0 }
Quoted 12 lines · Theodore Ts'o
Quoted 3 lines · Darrick J. Wong
Note that we /don't/ warn about these things if the user has signalled that they want an old format such as ext2, ext3, or hurd. Everyone should know by now that those are legacy.
So I took a closer look, and it turns out that we changed the default inode size for ext2 and ext3 file systems in 2008 (see commit
b1631cce648e("Create new filesystems with 256-byte inodes by default"), in e2fsprogs 1.40.4. Even a positively antedeluvian distro such as RHEL 7 uses e2fsprogs 1.42.9, and RHEL 6 EOL'ed November 30th, 2020.
Quoted 4 lines
There were only two cases where we created file systems with 128 byte inodes --- "small" and "floppy" sized file systems, and for the GNU Hurd, which only supports the original 128 byte inode. What will GNU Hurd do in 16.5 years? ¯\_(ツ)_/¯
Perhaps in that time someone can donate a disused Opteron 140 system? Assuming the motherboard capacitors haven't since lost their mojo.
Quoted 31 lines
Given that, I think we can simplify the patch a little, and just use a mke2fs.conf boolean to disable the warning message.
What do folks think?
- Ted
commit
f569fe86caddf964973ed35cdf36ed520ef23a0cAuthor: Darrick J. Wong <[email protected]> Date: Thu Aug 12 16:22:22 2021 -0700mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
(Note that even for ext2 and ext3, we changed the default for non-small file systems in 2008 in commit commit
b1631cce648e("Create new filesystems with 256-byte inodes by default").)So change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, and then add a warning to mke2fs itself if someone is trying to make us format a file system with 128-byte inodes. This can be suppressed by setting the boolean option
warn_y2038_datesin the mke2fs.conf file to false, which we do in the case of GNU Hurd, since it only supports 128 byte inodes as of this writing.
Quoted 3 lines
[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
the default for ext2/ext3 was changed for all but small file systems in 2008. ]
Even better!
Quoted 9 lines
Signed-off-by Darrick J. Wong <[email protected]>Signed-off-by Theodore Ts'o <[email protected]>misc/mke2fs.c +0
-0
misc/mke2fs.c profile_error: · line 2610
Quoted 8 lines
misc/mke2fs.c +5
-0@@ -2603,6 +2603,17 @@ profile_error:exit (1 ); } +/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for ext2, ext3, and hurd file systems.
Um... the conffile changes only disable the warning for Hurd?
Quoted 14 lines
misc/mke2fs.c +6
-0+*/ +if (inode_size ==EXT2_GOOD_OLD_INODE_SIZE && +get_bool_from_profile (fs_types,"warn_y2038_dates" ,1 )) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;misc/mke2fs.conf.5.in +0
-0
misc/mke2fs.conf.5.in This relation specifies the base file name for the huge files. · line 511
Quoted 7 lines
misc/mke2fs.conf.5.in +4
-0@@ -505,6 +505,13 @@ This relation specifies the base file name for the huge files. This relation specifies the (zero-padded) width of the field for the huge file number. .TP +.I warn_y2038_dates +This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038. The default value is true,
Nit: need a closing parentheses after '2038' or no opening paren.
misc/mke2fs.conf.5.in This relation specifies the base file name for the huge files. · line 513
Quoted 2 lines
misc/mke2fs.conf.5.in +2
-0+except for file systems created for the GNU Hurd, which does not support +inodes larger than 128 bytes.
I wonder if this statementt about Hurd this belongs in the conffile as a comment in the hurd section?
--D
Quoted 31 lines
misc/mke2fs.conf.5.in +1
-0+.TP .I zero_hugefiles This boolean relation specifies whether or not zero blocks will be written to the hugefiles whilemisc/mke2fs.conf.in +1
-3@@ -12,16 +12,13 @@ } ext4 = { features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize - inode_size = 256 } small = { blocksize = 1024 - inode_size = 128 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 inode_ratio = 8192 } big = {@@ -44,4 +41,5 @@ hurd = { blocksize = 4096 inode_size = 128 + warn_y2038_dates = 0 }
Quoted 7 lines · Darrick J. Wong
Quoted 4 lines
There were only two cases where we created file systems with 128 byte inodes --- "small" and "floppy" sized file systems, and for the GNU Hurd, which only supports the original 128 byte inode. What will GNU Hurd do in 16.5 years? ¯\_(ツ)_/¯
Perhaps in that time someone can donate a disused Opteron 140 system? Assuming the motherboard capacitors haven't since lost their mojo.
Apparently GNU Hurd uses a unsigned 32-bit int for time_t, so they have a 2106 problem. They "have no plans for a 64-bit userspace, but they have plans for a 64-bit kernel that can run 32-bit user space". Comments from the the GNU Hurd folks on an IRC chat from 2013:
<braunr> which overflows in 2106
<braunr> and we already include funny comments that predict our successors,
if any, will probably fail to deal with the problem until short before the overflow :>
<azeem> luckily, no nuclear reactors are running the Hurd sofar
https://www.gnu.org/software/hurd/open_issues/versioning.html
Quoted 7 lines
misc/mke2fs.c profile_error: · line 2610
Quoted 5 lines
misc/mke2fs.c +5
-0+/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for ext2, ext3, and hurd file systems. Um... the conffile changes only disable the warning for Hurd?
Oops, good catch, I'll fix up the comment.
Quoted 5 lines
misc/mke2fs.conf.5.in This relation specifies the base file name for the huge files. · line 511
Quoted 3 lines
misc/mke2fs.conf.5.in +3
-0+This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038. The default value is true,Nit: need a closing parentheses after '2038' or no opening paren.
Thanks, fixed.
Quoted 5 lines
misc/mke2fs.conf.5.in This relation specifies the base file name for the huge files. · line 513
Quoted 2 lines
misc/mke2fs.conf.5.in +2
-0+except for file systems created for the GNU Hurd, which does not support +inodes larger than 128 bytes.I wonder if this statementt about Hurd this belongs in the conffile as a comment in the hurd section?
We currently don't have a Hurd section. We probably could document more about the magic that mke2fs does when you specify "-o hurd", which probably should go in the mke2fs man page but I can't quite bring myself to care. Maybe some GNU Hurd folks can get interested to do this? :-)
- Ted
PATCH 1/1 mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
From: "Darrick J. Wong" <[email protected]>
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
(Note that even for ext2 and ext3, we changed the default for non-small file systems in 2008 in commit commit b1631cce648e ("Create new filesystems with 256-byte inodes by default").)
So change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, and then add a warning to mke2fs itself if someone is trying to make us format a file system with 128-byte inodes. This can be suppressed by setting the boolean option warn_y2038_dates in the mke2fs.conf file to false, which we do in the case of GNU Hurd, since it only supports 128 byte inodes as of this writing.
[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
the default for ext2/ext3 was changed for all but small file systems in 2008. ]
--- misc/mke2fs.c | 11 +++++++++++ misc/mke2fs.conf.5.in | 7 +++++++ misc/mke2fs.conf.in | 4 +--- 3 files changed, 19 insertions(+), 3 deletions(-)
misc/mke2fs.c +11 -0
@@ -2603,6 +2603,17 @@ profile_error:exit (1 ); } +/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for ext2, ext3, and hurd file systems. +*/ +if (inode_size ==EXT2_GOOD_OLD_INODE_SIZE && +get_bool_from_profile (fs_types,"warn_y2038_dates" ,1 )) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;
misc/mke2fs.conf.5.in +7 -0
@@ -505,6 +505,13 @@ This relation specifies the base file name for the huge files. This relation specifies the (zero-padded) width of the field for the huge file number. .TP +.I warn_y2038_dates +This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038. The default value is true, +except for file systems created for the GNU Hurd, which does not support +inodes larger than 128 bytes. +.TP .I zero_hugefiles This boolean relation specifies whether or not zero blocks will be written to the hugefiles while
misc/mke2fs.conf.in +1 -3
@@ -12,16 +12,13 @@ } ext4 = { features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize - inode_size = 256 } small = { blocksize = 1024 - inode_size = 128 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 inode_ratio = 8192 } big = {
@@ -44,4 +41,5 @@ hurd = { blocksize = 4096 inode_size = 128 + warn_y2038_dates = 0 }
Signature · 1 line
2.31.0
Oops, I sent the wrong commit; please ignore the -v4 version.
- Ted
PATCH 1/1 mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
In reply to Theodore Ts'oFrom: "Darrick J. Wong" <[email protected]>
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
(Note that even for ext2 and ext3, we changed the default for non-small file systems in 2008 in commit commit b1631cce648e ("Create new filesystems with 256-byte inodes by default").)
So change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, and then add a warning to mke2fs itself if someone is trying to make us format a file system with 128-byte inodes. This can be suppressed by setting the boolean option warn_y2038_dates in the mke2fs.conf file to false, which we do in the case of GNU Hurd, since it only supports 128 byte inodes as of this writing.
[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
the default for ext2/ext3 was changed for all but small file systems in 2008. ]
--- misc/mke2fs.c | 11 +++++++++++ misc/mke2fs.conf.5.in | 7 +++++++ misc/mke2fs.conf.in | 4 +--- 3 files changed, 19 insertions(+), 3 deletions(-)
misc/mke2fs.c +11 -0
@@ -2603,6 +2603,17 @@ profile_error:exit (1 ); } +/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for file systems created for the GNU Hurd. +*/ +if (inode_size ==EXT2_GOOD_OLD_INODE_SIZE && +get_bool_from_profile (fs_types,"warn_y2038_dates" ,1 )) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;
misc/mke2fs.conf.5.in +7 -0
@@ -505,6 +505,13 @@ This relation specifies the base file name for the huge files. This relation specifies the (zero-padded) width of the field for the huge file number. .TP +.I warn_y2038_dates +This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038). The default value is true, +except for file systems created for the GNU Hurd since it only supports +128-byte inodes. +.TP .I zero_hugefiles This boolean relation specifies whether or not zero blocks will be written to the hugefiles while
misc/mke2fs.conf.in +1 -3
@@ -12,16 +12,13 @@ } ext4 = { features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize - inode_size = 256 } small = { blocksize = 1024 - inode_size = 128 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 inode_ratio = 8192 } big = {
@@ -44,4 +41,5 @@ hurd = { blocksize = 4096 inode_size = 128 + warn_y2038_dates = 0 }
Signature · 1 line
2.31.0
Quoted 18 lines · Theodore Ts'o
From: "Darrick J. Wong" <[email protected]>
Filesystems with 128-byte inodes do not support timestamps beyond the year 2038. Since we're now less than 16.5 years away from that point, it's time to start warning users about this lack of support when they format an ext4 filesystem with small inodes.
(Note that even for ext2 and ext3, we changed the default for non-small file systems in 2008 in commit commit
b1631cce648e("Create new filesystems with 256-byte inodes by default").)So change the mke2fs.conf file to specify 256-byte inodes even for small filesystems, and then add a warning to mke2fs itself if someone is trying to make us format a file system with 128-byte inodes. This can be suppressed by setting the boolean option
warn_y2038_datesin the mke2fs.conf file to false, which we do in the case of GNU Hurd, since it only supports 128 byte inodes as of this writing.
Quoted 6 lines
[ Patch reworked by tytso to only warn in the case of GNU Hurd, since
the default for ext2/ext3 was changed for all but small file systems in 2008. ]Signed-off-by Darrick J. Wong <[email protected]>Signed-off-by Theodore Ts'o <[email protected]>
LGTM, insofar as I don't know how useful it is to review "my" own patch.
--D
Quoted 76 lines
--- misc/mke2fs.c | 11 +++++++++++ misc/mke2fs.conf.5.in | 7 +++++++ misc/mke2fs.conf.in | 4 +--- 3 files changed, 19 insertions(+), 3 deletions(-)misc/mke2fs.c +11
-0@@ -2603,6 +2603,17 @@ profile_error:exit (1 ); } +/* +* Warn the user that filesystems with 128-byte inodes will +* not work properly beyond 2038. This can be suppressed via +* a boolean in the mke2fs.conf file, and we will disable this +* warning for file systems created for the GNU Hurd. +*/ +if (inode_size ==EXT2_GOOD_OLD_INODE_SIZE && +get_bool_from_profile (fs_types,"warn_y2038_dates" ,1 )) +printf ( +_ ("128-byte inodes cannot handle dates beyond 2038 and are deprecated\n" )); +/* Make sure number of inodes specified will fit in 32 bits */ if (num_inodes ==0 ) {unsigned long long n;misc/mke2fs.conf.5.in +7
-0@@ -505,6 +505,13 @@ This relation specifies the base file name for the huge files. This relation specifies the (zero-padded) width of the field for the huge file number. .TP +.I warn_y2038_dates +This boolean relation specifies wheather mke2fs will issue a warning +when creating a file system with 128 byte inodes (and so therefore will +not support dates after January 19th, 2038). The default value is true, +except for file systems created for the GNU Hurd since it only supports +128-byte inodes. +.TP .I zero_hugefiles This boolean relation specifies whether or not zero blocks will be written to the hugefiles whilemisc/mke2fs.conf.in +1
-3@@ -12,16 +12,13 @@ } ext4 = { features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize - inode_size = 256 } small = { blocksize = 1024 - inode_size = 128 inode_ratio = 4096 } floppy = { blocksize = 1024 - inode_size = 128 inode_ratio = 8192 } big = {@@ -44,4 +41,5 @@ hurd = { blocksize = 4096 inode_size = 128 + warn_y2038_dates = 0 }Signature · 1 line
2.31.0