linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mke2fs: warn about missing y2038 support when formatting fresh ext4 fs
@ 2021-08-12 23:22 Darrick J. Wong
  2021-08-13 17:52 ` Theodore Ts'o
  0 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2021-08-12 23:22 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Andreas Dilger, linux-ext4

From: Darrick J. Wong <djwong@kernel.org>

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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
v2: fix the comments
---
 misc/mke2fs.c       |   39 +++++++++++++++++++++++++++++++++++++++
 misc/mke2fs.conf.in |    4 ++--
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 92003e11..114a64f7 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -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;
diff --git a/misc/mke2fs.conf.in b/misc/mke2fs.conf.in
index 01e35cf8..2fa1a824 100644
--- a/misc/mke2fs.conf.in
+++ b/misc/mke2fs.conf.in
@@ -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 = {

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-08-13 20:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 23:22 [PATCH v2] mke2fs: warn about missing y2038 support when formatting fresh ext4 fs Darrick J. Wong
2021-08-13 17:52 ` Theodore Ts'o
2021-08-13 18:14   ` Darrick J. Wong
2021-08-13 19:32     ` Theodore Ts'o
2021-08-13 19:34       ` [PATCH -v4] " Theodore Ts'o
2021-08-13 19:35         ` Theodore Ts'o
2021-08-13 19:35       ` [PATCH -v5] " Theodore Ts'o
2021-08-13 20:31         ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).