On Sat, 11 Aug 2012 10:36:17 +0800, Liu Bo wrote:
> On 08/10/2012 09:38 PM, Stefan Behrens wrote:
[...]
>> + flags = space.flags;
>> + /*
>> + * return
>> + * 0: if dup, single or RAID0 is configured for
>> + * any of metadata, system or data, else
>> + * 1: if RAID5 is configured, or if RAID1 or
>> + * RAID10 is configured and only two mirrors
>> + * are used, else
>> + * 2: if RAID6 is configured, else
>> + * num_mirrors - 1: if RAID1 or RAID10 is
>> + * configured and more than
>> + * 2 mirrors are used.
>> + */
>> + if (num_tolerated_disk_barrier_failures > 0 &&
>> + ((flags & (BTRFS_BLOCK_GROUP_DUP |
>> + BTRFS_BLOCK_GROUP_RAID0)) ||
>> + ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK)
>> + == 0)))
>
> Good work.
>
> We already have __get_block_group_index(), for dup, single, raid0 we can do the same thing like
> this:
> __get_block_group_index(flags) > 1
>
> the only problem is to make the function public :)
Thanks for your comments Liu Bo. And good luck with Oracle (please
correct me if I misinterpreted your updated email address).
That's correct that "__get_block_group_index() > 1" would be a little
bit shorter way to evaluate the RAID flags. But the rest of the btrfs
code (except for btrfs_can_relocate()) also explicitly evaluates the
flags instead of using the array index that __get_block_group_index()
returns. It is just following the convention.
>> + num_tolerated_disk_barrier_failures = 0;
>> + else if (num_tolerated_disk_barrier_failures > 1
>> + &&
>> + (flags & (BTRFS_BLOCK_GROUP_RAID1 |
>> + BTRFS_BLOCK_GROUP_RAID10)))
>> + num_tolerated_disk_barrier_failures = 1;
>> + }
[...]
>> @@ -2807,6 +2812,26 @@ int btrfs_balance(struct btrfs_balance_control *bctl,
>> }
>> }
>>
>> + if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) {
>> + int num_tolerated_disk_barrier_failures;
>> + u64 target = bctl->sys.target;
>> +
>> + num_tolerated_disk_barrier_failures =
>> + btrfs_calc_num_tolerated_disk_barrier_failures(fs_info);
>> + if (num_tolerated_disk_barrier_failures > 0 &&
>> + (target &
>> + (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID0 |
>> + BTRFS_AVAIL_ALLOC_BIT_SINGLE)))
>
> ditto.
Same as before + this time the code is working on the balance conversion
parameters where SINGLE is encoded in a different way.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html