On 2021/8/29 下午7:22, Forza wrote:
On 2021-08-27 12:08, David Sterba wrote:
quoted
On Mon, Aug 23, 2021 at 04:23:29PM -0400, Zygo Blaxell wrote:
quoted
On Mon, Aug 23, 2021 at 09:34:27PM +0200, Forza wrote:
quoted
Further up you showed that we can read encoded inlined data. What is
missing
for that we can read encoded inlined data that decode to >page_size
in size?
In uncompress_inline():
// decoded length of extent on disk...
max_size = btrfs_file_extent_ram_bytes(leaf, item);
...
// ...can never be more than one page because of this line(*)
max_size = min_t(unsigned long, PAGE_SIZE, max_size);
There might be further constraints around this code (e.g. the caller
only fills in structures for one page, or doesn't bother to call this
function at all for offsets above PAGE_SIZE).
All the restrictions would need to be removed in the kernel and support
for reading multi-page inline extents added where necessary. There
would
have to be an incompat bit on the filesystem to prevent old kernels from
trying (and failing) to read longer inline extents. The disk format is
already technically capable of specifying a longer inline extent (up to
min(UINT32_MAX, metadata_page_size)) but that was never the problem.
Regarding the idea of compressed inline extents, I'm not much in favor
of increasing the limit beyond one page (or sector). The metadata space
is more precious and that's also the motivation behind low default
max_inline. Another thing is mixing data and metadata with potentially
different block group profiles.
We already mix profiles today with inlining small extents. It is not a
problem as most people use a better/higher redundancy for metadata than
for data.
quoted
The inline files is IMO a nice little optimization and helps when the
size is below certain limit to avoid wasting data blocks and the
indirection.
To be fair, I think the benefit is that we inline instead of creating
4KiB extents for small amounts of data. This benefit would be true even
if that data was compressed data and the compressed size was <2KiB.
I do understand the earlier points that this would perhaps be a big
thing to change, also incompatible with earlier kernels. Given that work
the benefit is rather small.
Perhaps if we are doing incompatible changes in the future, this could
be considered at that time? One reference is what Qu wrote here about
taking in more factors to consider for inlining?
https://lore.kernel.org/linux-btrfs/d0dccd5e-c67f-a18d-8d6e-559504b5ee91@suse.com/ (local)
There are way more things to consider for inlining extent larger than
one sector.
- Reading the inline extent
Now we must consider multiple pages other than just simply copying the
data to the page.
This also brings extra error paths which must be considered.
- Writing the extra pages of the inline extent
Unlike current single sector inline, what if you overwrite the 2nd
page of the inline extent?
In theory, we should make the whole inline extents into one regular
extent, then this means we have to read the whole inline extent out,
re-marking them dirty.
We don't have the exact facility to do that.
The most similar one is defrag, but now we need to do that in write
path too.
Or you can treat them as regular extents, just cow the 2nd page?
Then it completely wastes the extra space in metadata.
Either way, it's way complex than you thought, and all my respect to
all those guys solving the corner cases with compression and inline.
So my idea towards inline and compression is pretty simple, they are
good optimization, but not critical part.
Thus if they are affecting regular core functions to be more complex
than they should, then no.
And extending inline extent size beyond page size is exactly bringing
extra cost to the developers, with little and uncertain benefit.
Thanks,
Qu
Thanks