public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/2] btrfs: return error if we're unable to read device stats
Date: Tue, 22 Sep 2020 19:28:55 +0200	[thread overview]
Message-ID: <20200922172855.GH6756@twin.jikos.cz> (raw)
In-Reply-To: <6f50f5be859468da38bd504c0f78a97dbcd0306d.1600461724.git.josef@toxicpanda.com>

On Fri, Sep 18, 2020 at 04:44:33PM -0400, Josef Bacik wrote:
> @@ -7270,22 +7271,30 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
>  	struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs;
>  	struct btrfs_device *device;
>  	struct btrfs_path *path = NULL;
> +	int ret = 0;
>  
>  	path = btrfs_alloc_path();
>  	if (!path)
>  		return -ENOMEM;
>  
>  	mutex_lock(&fs_devices->device_list_mutex);
> -	list_for_each_entry(device, &fs_devices->devices, dev_list)
> -		__btrfs_init_dev_stats(fs_info, device, path);
> +	list_for_each_entry(device, &fs_devices->devices, dev_list) {
> +		ret = __btrfs_init_dev_stats(fs_info, device, path);
> +		if (ret)
> +			goto out;
> +	}
>  	list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) {
> -		list_for_each_entry(device, &seed_devs->devices, dev_list)
> -			__btrfs_init_dev_stats(fs_info, device, path);
> +		list_for_each_entry(device, &seed_devs->devices, dev_list) {
> +			ret = __btrfs_init_dev_stats(fs_info, device, path);
> +			if (ret)
> +				break;

This jumps out of the inner list_for_each and continues traversing the
seed_list, is that intentional? Or goto out should be here as well.

> +		}
>  	}
> +out:
>  	mutex_unlock(&fs_devices->device_list_mutex);
>  
>  	btrfs_free_path(path);
> -	return 0;
> +	return ret;
>  }

      parent reply	other threads:[~2020-09-22 17:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-18 20:44 [PATCH 0/2][v2] Fix init for device stats for seed devices Josef Bacik
2020-09-18 20:44 ` [PATCH 1/2] btrfs: init " Josef Bacik
2020-09-18 21:47   ` Anand Jain
2020-09-21 20:25     ` David Sterba
2020-09-21 23:49       ` Anand Jain
2020-09-21 23:51   ` Anand Jain
2020-09-22 15:27   ` David Sterba
2020-09-22 17:12   ` David Sterba
2020-09-18 20:44 ` [PATCH 2/2] btrfs: return error if we're unable to read device stats Josef Bacik
2020-09-21 23:54   ` Anand Jain
2020-09-22 17:28   ` David Sterba [this message]

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=20200922172855.GH6756@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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