From: Cedric Blancher <cedric.blancher@gmail.com>
To: cygwin@cygwin.com
Subject: _PC_MIN_HOLE_SIZE pathconf() Re: Cygwin api to punch a hole into a file?
Date: Fri, 1 Dec 2023 11:44:30 +0100 [thread overview]
Message-ID: <CALXu0UctMLBqBa=FrJVRqyitGFB5a6mVbfr8rb4WiD6F5qc=-A@mail.gmail.com> (raw)
In-Reply-To: <ZWXBH_viPFuSF6be@calimero.vinschen.de>
On Tue, 28 Nov 2023 at 11:30, Corinna Vinschen via Cygwin
<cygwin@cygwin.com> wrote:
>
> On Nov 24 12:01, Corinna Vinschen via Cygwin wrote:
> > On Nov 23 23:36, Cedric Blancher via Cygwin wrote:
> > > Linux has fallocate(fd, FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE, ...)
> > > to punch a hole into a file, i.e. deallocate the blocks given and make
> > > the file a "sparse file".
> >
> > We don't support the Linux-specific fallocate(2) call, only ftruncate(2)
> > and posix_fallocate(3). Patches, as usual, thoughtfully considered.
>
> The next test release cygwin-3.5.0-0.485.g65831f88d6c4 introduces
> the Linux-specific fallocate(2) call. Naturally we can't support
> all flags, but the following flag combinations are allowed:
>
> - 0 same as posix_fallocate(3)
> - FALLOC_FL_KEEP_SIZE
> - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE
> - FALLOC_FL_ZERO_RANGE
> - FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE
>
> A few comments:
>
> - With 0 and FALLOC_FL_KEEP_SIZE, sparse blocks in the given range
> are re-allocated as per the POSIX requirements. For that, it uses
> the same code as FALLOC_FL_ZERO_RANGE, but only for the holes within
> the range.
>
> - With FALLOC_FL_KEEP_SIZE, over-allocation is done by setting
> the allocation size of a file while keeping EOF the same.
> However, in contrast to your typical Linux filesystem, over-
> allocation on Windows filesystems is only temporary. The
> over-allocated blocks are returned to free blocks as soon as
> the last HANDLE to the file is closed.
>
> - With FALLOC_FL_KEEP_SIZE, no over-allocation is performed on sparse
> files. The reason is that over-allocation on sparse files has no
> effect on Windows.
>
> - FALLOC_FL_ZERO_RANGE is implemented as writing zeros to the
> given range. For parts of the range which are already allocated
> data blocks, as much zeros are written as necessary. For holes
> in sparse files, only a single zero byte is written to the
> hole per 64K chunk, which is the allocation granularity of
> sparse files.
>
> - FALLOC_FL_ZERO_RANGE is NOT atomic.
>
> Please give it a try.
Could you please implement _PC_MIN_HOLE_SIZE in pathconf(), so that
people can query the minimum hole size for a (path in a) filesystem?
Should return nothing for FAT and NFSv3, should work on NTFS and
NFSv4.2
Ced
--
Cedric Blancher <cedric.blancher@gmail.com>
[https://plus.google.com/u/0/+CedricBlancher/]
Institute Pasteur
prev parent reply other threads:[~2023-12-01 10:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 22:36 Cedric Blancher
2023-11-24 11:01 ` Corinna Vinschen
2023-11-28 10:29 ` Corinna Vinschen
2023-12-01 10:22 ` Cedric Blancher
2023-12-01 11:02 ` Corinna Vinschen
2023-12-04 16:07 ` Andrey Repin
2023-12-05 6:36 ` Thomas Wolff
2023-12-05 13:53 ` Corinna Vinschen
2023-12-05 14:40 ` Thomas Wolff
2023-12-05 14:47 ` Thomas Wolff
2023-12-05 15:15 ` Corinna Vinschen
2023-12-01 10:44 ` Cedric Blancher [this message]
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='CALXu0UctMLBqBa=FrJVRqyitGFB5a6mVbfr8rb4WiD6F5qc=-A@mail.gmail.com' \
--to=cedric.blancher@gmail.com \
--cc=cygwin@cygwin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).