Linux EXT4 FS development
 help / color / mirror / Atom feed
From: "Theodore Tso" <tytso@mit.edu>
To: Nandakumar Raghavan <naraghavan@linux.microsoft.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	linux-ext4@vger.kernel.org, adilger@dilger.ca,
	srivatsa@csail.mit.edu
Subject: Re: [PATCH v2] e2fsck: take flock(LOCK_EX) on whole-disk device during filesystem check
Date: Thu, 27 Aug 2026 17:01:09 -0400	[thread overview]
Message-ID: <apCRFu5vpNxRLO8Y@mit.edu> (raw)
In-Reply-To: <ao7ygPaBH1AVudFR@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>

On Wed, Aug 26, 2026 at 07:04:48AM -0500, Nandakumar Raghavan wrote:
> This was on purpose and not something I missed. The sd_device_get_parent_with_subsystem_devtype
> requires libsystemd v251+, and e2fsck needs to keep working in contexts where
> that dependency isn't available or isn't guaranteed to be new enough - non-systemd distros, older
> LTS systems doing root-fs repair before userspace is fully up, embedded/recovery images, etc.

Cqn you name any other OS that has implemented

	https://systemd.io/BLOCK_DEVICE_LOCKING/

*other* than systemd?  So for non-systemd distros, who cares if we
don't have the functionality?  So what we could do is to use autoconf
with something like this:

AC_CHECK_LIB(libsystemd, sd_device_get_parent_with_subsystem_devtype,
	AC_DEFINE(HAVE_SD_DEVICE_GET_PARENT_WITH_SUBSYSTEM_DEVTYPE, 1,
		[Define to 1 if libsystemd has sd_device_get_parent_with_subsystem_devtype]))

We would only do the flock(LOCK_EX) if and only if the function is
present.  If it isn't, say on MacOS, FreeBSD, or RHEL 7 we won't play
the systemd locking game --- which is fine, because it doesn't matter
on those platforms.

If you care about running e2fsck built on RHEL 8 on RHEL 7, that's an
easy problem to solve.  A executable linked using shared libraries
won't work already since the shared libraries on RHEL 8 are too new.
But we have a solution already, which is to use e2fsck.static, which
is statically linked.

> Taking a hard runtime dependency on a versioned libsystemd API for a tool this fundamental felt
> like a much bigger cost than by parsing (/sys/dev/block/MAJ:MIN/partition, .../dev), which only
> relies on a stable kernel ABI with no library and no version floor. Happy to reconsider if
> the project wants to take the dependency, but wanted to flag the tradeoff explicitly rather
> than silently pick one side.

If we really cared about taking a binary built on a system with
libsystemd. and running on a system without libsystemd, another
solution that we've used is dlopen.

For an example of that's done, see misc/create_inode_libarchve.c and
the associated autoconf tests in configure.ac in the e2fsprogs
sources.  This is how "mke2fs -d embed_rootfs.tar.gz -t ext4 embed.img
1G" is handled without needing a hard dependency on libarchive being
installed.  If it's not installed then you'll just get the error
message "you need libarchive to be able to process tarballs".

I don't think the dlopen() approach is needed here, though.

Cheers,

					- Ted

  parent reply	other threads:[~2026-08-27 21:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 14:32 [PATCH] e2fsck: take flock(LOCK_EX) on whole-disk device during filesystem check Nandakumar Raghavan
2026-08-15  5:29 ` Nandakumar Raghavan
2026-08-18 22:44   ` Andreas Dilger
2026-08-24 13:24     ` Nandakumar Raghavan
2026-08-24 16:15       ` [PATCH v2] " Nandakumar Raghavan
2026-08-24 22:20         ` Andreas Dilger
2026-08-24 22:40         ` Darrick J. Wong
2026-08-26 14:04           ` Nandakumar Raghavan
2026-08-27  7:33             ` Andreas Dilger
2026-08-27 12:20               ` Nandakumar Raghavan
2026-08-27 21:01             ` Theodore Tso [this message]
2026-08-28 21:30         ` ddstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=apCRFu5vpNxRLO8Y@mit.edu \
    --to=tytso@mit.edu \
    --cc=adilger@dilger.ca \
    --cc=djwong@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=naraghavan@linux.microsoft.com \
    --cc=srivatsa@csail.mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox