Skip to contentSkip to conversation

New: Online ext4 defragmentation fails on 'inline' files (feature inline_data_

Bug 221007 [email protected] 1 participant 2 messages Jan 23 – Jan 25

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=221007

Bug ID: 221007
Summary: Online ext4 defragmentation fails on 'inline' files
(feature inline_data_
Product: File System
Version: 2.5
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P3
Component: ext4
Assignee: [email protected]
Reporter: [email protected]
Regression: No

Hi,

If one has an ext4 filesystem, with enabled feature flag 'inline_data', and there are effectively inline files, then the e4defrag tool crashes with a segfault. Bit exotic I admit, but we really use this...

How to reproduce:

----

Quoted 4 lines

cd /tmp
dd if=/dev/zero of=ext4.ima bs=1M count=10
mkfs.ext4 ./ext4.ima
debugfs -w ./ext4.ima

debugfs 1.47.3 (8-Jul-2025)
debugfs: feature inline_data
Filesystem features: has_journal ext_attr resize_inode dir_index orphan_file filetype needs_recovery extent 64bit flex_bg metadata_csum_seed inline_data sparse_super large_file huge_file dir_nlink extra_isize metadata_csum orphan_present
debugfs: q

Quoted 3 lines

mount ./ext4.ima /mnt
echo 'This is a very small file' > /mnt/smallfile.txt lsattr /mnt/smallfile.txt

------------------N--- /mnt/smallfile.txt

Quoted 2 lines

# File is indeed inline
e4defrag -c /mnt

e4defrag 1.47.3 (8-Jul-2025)
<Fragmented files> now/best size/ext

 Total/best extents                             1/0
 Average size per extent                        0 KB
 Fragmentation score                            inf

[0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag] This directory (/mnt) needs defragmentation.
Done.

Quoted 2 lines

# Obviously wrong, but not problematic
e4defrag /mnt

e4defrag 1.47.3 (8-Jul-2025)
ext4 defragmentation for directory(/mnt)
Segmentation fault (core dumped) e4defrag /mnt

Quoted 1 line

# Should not happen; occurs at first encounter of an inline file, always

---

e4defrag should totally ignore inline files, as they cannot be (de)fragmented.

Cheers, B.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 221007] Online ext4 defragmentation fails on 'inline' files (feature inline_data_

https://bugzilla.kernel.org/show_bug.cgi?id=221007

Christian Kujau ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |[email protected]

--- Comment #1 from Christian Kujau ([email protected]) --- While not necessarily a kernel issue, it's reproducible here once the inline_data flag is set:

-----------------------------------

$ uname -rm
6.19.0-rc6-snafu aarch64
$ pv -Ss 512m /dev/zero > test.img
$ losetup -f test.img
$ mkfs.ext4 -O inline_data -F /dev/loop0
$ mount -t ext4 /dev/loop0 /mnt/disk/
$ date > /mnt/disk/file.txt
$ ulimit -c unlimited
$ e4defrag /mnt/disk/
e4defrag 1.47.2 (1-Jan-2025)
ext4 defragmentation for directory(/mnt/disk/)
Segmentation fault (core dumped)
-----------------------------------

Some debugging output:

-----------------------------------

$ gdb -c core /usr/sbin/e4defrag
(gdb) bt
#0  0x0000aaaaca774390 in file_defrag (file=0xaaaadca9b7e0
"/mnt/disk/file.txt", buf=0xffffea194a90, flag=<optimized out>,
ftwbuf=<optimized out>) at ../../../misc/e4defrag.c:1559
#1  0x0000ffff8d041760 [PAC] in process_entry (data=data@entry=0xffffea194c08,
dir=dir@entry=0xffffea194b80, name=name@entry=0xaaaadca9c883 "file.txt",
namlen=<optimized out>, d_type=<optimized out>)
    at ../sysdeps/wordsize-64/../../io/ftw.c:472
#2  0x0000ffff8d041bc0 [PAC] in ftw_dir (data=data@entry=0xffffea194c08,
st=st@entry=0xffffea194c60, old_dir=old_dir@entry=0x0) at
../sysdeps/wordsize-64/../../io/ftw.c:551
#3  0x0000ffff8d042350 [PAC] in ftw_startup (dir=dir@entry=0xffffea194f40
"/mnt/disk", is_nftw=is_nftw@entry=1, func=func@entry=0xaaaaca7736e0
<file_defrag>, descriptors=descriptors@entry=2000,
    flags=flags@entry=3) at ../sysdeps/wordsize-64/../../io/ftw.c:771
#4  0x0000ffff8d042460 [PAC] in __new_nftw (path=path@entry=0xffffea194f40
"/mnt/disk", func=func@entry=0xaaaaca7736e0 <file_defrag>,
descriptors=descriptors@entry=2000, flags=flags@entry=3)
    at ../sysdeps/wordsize-64/../../io/ftw.c:844
#5  0x0000aaaaca7722c4 in main (argc=<optimized out>, argv=0xffffea198148) at
../../../misc/e4defrag.c:1913
-----------------------------------

Recompiling the userspace tools with -g should help (and I did that on another machine), but I can't make sense of the details shown :-\

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.