Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disk I/O optimization #1765

Merged
merged 2 commits into from
Aug 31, 2022
Merged

Disk I/O optimization #1765

merged 2 commits into from
Aug 31, 2022

Conversation

francescolavra
Copy link
Member

This change set aims at minimizing the number of I/O requests and scatter-gather buffers used to transfer a given amount of data to/from disk, which helps parallelizing I/O (especially when the I/O ring queue depth is limited) and minimizes the memory allocation needs for an I/O transfer.
The first commit implements merging of contiguous pagecache pages that have their backing memory areas adjacent (which happens frequently if the cache for a node is filled sequentially starting from offset 0) into a single scatter-gather buffer before doing a filesystem storage operation (both when reading and writing a page cache node).
The second commit implements extension of existing file extents to cover additional storage space beyond the initially allocated space, and removes the 1MB maximum extent size; this helps keeping the amount of file metadata down and minimizing fragmentation of file data into non-contiguous storage areas. Since allocations from the storage space are aligned to the allocation size, requesting large extents can create large unallocated ranges in the storage space; in order to be able to fill these ranges when requesting a new extent that does not fit into a single contiguous storage area, the create_extent() function upon allocation failure retries an allocation with a smaller size (down to a 1MB limit); the code that calls this function has been amended to properly handle the cases where the size of a created extent is smaller than requested.
#1165

Copy link
Collaborator

@sanderssj sanderssj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@wjhun wjhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

When contiguous pages have their backing memory areas adjacent to
each other (which happens frequently if the cache for a node is
filled sequentially starting from offset 0), they can be merged in
a single scatter-gather buffer before doing a filesystem storage
operation; this minimizes the number of SG buffers being used to
transfer a given amount of data, which translates into less I/O
requests to the storage device (especially when the I/O ring queue
depth is limited) and thus helps parallelizing I/O.
This commit implements such merging during both reading and writing
of page cache nodes.
When file data is being written beyond the range of an existing
file extent, if the storage space adjacent to the extent is free,
the extent can be extended to cover additional storage space,
instead of creating a new extent; this keeps the amount of file
metadata down and minimizes the number of disk I/O requests being
used to transfer a given amount of data.
The existing maximum limit of 1 MB on extent creation is no longer
necessary and is being removed. Since allocations from the storage
space are aligned to the allocation size, requesting large extents
can create large unallocated ranges in the storage space; in order
to be able to fill these ranges when requesting a new extent that
does not fit into a single contiguous storage area, the
create_extent() function upon allocation failure retries an
allocation with a smaller size (down to a 1MB limit); the code that
calls this function has been amended to properly handle the cases
where the size of a created extent is smaller than requested.
@francescolavra francescolavra merged commit 65434ad into master Aug 31, 2022
@francescolavra francescolavra deleted the feature/disk-io branch August 31, 2022 06:57
francescolavra added a commit that referenced this pull request Jun 2, 2023
When a request to create an extent of a certain size cannot be
fulfilled due to missing free contiguous storage space, and the
extent is created with a smaller size than requested, the existing
code is assigning the originally requested file range (instead of
the range actually allocated) to the extent being created, which
leads to filesystem corruption.
Regression introduced in commit 65434ad (#1765).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants