Commit 81ac4ae
committed
btrfs: extract the compressed folio padding into a helper
Currently after btrfs_compress_folios(), we zero the tail folio at
compress_file_range() after the btrfs_compress_folios() call.
However there are several problems with the incoming block size > page
size support:
- We may need extra padding folios for the compressed data
Or we will submit a write smaller than the block size.
- The current folio tail zeroing is not covering extra padding folios
Solve this problem by introducing a dedicated helper,
pad_compressed_folios(), which will:
- Do extra basic sanity checks
Focusing on the @out_folios and @total_out values.
- Zero the tailing folio
Now we don't need to tail zeroing inside compress_file_range()
anymore.
- Add extra padding zero folios
So that for bs > ps cases, the compressed data will always be bs
aligned.
This also implies we won't allocate dedicated large folios for
compressed data.
Finally since we're here, update the stale comments about
btrfs_compress_folios().
Signed-off-by: Qu Wenruo <[email protected]>
---
RFC v2->RFC v3:
- Fix a failure related to inline compressed data (btrfs/246 failure)
The check on whether the resulted compressed data should not happen
until we're sure no inlined extent is going to be created.
RFC v1->RFC v2:
- Fix a check causes more strict condition for subpage cases
Instead comparing the resulted compressed folios number, compare the
resulted blocks number instead.
For 64K page sized system with 4K block size, it will result any
compressed data larger than 64K to be rejected.
Even if the compression caused a pretty good result, e.g. 128K ->68K.
- Remove an unused local variable
Reason for RFC:
Although this seems to be a preparation patch for bs > ps support, this
one will determine the path we go for compressed folios.
There are 2 methods I can come up with:
- Allocate dedicated large folios following min_order for compressed
folios
This is the more common method, used by filemap and will be the method
for page cache.
The problem is, we will no longer share the compr_pool across all
btrfs filesystems, and the dedicated per-fs pool will have a much
harder time to fill its pool when memory is fragmented or
under-pressure.
The benefit is obvious, we will have the insurance that every folio
will contain at least one block for bs > ps cases.
- Allocate page sized folios but add extra padding folios for compressed
folios
The method I take in this patchset.
The benefit is we can still use the shared compr folios pool, meaning
a better latency filling the pool.
The problem is we must manually pad the compressed folios.
Thankfully the compressed folios are not filemap ones, we don't need
to bother about the folio flags at all.
Another problem is, we will have different handling for filemap and
compressed folios.
Filemap folios will have the min_order insurance, but not for
compressed folios.
I believe the inconsistency is still manageable, at least for now.
Thus I leave this one as RFC, any feedback will be appreciated.1 parent eeae4b3 commit 81ac4ae
2 files changed
+41
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1024 | 1024 | | |
1025 | 1025 | | |
1026 | 1026 | | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1027 | 1064 | | |
1028 | 1065 | | |
1029 | 1066 | | |
| |||
1033 | 1070 | | |
1034 | 1071 | | |
1035 | 1072 | | |
1036 | | - | |
| 1073 | + | |
1037 | 1074 | | |
1038 | 1075 | | |
1039 | 1076 | | |
| |||
1060 | 1097 | | |
1061 | 1098 | | |
1062 | 1099 | | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1063 | 1103 | | |
1064 | 1104 | | |
1065 | 1105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
868 | 867 | | |
869 | 868 | | |
870 | 869 | | |
| |||
964 | 963 | | |
965 | 964 | | |
966 | 965 | | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
973 | | - | |
974 | | - | |
975 | 966 | | |
976 | 967 | | |
977 | 968 | | |
| |||
0 commit comments