diff mbox series

btrfs: tests: Use BTRFS_MAX_EXTENT_SIZE to replace the intermediate number

Message ID 20181103092452.14572-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: tests: Use BTRFS_MAX_EXTENT_SIZE to replace the intermediate number | expand

Commit Message

Qu Wenruo Nov. 3, 2018, 9:24 a.m. UTC
In extent-io self test, we need 2 ordered extents at its maximum size to
do the test.

Instead of using the intermediate numbers, use BTRFS_MAX_EXTENT_SIZE for
@max_bytes, and twice @max_bytes for @total_dirty.
This should explain why we need all these magic numbers and prevent
people to modify them by accident.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/tests/extent-io-tests.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Nikolay Borisov Nov. 3, 2018, 9:29 a.m. UTC | #1
On 3.11.18 г. 11:24 ч., Qu Wenruo wrote:
> In extent-io self test, we need 2 ordered extents at its maximum size to
> do the test.
> 
> Instead of using the intermediate numbers, use BTRFS_MAX_EXTENT_SIZE for
> @max_bytes, and twice @max_bytes for @total_dirty.
> This should explain why we need all these magic numbers and prevent
> people to modify them by accident.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/tests/extent-io-tests.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index 9e0f4a01be14..c0ad9bc48f6b 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -62,8 +62,9 @@ static int test_find_delalloc(u32 sectorsize)
>  	struct page *page;
>  	struct page *locked_page = NULL;
>  	unsigned long index = 0;
> -	u64 total_dirty = SZ_256M;
> -	u64 max_bytes = SZ_128M;
> +	/* In this test we need at least 2 file extents at its maximum size */
> +	u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
> +	u64 total_dirty = 2 * max_bytes;
>  	u64 start, end, test_start;
>  	u64 found;
>  	int ret = -EINVAL;
>
David Sterba Nov. 5, 2018, 6:16 p.m. UTC | #2
On Sat, Nov 03, 2018 at 05:24:52PM +0800, Qu Wenruo wrote:
> In extent-io self test, we need 2 ordered extents at its maximum size to
> do the test.
> 
> Instead of using the intermediate numbers, use BTRFS_MAX_EXTENT_SIZE for
> @max_bytes, and twice @max_bytes for @total_dirty.
> This should explain why we need all these magic numbers and prevent
> people to modify them by accident.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 9e0f4a01be14..c0ad9bc48f6b 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -62,8 +62,9 @@  static int test_find_delalloc(u32 sectorsize)
 	struct page *page;
 	struct page *locked_page = NULL;
 	unsigned long index = 0;
-	u64 total_dirty = SZ_256M;
-	u64 max_bytes = SZ_128M;
+	/* In this test we need at least 2 file extents at its maximum size */
+	u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
+	u64 total_dirty = 2 * max_bytes;
 	u64 start, end, test_start;
 	u64 found;
 	int ret = -EINVAL;