因 ENOSPC 中断后恢复 btrfs 平衡

因 ENOSPC 中断后恢复 btrfs 平衡

我正在用 3 个设备(每个 3.7TB)构建 RAID5。我运行:

btrfs balance start -dconvert=raid5 -mconvert=raid5 /mnt/storage0

它确实处理了 3472 个块中的 3471 个(原文如此!),之后因 ENOSPC 错误而失败。

/mnt/storage0之前是一个由 2 个设备组成的 RAID0 卷(同样,每个 3.7TB,然后我添加了第三个驱动器)。我从卷中释放了一些空间并再次启动了该过程。不幸的是,它需要两天时间才能完成,我想知道是否有更好的方法?btrfs balance -mconvert -dconvert由于 ENOSPC 而失败后,是否可以以某种方式恢复?

答案1

我想这现在对你没有帮助(因为你可能已经处理过这个问题了)但是,其他人可能会寻找答案: https://man.archlinux.org/man/btrfs.5.en#FILESYSTEM_WITH_MULTIPLE_PROFILES回答你的问题:

It is possible that a btrfs filesystem contains multiple block group profiles of the same type. This could happen when a profile conversion using balance filters is interrupted (see btrfs-balance(8)). Some btrfs commands perform a test to detect this kind of condition and print a warning like this:

WARNING: Multiple block group profiles detected, see 'man btrfs(5)'.
WARNING:   Data: single, raid1
WARNING:   Metadata: single, raid1

The corresponding output of btrfs filesystem df might look like:

WARNING: Multiple block group profiles detected, see 'man btrfs(5)'.
WARNING:   Data: single, raid1
WARNING:   Metadata: single, raid1
Data, RAID1: total=832.00MiB, used=0.00B
Data, single: total=1.63GiB, used=0.00B
System, single: total=4.00MiB, used=16.00KiB
Metadata, single: total=8.00MiB, used=112.00KiB
Metadata, RAID1: total=64.00MiB, used=32.00KiB
GlobalReserve, single: total=16.25MiB, used=0.00B

There's more than one line for type Data and Metadata, while the profiles are single and RAID1.

This state of the filesystem OK but most likely needs the user/administrator to take an action and finish the interrupted tasks. This cannot be easily done automatically, also the user knows the expected final profiles.

In the example above, the filesystem started as a single device and single block group profile. Then another device was added, followed by balance with convert=raid1 but for some reason hasn't finished. Restarting the balance with convert=raid1 will continue and end up with filesystem with all block group profiles RAID1.

NOTE:
If you're familiar with balance filters, you can use convert=raid1,profiles=single,soft, which will take only the unconverted single profiles and convert them to raid1. This may speed up the conversion as it would not try to rewrite the already convert raid1 profiles.

Having just one profile is desired as this also clearly defines the profile of newly allocated block groups, otherwise this depends on internal allocation policy. When there are multiple profiles present, the order of selection is RAID56, RAID10, RAID1, RAID0 as long as the device number constraints are satisfied.

Commands that print the warning were chosen so they're brought to user attention when the filesystem state is being changed in that regard. This is: device add, device delete, balance cancel, balance pause. Commands that report space usage: filesystem df, device usage. The command filesystem usage provides a line in the overall summary:

Multiple profiles:                 yes (data, metadata)

长话短说:您的磁盘现在处于这样一种状态:一些文件正确地分布在磁盘上,而另一些则没有。您可以重新运行 balance,convert=raid5,profiles=single,soft这将导致只有具有single配置文件的文件(指未转换为 raid5 的文件)转换为 raid5。

还要注意,不推荐使用 raid5,尤其是对于元数据。

相关内容