btrfs: allow creating inline data extents for sector size < page size case
cover btrfs: allow creating inline data extents for sector size < page size case
There are two features disabled when sector size < page size (subpage) is allowed for btrfs:
- Inline data extent creation
- Sector perfect compressed write
Both share one critical technical problem, that inline or async submission all unlock the whole page.
Thankfully the major technical blockage is already solved with the recent sector perfect compressed write support for subpage cases.
So there is no need to disable inline data extent creation either. Yes, there are cases we can mixing inline and regular data extents, but that's also the case when page size == sector size, so it's not a show stopper.
The first patch is to fix a harmless bug that is only affecting subpage cases.
The second one enables the inline data extent creation for subpage cases.
Qu Wenruo (2):
btrfs: fix the qgroup data free range for inline data extents
btrfs: allow inline data extents creation if sector size < page size
fs/btrfs/inode.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
Signature · 1 line
2.47.0
PATCH 1/2 btrfs: fix the qgroup data free range for inline data extents
Inside function __cow_file_range_inline() since the inlined data no longer takes any data space, we need to free up the reserved space.
However the code is still using the old page size == sector size assumption, and will not handle subpage case well.
Thankfully it is not going to cause problem because we have two safe nets:
- Inline data extents creation is disable for sector size < page size cases for now
But it won't stay that for long.
- btrfs_qgroup_free_data() will only clear ranges which are already reserved
So even if we pass a range larger than what we need, it should still be fine, especially there should only be one sector reserved.
But just for the sake of consistentcy, fix the call site to use sectorsize instead of page size.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -711,7 +711,7 @@ static noinline int __cow_file_range_inline(struct btrfs_inode *inode,* And at reserve time, it's always aligned to page size, so * just free one page here. */ -btrfs_qgroup_free_data (inode,NULL ,0 ,PAGE_SIZE ,NULL ); +btrfs_qgroup_free_data (inode,NULL ,0 , fs_info->sectorsize,NULL );btrfs_free_path (path);btrfs_end_transaction (trans);return ret;
Signature · 1 line
2.47.0
PATCH 2/2 btrfs: allow inline data extents creation if sector size < page size
In reply to Qu WenruoPreviously inline data extents creation is disable if sector size < page size, as there are two blockage:
- Possible mixed inline and regular data extents
However this is also the case for sector size < page size cases, thus we do not treat mixed inline and regular extents as an error. So from day one, more mixed inline and regular extents are not a strong argument to disable inline extents.
- Unable to handle async/inline delalloc range for sector size < page size cases
This is fixed with the recent sector perfect compressed write support for sector size < page size cases.
And this is the main technical blockage.
With the major technical blockage already removed, we can enable inline data extents creation for sector size < page size, allowing the btrfs to have the same capacity no matter the page size.
--- fs/btrfs/inode.c | 13 ------------- 1 file changed, 13 deletions(-)
fs/btrfs/inode.c +0 -13
@@ -605,19 +605,6 @@ static bool can_cow_file_range_inline(struct btrfs_inode *inode,if (offset !=0 )return false; -/* -* Due to the page size limit, for subpage we can only trigger the -* writeback for the dirty sectors of page, that means data writeback -* is doing more writeback than what we want. -* -* This is especially unexpected for some call sites like fallocate, -* where we only increase i_size after everything is done. -* This means we can trigger inline extent even if we didn't want to. -* So here we skip inline extent creation completely. -*/ -if (fs_info->sectorsize !=PAGE_SIZE ) -return false; -/* Inline extents are limited to sectorsize. */ if (size > fs_info->sectorsize)return false;
Signature · 1 line
2.47.0