All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] fs/ext2: generate Y2K38-resilient filesystems
@ 2022-11-20 20:42 Yann E. MORIN
  2022-12-14 19:29 ` Peter Korsgaard
  0 siblings, 1 reply; 2+ messages in thread
From: Yann E. MORIN @ 2022-11-20 20:42 UTC (permalink / raw
  To: buildroot; +Cc: Yann E. MORIN

When creating a filesystem, mkfs.ext will chose the inode size depending
on the size of the filesystem. Small filesystem get 128-bytes inodes,
while bigger filesystems use 256-byte inodes (inode must be a power of 2
larger or equal to 128, and smaller or equal to the blocksize).

However, 128-byte inodes can't store timestamps past the dreaded
2038-01-19 03:14:07Z deadline, while inodes larger than or equal to 256
do not have the issue.

It turns out that the tipping point to decide whether a filesystem is
small or big, is about around the size of the filesystems we generate
for our runtime tests. This causes the kernel to emit warning like:

    ext2 filesystem being remounted at / supports timestamps until 2038 (0x7fffffff)

We add a new option to our ext2 filesystem, so that user can specify the
size of the inode. That new option defaults to 256 to be resilient to
the Y2K38 problem.

Note: it was already possible for users to explicitly pass the -I
option, through BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS. We could have
chosen to extend the existing value with a -I 256, but that is not
satisfactory. Indeed, we do want to ensure that the default is now
Y2K38-OK, even for existing configurations that did not have explicit
setting.

We also pass that new option before the user-specified arbitrary ones,
so that BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS still wins (in case -I was
set there).

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 fs/ext2/Config.in | 13 +++++++++++++
 fs/ext2/ext2.mk   |  1 +
 2 files changed, 14 insertions(+)

diff --git a/fs/ext2/Config.in b/fs/ext2/Config.in
index 705446df57..3c68638fd8 100644
--- a/fs/ext2/Config.in
+++ b/fs/ext2/Config.in
@@ -60,6 +60,19 @@ config BR2_TARGET_ROOTFS_EXT2_INODES
 	int "exact number of inodes (leave at 0 for auto calculation)"
 	default 0
 
+config BR2_TARGET_ROOTFS_EXT2_INODE_SIZE
+	int "inode size"
+	default 256
+	help
+	  Set the size of inodes, in bytes, as a power of 2 larger or
+	  equal to 128.
+
+	  Set to 0 to let the filesystem generator decide. If unsure,
+	  keep the default, 256.
+
+	  Note: 128-byte inodes suffer of the Y2K38 problem, and can't
+	  store timestamps beyond 2038-01-19 03:14:07Z.
+
 config BR2_TARGET_ROOTFS_EXT2_RESBLKS
 	int "reserved blocks percentage"
 	default 5
diff --git a/fs/ext2/ext2.mk b/fs/ext2/ext2.mk
index 5b5393f092..e69e79cd2e 100644
--- a/fs/ext2/ext2.mk
+++ b/fs/ext2/ext2.mk
@@ -22,6 +22,7 @@ ROOTFS_EXT2_OPTS = \
 	-N $(BR2_TARGET_ROOTFS_EXT2_INODES) \
 	-m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS) \
 	-L "$(ROOTFS_EXT2_LABEL)" \
+	-I $(BR2_TARGET_ROOTFS_EXT2_INODE_SIZE) \
 	$(ROOTFS_EXT2_MKFS_OPTS)
 
 ROOTFS_EXT2_DEPENDENCIES = host-e2fsprogs
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [PATCH] fs/ext2: generate Y2K38-resilient filesystems
  2022-11-20 20:42 [Buildroot] [PATCH] fs/ext2: generate Y2K38-resilient filesystems Yann E. MORIN
@ 2022-12-14 19:29 ` Peter Korsgaard
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Korsgaard @ 2022-12-14 19:29 UTC (permalink / raw
  To: Yann E. MORIN; +Cc: buildroot

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > When creating a filesystem, mkfs.ext will chose the inode size depending
 > on the size of the filesystem. Small filesystem get 128-bytes inodes,
 > while bigger filesystems use 256-byte inodes (inode must be a power of 2
 > larger or equal to 128, and smaller or equal to the blocksize).

 > However, 128-byte inodes can't store timestamps past the dreaded
 > 2038-01-19 03:14:07Z deadline, while inodes larger than or equal to 256
 > do not have the issue.

 > It turns out that the tipping point to decide whether a filesystem is
 > small or big, is about around the size of the filesystems we generate
 > for our runtime tests. This causes the kernel to emit warning like:

 >     ext2 filesystem being remounted at / supports timestamps until 2038 (0x7fffffff)

 > We add a new option to our ext2 filesystem, so that user can specify the
 > size of the inode. That new option defaults to 256 to be resilient to
 > the Y2K38 problem.

 > Note: it was already possible for users to explicitly pass the -I
 > option, through BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS. We could have
 > chosen to extend the existing value with a -I 256, but that is not
 > satisfactory. Indeed, we do want to ensure that the default is now
 > Y2K38-OK, even for existing configurations that did not have explicit
 > setting.

 > We also pass that new option before the user-specified arbitrary ones,
 > so that BR2_TARGET_ROOTFS_EXT2_MKFS_OPTIONS still wins (in case -I was
 > set there).

 > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
 > ---
 >  fs/ext2/Config.in | 13 +++++++++++++
 >  fs/ext2/ext2.mk   |  1 +
 >  2 files changed, 14 insertions(+)

 > diff --git a/fs/ext2/Config.in b/fs/ext2/Config.in
 > index 705446df57..3c68638fd8 100644
 > --- a/fs/ext2/Config.in
 > +++ b/fs/ext2/Config.in
 > @@ -60,6 +60,19 @@ config BR2_TARGET_ROOTFS_EXT2_INODES
 >  	int "exact number of inodes (leave at 0 for auto calculation)"
 >  	default 0
 
 > +config BR2_TARGET_ROOTFS_EXT2_INODE_SIZE
 > +	int "inode size"
 > +	default 256
 > +	help
 > +	  Set the size of inodes, in bytes, as a power of 2 larger or
 > +	  equal to 128.
 > +
 > +	  Set to 0 to let the filesystem generator decide. If unsure,

I added '.. based on the file system size' to make it clear that mkfs
doesn't just have a static default and committed, thanks.

-- 
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

end of thread, other threads:[~2022-12-14 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-20 20:42 [Buildroot] [PATCH] fs/ext2: generate Y2K38-resilient filesystems Yann E. MORIN
2022-12-14 19:29 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.