Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH 0/4] ext4: don't fail FS_IOC_{SETFLAGS,FSSETXATTR} after applying them aka things that fell out of my uapi16 library work
@ 2026-11-30 13:22 Christian Brauner
  2026-11-30 13:22 ` [PATCH 1/4] ext4: don't lose the result of ext4_ext_migrate() Christian Brauner
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christian Brauner @ 2026-11-30 13:22 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara, linux-ext4
  Cc: linux-fsdevel, Christian Brauner (Amutable)

I'm working on a uapi16 shared library and tool that generates
filesystem manifests according to https://uapi-group.org/specifications/specs/file_manifest

It's a Rust crate + C shared library + Rust binary. It has extensive
testing and as part of that some ext4 misbehavior was detected. So
here's my attempt at fixing it:

ext4 fails FS_IOC_SETFLAGS and FS_IOC_FSSETXATTR after it has already
written part of the request. The flags and the ctime are written first
and only then is the block mapping converted, the journaling mode
switched or the project ID changed. If one of those is refused the call
fails but the flags stick. We hit this with a test that passed
FS_NODUMP_FL | FS_NOATIME_FL to FS_IOC_SETFLAGS without reading the
flags first. It got EOPNOTSUPP back with both flags set.

xfs and btrfs check everything before they write anything and then do
the whole change in a single transaction. This gets ext4 there for
everything that can share a handle. Converting to block mapping and
changing the project ID now happen in the same handle as the flags.

The first patch fixes ext4_ext_migrate(). Since v5.5 it returns the
result of its last credit check instead of its own, so a conversion to
extents that fails with ENOSPC is reported as success and a restarted
handle comes back as 1. Once the conversion runs before the flags that
1 would silently drop the rest of the call.

The one real question is what to do about a cleared extent flag that
ext4 can't honor. Callers that don't start from FS_IOC_GETFLAGS leave
the flag out. Today that silently converts small files to block mapping
and fails for everything else. I'm treating it like the other visible
but unsettable flags. If anything else was asked for the rest is applied
and the call succeeds. If clearing the extent flag is all that was asked
for it still fails and nothing changes. btrfs silently leaves NOCOW
alone on a non-empty file too.

Failing and changing nothing would be stricter but it would break
restore tools that only work today because the flags stick. BorgBackup
before 1.4.2 builds its flags from scratch and ignores EOPNOTSUPP for
example. Borg switched to FS_IOC_GETFLAGS in 1.4.2 after running into
exactly this (cf. [1]) but the older releases are still around. The
downside is that repeating such a call fails the second time because
then only the extent flag differs. That's the same request as chattr -e
though so I don't see a way to tell them apart.

A refused attempt to set the extent flag, i.e., no extents feature or
inline data, still fails but doesn't apply the rest anymore. I didn't
give it the same treatment as the cleared flag. If you'd rather have
that it's a small change.

Setting the extent flag and switching the journaling mode still use
their own handles. ext4_ext_migrate() builds the new tree in a temporary
inode across several handles and the mode switch flushes the journal.
Their refusals happen before anything is written now but an I/O error
between them and the flags handle can still leave part of the change
behind.

Tested in VMs on 4k and 1k blocks with bigalloc, ext3, inline data,
buffered_iomap, dioread_lock, DAX and project quota, and with two new
fstests cases that I'll send separately.

[1]: https://github.com/borgbackup/borg/issues/9039

Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Christian Brauner (4):
      ext4: don't lose the result of ext4_ext_migrate()
      ext4: don't fail FS_IOC_SETFLAGS after applying it
      ext4: split the flag checks out of ext4_ioctl_setflags()
      ext4: don't fail FS_IOC_FSSETXATTR after applying it

 fs/ext4/ext4.h    |   3 +-
 fs/ext4/ioctl.c   | 333 ++++++++++++++++++++++++++++++------------------------
 fs/ext4/migrate.c |  69 ++++++-----
 3 files changed, 218 insertions(+), 187 deletions(-)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261130-work-ext4-setflags_migrate-41e19f46f4e1


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

end of thread, other threads:[~2026-11-30 13:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 13:22 [PATCH 0/4] ext4: don't fail FS_IOC_{SETFLAGS,FSSETXATTR} after applying them aka things that fell out of my uapi16 library work Christian Brauner
2026-11-30 13:22 ` [PATCH 1/4] ext4: don't lose the result of ext4_ext_migrate() Christian Brauner
2026-11-30 13:22 ` [PATCH 2/4] ext4: don't fail FS_IOC_SETFLAGS after applying it Christian Brauner
2026-11-30 13:22 ` [PATCH 3/4] ext4: split the flag checks out of ext4_ioctl_setflags() Christian Brauner
2026-11-30 13:22 ` [PATCH 4/4] ext4: don't fail FS_IOC_FSSETXATTR after applying it Christian Brauner
2026-11-30 13:39 ` [PATCH 0/4] ext4: don't fail FS_IOC_{SETFLAGS,FSSETXATTR} after applying them aka things that fell out of my uapi16 library work sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox