Re: [PATCH v10 2/3] btrfs: create read policy framework

David Sterba
2020-10-29T18:55:12Z

On Wed, Oct 28, 2020 at 09:14:46PM +0800, Anand Jain wrote:
> @@ -5485,7 +5486,19 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info,
> else
> num_stripes = map->num_stripes;
>
> - preferred_mirror = first + current->pid % num_stripes;
> + switch (fs_info->fs_devices->read_policy) {
> + default:
> + /*
> + * Shouldn't happen, just warn and use pid instead of failing.
> + */
> + btrfs_warn_rl(fs_info,
> + "unknown read_policy type %u, fallback to pid",
> + fs_info->fs_devices->read_policy);

So this would flood the system log with useless messages once this
happens. We should really reset it to pid or whatever default we choose.
Fixed.

> + fallthrough;
> + case BTRFS_READ_POLICY_PID:
> + preferred_mirror = first + current->pid % num_stripes;

This is in the original code, but this should really use ( ) to make the
precedence clear.