10

我想获取与特定文件相关的 BTRFS 校验和,但遗憾的是我没有找到合适的 ioctl 来执行此操作。有可能吗?如果是这样,该怎么做?在类似于 rsync 行为的情况下,我需要存储校验和以尝试减少 CPU 负载。

4

1 回答 1

2

刚才把这个乱七八糟的代码推到了我的 github repo 中。https://github.com/Lakshmipathi/btrfs-progs/tree/dump_csum 不是官方代码。我测试了大小在 100K 到 50GB 之间的文件。他们似乎很匹配。

用法:

./btrfs-debug-tree -f /path/to/file /btrfs/partition

将在目的地创建csumdump文件。

例子:

sudo ./btrfs-debug-tree -f /btrfs/50gbfile1 /dev/sda4

将使用文件块的 csum 创建一个名为“ /btrfs/50gbfile1.csumdump ”的输出文件。

注意:我是出于教育/学习目的而尝试这样做的,所以它带有所有常见的免责声明。计划在本周的某个时候清理此代码。

如果您打算使用,我建议您使用以下情况进行测试:

1) Create 20GB (or any file with size > 1KB) on /tmp/ 
2) mount your btrfs partition on /btrfs and copy file /tmp/file /btrfs/f1
3) Now dump the csum it will produce /btrfs/f1.csumdump
4) cp /tmp/file /btrfs/f2 and dump f2's csum.
5) Now compare f1.csumdump with f2.csumdump If they match, it seems to be 
working. If they didn't match something went wrong. 

时隔近 5 年更新!

新位置:https ://github.com/Lakshmipathi/dduper

于 2015-12-08T18:25:27.157 回答