From: Florian Weimer <fweimer@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Paul Eggert <eggert@cs.ucla.edu>,
libc-alpha@sourceware.org, linux-fsdevel@vger.kernel.org,
Trond Myklebust <trondmy@hammerspace.com>
Subject: Re: posix_fallocate behavior in glibc
Date: Tue, 30 Jul 2024 19:03:50 +0200 [thread overview]
Message-ID: <87o76ezua1.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20240730162042.GA31109@lst.de> (Christoph Hellwig's message of "Tue, 30 Jul 2024 18:20:42 +0200")
* Christoph Hellwig:
> On Tue, Jul 30, 2024 at 09:11:17AM -0700, Paul Eggert wrote:
>> It would help glibc distinguish the following cases:
>>
>> A. file systems whose internal structure supports the semantics of
>> posix_fallocate, and where user-mode code can approximate those semantics
>> by writing zeros, but where that feature has not been implemented in the
>> kernel's file system code so the system call currently fails with
>> EOPNOTSUPP.
>>
>> B. file systems whose internal structure cannot support the semantics of
>> posix_fallocate and you cannot approximate them, and where the system call
>> currently fails with EOPNOTSUPP.
>
> As mentioned earlier in the thread case a) are basically legacy / foreign
> OS compatibility file systems (minix, sysfs, hfs/hfsplus). They are
> probably not something that people actually use posix_fallocate on.
It's more about a file copying tool doing this by default on behalf of
the users (perhaps Midnight Commander?). If I recall, posix_fallocate
is also used by file-sharing clients, and those might be used with
external storage media that have older file systems.
> The only relevant exception is probably ext4 in ext2/ext3 mode, where
> the latter might still have users left running real workloads on it
> and not using it for usb disks or VM images.
Why doesn't the kernel perform allocation in these cases? There doesn't
seem to be a file-system-specific reason why it's impossible to do.
At the very least, we should have a variant of ftruncate that never
truncates, likely under the fallocate umbrella. It seems that that's
how posix_fallocate is used sometimes, for avoiding SIGBUS with mmap.
To these use cases, whether extents are allocated or not does not
matter.
>> Florian is proposing that different error numbers be returned for (A) vs
>> (B) so that glibc posix_fallocate can treat the cases differently.
>
> The problem with a new error code is that it will leak out to the
> application when using a new kernel and an old glibc.
If we removed the fallback code from glibc today, it would just be
EOPNOTSUPP that leaks to applications, so it's structurally the same
issue. The error codes that glibc's posix_fallocate can produce are all
different (unless write on the file fails with EOPNOTSUPP in the kernel,
but that would be quite unexpected). EOPNOTSUPP would be equally
surprising.
Thanks,
Florian
next prev parent reply other threads:[~2024-07-30 17:04 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 16:09 posix_fallocate behavior in glibc Christoph Hellwig
2024-07-29 17:23 ` Paul Eggert
2024-07-29 17:43 ` Christoph Hellwig
2024-07-29 17:54 ` Adhemerval Zanella Netto
[not found] ` <CAPBLoAf11hM0PLhqPG5gUyivU9U1manpOOhDWCPugUmWc1VVUw@mail.gmail.com>
2024-07-29 18:45 ` Christoph Hellwig
2024-07-29 17:57 ` Florian Weimer
2024-07-29 18:44 ` Christoph Hellwig
2024-07-29 18:52 ` Florian Weimer
2024-07-29 19:01 ` Christoph Hellwig
2024-07-29 19:23 ` Florian Weimer
2024-07-30 15:47 ` Christoph Hellwig
2024-07-30 16:11 ` Paul Eggert
2024-07-30 16:20 ` Christoph Hellwig
2024-07-30 17:03 ` Florian Weimer [this message]
2024-07-30 17:08 ` Christoph Hellwig
2024-07-30 17:29 ` Florian Weimer
2024-07-30 17:52 ` Mark Wielaard
2024-07-31 2:32 ` Theodore Ts'o
2024-07-29 23:53 ` Dave Chinner
-- strict thread matches above, loose matches on Subject: below --
2024-06-26 6:01 Christoph Hellwig
2024-07-29 15:09 ` Christoph Hellwig
2024-07-29 15:11 ` Sam James
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=87o76ezua1.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=hch@lst.de \
--cc=libc-alpha@sourceware.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=trondmy@hammerspace.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.