linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: Don't search devid for every verify_one_dev_extent() call
Date: Wed, 30 Jan 2019 11:13:59 +0200	[thread overview]
Message-ID: <3320eb74-a67e-2b71-ca09-6986a559f45b@suse.com> (raw)
In-Reply-To: <20190130074000.16638-2-wqu@suse.com>



On 30.01.19 г. 9:39 ч., Qu Wenruo wrote:
> verify_one_dev_extent() will call btrfs_find_device() for each dev
> extent, this waste some CPU time just searching the devices list.
> 
> Move the search one level up, into the btrfs_verify_dev_extents(), so
> for each device we only call btrfs_find_device() once.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Seems the sane thing to do, so:

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

> ---
>  fs/btrfs/volumes.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 2576b1a379c9..8e932d7d2fe6 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -7761,13 +7761,14 @@ static u64 calc_stripe_length(u64 type, u64 chunk_len, int num_stripes)
>  }
>  
>  static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
> -				 u64 chunk_offset, u64 devid,
> -				 u64 physical_offset, u64 physical_len)
> +				 struct btrfs_device *dev,
> +				 u64 chunk_offset, u64 physical_offset,
> +				 u64 physical_len)
>  {
>  	struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree;
>  	struct extent_map *em;
>  	struct map_lookup *map;
> -	struct btrfs_device *dev;
> +	u64 devid = dev->devid;
>  	u64 stripe_len;
>  	bool found = false;
>  	int ret = 0;
> @@ -7819,12 +7820,6 @@ static int verify_one_dev_extent(struct btrfs_fs_info *fs_info,
>  	}
>  
>  	/* Make sure no dev extent is beyond device bondary */
> -	dev = btrfs_find_device(fs_info, devid, NULL, NULL);
> -	if (!dev) {
> -		btrfs_err(fs_info, "failed to find devid %llu", devid);
> -		ret = -EUCLEAN;
> -		goto out;
> -	}
>  	if (physical_offset + physical_len > dev->disk_total_bytes) {
>  		btrfs_err(fs_info,
>  "dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
> @@ -7874,6 +7869,7 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
>  {
>  	struct btrfs_path *path;
>  	struct btrfs_root *root = fs_info->dev_root;
> +	struct btrfs_device *device = NULL;
>  	struct btrfs_key key;
>  	u64 prev_devid = 0;
>  	u64 prev_dev_ext_end = 0;
> @@ -7917,6 +7913,16 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
>  		devid = key.objectid;
>  		physical_offset = key.offset;
>  
> +		if (!device || devid != device->devid) {
> +			device = btrfs_find_device(fs_info, devid, NULL, NULL);
> +			if (!device) {
> +				btrfs_err(fs_info, "failed to find devid %llu",
> +					  devid);
> +				ret = -EUCLEAN;
> +				goto out;
> +			}
> +		}
> +
>  		dext = btrfs_item_ptr(leaf, slot, struct btrfs_dev_extent);
>  		chunk_offset = btrfs_dev_extent_chunk_offset(leaf, dext);
>  		physical_len = btrfs_dev_extent_length(leaf, dext);
> @@ -7930,7 +7936,7 @@ int btrfs_verify_dev_extents(struct btrfs_fs_info *fs_info)
>  			goto out;
>  		}
>  
> -		ret = verify_one_dev_extent(fs_info, chunk_offset, devid,
> +		ret = verify_one_dev_extent(fs_info, device, chunk_offset,
>  					    physical_offset, physical_len);
>  		if (ret < 0)
>  			goto out;
> 

  reply	other threads:[~2019-01-30  9:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  7:39 [PATCH 0/2] btrfs: Speedup chunk allocation for large fs Qu Wenruo
2019-01-30  7:39 ` [PATCH 1/2] btrfs: Don't search devid for every verify_one_dev_extent() call Qu Wenruo
2019-01-30  9:13   ` Nikolay Borisov [this message]
2019-01-31  9:38   ` Anand Jain
2019-01-30  7:40 ` [PATCH RFC 2/2] btrfs: Introduce free dev extent hint to speed up chunk allocation Qu Wenruo
2019-01-31  2:38   ` Qu Wenruo
2019-02-08 22:27 ` [PATCH 0/2] btrfs: Speedup chunk allocation for large fs 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=3320eb74-a67e-2b71-ca09-6986a559f45b@suse.com \
    --to=nborisov@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@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).