Collapsing ranges in sparse files in APFS?

22 views
Skip to first unread message

Jens Alfke

unread,
Jan 20, 2019, 6:14:36 PM1/20/19
to Darwin Dev
I’m looking into sparse-file operations in APFS. I see I can use fcntl to preallocate space and to punch holes in a file. But I don’t see a command to remove a byte range from a file without leaving a hole, equivalent to the
FALLOC_FL_COLLAPSE_RANGE mode of Linux’s fallocate, described thus:

> Specifying the FALLOC_FL_COLLAPSE_RANGE flag (available since Linux 3.15) in mode removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at offset and continues for len bytes. At the completion of the operation, the contents of the file starting at the location offset+len will be appended at the location offset, and the file will be len bytes smaller.

Is there such an operation in Darwin, with an APFS filesystem?

—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (Darwi...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/darwin-dev/darwin-dev-garchive-73044%40googlegroups.com

This email sent to darwin-dev-g...@googlegroups.com

Chris Sarcone

unread,
Jan 21, 2019, 8:19:39 PM1/21/19
to Jens Alfke, Darwin Dev
Hi Jens —

On Jan 20, 2019, at 3:14 PM, Jens Alfke <je...@mooseyard.com> wrote:

I’m looking into sparse-file operations in APFS. I see I can use fcntl to preallocate space and to punch holes in a file. But I don’t see a command to remove a byte range from a file without leaving a hole, equivalent to the
FALLOC_FL_COLLAPSE_RANGE mode of Linux’s fallocate, described thus:

Specifying the FALLOC_FL_COLLAPSE_RANGE flag (available since Linux 3.15) in mode removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at offset and continues for len bytes. At the completion of the operation, the contents of the file starting at the location offset+len will be appended at the location offset, and the file will be len bytes smaller.

Is there such an operation in Darwin, with an APFS filesystem?

No, but you can file a Radar bug asking for the feature and we can evaluate it for inclusion.

Thanks,

— Chris


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

19191 Vallco Parkway

M/S 77-1SSG

Cupertino CA 95014

phone: (408) 974-4033

fax:   (408) 862-7577

email: sar...@apple.com


Jens Alfke

unread,
Jan 22, 2019, 1:30:19 PM1/22/19
to Chris Sarcone, Darwin Dev


On Jan 21, 2019, at 5:19 PM, Chris Sarcone <sar...@apple.com> wrote:

No, but you can file a Radar bug asking for the feature and we can evaluate it for inclusion.

OK, filed as rdar://47450388

(The Bug Reporter site didn’t have any category for “Filesystem”, “Core OS” or “Kernel”, so I chose “Something not listed here”. I’m smiling to myself at the irony that operating systems have grown to such a degree that something as fundamental as the filesystem no longer merits a place in a feature list!)

—Jens
Reply all
Reply to author
Forward
0 new messages