linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 09/15] btrfs-progs: Always pass 0 for offset when calling btrfs_free_extent for btree blocks.
Date: Mon, 11 Jun 2018 13:05:26 +0800	[thread overview]
Message-ID: <d6a85c64-e6f8-a55a-ddad-339a8e1b4e0d@gmx.com> (raw)
In-Reply-To: <1528462078-24490-10-git-send-email-nborisov@suse.com>



On 2018年06月08日 20:47, Nikolay Borisov wrote:
> Currently some instances of btrfs_free_extent are called with the
> last parameter ("offset") being set to 1. This makes no sense, since
> offset is used for data extents. I suspect this is a left-over from
> 95d3f20b51e9 ("Mixed back reference  (FORWARD ROLLING FORMAT CHANGE)")
> since this commit changed the signature of the function from :
> 
> -int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
> -                     *root, u64 bytenr, u64 num_bytes, u64 parent,
> -                     u64 root_objectid, u64 ref_generation,
> -                     u64 owner_objectid, int pin);
> 
> to
> 
> +int btrfs_free_extent(struct btrfs_trans_handle *trans,
> +                     struct btrfs_root *root,
> +                     u64 bytenr, u64 num_bytes, u64 parent,
> +                     u64 root_objectid, u64 owner, u64 offset);
> 
> I.e the last parameter was "pin" and not offset. So these are just
> leftovers with no semantic meaning. Fix this by passing 0.

And indeed, for tree blocks the @offset parameter is not used at all.

The call sites involving the offset is:
btrfs_free_extent()
|- __free_extent()
   |- lookup_extent_backref()
      |- lookup_inline_extent_backref() <<<
      |- lookup_extent_data_ref()       <<<

And in lookup_inline_extent_backref() we won't use @offset for tree
blocks anyway.

The the 1 passed as @offset should be a left-over.

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

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  ctree.c       | 4 ++--
>  extent-tree.c | 6 +++---
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/ctree.c b/ctree.c
> index 8f3338b4693a..d8a6883aa85f 100644
> --- a/ctree.c
> +++ b/ctree.c
> @@ -334,7 +334,7 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
>  		WARN_ON(btrfs_header_generation(parent) != trans->transid);
>  
>  		btrfs_free_extent(trans, root, buf->start, buf->len,
> -				  0, root->root_key.objectid, level, 1);
> +				  0, root->root_key.objectid, level, 0);
>  	}
>  	if (!list_empty(&buf->recow)) {
>  		list_del_init(&buf->recow);
> @@ -738,7 +738,7 @@ static int balance_level(struct btrfs_trans_handle *trans,
>  
>  		ret = btrfs_free_extent(trans, root, mid->start, mid->len,
>  					0, root->root_key.objectid,
> -					level, 1);
> +					level, 0);
>  		/* once for the root ptr */
>  		free_extent_buffer(mid);
>  		return ret;
> diff --git a/extent-tree.c b/extent-tree.c
> index 079204ed290f..ab57c20d9dee 100644
> --- a/extent-tree.c
> +++ b/extent-tree.c
> @@ -2961,7 +2961,7 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
>  			path->slots[*level]++;
>  			ret = btrfs_free_extent(trans, root, bytenr, blocksize,
>  						parent->start, root_owner,
> -						root_gen, *level - 1, 1);
> +						root_gen, *level - 1, 0);
>  			BUG_ON(ret);
>  			continue;
>  		}
> @@ -3003,7 +3003,7 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
>  	root_gen = btrfs_header_generation(parent);
>  	ret = btrfs_free_extent(trans, root, path->nodes[*level]->start,
>  				path->nodes[*level]->len, parent->start,
> -				root_owner, root_gen, *level, 1);
> +				root_owner, root_gen, *level, 0);
>  	free_extent_buffer(path->nodes[*level]);
>  	path->nodes[*level] = NULL;
>  	*level += 1;
> @@ -3054,7 +3054,7 @@ static int noinline walk_up_tree(struct btrfs_trans_handle *trans,
>  						path->nodes[*level]->start,
>  						path->nodes[*level]->len,
>  						parent->start, root_owner,
> -						root_gen, *level, 1);
> +						root_gen, *level, 0);
>  			BUG_ON(ret);
>  			free_extent_buffer(path->nodes[*level]);
>  			path->nodes[*level] = NULL;
> 

  reply	other threads:[~2018-06-11  5:05 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 12:47 [PATCH 00/15] Add delayed-refs support to btrfs-progs Nikolay Borisov
2018-06-08 12:47 ` [PATCH 01/15] btrfs-progs: Remove root argument from pin_down_bytes Nikolay Borisov
2018-06-11  4:41   ` Qu Wenruo
2018-06-08 12:47 ` [PATCH 02/15] btrfs-progs: Remove root argument from btrfs_del_csums Nikolay Borisov
2018-06-11  4:46   ` Qu Wenruo
2018-06-11  7:02     ` Nikolay Borisov
2018-06-11  7:40       ` Qu Wenruo
2018-06-11  7:48         ` Nikolay Borisov
2018-06-11  8:08           ` Qu Wenruo
2018-06-11  8:09             ` Nikolay Borisov
2018-06-08 12:47 ` [PATCH 03/15] btrfs-progs: Add functions to modify the used space by a root Nikolay Borisov
2018-06-11  4:47   ` Qu Wenruo
2018-06-08 12:47 ` [PATCH 04/15] btrfs-progs: Refactor the root used bytes are updated Nikolay Borisov
2018-06-08 12:47 ` [PATCH 05/15] btrfs-progs: Make update_block_group take fs_info instead of root Nikolay Borisov
2018-06-11  4:49   ` Qu Wenruo
2018-06-08 12:47 ` [PATCH 06/15] btrfs-progs: check: Drop trans/root arguments from free_extent_hook Nikolay Borisov
2018-06-11  4:55   ` Qu Wenruo
2018-06-11  7:04     ` Nikolay Borisov
2018-06-08 12:47 ` [PATCH 07/15] btrfs-progs: Remove root argument from __free_extent Nikolay Borisov
2018-06-11  4:58   ` Qu Wenruo
2018-06-11  7:06     ` Nikolay Borisov
2018-06-08 12:47 ` [PATCH 08/15] btrfs-progs: Remove root argument from alloc_reserved_tree_block Nikolay Borisov
2018-06-08 12:47 ` [PATCH 09/15] btrfs-progs: Always pass 0 for offset when calling btrfs_free_extent for btree blocks Nikolay Borisov
2018-06-11  5:05   ` Qu Wenruo [this message]
2018-06-08 12:47 ` [PATCH 10/15] btrfs-progs: Add boolean to signal whether we are re-initing extent tree Nikolay Borisov
2018-06-08 12:47 ` [PATCH 11/15] btrfs-progs: Add delayed refs infrastructure Nikolay Borisov
2018-06-08 14:53   ` [PATCH 11/15 v2] " Nikolay Borisov
2018-06-11  5:20   ` [PATCH 11/15] " Qu Wenruo
2018-06-11  7:10     ` Nikolay Borisov
2018-06-11  7:46       ` Qu Wenruo
2018-07-30  8:34   ` Misono Tomohiro
2018-07-30  9:11     ` Nikolay Borisov
2018-08-02 12:17     ` David Sterba
2018-06-08 12:47 ` [PATCH 12/15] btrfs-progs: Add __free_extent2 function Nikolay Borisov
2018-06-08 12:47 ` [PATCH 13/15] btrfs-progs: Add alloc_reserved_tree_block2 function Nikolay Borisov
2018-06-08 12:47 ` [PATCH 14/15] btrfs-progs: Wire up delayed refs Nikolay Borisov
2018-07-30  8:33   ` Misono Tomohiro
2018-07-30  9:30     ` Nikolay Borisov
2018-06-08 12:47 ` [PATCH 15/15] btrfs-progs: Remove old delayed refs infrastructure Nikolay Borisov
2018-06-08 14:49   ` [PATCH 15/15 v2] " Nikolay Borisov
2018-06-08 13:50 ` [PATCH 00/15] Add delayed-refs support to btrfs-progs Qu Wenruo
2018-06-08 14:08   ` Nikolay Borisov
2018-06-08 14:21     ` Qu Wenruo
2018-07-16 15:39 ` David Sterba
2018-09-12 11:51   ` Su Yue
2018-09-12 18:02     ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d6a85c64-e6f8-a55a-ddad-339a8e1b4e0d@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).