Re: [PATCH 1/5] block: new sector copy api

Christoph Hellwig
2025-05-28T07:46:04Z

On Tue, May 27, 2025 at 11:45:26AM -0600, Keith Busch wrote:
> Just fyi, the initial user I was planning to target with the block
> layer's copy fallback isn't in kernel yet. Just an RFC at this moment on
> btrfs:
>
> https://lore.kernel.org/linux-btrfs/20250515163641.3449017-10-maharmstone@fb.com/
>
> The blk-lib function could easily replace that patch's "do_copy()"
> without to much refactoring on the btrfs side.

Well, that code would be much better off using a long living buffer,
because the frequent allocations are worse. Also from talking to a btrfs
guys sitting next to me at least the classic relocation can actually be
in the normal write path, so you probably also don't want it to fail
because a large memory allocation fails.

What we did for the GC code in XFS that exists to basically do the same
is to do a large allocation at mount time, and then just keep reusing
it.