linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages()
@ 2010-03-25 12:30 Miao Xie
  2010-03-31  0:23 ` Chris Mason
  0 siblings, 1 reply; 3+ messages in thread
From: Miao Xie @ 2010-03-25 12:30 UTC (permalink / raw)
  To: Chris Mason; +Cc: Linux Btrfs

From: Zhao Lei <zhaolei@cn.fujitsu.com>

num_copies's value is not changed in this function,
and it is not necessary to calculate its value multi-times.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
 fs/btrfs/disk-io.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 11d0ad3..79d9196 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -301,7 +301,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
 {
 	struct extent_io_tree *io_tree;
 	int ret;
-	int num_copies = 0;
+	int num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
+					  eb->start, eb->len);
 	int mirror_num = 0;
 
 	io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
@@ -312,8 +313,6 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
 		    !verify_parent_transid(io_tree, eb, parent_transid))
 			return ret;
 
-		num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
-					      eb->start, eb->len);
 		if (num_copies == 1)
 			return ret;
 
-- 
1.6.5.2



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

* Re: [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages()
  2010-03-25 12:30 [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages() Miao Xie
@ 2010-03-31  0:23 ` Chris Mason
  2010-03-31  4:04   ` Zhaolei
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Mason @ 2010-03-31  0:23 UTC (permalink / raw)
  To: Miao Xie; +Cc: Linux Btrfs

On Thu, Mar 25, 2010 at 08:30:17PM +0800, Miao Xie wrote:
> From: Zhao Lei <zhaolei@cn.fujitsu.com>
> 
> num_copies's value is not changed in this function,
> and it is not necessary to calculate its value multi-times.

It is true that we don't need to calculate this multiple times, but with
the existing code the calculation is only done when there is an IO
error.

We could use a check for num_copies == 0 before calling the calc
function.

-chris

> 
> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
> ---
>  fs/btrfs/disk-io.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 11d0ad3..79d9196 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -301,7 +301,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
>  {
>  	struct extent_io_tree *io_tree;
>  	int ret;
> -	int num_copies = 0;
> +	int num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
> +					  eb->start, eb->len);
>  	int mirror_num = 0;
>  
>  	io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
> @@ -312,8 +313,6 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
>  		    !verify_parent_transid(io_tree, eb, parent_transid))
>  			return ret;
>  
> -		num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
> -					      eb->start, eb->len);
>  		if (num_copies == 1)
>  			return ret;
>  
> -- 
> 1.6.5.2
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: Re: [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages()
  2010-03-31  0:23 ` Chris Mason
@ 2010-03-31  4:04   ` Zhaolei
  0 siblings, 0 replies; 3+ messages in thread
From: Zhaolei @ 2010-03-31  4:04 UTC (permalink / raw)
  To: Chris Mason, Miao Xie, Linux Btrfs

Chris Mason wrote:
> On Thu, Mar 25, 2010 at 08:30:17PM +0800, Miao Xie wrote:
>> From: Zhao Lei <zhaolei@cn.fujitsu.com>
>>
>> num_copies's value is not changed in this function,
>> and it is not necessary to calculate its value multi-times.
> 
> It is true that we don't need to calculate this multiple times, but with
> the existing code the calculation is only done when there is an IO
> error.
> 
> We could use a check for num_copies == 0 before calling the calc
> function.
> 
> -chris

Hello, chris

I'll modify this patch to read num_copies only in IO error.

Thanks
Zhaolei

>> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
>> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
>> ---
>>  fs/btrfs/disk-io.c |    5 ++---
>>  1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
>> index 11d0ad3..79d9196 100644
>> --- a/fs/btrfs/disk-io.c
>> +++ b/fs/btrfs/disk-io.c
>> @@ -301,7 +301,8 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
>>  {
>>  	struct extent_io_tree *io_tree;
>>  	int ret;
>> -	int num_copies = 0;
>> +	int num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
>> +					  eb->start, eb->len);
>>  	int mirror_num = 0;
>>  
>>  	io_tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
>> @@ -312,8 +313,6 @@ static int btree_read_extent_buffer_pages(struct btrfs_root *root,
>>  		    !verify_parent_transid(io_tree, eb, parent_transid))
>>  			return ret;
>>  
>> -		num_copies = btrfs_num_copies(&root->fs_info->mapping_tree,
>> -					      eb->start, eb->len);
>>  		if (num_copies == 1)
>>  			return ret;
>>  
>> -- 
>> 1.6.5.2
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 



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

end of thread, other threads:[~2010-03-31  4:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-25 12:30 [PATCH 05/18] btrfs: Take num_copies out of loop for btree_read_extent_buffer_pages() Miao Xie
2010-03-31  0:23 ` Chris Mason
2010-03-31  4:04   ` Zhaolei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).