在btrfs-check中,如何自动或手动修复错误“错误2000,链接计数错误”

在btrfs-check中,如何自动或手动修复错误“错误2000,链接计数错误”

我运行 btrfs-check 并收到以下错误:

$ sudo btrfs check --progress --force /dev/nvme0n1p7
Opening filesystem to check...
WARNING: filesystem mounted, continuing because of --force
Checking filesystem on /dev/nvme0n1p7
UUID: 0abfed09-85c5-44c3-8df1-8ed5db4bfe19
[1/7] checking root items                      (0:00:01 elapsed, 1111740 items checked)
[2/7] checking extents                         (0:00:10 elapsed, 148597 items checked)
[3/7] checking free space tree                 (0:00:00 elapsed, 330 items checked)
root 5 inode 14139676 errors 2000, link count wrong0:17 elapsed, 116205 items checked)
root 5 inode 14141114 errors 2000, link count wrong
root 5 inode 14141174 errors 2000, link count wrong
root 5 inode 14141175 errors 2000, link count wrong
root 5 inode 14141186 errors 2000, link count wrong
root 5 inode 14148125 errors 2000, link count wrong
root 5 inode 14148148 errors 2000, link count wrong
root 5 inode 14148168 errors 2000, link count wrong
root 5 inode 14148190 errors 2000, link count wrong
root 5 inode 14154429 errors 2000, link count wrong
root 5 inode 14154456 errors 2000, link count wrong
root 5 inode 14154459 errors 2000, link count wrong
root 5 inode 14154460 errors 2000, link count wrong
root 5 inode 14154468 errors 2000, link count wrong
root 5 inode 14154499 errors 2000, link count wrong
root 5 inode 14156088 errors 2000, link count wrong
root 5 inode 14156134 errors 2000, link count wrong
root 5 inode 14156137 errors 2000, link count wrong
root 5 inode 14157822 errors 2000, link count wrong
root 5 inode 14157857 errors 2000, link count wrong
root 5 inode 14157858 errors 2000, link count wrong
root 5 inode 14157859 errors 2000, link count wrong
root 5 inode 14157869 errors 2000, link count wrong
root 5 inode 14157870 errors 2000, link count wrong
root 5 inode 14157882 errors 2000, link count wrong
root 5 inode 14157919 errors 2000, link count wrong
[4/7] checking fs roots                        (0:00:18 elapsed, 117976 items checked)
ERROR: errors found in fs roots
found 313327153152 bytes used, error(s) found
total csum bytes: 303052904
total tree bytes: 2434465792
total fs tree bytes: 1940045824
total extent tree bytes: 117424128
btree space waste bytes: 467887914
file data blocks allocated: 350095093760
 referenced 275078295552

没有详细说明哪个文件/路径被破坏。我该如何手动修复它?

更新1:当我尝试确定损坏的范围时,我使用以下脚本查找与上述缺陷 inode 关联的所有文件:

#!/bin/bash

inode_list="14139676 14141114 14141174 14141175 14141186 14148125 14148148 14148168 14148190 14154429 14154456 14154459 14154460 14154468 14154499 14156088 14156134 14156137 14157822 14157857 14157858 14157859 14157869 14157870 14157882 14157919" # replace with your inode numbers
directory="/home" # replace with your directory

for inode in $inode_list
do
  echo "looking for inode $inode"
  find $directory -inum $inode
done

令人惊讶的是,没有发现文件:

$ sudo ./findINode.sh 
looking for inode 14139676
looking for inode 14141114
looking for inode 14141174
looking for inode 14141175
looking for inode 14141186
looking for inode 14148125
looking for inode 14148148
looking for inode 14148168
looking for inode 14148190
looking for inode 14154429
looking for inode 14154456
looking for inode 14154459
looking for inode 14154460
looking for inode 14154468
looking for inode 14154499
looking for inode 14156088
looking for inode 14156134
looking for inode 14156137
looking for inode 14157822
looking for inode 14157857
looking for inode 14157858
looking for inode 14157859
looking for inode 14157869
looking for inode 14157870
looking for inode 14157882
looking for inode 14157919

这怎么发生的?这是否意味着可以执行任何“危险”修复选项而不会丢失数据?

更新2:所以我继续删除它们:

inode_list="14139676 14141114 14141174 14141175 14141186 14148125 14148148 14148168 14148190 14154429 14154456 14154459 14154460 14154468 14154499 14156088 14156134 14156137 14157822 14157857 14157858 14157859 14157869 14157870 14157882 14157919" # replace with your inode numbers
directory="/home"

for inode in $inode_list
do
  echo "deleting inode $inode"
  find $directory -inum $inode -delete
done

但问题仍然存在,所有被假定删除的 inode 仍然在 btrfs 检查中报告,这是由有缺陷的实现引起的吗?删除它们的替代方法有哪些?

相关内容