Skip to content

Wish-list: Take advantage of Linux-specific fallocate syscalls #7

Description

@rail5

See: https://man7.org/linux/man-pages/man2/fallocate.2.html

If we are using the Linux Kernel and either an ext4 or XFS filesystem, there are two potentially helpful fallocate flags which aren't available on other platforms: FALLOC_FL_INSERT_RANGE and FALLOC_FL_COLLAPSE_RANGE

All other systems only allow for: replaces, inserts to the end of the file, and removals from the end of the file. As such, currently, when Polonius does (for example) an "insert" to some position of a file prior to EOF, it begins by inserting to the end of the file, and then doing a series of "replaces" to achieve the desired result.

These system calls would allow us to perform "inserts" and "removes" DIRECTLY to earlier portions of files.

However, to my knowledge, these could not be done with "byte-level" granularity. From the fallocate manpage:

A filesystem may place limitations on the granularity of the
operation, in order to ensure efficient implementation.
Typically, offset and len must be a multiple of the filesystem
logical block size, which varies according to the filesystem type
and configuration. If a filesystem has such a requirement,
fallocate() fails with the error EINVAL if this requirement is
violated.

It would be nice to be able to take advantage of these syscalls in the event that the user is on the Linux kernel & is using a compatible filesystem such as ext4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions