Re: [PATCH 3/5] Btrfs: self-tests: Support non-4k page size

2016-05-30 Thread Feifei Xu



On 2016/5/30 21:55, David Sterba wrote:

On Sun, May 29, 2016 at 01:17:34PM +0800, Fei Fei Xu wrote:

There are more instances of the pointed style issues, please fix all of
them. As the changes do not affect functionality I'll add the paches to
for-next, but I'm expecting a v2.

Thanks, I will send out v2 soon according to all above comments.

What's the base of the patchset? Does not apply cleanly on the current
integration (ie. what's in master).

It is based on branch master commit 2f7c3a18a2dc79ddf7b , which is not 
up-to-date already.

I will send out a v2 soon to fix this.

Thanks
Feifei







--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] Btrfs: self-tests: Support non-4k page size

2016-05-30 Thread David Sterba
On Sun, May 29, 2016 at 01:17:34PM +0800, Fei Fei Xu wrote:
> > There are more instances of the pointed style issues, please fix all of
> > them. As the changes do not affect functionality I'll add the paches to
> > for-next, but I'm expecting a v2.
> Thanks, I will send out v2 soon according to all above comments.

What's the base of the patchset? Does not apply cleanly on the current
integration (ie. what's in master).
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] Btrfs: self-tests: Support non-4k page size

2016-05-28 Thread Fei Fei Xu



On 2016/5/28 3:29, David Sterba wrote:

On Fri, May 27, 2016 at 03:00:36PM +0800, Feifei Xu wrote:

self-tests code assumes 4k as the sectorsize and nodesize. This commit
enables the self-tests code to be executed on non-4k page sized
systems (e.g. ppc64).

To test all possible sectorsizes, this commit adds a sectorsize
array. This commit executes the tests for all possible sectorsizes and
nodesizes.

Signed-off-by: Feifei Xu 
Signed-off-by: Chandan Rajendra 
---
  fs/btrfs/ctree.c   |   6 +-
  fs/btrfs/disk-io.c |   9 +-
  fs/btrfs/disk-io.h |   3 +-
  fs/btrfs/extent_io.c   |  10 +-
  fs/btrfs/extent_io.h   |   4 +-
  fs/btrfs/free-space-cache.c|   2 +-
  fs/btrfs/super.c   |  62 --
  fs/btrfs/tests/btrfs-tests.c   |   6 +-
  fs/btrfs/tests/btrfs-tests.h   |  27 +--
  fs/btrfs/tests/extent-buffer-tests.c   |  13 +-
  fs/btrfs/tests/extent-io-tests.c   |  85 
  fs/btrfs/tests/free-space-tests.c  |  67 +++---
  fs/btrfs/tests/free-space-tree-tests.c |  30 +--
  fs/btrfs/tests/inode-tests.c   | 379 ++---
  fs/btrfs/tests/qgroup-tests.c  | 111 ++
  15 files changed, 462 insertions(+), 352 deletions(-)

The patch is quite big, please separate all changes that are not related
to the 4096/sectorsize/PAGE_SIZE change, eg. adding missing "\n" to
strings, replacement of constants with defines

OK.

@@ -1314,14 +1315,16 @@ static struct btrfs_root *btrfs_alloc_root(struct 
btrfs_fs_info *fs_info,
  
  #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS

  /* Should only be used by the testing infrastructure */
-struct btrfs_root *btrfs_alloc_dummy_root(void)
+struct btrfs_root *
+btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize)

Please keep the style as-is, ie. return type and name on one line


  {
struct btrfs_root *root;
  
  	root = btrfs_alloc_root(NULL, GFP_KERNEL);

if (!root)
return ERR_PTR(-ENOMEM);
-   __setup_root(4096, 4096, 4096, root, NULL, 1);
+   __setup_root(nodesize, sectorsize, sectorsize, root, NULL,

The 3rd parameter is stripesize, but we don't use it anywhere so
sectorsize should be fine, just looks a bit strange.


+   BTRFS_ROOT_TREE_OBJECTID);
set_bit(BTRFS_ROOT_DUMMY_ROOT, >state);
root->alloc_bytenr = 0;
  
--- a/fs/btrfs/extent_io.c

+++ b/fs/btrfs/extent_io.c
@@ -4714,16 +4714,16 @@ err:
  }
  
  struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,

-   u64 start)
+   u64 start, u32 alt_nodesize)

This could be named 'nodesize'.


  {
unsigned long len;
  
  	if (!fs_info) {

/*
 * Called only from tests that don't always have a fs_info
-* available, but we know that nodesize is 4096
+* available
 */
-   len = 4096;
+   len = alt_nodesize;
} else {
len = fs_info->tree_root->nodesize;
}
@@ -4819,7 +4819,7 @@ struct extent_buffer *find_extent_buffer(struct 
btrfs_fs_info *fs_info,
  
  #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS

  struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
-  u64 start)
+   u64 start, u32 alt_nodesize)

dtto


  {
struct extent_buffer *eb, *exists = NULL;
int ret;
@@ -4827,7 +4827,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct 
btrfs_fs_info *fs_info,
eb = find_extent_buffer(fs_info, start);
if (eb)
return eb;
-   eb = alloc_dummy_extent_buffer(fs_info, start);
+   eb = alloc_dummy_extent_buffer(fs_info, start, alt_nodesize);
if (!eb)
return NULL;
eb->fs_info = fs_info;
ctl->extents_thresh = 0;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index bf71071..c97c250 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2318,28 +2318,54 @@ static void btrfs_print_mod_info(void)
  
  static int btrfs_run_sanity_tests(void)

  {
-   int ret;
-
+   int ret, i;
+   u32 sectorsize, nodesize;
+   u32 test_sectorsize[] = {
+   PAGE_SIZE,
+   };
ret = btrfs_init_test_fs();
if (ret)
return ret;
+   for (i = 0; i < ARRAY_SIZE(test_sectorsize); i++) {
+   /* Validate sectorsize. */
+   sectorsize = test_sectorsize[i];
+   if (!is_power_of_2(sectorsize) || sectorsize < SZ_4K ||
+   sectorsize > PAGE_SIZE) {
+   continue;
+   }
  
-	ret = btrfs_test_free_space_cache();

-   if (ret)
-   goto out;
-   ret = 

Re: [PATCH 3/5] Btrfs: self-tests: Support non-4k page size

2016-05-27 Thread David Sterba
On Fri, May 27, 2016 at 03:00:36PM +0800, Feifei Xu wrote:
> self-tests code assumes 4k as the sectorsize and nodesize. This commit
> enables the self-tests code to be executed on non-4k page sized
> systems (e.g. ppc64).
> 
> To test all possible sectorsizes, this commit adds a sectorsize
> array. This commit executes the tests for all possible sectorsizes and
> nodesizes.
> 
> Signed-off-by: Feifei Xu 
> Signed-off-by: Chandan Rajendra 
> ---
>  fs/btrfs/ctree.c   |   6 +-
>  fs/btrfs/disk-io.c |   9 +-
>  fs/btrfs/disk-io.h |   3 +-
>  fs/btrfs/extent_io.c   |  10 +-
>  fs/btrfs/extent_io.h   |   4 +-
>  fs/btrfs/free-space-cache.c|   2 +-
>  fs/btrfs/super.c   |  62 --
>  fs/btrfs/tests/btrfs-tests.c   |   6 +-
>  fs/btrfs/tests/btrfs-tests.h   |  27 +--
>  fs/btrfs/tests/extent-buffer-tests.c   |  13 +-
>  fs/btrfs/tests/extent-io-tests.c   |  85 
>  fs/btrfs/tests/free-space-tests.c  |  67 +++---
>  fs/btrfs/tests/free-space-tree-tests.c |  30 +--
>  fs/btrfs/tests/inode-tests.c   | 379 
> ++---
>  fs/btrfs/tests/qgroup-tests.c  | 111 ++
>  15 files changed, 462 insertions(+), 352 deletions(-)

The patch is quite big, please separate all changes that are not related
to the 4096/sectorsize/PAGE_SIZE change, eg. adding missing "\n" to
strings, replacement of constants with defines

> @@ -1314,14 +1315,16 @@ static struct btrfs_root *btrfs_alloc_root(struct 
> btrfs_fs_info *fs_info,
>  
>  #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
>  /* Should only be used by the testing infrastructure */
> -struct btrfs_root *btrfs_alloc_dummy_root(void)
> +struct btrfs_root *
> +btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize)

Please keep the style as-is, ie. return type and name on one line

>  {
>   struct btrfs_root *root;
>  
>   root = btrfs_alloc_root(NULL, GFP_KERNEL);
>   if (!root)
>   return ERR_PTR(-ENOMEM);
> - __setup_root(4096, 4096, 4096, root, NULL, 1);
> + __setup_root(nodesize, sectorsize, sectorsize, root, NULL,

The 3rd parameter is stripesize, but we don't use it anywhere so
sectorsize should be fine, just looks a bit strange.

> + BTRFS_ROOT_TREE_OBJECTID);
>   set_bit(BTRFS_ROOT_DUMMY_ROOT, >state);
>   root->alloc_bytenr = 0;
>  
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -4714,16 +4714,16 @@ err:
>  }
>  
>  struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info 
> *fs_info,
> - u64 start)
> + u64 start, u32 alt_nodesize)

This could be named 'nodesize'.

>  {
>   unsigned long len;
>  
>   if (!fs_info) {
>   /*
>* Called only from tests that don't always have a fs_info
> -  * available, but we know that nodesize is 4096
> +  * available
>*/
> - len = 4096;
> + len = alt_nodesize;
>   } else {
>   len = fs_info->tree_root->nodesize;
>   }
> @@ -4819,7 +4819,7 @@ struct extent_buffer *find_extent_buffer(struct 
> btrfs_fs_info *fs_info,
>  
>  #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
>  struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info,
> -u64 start)
> + u64 start, u32 alt_nodesize)

dtto

>  {
>   struct extent_buffer *eb, *exists = NULL;
>   int ret;
> @@ -4827,7 +4827,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct 
> btrfs_fs_info *fs_info,
>   eb = find_extent_buffer(fs_info, start);
>   if (eb)
>   return eb;
> - eb = alloc_dummy_extent_buffer(fs_info, start);
> + eb = alloc_dummy_extent_buffer(fs_info, start, alt_nodesize);
>   if (!eb)
>   return NULL;
>   eb->fs_info = fs_info;
>   ctl->extents_thresh = 0;

> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> index bf71071..c97c250 100644
> --- a/fs/btrfs/super.c
> +++ b/fs/btrfs/super.c
> @@ -2318,28 +2318,54 @@ static void btrfs_print_mod_info(void)
>  
>  static int btrfs_run_sanity_tests(void)
>  {
> - int ret;
> -
> + int ret, i;
> + u32 sectorsize, nodesize;
> + u32 test_sectorsize[] = {
> + PAGE_SIZE,
> + };
>   ret = btrfs_init_test_fs();
>   if (ret)
>   return ret;
> + for (i = 0; i < ARRAY_SIZE(test_sectorsize); i++) {
> + /* Validate sectorsize. */
> + sectorsize = test_sectorsize[i];
> + if (!is_power_of_2(sectorsize) || sectorsize < SZ_4K ||
> + sectorsize > PAGE_SIZE) {
> + continue;
> + }
>  
> - ret = btrfs_test_free_space_cache();
> 

[PATCH 3/5] Btrfs: self-tests: Support non-4k page size

2016-05-27 Thread Feifei Xu
self-tests code assumes 4k as the sectorsize and nodesize. This commit
enables the self-tests code to be executed on non-4k page sized
systems (e.g. ppc64).

To test all possible sectorsizes, this commit adds a sectorsize
array. This commit executes the tests for all possible sectorsizes and
nodesizes.

Signed-off-by: Feifei Xu 
Signed-off-by: Chandan Rajendra 
---
 fs/btrfs/ctree.c   |   6 +-
 fs/btrfs/disk-io.c |   9 +-
 fs/btrfs/disk-io.h |   3 +-
 fs/btrfs/extent_io.c   |  10 +-
 fs/btrfs/extent_io.h   |   4 +-
 fs/btrfs/free-space-cache.c|   2 +-
 fs/btrfs/super.c   |  62 --
 fs/btrfs/tests/btrfs-tests.c   |   6 +-
 fs/btrfs/tests/btrfs-tests.h   |  27 +--
 fs/btrfs/tests/extent-buffer-tests.c   |  13 +-
 fs/btrfs/tests/extent-io-tests.c   |  85 
 fs/btrfs/tests/free-space-tests.c  |  67 +++---
 fs/btrfs/tests/free-space-tree-tests.c |  30 +--
 fs/btrfs/tests/inode-tests.c   | 379 ++---
 fs/btrfs/tests/qgroup-tests.c  | 111 ++
 15 files changed, 462 insertions(+), 352 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index decd0a3..dcb9b8d 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1373,7 +1373,8 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct 
btrfs_path *path,
 
if (tm->op == MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
BUG_ON(tm->slot != 0);
-   eb_rewin = alloc_dummy_extent_buffer(fs_info, eb->start);
+   eb_rewin = alloc_dummy_extent_buffer(fs_info, eb->start,
+   eb->len);
if (!eb_rewin) {
btrfs_tree_read_unlock_blocking(eb);
free_extent_buffer(eb);
@@ -1454,7 +1455,8 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
} else if (old_root) {
btrfs_tree_read_unlock(eb_root);
free_extent_buffer(eb_root);
-   eb = alloc_dummy_extent_buffer(root->fs_info, logical);
+   eb = alloc_dummy_extent_buffer(root->fs_info, logical,
+   root->nodesize);
} else {
btrfs_set_lock_blocking_rw(eb_root, BTRFS_READ_LOCK);
eb = btrfs_clone_extent_buffer(eb_root);
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 91d1239..9f85f1e 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1147,7 +1147,8 @@ struct extent_buffer *btrfs_find_create_tree_block(struct 
btrfs_root *root,
 u64 bytenr)
 {
if (btrfs_test_is_dummy_root(root))
-   return alloc_test_extent_buffer(root->fs_info, bytenr);
+   return alloc_test_extent_buffer(root->fs_info, bytenr,
+   root->nodesize);
return alloc_extent_buffer(root->fs_info, bytenr);
 }
 
@@ -1314,14 +1315,16 @@ static struct btrfs_root *btrfs_alloc_root(struct 
btrfs_fs_info *fs_info,
 
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 /* Should only be used by the testing infrastructure */
-struct btrfs_root *btrfs_alloc_dummy_root(void)
+struct btrfs_root *
+btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize)
 {
struct btrfs_root *root;
 
root = btrfs_alloc_root(NULL, GFP_KERNEL);
if (!root)
return ERR_PTR(-ENOMEM);
-   __setup_root(4096, 4096, 4096, root, NULL, 1);
+   __setup_root(nodesize, sectorsize, sectorsize, root, NULL,
+   BTRFS_ROOT_TREE_OBJECTID);
set_bit(BTRFS_ROOT_DUMMY_ROOT, >state);
root->alloc_bytenr = 0;
 
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 8e79d00..2223361 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -90,7 +90,8 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info 
*fs_info,
 void btrfs_free_fs_root(struct btrfs_root *root);
 
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
-struct btrfs_root *btrfs_alloc_dummy_root(void);
+struct btrfs_root *
+btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize);
 #endif
 
 /*
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 2f83448..7ada3b8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4714,16 +4714,16 @@ err:
 }
 
 struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
-   u64 start)
+   u64 start, u32 alt_nodesize)
 {
unsigned long len;
 
if (!fs_info) {
/*
 * Called only from tests that don't always have a fs_info
-* available, but we know that nodesize is 4096
+* available
 */
-   len = 4096;
+   len = alt_nodesize;
} else {