All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: zoned: limit max extent size to max zone append
@ 2021-06-01 13:02 Johannes Thumshirn
  2021-06-01 13:02 ` [PATCH 1/2] btrfs: add a helper for retrieving BTRFS_MAX_EXTENT_SIZE Johannes Thumshirn
  2021-06-01 13:02 ` [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size Johannes Thumshirn
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2021-06-01 13:02 UTC (permalink / raw)
  To: David Sterba
  Cc: Johannes Thumshirn, Damien Le Moal, Naohiro Aota, linux-btrfs

The first patch factors out retrieving BTRFS_MAX_EXTENT_SIZE into a helper and
the second patch fixes the actual problem for zoned btrfs.

Johannes Thumshirn (2):
  btrfs: add a helper for retrieving BTRFS_MAX_EXTENT_SIZE
  btrfs: zoned: limit ordered extent to zoned append size

 fs/btrfs/ctree.h                 | 26 ++++++++++++++++++--------
 fs/btrfs/delalloc-space.c        |  6 +++---
 fs/btrfs/extent_io.c             |  2 +-
 fs/btrfs/inode.c                 | 22 ++++++++++++----------
 fs/btrfs/tests/extent-io-tests.c |  2 +-
 fs/btrfs/tests/inode-tests.c     | 31 ++++++++++++++++---------------
 6 files changed, 51 insertions(+), 38 deletions(-)

-- 
2.31.1


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

* [PATCH 1/2] btrfs: add a helper for retrieving BTRFS_MAX_EXTENT_SIZE
  2021-06-01 13:02 [PATCH 0/2] btrfs: zoned: limit max extent size to max zone append Johannes Thumshirn
@ 2021-06-01 13:02 ` Johannes Thumshirn
  2021-06-01 13:02 ` [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size Johannes Thumshirn
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Thumshirn @ 2021-06-01 13:02 UTC (permalink / raw)
  To: David Sterba
  Cc: Johannes Thumshirn, Damien Le Moal, Naohiro Aota, linux-btrfs

Add a helper for retrieving BTRFS_MAX_EXTENT_SIZE as a preparation for a
fix in this area.

This patch has no functional changes.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/ctree.h                 | 23 +++++++++++++++--------
 fs/btrfs/delalloc-space.c        |  6 +++---
 fs/btrfs/extent_io.c             |  2 +-
 fs/btrfs/inode.c                 | 22 ++++++++++++----------
 fs/btrfs/tests/extent-io-tests.c |  2 +-
 fs/btrfs/tests/inode-tests.c     | 31 ++++++++++++++++---------------
 6 files changed, 48 insertions(+), 38 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c63980977fa4..5d0398528a7a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -105,14 +105,6 @@ struct btrfs_ref;
 #define BTRFS_STAT_CURR		0
 #define BTRFS_STAT_PREV		1
 
-/*
- * Count how many BTRFS_MAX_EXTENT_SIZE cover the @size
- */
-static inline u32 count_max_extents(u64 size)
-{
-	return div_u64(size + BTRFS_MAX_EXTENT_SIZE - 1, BTRFS_MAX_EXTENT_SIZE);
-}
-
 static inline unsigned long btrfs_chunk_item_size(int num_stripes)
 {
 	BUG_ON(num_stripes == 0);
@@ -1379,6 +1371,21 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
 	return BTRFS_MAX_ITEM_SIZE(info) - sizeof(struct btrfs_dir_item);
 }
 
+static inline u64 btrfs_get_max_extent_size(struct btrfs_fs_info *fs_info)
+{
+	return BTRFS_MAX_EXTENT_SIZE;
+}
+
+/*
+ * Count how many BTRFS_MAX_EXTENT_SIZE cover the @size
+ */
+static inline u32 count_max_extents(struct btrfs_fs_info *fs_info, u64 size)
+{
+	u64 max_extent_size = btrfs_get_max_extent_size(fs_info);
+
+	return div_u64(size + max_extent_size - 1, max_extent_size);
+}
+
 /*
  * Flags for mount options.
  *
diff --git a/fs/btrfs/delalloc-space.c b/fs/btrfs/delalloc-space.c
index 56642ca7af10..2618693308d1 100644
--- a/fs/btrfs/delalloc-space.c
+++ b/fs/btrfs/delalloc-space.c
@@ -270,7 +270,7 @@ static void calc_inode_reservations(struct btrfs_fs_info *fs_info,
 				    u64 num_bytes, u64 *meta_reserve,
 				    u64 *qgroup_reserve)
 {
-	u64 nr_extents = count_max_extents(num_bytes);
+	u64 nr_extents = count_max_extents(fs_info, num_bytes);
 	u64 csum_leaves = btrfs_csum_bytes_to_leaves(fs_info, num_bytes);
 	u64 inode_update = btrfs_calc_metadata_size(fs_info, 1);
 
@@ -344,7 +344,7 @@ int btrfs_delalloc_reserve_metadata(struct btrfs_inode *inode, u64 num_bytes)
 	 * needs to free the reservation we just made.
 	 */
 	spin_lock(&inode->lock);
-	nr_extents = count_max_extents(num_bytes);
+	nr_extents = count_max_extents(fs_info, num_bytes);
 	btrfs_mod_outstanding_extents(inode, nr_extents);
 	inode->csum_bytes += num_bytes;
 	btrfs_calculate_inode_block_rsv_size(fs_info, inode);
@@ -407,7 +407,7 @@ void btrfs_delalloc_release_extents(struct btrfs_inode *inode, u64 num_bytes)
 	unsigned num_extents;
 
 	spin_lock(&inode->lock);
-	num_extents = count_max_extents(num_bytes);
+	num_extents = count_max_extents(fs_info, num_bytes);
 	btrfs_mod_outstanding_extents(inode, -num_extents);
 	btrfs_calculate_inode_block_rsv_size(fs_info, inode);
 	spin_unlock(&inode->lock);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 13c5e880404d..954d28df887a 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1863,7 +1863,7 @@ noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
 				    u64 *end)
 {
 	struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
-	u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
+	u64 max_bytes = btrfs_get_max_extent_size(btrfs_sb(inode->i_sb));
 	u64 delalloc_start;
 	u64 delalloc_end;
 	bool found;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2eedcf65b8aa..8ba4b194cd3e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1936,6 +1936,7 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
 void btrfs_split_delalloc_extent(struct inode *inode,
 				 struct extent_state *orig, u64 split)
 {
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	u64 size;
 
 	/* not delalloc, ignore it */
@@ -1943,7 +1944,7 @@ void btrfs_split_delalloc_extent(struct inode *inode,
 		return;
 
 	size = orig->end - orig->start + 1;
-	if (size > BTRFS_MAX_EXTENT_SIZE) {
+	if (size > btrfs_get_max_extent_size(fs_info)) {
 		u32 num_extents;
 		u64 new_size;
 
@@ -1952,10 +1953,10 @@ void btrfs_split_delalloc_extent(struct inode *inode,
 		 * applies here, just in reverse.
 		 */
 		new_size = orig->end - split + 1;
-		num_extents = count_max_extents(new_size);
+		num_extents = count_max_extents(fs_info, new_size);
 		new_size = split - orig->start;
-		num_extents += count_max_extents(new_size);
-		if (count_max_extents(size) >= num_extents)
+		num_extents += count_max_extents(fs_info, new_size);
+		if (count_max_extents(fs_info, size) >= num_extents)
 			return;
 	}
 
@@ -1972,6 +1973,7 @@ void btrfs_split_delalloc_extent(struct inode *inode,
 void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 				 struct extent_state *other)
 {
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	u64 new_size, old_size;
 	u32 num_extents;
 
@@ -1985,7 +1987,7 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 		new_size = other->end - new->start + 1;
 
 	/* we're not bigger than the max, unreserve the space and go */
-	if (new_size <= BTRFS_MAX_EXTENT_SIZE) {
+	if (new_size <= btrfs_get_max_extent_size(fs_info)) {
 		spin_lock(&BTRFS_I(inode)->lock);
 		btrfs_mod_outstanding_extents(BTRFS_I(inode), -1);
 		spin_unlock(&BTRFS_I(inode)->lock);
@@ -2011,10 +2013,10 @@ void btrfs_merge_delalloc_extent(struct inode *inode, struct extent_state *new,
 	 * this case.
 	 */
 	old_size = other->end - other->start + 1;
-	num_extents = count_max_extents(old_size);
+	num_extents = count_max_extents(fs_info, old_size);
 	old_size = new->end - new->start + 1;
-	num_extents += count_max_extents(old_size);
-	if (count_max_extents(new_size) >= num_extents)
+	num_extents += count_max_extents(fs_info, old_size);
+	if (count_max_extents(fs_info, new_size) >= num_extents)
 		return;
 
 	spin_lock(&BTRFS_I(inode)->lock);
@@ -2093,7 +2095,7 @@ void btrfs_set_delalloc_extent(struct inode *inode, struct extent_state *state,
 	if (!(state->state & EXTENT_DELALLOC) && (*bits & EXTENT_DELALLOC)) {
 		struct btrfs_root *root = BTRFS_I(inode)->root;
 		u64 len = state->end + 1 - state->start;
-		u32 num_extents = count_max_extents(len);
+		u32 num_extents = count_max_extents(fs_info, len);
 		bool do_list = !btrfs_is_free_space_inode(BTRFS_I(inode));
 
 		spin_lock(&BTRFS_I(inode)->lock);
@@ -2135,7 +2137,7 @@ void btrfs_clear_delalloc_extent(struct inode *vfs_inode,
 	struct btrfs_inode *inode = BTRFS_I(vfs_inode);
 	struct btrfs_fs_info *fs_info = btrfs_sb(vfs_inode->i_sb);
 	u64 len = state->end + 1 - state->start;
-	u32 num_extents = count_max_extents(len);
+	u32 num_extents = count_max_extents(fs_info, len);
 
 	if ((state->state & EXTENT_DEFRAG) && (*bits & EXTENT_DEFRAG)) {
 		spin_lock(&inode->lock);
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 73e96d505f4f..99b791b931d7 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -64,7 +64,7 @@ static int test_find_delalloc(u32 sectorsize)
 	struct page *locked_page = NULL;
 	unsigned long index = 0;
 	/* In this test we need at least 2 file extents at its maximum size */
-	u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
+	u64 max_bytes = btrfs_get_max_extent_size(NULL);
 	u64 total_dirty = 2 * max_bytes;
 	u64 start, end, test_start;
 	bool found;
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
index c9874b12d337..0a437371ee21 100644
--- a/fs/btrfs/tests/inode-tests.c
+++ b/fs/btrfs/tests/inode-tests.c
@@ -917,6 +917,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	struct btrfs_fs_info *fs_info = NULL;
 	struct inode *inode = NULL;
 	struct btrfs_root *root = NULL;
+	u64 max_extent_size = btrfs_get_max_extent_size(NULL);
 	int ret = -ENOMEM;
 
 	test_msg("running outstanding_extents tests");
@@ -943,7 +944,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 
 	/* [BTRFS_MAX_EXTENT_SIZE] */
 	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), 0,
-					BTRFS_MAX_EXTENT_SIZE - 1, 0, NULL);
+					max_extent_size - 1, 0, NULL);
 	if (ret) {
 		test_err("btrfs_set_extent_delalloc returned %d", ret);
 		goto out;
@@ -956,8 +957,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	}
 
 	/* [BTRFS_MAX_EXTENT_SIZE][sectorsize] */
-	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), BTRFS_MAX_EXTENT_SIZE,
-					BTRFS_MAX_EXTENT_SIZE + sectorsize - 1,
+	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), max_extent_size,
+					max_extent_size + sectorsize - 1,
 					0, NULL);
 	if (ret) {
 		test_err("btrfs_set_extent_delalloc returned %d", ret);
@@ -972,8 +973,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 
 	/* [BTRFS_MAX_EXTENT_SIZE/2][sectorsize HOLE][the rest] */
 	ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
-			       BTRFS_MAX_EXTENT_SIZE >> 1,
-			       (BTRFS_MAX_EXTENT_SIZE >> 1) + sectorsize - 1,
+			       max_extent_size >> 1,
+			       (max_extent_size >> 1) + sectorsize - 1,
 			       EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
 			       EXTENT_UPTODATE, 0, 0, NULL);
 	if (ret) {
@@ -988,8 +989,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	}
 
 	/* [BTRFS_MAX_EXTENT_SIZE][sectorsize] */
-	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), BTRFS_MAX_EXTENT_SIZE >> 1,
-					(BTRFS_MAX_EXTENT_SIZE >> 1)
+	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), max_extent_size >> 1,
+					(max_extent_size >> 1)
 					+ sectorsize - 1,
 					0, NULL);
 	if (ret) {
@@ -1007,8 +1008,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	 * [BTRFS_MAX_EXTENT_SIZE+sectorsize][sectorsize HOLE][BTRFS_MAX_EXTENT_SIZE+sectorsize]
 	 */
 	ret = btrfs_set_extent_delalloc(BTRFS_I(inode),
-			BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize,
-			(BTRFS_MAX_EXTENT_SIZE << 1) + 3 * sectorsize - 1,
+			max_extent_size + 2 * sectorsize,
+			(max_extent_size << 1) + 3 * sectorsize - 1,
 			0, NULL);
 	if (ret) {
 		test_err("btrfs_set_extent_delalloc returned %d", ret);
@@ -1025,8 +1026,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	* [BTRFS_MAX_EXTENT_SIZE+sectorsize][sectorsize][BTRFS_MAX_EXTENT_SIZE+sectorsize]
 	*/
 	ret = btrfs_set_extent_delalloc(BTRFS_I(inode),
-			BTRFS_MAX_EXTENT_SIZE + sectorsize,
-			BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, 0, NULL);
+			max_extent_size + sectorsize,
+			max_extent_size + 2 * sectorsize - 1, 0, NULL);
 	if (ret) {
 		test_err("btrfs_set_extent_delalloc returned %d", ret);
 		goto out;
@@ -1040,8 +1041,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 
 	/* [BTRFS_MAX_EXTENT_SIZE+4k][4K HOLE][BTRFS_MAX_EXTENT_SIZE+4k] */
 	ret = clear_extent_bit(&BTRFS_I(inode)->io_tree,
-			       BTRFS_MAX_EXTENT_SIZE + sectorsize,
-			       BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1,
+			       max_extent_size + sectorsize,
+			       max_extent_size + 2 * sectorsize - 1,
 			       EXTENT_DELALLOC | EXTENT_DELALLOC_NEW |
 			       EXTENT_UPTODATE, 0, 0, NULL);
 	if (ret) {
@@ -1060,8 +1061,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
 	 * might fail and I'd rather satisfy my paranoia at this point.
 	 */
 	ret = btrfs_set_extent_delalloc(BTRFS_I(inode),
-			BTRFS_MAX_EXTENT_SIZE + sectorsize,
-			BTRFS_MAX_EXTENT_SIZE + 2 * sectorsize - 1, 0, NULL);
+			max_extent_size + sectorsize,
+			max_extent_size + 2 * sectorsize - 1, 0, NULL);
 	if (ret) {
 		test_err("btrfs_set_extent_delalloc returned %d", ret);
 		goto out;
-- 
2.31.1


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

* [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size
  2021-06-01 13:02 [PATCH 0/2] btrfs: zoned: limit max extent size to max zone append Johannes Thumshirn
  2021-06-01 13:02 ` [PATCH 1/2] btrfs: add a helper for retrieving BTRFS_MAX_EXTENT_SIZE Johannes Thumshirn
@ 2021-06-01 13:02 ` Johannes Thumshirn
  2021-06-01 16:17   ` David Sterba
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Thumshirn @ 2021-06-01 13:02 UTC (permalink / raw)
  To: David Sterba
  Cc: Johannes Thumshirn, Damien Le Moal, Naohiro Aota, linux-btrfs

Damien reported a test failure with btrfs/209. The test itself ran fine,
but the fsck run afterwards reported a corrupted filesystem.

The filesystem corruption happens because we're splitting an extent and
then writing the extent twice. We have to split the extent though, because
we're creating too large extents for a REQ_OP_ZONE_APPEND operation.

When dumping the extent tree, we can see two EXTENT_ITEMs at the same
start address but different lengths.

$ btrfs inspect dump-tree /dev/nullb1 -t extent
...
   item 19 key (269484032 EXTENT_ITEM 126976) itemoff 15470 itemsize 53
           refs 1 gen 7 flags DATA
           extent data backref root FS_TREE objectid 257 offset 786432 count 1
   item 20 key (269484032 EXTENT_ITEM 262144) itemoff 15417 itemsize 53
           refs 1 gen 7 flags DATA
           extent data backref root FS_TREE objectid 257 offset 786432 count 1

On a zoned filesystem, limit the size of an ordered extent to the maximum
size that can be issued as a single REQ_OP_ZONE_APPEND operation.

Note: This patch breaks fstests btrfs/079, as it increases the number of
on-disk extents from 80 to 83 per 10M write.

Reported-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/ctree.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 5d0398528a7a..6fbafaaebda0 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1373,7 +1373,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
 
 static inline u64 btrfs_get_max_extent_size(struct btrfs_fs_info *fs_info)
 {
-	return BTRFS_MAX_EXTENT_SIZE;
+	if (!fs_info || !fs_info->max_zone_append_size)
+		return BTRFS_MAX_EXTENT_SIZE;
+	return min_t(u64, BTRFS_MAX_EXTENT_SIZE,
+		     ALIGN_DOWN(fs_info->max_zone_append_size, PAGE_SIZE));
 }
 
 /*
-- 
2.31.1


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

* Re: [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size
  2021-06-01 13:02 ` [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size Johannes Thumshirn
@ 2021-06-01 16:17   ` David Sterba
  2021-06-02  6:05     ` Johannes Thumshirn
  0 siblings, 1 reply; 6+ messages in thread
From: David Sterba @ 2021-06-01 16:17 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: David Sterba, Damien Le Moal, Naohiro Aota, linux-btrfs

On Tue, Jun 01, 2021 at 10:02:10PM +0900, Johannes Thumshirn wrote:
> Damien reported a test failure with btrfs/209. The test itself ran fine,
> but the fsck run afterwards reported a corrupted filesystem.
> 
> The filesystem corruption happens because we're splitting an extent and
> then writing the extent twice. We have to split the extent though, because
> we're creating too large extents for a REQ_OP_ZONE_APPEND operation.
> 
> When dumping the extent tree, we can see two EXTENT_ITEMs at the same
> start address but different lengths.
> 
> $ btrfs inspect dump-tree /dev/nullb1 -t extent
> ...
>    item 19 key (269484032 EXTENT_ITEM 126976) itemoff 15470 itemsize 53
>            refs 1 gen 7 flags DATA
>            extent data backref root FS_TREE objectid 257 offset 786432 count 1
>    item 20 key (269484032 EXTENT_ITEM 262144) itemoff 15417 itemsize 53
>            refs 1 gen 7 flags DATA
>            extent data backref root FS_TREE objectid 257 offset 786432 count 1
> 
> On a zoned filesystem, limit the size of an ordered extent to the maximum
> size that can be issued as a single REQ_OP_ZONE_APPEND operation.
> 
> Note: This patch breaks fstests btrfs/079, as it increases the number of
> on-disk extents from 80 to 83 per 10M write.
> 
> Reported-by: Damien Le Moal <damien.lemoal@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  fs/btrfs/ctree.h | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index 5d0398528a7a..6fbafaaebda0 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -1373,7 +1373,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
>  
>  static inline u64 btrfs_get_max_extent_size(struct btrfs_fs_info *fs_info)
>  {
> -	return BTRFS_MAX_EXTENT_SIZE;
> +	if (!fs_info || !fs_info->max_zone_append_size)
> +		return BTRFS_MAX_EXTENT_SIZE;
> +	return min_t(u64, BTRFS_MAX_EXTENT_SIZE,
> +		     ALIGN_DOWN(fs_info->max_zone_append_size, PAGE_SIZE));

Should this be set only once in btrfs_check_zoned_mode ?

>  }
>  
>  /*
> -- 
> 2.31.1
> 

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

* Re: [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size
  2021-06-01 16:17   ` David Sterba
@ 2021-06-02  6:05     ` Johannes Thumshirn
  2021-06-02 11:13       ` David Sterba
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Thumshirn @ 2021-06-02  6:05 UTC (permalink / raw)
  To: dsterba; +Cc: David Sterba, Damien Le Moal, Naohiro Aota, linux-btrfs

On 01/06/2021 18:20, David Sterba wrote:
>> ---
>>  fs/btrfs/ctree.h | 5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
>> index 5d0398528a7a..6fbafaaebda0 100644
>> --- a/fs/btrfs/ctree.h
>> +++ b/fs/btrfs/ctree.h
>> @@ -1373,7 +1373,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
>>  
>>  static inline u64 btrfs_get_max_extent_size(struct btrfs_fs_info *fs_info)
>>  {
>> -	return BTRFS_MAX_EXTENT_SIZE;
>> +	if (!fs_info || !fs_info->max_zone_append_size)
>> +		return BTRFS_MAX_EXTENT_SIZE;
>> +	return min_t(u64, BTRFS_MAX_EXTENT_SIZE,
>> +		     ALIGN_DOWN(fs_info->max_zone_append_size, PAGE_SIZE));
> 
> Should this be set only once in btrfs_check_zoned_mode ?

Do you mean adding a fs_info->max_extent_size member or 
fs_info->max_zone_append_size = min(BTRFS_MAX_EXTENT_SIZE, queue_max_append_size())?

I'd opt for #1 

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

* Re: [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size
  2021-06-02  6:05     ` Johannes Thumshirn
@ 2021-06-02 11:13       ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2021-06-02 11:13 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: David Sterba, Damien Le Moal, Naohiro Aota, linux-btrfs

On Wed, Jun 02, 2021 at 06:05:45AM +0000, Johannes Thumshirn wrote:
> On 01/06/2021 18:20, David Sterba wrote:
> >> ---
> >>  fs/btrfs/ctree.h | 5 ++++-
> >>  1 file changed, 4 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> >> index 5d0398528a7a..6fbafaaebda0 100644
> >> --- a/fs/btrfs/ctree.h
> >> +++ b/fs/btrfs/ctree.h
> >> @@ -1373,7 +1373,10 @@ static inline u32 BTRFS_MAX_XATTR_SIZE(const struct btrfs_fs_info *info)
> >>  
> >>  static inline u64 btrfs_get_max_extent_size(struct btrfs_fs_info *fs_info)
> >>  {
> >> -	return BTRFS_MAX_EXTENT_SIZE;
> >> +	if (!fs_info || !fs_info->max_zone_append_size)
> >> +		return BTRFS_MAX_EXTENT_SIZE;
> >> +	return min_t(u64, BTRFS_MAX_EXTENT_SIZE,
> >> +		     ALIGN_DOWN(fs_info->max_zone_append_size, PAGE_SIZE));
> > 
> > Should this be set only once in btrfs_check_zoned_mode ?
> 
> Do you mean adding a fs_info->max_extent_size member or 
> fs_info->max_zone_append_size = min(BTRFS_MAX_EXTENT_SIZE, queue_max_append_size())?
> 
> I'd opt for #1 

Yeah, replace BTRFS_MAX_EXTENT_SIZE by a fs_info member and then adjust
it for max append zone.

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

end of thread, other threads:[~2021-06-02 15:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 13:02 [PATCH 0/2] btrfs: zoned: limit max extent size to max zone append Johannes Thumshirn
2021-06-01 13:02 ` [PATCH 1/2] btrfs: add a helper for retrieving BTRFS_MAX_EXTENT_SIZE Johannes Thumshirn
2021-06-01 13:02 ` [PATCH 2/2] btrfs: zoned: limit ordered extent to zoned append size Johannes Thumshirn
2021-06-01 16:17   ` David Sterba
2021-06-02  6:05     ` Johannes Thumshirn
2021-06-02 11:13       ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.