]> git.ipfire.org Git - thirdparty/e2fsprogs.git/log
thirdparty/e2fsprogs.git
2 months agotests/f_opt_extent: use tune2fs from the build tree in the test script master
Theodore Ts'o [Fri, 3 Apr 2026 15:20:06 +0000 (11:20 -0400)] 
tests/f_opt_extent: use tune2fs from the build tree in the test script

There may not be tune2fs installed as a system binary, so use the
tune2fs from the build tree to provide hermetic testing.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agofuse2fs: fix build failure on systems which don't define EUCLEAN
Theodore Ts'o [Fri, 3 Apr 2026 03:53:27 +0000 (23:53 -0400)] 
fuse2fs: fix build failure on systems which don't define EUCLEAN

MacOS doesn't have EUCLEAN, so we use EIO as the closest error code.
But then we need to avoid a compile error caused by a duplicate case
labels of EUCLEAN and EIO.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibsupport: add a portable get_thread_id() function
Theodore Ts'o [Fri, 3 Apr 2026 02:54:13 +0000 (22:54 -0400)] 
libsupport: add a portable get_thread_id() function

The gettid() system call is only available on Linux.  So create a new
function, get_thread_id() which implements a number of different ways
of providing a thread id as an integer.

Use get_thread_id() instead of gettid() in fuse2fs.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agolibsupport: fix portability issues with the bthread.c
Theodore Ts'o [Fri, 3 Apr 2026 01:27:34 +0000 (21:27 -0400)] 
libsupport: fix portability issues with the bthread.c

The function pthread_setname_np() is non-portable; that's what the
"np" means.  In particular, on Mac systems, the function takes only a
single argument, while on most other systems which have the function,
it takes two arguments.

Also fix a problem where a 1-bit signed integer can only accept values
of 0 or -1.  Change it to be a 1-bit unsigned integer, which can
accept values of 0 or 1.  Clang will issue a warning if 1-bit signed
integer are used incorrectly, and fail with -Werror.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoMerge tag 'tags/fuse2fs-writability_2026-03-12' into next
Theodore Ts'o [Thu, 2 Apr 2026 13:59:16 +0000 (09:59 -0400)] 
Merge tag 'tags/fuse2fs-writability_2026-03-12' into next

fuse2fs: better tracking of writable state [07/18]

There are multiple mutability variables in play in fuse2fs -- first,
EXT2_FLAG_RW tracks whether or not we can write anything to the
filesystem.  However, there's a second state, which is whether or not
we actually want to write to the filesystem, regardless of the library
state.  This can happen if we open libext2fs for writing, but then
discover something about the filesystem that makes us not want to write
to it after all.

Split out this second variable into an explicit variable in fuse2fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agoMerge tag 'tags/fuse2fs-tracing_2026-03-12' into next
Theodore Ts'o [Thu, 2 Apr 2026 13:57:30 +0000 (09:57 -0400)] 
Merge tag 'tags/fuse2fs-tracing_2026-03-12' into next

fuse2fs: improve operation tracing [06/18]

This series improves the ability for developers to trace the activities
of fuse2fs by adding more debugging printfs and tracing abilities of
fuse2fs.  It also registers a com_err handler for libext2fs so we can
capture errors coming out of there, and changes filesystem error
reporting to tell us the function name instead of just fuse2fs.c.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agoMerge tag 'tags/fuse2fs-refactor-mounting_2026-03-12' into next
Theodore Ts'o [Thu, 2 Apr 2026 13:52:23 +0000 (09:52 -0400)] 
Merge tag 'tags/fuse2fs-refactor-mounting_2026-03-12' into next

fuse2fs: refactor mount code [05/18]

Here, we hoist the mounting code out of main() into a pile of separate
helper functions to reduce the complexity of understanding the mount
code.  This isn't strictly required for iomap, but it makes main() a lot
easier to understand.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agoMerge tag 'tags/fuse2fs-refactor-unmounting_2026-03-12' into next
Theodore Ts'o [Thu, 2 Apr 2026 13:50:52 +0000 (09:50 -0400)] 
Merge tag 'tags/fuse2fs-refactor-unmounting_2026-03-12' into next

fuse2fs: refactor unmount code [04/18]

In this series, we refactor the code around ext2fs_close to get ready
for iomap mode.  The significant part of this series is moving the
unmount code to op_destroy, because we want to release the block device
as a part of the umount(2) process to maintain expected behavior of the
in-kernel local filesystem drivers.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agoMerge tag 'tags/fuse2fs-refactor-operation-startup_2026-03-12' into next
Theodore Ts'o [Thu, 2 Apr 2026 13:45:56 +0000 (09:45 -0400)] 
Merge tag 'tags/fuse2fs-refactor-operation-startup_2026-03-12' into next

fuse2fs: clean up operation startup [03/18]

Reduce the amount of boilerplate in fuse2fs by creating helper functions
to start and finish a file operation instead of open-coding the logic
all over the place.  This also fixes a couple of theoretical races.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agotests: update tests after improving dir_index support
Theodore Ts'o [Thu, 2 Apr 2026 12:46:10 +0000 (08:46 -0400)] 
tests: update tests after improving dir_index support

Commit f3c5e16bc36c ("libext2fs: initialize htree when expanding
directory") allows libext2fs to better support htree directories.
This breaks a number of e2fsprogs regression tests because it changes
the expected output.  Fix these up.

Fixes: f3c5e16bc36c ("libext2fs: initialize htree when expanding directory")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoMerge tag 'fuse2fs-new-features_2026-03-13' into next
Theodore Ts'o [Thu, 19 Mar 2026 14:58:13 +0000 (10:58 -0400)] 
Merge tag 'fuse2fs-new-features_2026-03-13' into next

fuse2fs: add some easy new features [02/18]

As of 2025, libfuse is a lot more capable than it was in 2013.
Implement some new features such as readdirplus and directory seeking
for better directory performance, and reduce the amount of filesystem
flushing so that it only happens when userspace explicitly asks for it.
Now we also can add htree indices to large directories, support MMP in
fuse2fs, and link count overflows are handled correctly.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agoMerge tag 'fuse2fs-locking_2026-03-12' into next
Theodore Ts'o [Thu, 19 Mar 2026 14:42:27 +0000 (10:42 -0400)] 
Merge tag 'fuse2fs-locking_2026-03-12' into next

fuse2fs: fix locking problems [01/18]

Teach fuse2fs to flock the file(s) underlying the filesystem if the fs
is stored in a regular file, so that we don't have to create and
maintain separate lockfiles.

For block devices, fix a weird race between mount and unmount that is
causing testing failures by waiting a small amount of time to grab a
lock.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: fix orphan file size > kernel limit with large blocksize
Baokun Li [Thu, 20 Nov 2025 13:55:14 +0000 (21:55 +0800)] 
libext2fs: fix orphan file size > kernel limit with large blocksize

Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
limits the maximum supported orphan file size to 8 << 20.

However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
blocks when creating a filesystem.

With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
than the kernel allows, so mount prints an error and fails:

    EXT4-fs (vdb): orphan file too big: 8650752
    EXT4-fs (vdb): mount failed

Thus, orphan file size is capped at 512 filesystem blocks in both e2fsprogs
and the kernel.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Message-ID: <20251120135514.3013973-1-libaokun@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agoRevert "libext2fs: fix orphan file size > kernel limit with large blocksize"
Theodore Ts'o [Thu, 12 Mar 2026 19:35:05 +0000 (15:35 -0400)] 
Revert "libext2fs: fix orphan file size > kernel limit with large blocksize"

This reverts commit 6f03c698ef53bb9d0cd42c9bd0b68e8ce72f8345.

    Due to missing parenthesis around the #defines for
    EXT4_{MAX,DEFAULT}_ORPHAN_FILE_SIZE, the default number of blocks
    assigned to the orphan file was calculated as 2 when the file system
    has more than 2**21 blocks:

       % mke2fs  -t ext4 -Fq /tmp/foo.img 8191M
       /tmp/foo.img contains a ext4 file system
               created on Wed Mar 11 09:54:04 2026
       % debugfs -R "extents <12>" /tmp/foo.img
       debugfs 1.47.4 (6-Mar-2025)
       Level Entries       Logical          Physical Length Flags
        0/ 0   1/  1     0 -   510    9255 -    9765    511

       % mke2fs  -t ext4 -Fq /tmp/foo.img 8192M
       /tmp/foo.img contains a ext4 file system
               created on Wed Mar 11 09:54:11 2026
       % debugfs -R "extents <12>" /tmp/foo.img
       debugfs 1.47.4 (6-Mar-2025)
       Level Entries       Logical          Physical Length Flags
        0/ 0   1/  1     0 -     1    9255 -    9256      2  <======

The problem addressed by the reverted commit will fixed via the next
commit.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2 months agofuse2fs: enable the shutdown ioctl
Darrick J. Wong [Thu, 28 Aug 2025 17:30:45 +0000 (10:30 -0700)] 
fuse2fs: enable the shutdown ioctl

Implement a bastardized version of EXT4_IOC_SHUTDOWN, because the people
who invented the ioctl got the direction wrong, so we can't actually
read the flags.  So all we do is flush the filesystem, clear the
writable flags, and hope that's what the user wanted.

Since we change __FUSE2FS_CHECK_CONTEXT to return an error code on a
shut down filesystem, remove FUSE2FS_CHECK_CONTEXT_RETURN so that
op_destroy always tears everything down and logs the unmount message.
Later on in the iomap patchset this will become critical because we need
to try to close the block device before unmount completes to avoid
problems with fstests.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: record thread id in debug trace data
Darrick J. Wong [Thu, 28 Aug 2025 17:30:44 +0000 (10:30 -0700)] 
fuse2fs: record thread id in debug trace data

Record the thread ID in the debug trace data so that we can trace
operations going through the fuse server more easily.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: track our own writable state
Darrick J. Wong [Thu, 28 Aug 2025 17:30:45 +0000 (10:30 -0700)] 
fuse2fs: track our own writable state

Track our own willingness to write to the filesystem in a separate
variable from that of libext2fs.  There's a small window between opening
the filesystem and mounting it where the library is rw but we might fail
a mount task and therefore don't want to write anything more.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: pass a struct fuse2fs to fs_writeable
Darrick J. Wong [Thu, 28 Aug 2025 17:30:44 +0000 (10:30 -0700)] 
fuse2fs: pass a struct fuse2fs to fs_writeable

Pass the outer fuse2fs context to fs_writable in preparation for the
next patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: adjust OOM killer score if possible
Darrick J. Wong [Wed, 22 Oct 2025 16:52:52 +0000 (09:52 -0700)] 
fuse2fs: adjust OOM killer score if possible

Users don't like it when their filesystems go down unexpectedly.  Set
the OOM score adjustment to -500 to try to prevent this, particularly
because fuse2fs doesn't support journal transactions.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: hoist unmount code from main
Darrick J. Wong [Thu, 28 Aug 2025 17:30:42 +0000 (10:30 -0700)] 
fuse2fs: hoist unmount code from main

Hoist the unmount code into a separate function so that we can reduce
the complexity of main().  This also sets us up for unmounting the
filesystem from op_destroy, which we'll need for fuse2fs+iomap mode to
maintain the expected behavior that the block device is free when
umount(8) returns.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: collect runtime of various operations
Darrick J. Wong [Thu, 28 Aug 2025 17:30:42 +0000 (10:30 -0700)] 
fuse2fs: collect runtime of various operations

Collect the run time of various operations so that we can do some simple
profiling.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: improve tracing for file range operations
Darrick J. Wong [Thu, 28 Aug 2025 17:30:44 +0000 (10:30 -0700)] 
fuse2fs: improve tracing for file range operations

Improve the tracing for read, write, readdir, and fallocate by reporting
the inode number and the file range in all tracepoints relating to file
IO.  Make the file ranges hexadecimal to make it easier for the
programmer to convert bytes to block numbers and back.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: register as an IO flusher thread
Darrick J. Wong [Thu, 28 Aug 2025 17:30:43 +0000 (10:30 -0700)] 
fuse2fs: register as an IO flusher thread

fuse2fs is involved in the filesystem I/O path and can allocate memory
while processing I/O requests.  Therefore, we need to register that fact
with the kernel so that memory allocations done by libext2fs don't start
a round of filesystem memory reclaim, which could cause more writeout to
get dumped on fuse2fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: hoist lockfile code
Darrick J. Wong [Thu, 28 Aug 2025 17:30:42 +0000 (10:30 -0700)] 
fuse2fs: hoist lockfile code

Hoist the lockfile handling code into separate helpers before we start
rearranging the code that opens and closes filesystems.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: clean up more boilerplate
Darrick J. Wong [Thu, 28 Aug 2025 17:30:41 +0000 (10:30 -0700)] 
fuse2fs: clean up more boilerplate

Clean up these opencoded bits everywhere.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: print the function name in error messages, not the file name
Darrick J. Wong [Thu, 28 Aug 2025 17:30:44 +0000 (10:30 -0700)] 
fuse2fs: print the function name in error messages, not the file name

It would be nice to know which fuse op actually causes failures such as:
FUSE2FS (sda4): Directory block checksum does not match directory block at ../../misc/fuse2fs.c:819.

The filename is utterly pointless, there's only one for the whole
daemon.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: split filesystem mounting into helper functions
Darrick J. Wong [Thu, 28 Aug 2025 17:30:42 +0000 (10:30 -0700)] 
fuse2fs: split filesystem mounting into helper functions

Break up main() by moving the filesystem mounting logic into separate
helper functions.  This originally made it easier to move that part
around for fuseblk support, and I kept it around because splitting up
the mounting code into multiple smaller functions makes them easier to
understand.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: get rid of the global_fs variable
Darrick J. Wong [Thu, 28 Aug 2025 17:30:42 +0000 (10:30 -0700)] 
fuse2fs: get rid of the global_fs variable

Get rid of this global variable now that we don't need it anywhere.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: clean up operation completion
Darrick J. Wong [Thu, 28 Aug 2025 17:30:41 +0000 (10:30 -0700)] 
fuse2fs: clean up operation completion

Create a helper to release the BFL and log any errors.  This cuts down
on the boilerplate.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: hook library error message printing
Darrick J. Wong [Thu, 28 Aug 2025 17:30:44 +0000 (10:30 -0700)] 
fuse2fs: hook library error message printing

Hook the com_err library so that error messages coming from libext2fs
such as:
Illegal block number passed to ext2fs_test_block_bitmap #9462 for block bitmap for /dev/sda

are actually printed with the standard "FUSE2FS (sda):" prefix.
Libraries shouldn't be printing that kind of stuff, but it is what it
is, and what it is is against the normal conventions.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: implement MMP updates
Darrick J. Wong [Mon, 6 Oct 2025 22:48:35 +0000 (15:48 -0700)] 
fuse2fs: implement MMP updates

Periodically rewrite the MMP block while we're mounted like the Linux
driver does, so that other potential users don't see EXT4_MMP_SEQ_FSCK
and erroneously report that the ext4 filesystem is being fscked.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: clean up operation startup
Darrick J. Wong [Thu, 28 Aug 2025 17:30:41 +0000 (10:30 -0700)] 
fuse2fs: clean up operation startup

Create a helper to take the BFL and give us a reference to the
ext2_filsys that we're protecting with the BFL.  This eliminates a
theoretical race with any code that sets or clears fuse2fs:fs.  But
really it just cuts down on the boilerplate.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibsupport: add background thread manager
Darrick J. Wong [Thu, 23 Oct 2025 19:17:46 +0000 (12:17 -0700)] 
libsupport: add background thread manager

Add some simple code to manage a background thread that wakes up
periodically.  This will be needed for MMP in fuse2fs, among other
things.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: move fs assignment closer to locking the bfl
Darrick J. Wong [Thu, 28 Aug 2025 17:30:41 +0000 (10:30 -0700)] 
fuse2fs: move fs assignment closer to locking the bfl

Move the "fs = ff->fs" statements closer to where we take the BFL so
that we can refactor them easily in the next patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: fix link count overflows on dir_nlink filesystems
Darrick J. Wong [Fri, 3 Oct 2025 22:14:40 +0000 (15:14 -0700)] 
fuse2fs: fix link count overflows on dir_nlink filesystems

On a dir_nlink filesystem, a dir with more than 65000 subdirs ends up
with i_links_count (aka nlink) of 1.  libext2fs wraps around and does
the wrong thing, which may have caused a lot of havoc over the years.
The kernel actually knows how to do this properly (it freezes the link
count at 1 when it would overflow) so use the helpers we added in the
previous patch to make fuse2fs behave the same as the kernel.

This is a convenient time to fix the annoying behavior that one has to
call remove_inode twice to rmdir a directory, and actually check for
link count overflows when renaming or hardlinking files.

Found via ext4/045.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: consolidate file handle checking in op_ioctl
Darrick J. Wong [Thu, 28 Aug 2025 17:30:41 +0000 (10:30 -0700)] 
fuse2fs: consolidate file handle checking in op_ioctl

Reduce code size by checking the file handle in op_ioctl dispatch
instead of every single ioctl implementation.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: improve error handling behaviors
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: improve error handling behaviors

Make the behavior of fuse2fs on filesystem errors consistent with what
the kernel driver does.  Sort of.  We can't panic the kernel, but we can
abort the server, which leaves a dead mount.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: rework fallocate file handle extraction
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: rework fallocate file handle extraction

Move the context and file handle checking to op_fallocate so that we can
pass them to the alloc/punch/zero helpers.  This eliminates redundant
checking in the zero_range path.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: constrain worker thread count
Darrick J. Wong [Thu, 28 Aug 2025 20:45:41 +0000 (13:45 -0700)] 
fuse2fs: constrain worker thread count

fuse2fs isn't all that scalable -- there's a big kernel lock around all
the libext2fs code.  Constrain the fuse worker thread count to reduce
unnecessary lock contention.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: rework checking file handles
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: rework checking file handles

We only use FUSE2FS_CHECK_MAGIC for one thing -- to check the magic
number of file handles.  Make the whole macro more specific to file
handles, and move it to the top of each function so that we don't take
locks or any other silly stuff like that.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: cache symlink targets in the kernel
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: cache symlink targets in the kernel

Speed up symlinks by allowing the kernel to cache them.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: rework FUSE2FS_CHECK_CONTEXT not to rely on global_fs
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: rework FUSE2FS_CHECK_CONTEXT not to rely on global_fs

If the fuse2fs object that libfuse hands to us has the wrong magic
number, something is clearly wrong.  In that case, we don't really want
to rely on the global_fs variable actually pointing to a valid
ext2_filsys object because something could be wrong there too.  Instead,
try to emit an error on stderr and just bail out.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: improve want_extra_isize handling
Darrick J. Wong [Thu, 28 Aug 2025 17:30:40 +0000 (10:30 -0700)] 
fuse2fs: improve want_extra_isize handling

System administrators can set the {min,want}_extra_isize fields in the
superblock to try to influence the allocation of extra space in an
inode.  Currently fuse2fs ignores any such value and sets it to the
minimum possible size; let's actually follow it, like the kernel does.

Note: fuse2fs isn't quite as flexible as the kernel is about changing
extra_isize, so this isn't quite good enough to pass ext4/022.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: only flush O_SYNC files on close
Darrick J. Wong [Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)] 
fuse2fs: only flush O_SYNC files on close

Don't call ext2fs_flush2() from op_release unless the file was opened
with either synchronous write flag.

XXX: Maybe this should be replaced with actual incore state tracking for
inodes?

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: implement dirsync mode
Darrick J. Wong [Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)] 
fuse2fs: implement dirsync mode

Implement dirsync so that we only perform full metadata flushes on
directory updates when the sysadmin explicitly wants it.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: implement readdirplus
Darrick J. Wong [Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)] 
fuse2fs: implement readdirplus

Implement "readdirplus", which I think means that we return full stat
information for directory entries as part of the readdir results.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: implement dir seeking
Darrick J. Wong [Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)] 
fuse2fs: implement dir seeking

Report (fake) directory offsets to readdir so that libfuse can send
smaller datasets to the kernel.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: use file handles when possible
Darrick J. Wong [Thu, 28 Aug 2025 17:30:39 +0000 (10:30 -0700)] 
fuse2fs: use file handles when possible

Use file handles when possible, so the f* family of file syscalls
doesn't have to do a complete path lookup for every single call.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: read bitmaps asynchronously during initialization
Darrick J. Wong [Fri, 12 Sep 2025 22:24:25 +0000 (15:24 -0700)] 
fuse2fs: read bitmaps asynchronously during initialization

The kernel reads the bitmaps asynchronously when the filesystem is
mounted.  Do this as well in fuse2fs to reduce mount times.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: check root directory while mounting
Darrick J. Wong [Fri, 12 Sep 2025 22:07:00 +0000 (15:07 -0700)] 
fuse2fs: check root directory while mounting

The kernel will fail a mount attempt if the root directory inode isn't
even minimally readable at mount time.  Do the same for fuse2fs so that
we can pass ext4/008.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: enable more caching
Darrick J. Wong [Tue, 27 Jan 2026 01:28:45 +0000 (17:28 -0800)] 
fuse2fs: enable more caching

Don't flush the pagecache when we open a file, and cache dirents when
someone asks for readdir.  Our fuse server assumes that the filesystem
isn't mounted anywhere else, so file and directory data cannot change
out from under the kernel.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: disable write access when cluster size > block size
Darrick J. Wong [Wed, 28 Jan 2026 18:00:23 +0000 (10:00 -0800)] 
fuse2fs: disable write access when cluster size > block size

The libext2fs punch functions do not handle cluster deallocation
correctly when the bigalloc cluster size is larger than a single
fsblock.  To avoid trashing these filesystems until we can fix it, mount
the filesystem in readonly mode.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: always use ext2fs_mmp_get_mem to allocate fs->mmp_buf
Darrick J. Wong [Tue, 7 Oct 2025 17:41:58 +0000 (10:41 -0700)] 
libext2fs: always use ext2fs_mmp_get_mem to allocate fs->mmp_buf

Always use our special allocator function to allocate the MMP buffer.
This will be useful in case we ever pass that buffer to ext2fs_mmp_write
on a filesystem that is opened with O_DIRECT.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: refactor aligned MMP buffer allocation
Darrick J. Wong [Tue, 7 Oct 2025 17:36:12 +0000 (10:36 -0700)] 
libext2fs: refactor aligned MMP buffer allocation

Hoist the code that allocates an MMP buffer into a separate helper.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: try to grab block device O_EXCL repeatedly
Darrick J. Wong [Tue, 21 Oct 2025 01:08:26 +0000 (18:08 -0700)] 
fuse2fs: try to grab block device O_EXCL repeatedly

generic/646 keeps failing to mount in this fashion:

 run fstests generic/646 at 2025-10-20 17:10:26
 [U] FUSE2FS (sda4): mounted filesystem f8f21d10-2ec9-4aef-a509-b32659b4e6b0.
 fuse: EXPERIMENTAL iomap feature enabled.  Use at your own risk!
 [U] FUSE2FS (sda4): shut down requested.
 [U] FUSE2FS (sda4): unmounted filesystem f8f21d10-2ec9-4aef-a509-b32659b4e6b0.
 [U] FUSE2FS (sda4): mounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
 fuse: EXPERIMENTAL iomap feature enabled.  Use at your own risk!
 [U] FUSE2FS (sda4): shut down requested.
 [U] FUSE2FS (sda4): unmounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
 [U] FUSE2FS (sda4): mounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.
 [U] FUSE2FS (sda4): Warning: Mounting unchecked fs, running e2fsck is recommended.
 [U] FUSE2FS (sda4): Device or resource busy.
 [U] FUSE2FS (sda4): Please run e2fsck -fy.
 [U] Mount failed while opening filesystem.  Check dmesg(1) for details.
 [U] FUSE2FS (sda4): unmounted filesystem 9efc6297-74c0-448c-b253-cecffd947239.

It turns out that one can mount a fuse filesystem and unmount it before
the kernel even has a chance to send FUSE_INIT to the fuse server.  If
this occurs, the unmount code will abort the FUSE_INIT request and tear
down the fs mount immediately.

Unfortunately for fstests, the fuse server may have already opened the
block device with O_EXCL and will keep running with the bdev open until
libfuse notices that the connection to the kernel died and tells the
fuse server to destroy itself.  That might not happen for a long time
after the unmount program exits, in which case a subsequent invocation
of the fuse server can race with the dying fuse server to open the block
device.  When this happens, the new invocation fails with "Device or
resource busy".

This is exactly what's happening in this test, which is only noticeable
because it cycles the scratch mount so quickly.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: fix ext2fs_mmp_update
Darrick J. Wong [Mon, 6 Oct 2025 23:00:15 +0000 (16:00 -0700)] 
libext2fs: fix ext2fs_mmp_update

ext2fs_mmp_read has this undocumented behavior that it updates
fs->mmp_cmp and not fs->mmp_buf.  Therefore, ext2fs_mmp_update2 actually
updates a stale version of the MMP buffer and writes that out to disk.
Fortunately the only two fields that get updated regularly mmp_time and
mmp_seq so the behavior was never incorrect, but this confused me for a
while, so let's fix it.

Cc: <linux-ext4@vger.kernel.org> # v1.42
Fixes: 0f5eba7501f467 ("ext2fs: add multi-mount protection (INCOMPAT_MMP)")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: quiet down write-protect warning
Darrick J. Wong [Tue, 21 Oct 2025 20:00:15 +0000 (13:00 -0700)] 
fuse2fs: quiet down write-protect warning

No need to retry the mount with write protection if we already set ro
and cleared EXT2_FLAG_RO.

Fixes: e352b2ad174573 ("fuse2fs: mount norecovery if main block device is readonly")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: create link count adjustment helpers for dir_nlink
Darrick J. Wong [Fri, 3 Oct 2025 21:56:10 +0000 (14:56 -0700)] 
libext2fs: create link count adjustment helpers for dir_nlink

Create some helpers to deal with link count adjustments for directories
on dir_nlink filesystems that become large enough to have an htree
index.  In other words, fix the problem that creating a new child
subdirectory can overflow the link count of the parent directory.

The unused library functions created by this patch will be used in the
next patch to fix problems with fuse2fs.

Cc: <linux-ext4@vger.kernel.org> # v1.40
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agofuse2fs: try to lock filesystem image files before using them
Darrick J. Wong [Thu, 28 Aug 2025 17:30:52 +0000 (10:30 -0700)] 
fuse2fs: try to lock filesystem image files before using them

Originally, this patch added support for using flock() to protect the
files opened by the Unix IO manager so that systemd and udev could not
access the block device while e2fsprogs is doing something with the
device.  However, flocking block devices for the duration of a mount
creates stalling problems with udev, because it will not process a
uevent for a block device until it can flock(LOCK_SH) the block device.
As a result, udevsettle blocks for 2 minutes until it times out and
exits with failure.

Since libext2fs generally opens block devices (on Linux) with O_EXCL,
fuse2fs is guaranteed to be the only program accessing the filesystem if
it's on a block device.  However, O_EXCL doesn't do anything for
non-block devices, so we need a way to coordinate write access to
filesystem image files.  Use the locking code, but only if we have a
non-block device.

Link: https://systemd.io/BLOCK_DEVICE_LOCKING/
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: initialize htree when expanding directory
Darrick J. Wong [Fri, 3 Oct 2025 16:24:20 +0000 (09:24 -0700)] 
libext2fs: initialize htree when expanding directory

Teach ext2fs_link to initialize the htree when we're expanding a
directory beyond the first block.  This brings fuse2fs' behavior in line
with the kernel and dramatically improves performance.  It also is the
start of a bunch of bug fixing for ext4/045.  This is a straight port of
fs/ext4/namei.c.

This patch is needed for the next patch, which fixes the dir_nlink
functionality, because apparently the two features are intertwined.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
2 months agolibext2fs: add POSIX advisory locking to the unix IO manager
Darrick J. Wong [Tue, 21 Oct 2025 00:29:48 +0000 (17:29 -0700)] 
libext2fs: add POSIX advisory locking to the unix IO manager

Add support for using flock() to protect the files opened by the Unix IO
manager so that other fuse2fs servers cannot stomp all over the
filesystem.  We may some day want to adopt this in e2fsck.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
3 months agoUpdate release notes, etc., for the 1.47.4 release v1.47.4
Theodore Ts'o [Fri, 6 Mar 2026 16:24:44 +0000 (11:24 -0500)] 
Update release notes, etc., for the 1.47.4 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agomisc: fix a dropped line in the mke2fs.conf man page
Theodore Ts'o [Fri, 6 Mar 2026 17:13:08 +0000 (12:13 -0500)] 
misc: fix a dropped line in the mke2fs.conf man page

The transformation ".I proceed_delay" to "/fIProceed_delay/fR" left a
leading period behind, and "./fIproceed_delay/fR" was treated a
undefined roff macro.

Fixes: 29cebc07bd8f ("doc: Updated `ext4`, `mke2fs`, `mke2fs.conf`....")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agodebian: drop the kfreebsd architecture
Theodore Ts'o [Fri, 6 Mar 2026 17:02:03 +0000 (12:02 -0500)] 
debian: drop the kfreebsd architecture

This is no longer supported and causeds a Lintian error

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Fri, 6 Mar 2026 16:05:22 +0000 (11:05 -0500)] 
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agomisc: improve description of the salt in the e4crypt man page
Theodore Ts'o [Fri, 6 Mar 2026 15:52:51 +0000 (10:52 -0500)] 
misc: improve description of the salt in the e4crypt man page

Addresses-Debian-Bug: #1125176
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agoci.yml: drop building e2fsprogs on mingw32
Theodore Ts'o [Fri, 6 Mar 2026 00:14:38 +0000 (19:14 -0500)] 
ci.yml: drop building e2fsprogs on mingw32

A change in the github actions' runtime infrastructgure means that it
now take over 4 hours to run "mke2fs.exe -T ext4 image.ext4 128M".
The importance of 32-bit Windows support is much less now, so just
drop mingw32.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agofsck: fix memory leak of inst->type
Wu Guanghao [Fri, 21 Nov 2025 03:36:11 +0000 (11:36 +0800)] 
fsck: fix memory leak of inst->type

The function free_instance() does not release i->type, resulting in a
memory leak.

Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Message-ID: <20251121033612.2423536-2-wuguanghao3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agoMerge branch 'man-pages-update' of github.com:bberberov/e2fsprogs into maint
Theodore Ts'o [Thu, 5 Mar 2026 15:52:02 +0000 (10:52 -0500)] 
Merge branch 'man-pages-update' of github.com:bberberov/e2fsprogs into maint

3 months agoMerge branch 'rbt/largefile' of github.com:robertlinux/e2fsprogs into maint
Theodore Ts'o [Thu, 5 Mar 2026 15:37:49 +0000 (10:37 -0500)] 
Merge branch 'rbt/largefile' of github.com:robertlinux/e2fsprogs into maint

3 months agoe4defrag: don't try to defragment files which have 0 or 1 blocks
Theodore Ts'o [Fri, 16 Jan 2026 23:01:09 +0000 (18:01 -0500)] 
e4defrag: don't try to defragment files which have 0 or 1 blocks

This fixes a crash in e4defrag when the file is using the inline_data
feature, and so the file data is stored in the inode table.
Technically speaking, such a file does not consume any data blocks,
but when an application program calls stat(2) on such a file, and
st_blocks is set to 0, it might confuse the program into thinking the
file did not contain any data.  For this reason, ext4 returns 1 in
st_blocks.  (For other files or directories, st_blocks will be a
multiple of the file system block size divided by 512, since st_blocks
is denominated in units of 512 sectors on Linux --- and most other Unix
systems with the notable exception of HP-UX[1].)

[1] https://unix.stackexchange.com/questions/669543

Unfortunately, when e4defrag tries to defragment a inline data file,
it divides st_blocks by (fs->block_size / 512) resulting in e4defrag
(correctly) concluding that the file uses 0 data blocks; but since
files were skipped only when st_blocks == 0, e4defrag will then divide
the number of blocks that were defragmented (0) with the number of
blocks in the file (0), triggering a divide by zero crash.

As it turns out, it's pointless to try to defrag a file with 0 or 1
data blocks (include files with inline data).  So fix this by skipping
any file where st_blocks <= block_size / 512.

Fixes: https://github.com/tytso/e2fsprogs/issues/260
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
3 months agoCreate draft release notes for the 1.47.4 release
Theodore Ts'o [Thu, 5 Mar 2026 15:29:41 +0000 (10:29 -0500)] 
Create draft release notes for the  1.47.4 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 months agodoc: Updated `ext4` man page, using a simple table for `KERNEL SUPPORT`
Boian Berberov [Thu, 29 Jan 2026 19:29:39 +0000 (13:29 -0600)] 
doc: Updated `ext4` man page, using a simple table for `KERNEL SUPPORT`

Signed-off-by: Boian Berberov <7432115+bberberov@users.noreply.github.com>
4 months agodoc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #3
Boian Berberov [Thu, 29 Jan 2026 19:26:15 +0000 (13:26 -0600)] 
doc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #3

- Whitespace between sentences
- Highlighted `^` options

Signed-off-by: Boian Berberov <7432115+bberberov@users.noreply.github.com>
4 months agodoc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #2
Boian Berberov [Mon, 12 Jan 2026 21:55:45 +0000 (15:55 -0600)] 
doc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #2

- Rewrote man pages for easier readability in raw form
- Reduce vertical whitespace by combining lines
- Added two spaces between sentences where missing

Signed-off-by: Boian Berberov <7432115+bberberov@users.noreply.github.com>
4 months agodoc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #1
Boian Berberov [Mon, 12 Jan 2026 21:38:43 +0000 (15:38 -0600)] 
doc: Updated `ext4`, `mke2fs`, `mke2fs.conf` and `tune2fs` man pages #1

- Updated highlighting of options/features/parameters
- Improved formatting consistency
- Added missing `man` page section numbers

- `ext4.5.in`
  - Minor edits in `data_err=`, `max_batch_time=`, `min_batch_time`, `prjquota`
  - Added `fast_commit` and `orphan_file` to `KERNEL SUPPORT`
- `mke2fs.8.in`
  - Minor edits in `quotatype`, `-g blocks-per-group`
- `mke2fs.conf.5.in`
  - Updated highlighting of stanzas/relations
- `tune2fs.8.in`
  - Fixed `Tune2fs` -> `tune2fs`

Signed-off-by: Boian Berberov <7432115+bberberov@users.noreply.github.com>
5 months agoconfigure: check for FS_IOC_READ_VERITY_METADATA availability
Thomas Petazzoni [Sat, 22 Nov 2025 20:12:23 +0000 (21:12 +0100)] 
configure: check for FS_IOC_READ_VERITY_METADATA availability

Commit 6bfa843b4435334ac073e42950b48d8bacb54977 ("mke2fs: enable
copying of fs-verity metadata") introduced support for reading
fs-verity metadata, which requires using the
FS_IOC_READ_VERITY_METADATA.

The code is conditionally compiled when the kernel headers have
<linux/fsverity.h> available. Unfortunately, this check is not
sufficient: <linux/fsverity.h> was introduced in Linux 5.10, but the
FS_IOC_READ_VERITY_METADATA was not introduced before 5.12, so if one
is using 5.10 or 5.11 kernel headers, the build fails with:

./../misc/create_inode.c: In function ‘copy_fs_verity_data’:
./../misc/create_inode.c:589:10: error: variable ‘arg’ has initializer but incomplete type
  589 |   struct fsverity_read_metadata_arg arg = {
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
[...]
./../misc/create_inode.c:600:20: error: ‘FS_IOC_READ_VERITY_METADATA’ undeclared (first use in this function)
  600 |   size = ioctl(fd, FS_IOC_READ_VERITY_METADATA, &arg);
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~

This commit therefore extends the configure.ac check to ensure that
not only <linux/fsverity.h> exists but also that it defines the
FS_IOC_READ_VERITY_METADATA ioctl.

Closes: https://github.com/tytso/e2fsprogs/pull/256
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
5 months agolibext2fs: fix orphan file size > kernel limit with large blocksize
Baokun Li [Wed, 12 Nov 2025 12:21:57 +0000 (20:21 +0800)] 
libext2fs: fix orphan file size > kernel limit with large blocksize

Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big")
limits the maximum supported orphan file size to 8 << 20.

However, in e2fsprogs, the orphan file size is set to 32–512 filesystem
blocks when creating a filesystem.

With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger
than the kernel allows, so mount prints an error and fails:

    EXT4-fs (vdb): orphan file too big: 8650752
    EXT4-fs (vdb): mount failed

Therefore, synchronize the kernel change to e2fsprogs to avoid creating
orphan files larger than the kernel limit.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Message-ID: <20251112122157.1990595-1-libaokun@huaweicloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomisc/create_inode.c: Fix for file larger than 2GB
Robert Yang [Sun, 30 Nov 2025 13:47:50 +0000 (21:47 +0800)] 
misc/create_inode.c: Fix for file larger than 2GB

Fixed:
$ dd if=/dev/zero of=../image.ext4 bs=1M count=4k
$ dd if=/dev/random of=../rootfs/largefile bs=1M count=3k
$ ./misc/mke2fs -t ext4 -d ../rootfs/ ../image.ext4
__populate_fs: Ext2 file too big while writing file "largefile"
mke2fs: Ext2 file too big while populating file system

This was because the offset is overflow, use __u64 to fix the problem.

Another code which uses ext2_off_t is copy_fs_verity_data(), but it only copies
the metadata, so it should be enough large for it, just leave it there.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
6 months agomke2fs: fix memory leak which causes ASAN to complain
Theodore Ts'o [Wed, 12 Nov 2025 02:33:30 +0000 (21:33 -0500)] 
mke2fs: fix memory leak which causes ASAN to complain

Fixes: 06f50e001b7d ("mke2fs: support multiple '-E' options")
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agodebian: mark libext2fs-dev as Multi-Arch: same
Luca Boccassi [Mon, 20 Oct 2025 14:44:09 +0000 (15:44 +0100)] 
debian: mark libext2fs-dev as Multi-Arch: same

Multiple architectures can be coinstalled without issues

Addresses-Debian-Bug: #1118461
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: suppress large block warning if the kernel supports them
Theodore Ts'o [Wed, 12 Nov 2025 01:59:37 +0000 (20:59 -0500)] 
mke2fs: suppress large block warning if the kernel supports them

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: if the kernel supports bs > gt, skip the large blockize check
Theodore Ts'o [Tue, 11 Nov 2025 20:53:46 +0000 (15:53 -0500)] 
mke2fs: if the kernel supports bs > gt, skip the large blockize check

There are patches which alow ext4 to support file systems where the
block size is larger than the page size.  For such kernels, skip the
test for large block sizes, which would require the user to explicitly
answer give permission to proceed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agodoc: fix mke2fs.8 Extended Options formatting
Andreas Dilger [Sat, 20 Sep 2025 22:50:30 +0000 (16:50 -0600)] 
doc: fix mke2fs.8 Extended Options formatting

The two consecutive .TP macros cause bad formatting for the
remaining options.  Remove one.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Message-ID: <20250920225030.29470-1-adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: fix missing .TP in man page
Ralph Siemsen [Wed, 10 Sep 2025 13:51:48 +0000 (09:51 -0400)] 
mke2fs: fix missing .TP in man page

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Fixes: 3fffe9dd6be5 ("tune2fs: replace the -r option with -E revision=<fs-rev>")
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Message-ID: <20250910-mke2fs-small-fixes-v2-4-55c9842494e0@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: add root_selinux option for root inode label
Ralph Siemsen [Wed, 10 Sep 2025 13:51:47 +0000 (09:51 -0400)] 
mke2fs: add root_selinux option for root inode label

This option allows setting the SELinux security context (label) for the
root directory. A common value would be system_u:object_r:root_t
possibly with a level/range such as :s0 suffix (for MCS/MLS policy).

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Message-ID: <20250910-mke2fs-small-fixes-v2-3-55c9842494e0@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: support multiple '-E' options
Ralph Siemsen [Wed, 10 Sep 2025 13:51:46 +0000 (09:51 -0400)] 
mke2fs: support multiple '-E' options

The '-E' option for specifying extended attributes can now be used
multiple times. The existing support for multiple attributes encoded
as comma-separated string is maintained for each '-E' option.

Prior to this change, if multiple '-E' options were specified, then
only the last one was used. Earlier ones were silently ignored.

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Message-ID: <20250910-mke2fs-small-fixes-v2-2-55c9842494e0@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agomke2fs: document the hash_seed option
Ralph Siemsen [Wed, 10 Sep 2025 13:51:45 +0000 (09:51 -0400)] 
mke2fs: document the hash_seed option

For reproducible builds, it is necessary to control the random seed used
for hashing. Document the extended option for this feature.

Fixes: e1f71006 ("AOSP: mke2fs, libext2fs: make filesystem image reproducible")
Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Message-ID: <20250910-mke2fs-small-fixes-v2-1-55c9842494e0@linaro.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agoext2fs: fix fast symlink blocks check
Andreas Dilger [Fri, 8 Aug 2025 08:04:27 +0000 (02:04 -0600)] 
ext2fs: fix fast symlink blocks check

Use ext4_inode_is_fast_symlink() in ext2fs_inode_has_valid_blocks2()
instead of depending exclusively on i_blocks == 0 to determine
if an inode is a fast symlink. Otherwise, if a fast symlink has a
large external xattr inode that increases i_blocks, it will be
incorrectly reported as having invalid blocks.

Change-Id: Ibde2348da39401601abedd603bd7e4ef97091abe
Fixes: 0684a4f33 ("Overhaul extended attribute handling")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/59871
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-19121
Message-ID: <20250808080505.1307694-1-adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 months agoMerge branch 'maint' of ../e2fsprogs-maint into next
Theodore Ts'o [Tue, 11 Nov 2025 18:45:06 +0000 (13:45 -0500)] 
Merge branch 'maint' of ../e2fsprogs-maint into next

6 months agoe2fsck: check for extended attributes with ea_inode but a zero ea_size
Theodore Ts'o [Fri, 26 Sep 2025 01:11:52 +0000 (21:11 -0400)] 
e2fsck: check for extended attributes with ea_inode but a zero ea_size

The combination of e_value_inum != 0 and e_value_size == 0 is invalid
and can trigger kernel warnings.  This should only happen with
delierately corrupted extended attribute entries; so if we come across
one, just clear the xattrs.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 months agoMerge tag 'fuse2fs-fixes_2025-10-17' into next
Theodore Ts'o [Tue, 21 Oct 2025 00:18:51 +0000 (17:18 -0700)] 
Merge tag 'fuse2fs-fixes_2025-10-17' into next

fuse2fs: round 6 bug fixes [01/17]

This series fixes more bugs in libext2fs and fuse2fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: mount norecovery if main block device is readonly
Darrick J. Wong [Thu, 28 Aug 2025 17:30:43 +0000 (10:30 -0700)] 
fuse2fs: mount norecovery if main block device is readonly

If the main block device is read-only, downgrade the mount to an ro
norecovery mount to match what the kernel does.  This will make
generic/050 somewhat less grouchy.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: make norecovery behavior consistent with the kernel
Darrick J. Wong [Thu, 28 Aug 2025 17:30:43 +0000 (10:30 -0700)] 
fuse2fs: make norecovery behavior consistent with the kernel

Amazingly, norecovery/noload on the kernel ext4 driver allows a
read-write mount even for journalled filesystems.  The one case where
mounting fails is if there's a journal and it's dirty AND you didn't
specify norecovery.  Make the fuse2fs option behave the same as the
kernel.

Also, ext2fs_run_ext3_journal doesn't explicitly check EXT2_FILE_RW
state, which means fuse2fs must do that.

Found via ext4/271.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: recheck support after replaying journal
Darrick J. Wong [Thu, 28 Aug 2025 17:30:43 +0000 (10:30 -0700)] 
fuse2fs: recheck support after replaying journal

The journal could have contained a new primary superblock, so we need to
recheck feature support after recovering it, because otherwise fuse2fs
could blow up on an unsupported feature that was enabled by a journal
transaction.

We also don't need to clear needsrecovery or dirty the superblock after
recovering the journal because ext2fs_run_ext3_journal does that for us.
Remove those lines.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: spot check clean journals
Darrick J. Wong [Tue, 7 Oct 2025 21:10:18 +0000 (14:10 -0700)] 
fuse2fs: spot check clean journals

Even though fuse2fs doesn't (yet) support writing new transactions to
the journal, we ought at least to check that the superblock is ok when
we mount a clean filesystem.  This fixes complaints by ext4/012 about
mount failing to notice a corrupt journal.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: check free space when creating a symlink
Darrick J. Wong [Fri, 12 Sep 2025 22:26:01 +0000 (15:26 -0700)] 
fuse2fs: check free space when creating a symlink

Make sure we have enough space to create the symlink and its remote
block.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: work around EBUSY discard returns from dm-thinp
Darrick J. Wong [Fri, 5 Sep 2025 22:25:34 +0000 (15:25 -0700)] 
fuse2fs: work around EBUSY discard returns from dm-thinp

generic/500 has this interesting failure mode when fuse2fs is running in
fuseblk mode:

 --- /run/fstests/bin/tests/generic/500.out      2025-07-15 14:45:15.092576090 -0700
 +++ /var/tmp/fstests/generic/500.out.bad        2025-09-05 15:09:35.211499883 -0700
 @@ -1,2 +1,22 @@
  QA output created by 500
 +fstrim: /opt: FITRIM ioctl failed: Device or resource busy

Apparently you can overwhelm dm-thinp with a large number of discard
requests, at which point it starts returning EBUSY.  This is unexpected
behavior but let's mask that off because discard is advisory anyways.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: fix in_file_group missing the primary process gid
Darrick J. Wong [Fri, 5 Sep 2025 21:17:14 +0000 (14:17 -0700)] 
fuse2fs: fix in_file_group missing the primary process gid

I forgot that Unix processes have both a primary group id and a list of
supplementary group ids.  The primary is provided by the fuse client;
the supplemental groups are noted by the Groups: field of
/proc/self/status.

If a process does not have /any/ supplemental group ids, then
in_file_group returns the wrong answer if the inode gid matches the
group id provided by the fuse client because it doesn't check that
anymore.  Make it so the primary group id check always happens.

Found by generic/375.

Cc: <linux-ext4@vger.kernel.org> # v1.47.3
Fixes: 3469e6ff606af8 ("fuse2fs: fix group membership checking in op_chmod")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
7 months agofuse2fs: don't update atime when reading executable file content
Darrick J. Wong [Fri, 5 Sep 2025 20:52:24 +0000 (13:52 -0700)] 
fuse2fs: don't update atime when reading executable file content

The kernel doesn't update the atime of program files when it's paging
their content into memory, so fuse2fs shouldn't either.  Found by
generic/120.

Cc: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>