[systemd-devel] [EXT] [PATCH] libblkid: fix spurious ext superblock checksum mismatches
Karel Zak
kzak at redhat.com
Thu Nov 21 10:44:14 UTC 2024
On Tue, Nov 19, 2024 at 09:49:57AM GMT, Theodore Ts'o wrote:
> The O_DIRECT read isn't a magic bullet.
Hmm... the nice thing about this patch is that it only uses O_DIRECT
when necessary (if the ordinary method fails). This means that it does
not add complexity or overhead to regular FS probing.
> For example, if you have a
> scratch file system which is guaranteed not to survive a Kubernetes or
> Borg container getting aborted, you might decide to format the file
> system without a jbd2 journal, since that would be more efficient, and
> by definition you don't care about the contents of the file system
> after a crash. So there are millions of ext4 file systems in
> hyperscale computing environments that are created without a journal;
> and in that case, O_DIRECT will not be sufficient for guaranteeing a
> consistent read of the superblock.
>
> In the long term, I'll probably be adding an ioctl which will allow
> userspace to read the superblock consistently for a mounted file
> system. We actually already have ioctls, EXT4_IOC_GETFSUUID and
> FS_IOC_GETFSLABEL which will allow userspace to fetch the UUID and
> Label for a mounted file system. So eventually, I'll probably end
> up adding EXT4_IOC_GET_SUPERBLOCK. Let me know if this is something
> that util-linux would very much want.
I doubt it will be helpful for us.
I believe that EXT4_IOC_GET_SUPERBLOCK will be used with a mountpoint
file descriptor, but libblkid works directly with the block device
(e.g. open(/dev/sda1)) where it searches for valid filesystems.
Another issue is that libblkid does not check if the device is
mounted, so the FS prober can be triggered in all cases. It simply
calls seek()+read() and tries to be smart.
Ideally, we would have a generic ioctl (for block devices) to ask the
kernel if a superblock at a specific location is valid.
ioctl(fd, BLKVERIFYFS, { .fsname="ext4", .offset=123456 })
This would greatly simplify the complex processes currently in
userspace, and it would remove duplicity. Currently, we have many file
system checks in libblkid to verify that the on-disk data are not
random bytes. These same checks are also present in file system
drivers when reading the superblock.
Another userspace dream ... :-)
> Note: this does require figuring out (a) whether the file system is
> mounted, and (b) if so, where is it mounted. So if blkid wants to use
> this, it would need to have something like the function
> ext2fs_check_mount_point[1].
Yes, that's not good.
Karel
--
Karel Zak <kzak at redhat.com>
http://karelzak.blogspot.com
More information about the systemd-devel
mailing list