public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: allow creating inline data extents for sector size < page size case
@ 2024-11-15  6:03 Qu Wenruo
  2024-11-15  6:03 ` [PATCH 1/2] btrfs: fix the qgroup data free range for inline data extents Qu Wenruo
  2024-11-15  6:03 ` [PATCH 2/2] btrfs: allow inline data extents creation if sector size < page size Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-11-15  6:03 UTC (permalink / raw)
  To: linux-btrfs

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(-)

-- 
2.47.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] btrfs: fix the qgroup data free range for inline data extents
  2024-11-15  6:03 [PATCH 0/2] btrfs: allow creating inline data extents for sector size < page size case Qu Wenruo
@ 2024-11-15  6:03 ` Qu Wenruo
  2024-11-15  6:03 ` [PATCH 2/2] btrfs: allow inline data extents creation if sector size < page size Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-11-15  6:03 UTC (permalink / raw)
  To: linux-btrfs

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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f8803d9522e7..a0599369ca0c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -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;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] btrfs: allow inline data extents creation if sector size < page size
  2024-11-15  6:03 [PATCH 0/2] btrfs: allow creating inline data extents for sector size < page size case Qu Wenruo
  2024-11-15  6:03 ` [PATCH 1/2] btrfs: fix the qgroup data free range for inline data extents Qu Wenruo
@ 2024-11-15  6:03 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2024-11-15  6:03 UTC (permalink / raw)
  To: linux-btrfs

Previously 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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/inode.c | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a0599369ca0c..712157ecda08 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -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;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-15  6:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15  6:03 [PATCH 0/2] btrfs: allow creating inline data extents for sector size < page size case Qu Wenruo
2024-11-15  6:03 ` [PATCH 1/2] btrfs: fix the qgroup data free range for inline data extents Qu Wenruo
2024-11-15  6:03 ` [PATCH 2/2] btrfs: allow inline data extents creation if sector size < page size Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox