public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: linux-ext4@vger.kernel.org
Subject: [BUG] lseek in sparse files broken on ext3 mounted as ext4
Date: Sat, 28 Mar 2026 19:24:56 +0300 (MSK)	[thread overview]
Message-ID: <594c17d9-c00f-e485-96fb-cedf27ce3aa3@ispras.ru> (raw)

Hi!

Mounting ext3 with '-o delalloc' is explicitly rejected by the kernel
("EXT4-fs: Mount option(s) incompatible with ext3" in dmesg).

At the same time, mounting ext3 with '-t ext4' is accepted, and enables
delayed allocation. In this case, lseek with SEEK_DATA/SEEK_HOLE requests
does not work correctly and breaks userspace programs such as install(1)
from coreutils.

To reproduce, it is sufficient to prepare an ext3 image as usual and mount it
as ext4:

truncate -s 1G img-ext3
mkfs.ext3 img-ext3
mkdir mnt-ext3
mount -t ext4 img-ext3 mnt-ext3

and run the following repro script:

#!/bin/sh
echo | dd of=src bs=1 count=1 seek=64K
strace -v -o install.strace install src dst
cmp src dst

the output should be

src dst differ: char 65537, line 1

with

lseek(3, 0, SEEK_DATA)                  = -1 ENXIO

in install.strace on the first lseek call, meaning that it reports
"no more data until EOF" (and hence install does not copy anything).

Either mounting with '-o nodelalloc' or fdatasync'ing the file before install
(conv=fdatasync in dd or 'sync -d src' after dd) avoids the problem.

The old ext4 wiki [1], the KernelNewbies wiki [2], and the Arch wiki [3]
all claim that mounting ext3 as ext4 is expected to work correctly.

[1] https://archive.kernel.org/oldwiki/ext4.wiki.kernel.org/index.php/UpgradeToExt4.html
[2] https://kernelnewbies.org/Ext4
[3] https://wiki.archlinux.org/title/Ext4

Thanks.
Alexander

             reply	other threads:[~2026-03-28 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-28 16:24 Alexander Monakov [this message]
2026-04-07  7:46 ` [BUG] lseek in sparse files broken on ext3 mounted as ext4 Alexander Monakov

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=594c17d9-c00f-e485-96fb-cedf27ce3aa3@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=linux-ext4@vger.kernel.org \
    /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