Skip to contentSkip to conversation

bootfs: simple bootloader filesystem

PATCH In review Darrick J. Wong 5 participants 12 messages Apr 1, 2019 – Apr 9, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bootfs: simple bootloader filesystem

From: Darrick J. Wong <[email protected]>

Does your computer use a bootloader which arrogantly declares that it can read boot files off a filesystem but isn't sophisticated enough even to recognize when that filesystem needs journal recovery?

Does your system software deployment program foolishly omit system calls to flush newly unwrapped packages to disk? Do you sometimes wonder if they've forgotten that old maxim, "wait for the disk drive light to turn off /before/ you power down"?

Are your computer operators aggressively derpy? Do they have a habit of leaving disk cables on the floor so they can trip over them twenty times a day? Does this leave you with sad files full of zeroes?

If so, bootfs is for you! This new filesystem type uses journalling to ensure metadata integrity, but forces all writes and directory tree updates to be synchronous, fsyncs files on close, and checkpoints its journal whenever a synchronization event happens. Some allege this is very slow, but I've been able to max out the iops on both of my double height floppy drives! In a power-cycling stress test, I found that the switch broke off in my hand before I lost any data. This concept may sound terrible, but like any good crutch, it _is_ made of wood!

---
 fs/ext4/Kconfig |   23 ++++++++
 fs/ext4/ext4.h  |    3 +
 fs/ext4/file.c  |    2 -
 fs/ext4/fsync.c |    3 +
 fs/ext4/super.c |  152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 182 insertions(+), 1 deletion(-)
fs/ext4/Kconfig +23 -0
index 06f77ca7f36e..44fe22505639 100644
@@ -105,3 +105,26 @@ config EXT4_DEBUG
 	  If you select Y here, then you will be able to turn on debugging
 	  with a command such as:
 		echo 1 > /sys/module/ext4/parameters/mballoc_debug
+
+config BOOT_FS
+	bool "Simple Bootloader Filesystem"
+	depends on EXT4_FS
+	help
+	  Certain unified bootloaders have incomplete filesystem drivers
+	  which expect never to have to deal with unrecovered logs and
+	  metadata.  This can lead to boot failures if the system goes
+	  down immediately after deploying new boot files.
+
+	  Worse yet, certain package deployment systems still do not call
+	  fsync to force newly deployed file data out to storage, which
+	  can lead to missing or zero-filled files on restart.
+
+	  If your software ecosystem is deficient like this, bootfs can
+	  compensate!  It forces synchronous writes and directory updates
+	  and while it does use a journal for metadata integrity, it forces
+	  journal checkpointing on every fsync and sync call.
+
+	  These special bootfs filesystems can be formatted with the
+	  mkfs.bootfs utility.
+
+	  Say Y here if your software sucks.
fs/ext4/ext4.h +3 -0
index 82ffdacdc7fa..32d53c5069af 100644
@@ -3250,4 +3250,7 @@ extern const struct iomap_ops ext4_iomap_ops;
 #define EFSBADCRC	EBADMSG		/* Bad CRC detected */
 #define EFSCORRUPTED	EUCLEAN		/* Filesystem is corrupted */
 
+int bootfs_sync_fs(struct super_block *sb);
+int bootfs_release_file(struct file *file);
+
 #endif	/* _EXT4_H */
fs/ext4/file.c +1 -1
index 98ec11f69cd4..393a03e7a311 100644
@@ -100,7 +100,7 @@ static int ext4_release_file(struct inode *inode, struct file *filp)
 	if (is_dx(inode) && filp->private_data)
 		ext4_htree_free_dir_info(filp->private_data);
 
-	return 0;
+	return bootfs_release_file(filp);
 }
 
 static void ext4_unwritten_wait(struct inode *inode)
fs/ext4/fsync.c +3 -0
index 5508baa11bb6..ff55ac5c1635 100644
@@ -158,6 +158,9 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		if (!ret)
 			ret = err;
 	}
+
+	if (!ret)
+		ret = bootfs_sync_fs(inode->i_sb);
 out:
 	err = file_check_and_advance_wb_err(file);
 	if (ret == 0)
fs/ext4/super.c +152 -0

206 lines not on this page · raw message

#1 lore raw

PATCH 1/1 e2fsprogs: create tools for formatting and fscking bootfs

From: Darrick J. Wong <[email protected]>

Create tools and documentation for our new simple bootloader filesystem.

---
 e2fsck/Makefile.in  |    4 ++--
 misc/Makefile.in    |    8 ++++----
 misc/ext4.5.in      |    5 +++++
 misc/mke2fs.conf.in |    3 +++
 4 files changed, 14 insertions(+), 6 deletions(-)
e2fsck/Makefile.in +2 -2
index 9799274fa..69bd244d7 100644
@@ -196,7 +196,7 @@ install: $(PROGS) $(MANPAGES) $(FMANPAGES) installdirs
 		$(ES) "	INSTALL $(root_sbindir)/$$i"; \
 		$(INSTALL_PROGRAM) $$i $(DESTDIR)$(root_sbindir)/$$i; \
 	done
-	$(Q) for i in ext2 ext3 ext4; do \
+	$(Q) for i in ext2 ext3 ext4 bootfs; do \
 		$(ES) "	LINK $(root_sbindir)/fsck.$$i"; \
 		(cd $(DESTDIR)$(root_sbindir); \
 			$(LN) $(LINK_INSTALL_FLAGS) e2fsck fsck.$$i); \
@@ -215,7 +215,7 @@ install: $(PROGS) $(MANPAGES) $(FMANPAGES) installdirs
 		$(ES) "	INSTALL_DATA $(man5dir)/$$i"; \
 		$(INSTALL_DATA) $$i $(DESTDIR)$(man5dir)/$$i; \
 	done
-	$(Q) for i in ext2 ext3 ext4; do \
+	$(Q) for i in ext2 ext3 ext4 bootfs; do \
 		$(ES) "	LINK $(man8dir)/fsck.$$i.8"; \
 		(cd $(DESTDIR)$(man8dir); \
 			$(LN) $(LINK_INSTALL_FLAGS) e2fsck.8 fsck.$$i.8); \
misc/Makefile.in +4 -4
index 22c984893..c961f26fd 100644
@@ -545,7 +545,7 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
 		$(ES) "	INSTALL $(sbindir)/$$i"; \
 		$(INSTALL_PROGRAM) $$i $(DESTDIR)$(sbindir)/$$i; \
 	done
-	$(Q) for i in ext2 ext3 ext4; do \
+	$(Q) for i in ext2 ext3 ext4 bootfs; do \
 		$(ES) "	LINK $(root_sbindir)/mkfs.$$i"; \
 		(cd $(DESTDIR)$(root_sbindir); \
 			$(LN) $(LINK_INSTALL_FLAGS) mke2fs mkfs.$$i); \
@@ -576,7 +576,7 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
 	done
 	$(Q) $(RM) -f $(DESTDIR)$(man8dir)/mkfs.ext2.8.gz \
 		$(DESTDIR)$(man8dir)/mkfs.ext3.8.gz
-	$(Q) for i in ext2 ext3 ext4; do \
+	$(Q) for i in ext2 ext3 ext4 bootfs; do \
 		$(ES) "	LINK mkfs.$$i.8"; \
 		(cd $(DESTDIR)$(man8dir); \
 			$(LN) $(LINK_INSTALL_FLAGS) mke2fs.8 mkfs.$$i.8); \
@@ -595,7 +595,7 @@ install: all $(SMANPAGES) $(UMANPAGES) installdirs
 		$(ES) "	INSTALL_DATA $(man5dir)/$$i"; \
 		$(INSTALL_DATA) $$i $(DESTDIR)$(man5dir)/$$i; \
 	done
-	$(Q) for i in ext2 ext3; do \
+	$(Q) for i in ext2 ext3 bootfs; do \
 		$(ES) "	LINK $$i.5"; \
 		(cd $(DESTDIR)$(man5dir); \
 			$(LN) $(LINK_INSTALL_FLAGS) ext4.5 $$i.5); \
@@ -674,7 +674,7 @@ uninstall:
 	for i in $(FMANPAGES); do \
 		$(RM) -f $(DESTDIR)$(man5dir)/$$i; \
 	done
-	$(Q) for i in ext2 ext3; do \
+	$(Q) for i in ext2 ext3 bootfs; do \
 		$(ES) "	LINK $$i.5"; \
 		$(RM) -f $(DESTDIR)$(man5dir)/$$i.5; \
 	done
misc/ext4.5.in +5 -0
index ee5e17097..7eff9c1d1 100644
@@ -9,6 +9,8 @@ ext2 \- the second extended file system
 ext3 \- the third extended file system
 .br
 ext4 \- the fourth extended file system
+.br
+bootfs \- the simple bootloader file system
 .SH DESCRIPTION
 The second, third, and fourth extended file systems, or ext2, ext3, and
 ext4 as they are commonly known, are Linux file systems that have
@@ -19,6 +21,9 @@ previously intended for use with the ext2 and ext3 file systems can be
 mounted using the ext4 file system driver, and indeed in many modern
 Linux distributions, the ext4 file system driver has been configured
 to handle mount requests for ext2 and ext3 file systems.
+bootfs is a simple bootloader filesystem that trades thirty years' worth of
+filesystem design and speed improvements for safety in the face of poorly
+written userspace software and bootloaders; it is basically ext3 with extents.
 .SH FILE SYSTEM FEATURES
 A file system formatted for ext2, ext3, or ext4 can have some
 collection of the following file system feature flags enabled.  Some of
misc/mke2fs.conf.in +3 -0
index 00afd9128..b60f86f6d 100644
@@ -10,6 +10,9 @@
 	ext3 = {
 		features = has_journal
 	}
+	bootfs = {
+		features = has_journal,extent
+	}
 	ext4 = {
 		features = has_journal,extent,huge_file,flex_bg,metadata_csum,64bit,dir_nlink,extra_isize
 		inode_size = 256
Acked-by on v1 1/1
#2 lore raw
In reply to Darrick J. Wong
Quoted 24 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Does your computer use a bootloader which arrogantly declares that it can read boot files off a filesystem but isn't sophisticated enough even to recognize when that filesystem needs journal recovery?

Does your system software deployment program foolishly omit system calls to flush newly unwrapped packages to disk? Do you sometimes wonder if they've forgotten that old maxim, "wait for the disk drive light to turn off /before/ you power down"?

Are your computer operators aggressively derpy? Do they have a habit of leaving disk cables on the floor so they can trip over them twenty times a day? Does this leave you with sad files full of zeroes?

If so, bootfs is for you! This new filesystem type uses journalling to ensure metadata integrity, but forces all writes and directory tree updates to be synchronous, fsyncs files on close, and checkpoints its journal whenever a synchronization event happens. Some allege this is very slow, but I've been able to max out the iops on both of my double height floppy drives! In a power-cycling stress test, I found that the switch broke off in my hand before I lost any data. This concept may sound terrible, but like any good crutch, it _is_ made of wood!

Quoted 1 line

^^^^^^^^^^

Ooooo - such a hot topic! Finally bootfs is more than just we-really-should-do-this conference talk!

Looks good to me - with this we can finally move on from LILO....

FWIW, Should this have a cc: [email protected] tag on it so it gets out into distro-world ASAP?

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#3 lore raw
Quoted 25 lines · Dave Chinner
Quoted 24 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Does your computer use a bootloader which arrogantly declares that it can read boot files off a filesystem but isn't sophisticated enough even to recognize when that filesystem needs journal recovery?

Does your system software deployment program foolishly omit system calls to flush newly unwrapped packages to disk? Do you sometimes wonder if they've forgotten that old maxim, "wait for the disk drive light to turn off /before/ you power down"?

Are your computer operators aggressively derpy? Do they have a habit of leaving disk cables on the floor so they can trip over them twenty times a day? Does this leave you with sad files full of zeroes?

If so, bootfs is for you! This new filesystem type uses journalling to ensure metadata integrity, but forces all writes and directory tree updates to be synchronous, fsyncs files on close, and checkpoints its journal whenever a synchronization event happens. Some allege this is very slow, but I've been able to max out the iops on both of my double height floppy drives! In a power-cycling stress test, I found that the switch broke off in my hand before I lost any data. This concept may sound terrible, but like any good crutch, it _is_ made of wood!

Quoted 7 lines
Quoted 1 line

^^^^^^^^^^

Ooooo - such a hot topic! Finally bootfs is more than just we-really-should-do-this conference talk!

Looks good to me - with this we can finally move on from LILO....

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 4 lines

FWIW, Should this have a cc: [email protected] tag on it so it gets out into distro-world ASAP?

Eh, I was going to let AI autoselect it...

--D

Quoted 6 lines

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#4 lore raw
Quoted 35 lines · Darrick J. Wong
Quoted 25 lines · Dave Chinner
Quoted 24 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Does your computer use a bootloader which arrogantly declares that it can read boot files off a filesystem but isn't sophisticated enough even to recognize when that filesystem needs journal recovery?

Does your system software deployment program foolishly omit system calls to flush newly unwrapped packages to disk? Do you sometimes wonder if they've forgotten that old maxim, "wait for the disk drive light to turn off /before/ you power down"?

Are your computer operators aggressively derpy? Do they have a habit of leaving disk cables on the floor so they can trip over them twenty times a day? Does this leave you with sad files full of zeroes?

If so, bootfs is for you! This new filesystem type uses journalling to ensure metadata integrity, but forces all writes and directory tree updates to be synchronous, fsyncs files on close, and checkpoints its journal whenever a synchronization event happens. Some allege this is very slow, but I've been able to max out the iops on both of my double height floppy drives! In a power-cycling stress test, I found that the switch broke off in my hand before I lost any data. This concept may sound terrible, but like any good crutch, it _is_ made of wood!

Quoted 7 lines
Quoted 1 line

^^^^^^^^^^

Ooooo - such a hot topic! Finally bootfs is more than just we-really-should-do-this conference talk!

Looks good to me - with this we can finally move on from LILO....

Quoted 8 lines

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Wouldn't it be enough if Grub marked the file IMMUTABLE so that it didn't get remapped/rewritten? The RPM pre/post kernel update scripts already have hooks to rerun grub and update /etc/grub.conf, so they should also be able to handle set/clear of the immutable flag during upgrade.

Cheers, Andreas

#5 lore raw
Quoted 41 lines · Andreas Dilger
Quoted 40 lines · Darrick J. Wong
Quoted 25 lines · Dave Chinner
Quoted 24 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Does your computer use a bootloader which arrogantly declares that it can read boot files off a filesystem but isn't sophisticated enough even to recognize when that filesystem needs journal recovery?

Does your system software deployment program foolishly omit system calls to flush newly unwrapped packages to disk? Do you sometimes wonder if they've forgotten that old maxim, "wait for the disk drive light to turn off /before/ you power down"?

Are your computer operators aggressively derpy? Do they have a habit of leaving disk cables on the floor so they can trip over them twenty times a day? Does this leave you with sad files full of zeroes?

If so, bootfs is for you! This new filesystem type uses journalling to ensure metadata integrity, but forces all writes and directory tree updates to be synchronous, fsyncs files on close, and checkpoints its journal whenever a synchronization event happens. Some allege this is very slow, but I've been able to max out the iops on both of my double height floppy drives! In a power-cycling stress test, I found that the switch broke off in my hand before I lost any data. This concept may sound terrible, but like any good crutch, it _is_ made of wood!

Quoted 7 lines
Quoted 1 line

^^^^^^^^^^

Ooooo - such a hot topic! Finally bootfs is more than just we-really-should-do-this conference talk!

Looks good to me - with this we can finally move on from LILO....

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

Quoted 8 lines
Quoted 3 lines

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Wouldn't it be enough if Grub marked the file IMMUTABLE so that it didn't get remapped/rewritten? The RPM pre/post kernel update scripts already have hooks to rerun grub and update /etc/grub.conf, so they should also be able to handle set/clear of the immutable flag during upgrade.

It would not, because the fundamental problem (with grub) is that it stumbles if the log hasn't been checkpointed. The transaction to add the immutable flag will just end up pending in the log like any other metadata change, because that doesn't force a log checkpoint.

(Unless you're suggesting that adding IMMUTABLE also checkpoint the log, which would be a lot of disk writing work...)

--D

Quoted 6 lines

Cheers, Andreas

maintainer
#6 lore raw
In reply to Darrick J. Wong
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

That's not guaranteed to work for all file systems, of course. So the right answer may be to define a new IOCTL which causes all file system to do whatever log truncation is needed so that grub will do the right thing.

- Ted

#7 lore raw
Quoted 11 lines · Theodore Ts'o
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 5 lines

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

Certain operating systems have hacked this in. My concern would be when /boot is on / ... calling FIFREEZE on the root fs would most likely be a bad thing. Certain operating systems avoid calling FIFREEZE for /boot-on-root. ;)

Doing it for a standalone /boot seems like a reasonable (if hacky) workaround as long as we lack a more targeted quiesce interface...

-Eric

Quoted 7 lines

That's not guaranteed to work for all file systems, of course. So the right answer may be to define a new IOCTL which causes all file system to do whatever log truncation is needed so that grub will do the right thing.

- Ted

#8 lore raw
Quoted 18 lines · Eric Sandeen
Quoted 11 lines · Theodore Ts'o
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 5 lines

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

Quoted 7 lines

Certain operating systems have hacked this in. My concern would be when /boot is on / ... calling FIFREEZE on the root fs would most likely be a bad thing. Certain operating systems avoid calling FIFREEZE for /boot-on-root. ;)

Doing it for a standalone /boot seems like a reasonable (if hacky) workaround as long as we lack a more targeted quiesce interface...

The other problem we noticed is that neither the grub scripts nor the rpm package scripts bother to call fsync on the files they write (or sync after they're done to mop up after everyone else), so I figured as long as I'm ("jokingly") working around it all in kernel space, why not just go all the way? :P

Ok, I'll go work on an ioctl or something.

--D

Quoted 9 lines

-Eric

Quoted 7 lines

That's not guaranteed to work for all file systems, of course. So the right answer may be to define a new IOCTL which causes all file system to do whatever log truncation is needed so that grub will do the right thing.

- Ted

#9 lore raw
Quoted 27 lines · Darrick J. Wong
Quoted 18 lines · Eric Sandeen
Quoted 11 lines · Theodore Ts'o
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 5 lines

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

Quoted 7 lines

Certain operating systems have hacked this in. My concern would be when /boot is on / ... calling FIFREEZE on the root fs would most likely be a bad thing. Certain operating systems avoid calling FIFREEZE for /boot-on-root. ;)

Doing it for a standalone /boot seems like a reasonable (if hacky) workaround as long as we lack a more targeted quiesce interface...

Quoted 7 lines

The other problem we noticed is that neither the grub scripts nor the rpm package scripts bother to call fsync on the files they write (or sync after they're done to mop up after everyone else), so I figured as long as I'm ("jokingly") working around it all in kernel space, why not just go all the way? :P

Ok, I'll go work on an ioctl or something.

FWIW, I didn't mean that I didn't like bootfs! I kind of like bootfs!

-Eric

#10 lore raw
In reply to Darrick J. Wong
Quoted 28 lines · Darrick J. Wong
Quoted 18 lines · Eric Sandeen
Quoted 11 lines · Theodore Ts'o
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 5 lines

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

Quoted 7 lines

Certain operating systems have hacked this in. My concern would be when /boot is on / ... calling FIFREEZE on the root fs would most likely be a bad thing. Certain operating systems avoid calling FIFREEZE for /boot-on-root. ;)

Doing it for a standalone /boot seems like a reasonable (if hacky) workaround as long as we lack a more targeted quiesce interface...

Quoted 7 lines

The other problem we noticed is that neither the grub scripts nor the rpm package scripts bother to call fsync on the files they write (or sync after they're done to mop up after everyone else), so I figured as long as I'm ("jokingly") working around it all in kernel space, why not just go all the way? :P

Ok, I'll go work on an ioctl or something.

If Grub isn't even bothering to call fsync() on a file, what is the chance that they would call a special ioctl on the file?

What about doing "chattr +S /boot" so that all file IO in this directory is done synchronously, which would work even if /boot is not on a separate filesystem? The "+S" flag is inherited by new files created in the directory.

Cheers, Andreas

#11 lore raw
Quoted 35 lines · Andreas Dilger
Quoted 34 lines · Darrick J. Wong
Quoted 18 lines · Eric Sandeen
Quoted 11 lines · Theodore Ts'o
Quoted 9 lines · Darrick J. Wong

When Ted is done laughing, I really would like to consider something like this to solve the problem of grub-style bootloaders requiring a lease on the blocks underneath a file with a term exceeding that of the running kernel.

We can probably skip the harsh synchronous writes in favor of fsync on close, but we would need to keep the critical component of checkpointing the journal on fsync and syncfs.

Quoted 5 lines

At least for ext4, we don't need to add anything new, since FIFREEZE force a journal checkpoint. So we could try to get a patch into grub which causes update_grub to open each kernel that it finds, and calls fsync(2) on it, and then for all file systems where it finds a kernel, it can call FIFREEZE and FITHAW on it, and that would be that.

Quoted 7 lines

Certain operating systems have hacked this in. My concern would be when /boot is on / ... calling FIFREEZE on the root fs would most likely be a bad thing. Certain operating systems avoid calling FIFREEZE for /boot-on-root. ;)

Doing it for a standalone /boot seems like a reasonable (if hacky) workaround as long as we lack a more targeted quiesce interface...

The other problem we noticed is that neither the grub scripts nor the rpm package scripts bother to call fsync on the files they write (or sync after they're done to mop up after everyone else), so I figured as long as I'm ("jokingly") working around it all in kernel space, why not just go all the way? :P

Quoted 4 lines
Quoted 1 line

Ok, I'll go work on an ioctl or something.

If Grub isn't even bothering to call fsync() on a file, what is the chance that they would call a special ioctl on the file?

Well yes, that is the justification for the existence of bootfs, isn't it? :)

Quoted 3 lines

What about doing "chattr +S /boot" so that all file IO in this directory is done synchronously, which would work even if /boot is not on a separate filesystem? The "+S" flag is inherited by new files created in the directory.

That also isn't sufficient, since it doesn't solve the problem of grub needing the journal/log to be checkpointed.

(I mean, unless you meant chattr +S on *bootfs* instead of its forced -o sync,dirsync funniness?)

--D

Quoted 6 lines

Cheers, Andreas