aboutsummaryrefslogtreecommitdiff
path: root/net/compat.c
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2023-07-15 19:08:33 +0800
committerDavid Sterba <dsterba@suse.com>2023-08-21 14:52:17 +0200
commit13840f3f2837b9a00f06d2d8d93dbdc6b2b6532e (patch)
treef09ad0e06f59b6323d05fca6d71d40487f01dd45 /net/compat.c
parent682a0bc5573f3c10a435fb9650c856bb325d2733 (diff)
btrfs: refactor main loop in memcpy_extent_buffer()
[BACKGROUND] Currently memcpy_extent_buffer() does a loop where it would stop at any page boundary inside [dst_offset, dst_offset + len) or [src_offset, src_offset + len). This is mostly allowing us to do copy_pages(), but if we're going to use folios we will need to handle multi-page (the old behavior) or single folio (the new optimization). The current code would be a burden for future changes. [ENHANCEMENT] There is a hidden pitfall of the naming memcpy_extent_buffer(), unlike regular memcpy(), this function can handle overlapping ranges. So here we extract write_extent_buffer() into a new internal helper, __write_extent_buffer(), and add a new parameter @use_memmove, to indicate whether we should use memmove() or regular memcpy(). Now we can go __write_extent_buffer() to handle writing into the dst range, with proper overlapping detection. This has a tiny change to the chance of calling memmove(). As the split only happens at the source range page boundaries, the memcpy/memmove() range would be slightly larger than the old code, thus slightly increase the chance we call memmove() other than memcopy(). Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'net/compat.c')
0 files changed, 0 insertions, 0 deletions