Btrfs ioctl: get file checksums from user space

I would like to get the BTRFS checksums related to a specific file, but unfortunately I did not find a suitable ioctl to perform this action. Can this be done? If so, how to do it? I need to save checksums in order to try to reduce the CPU load in cases like rsync behavior.

+7
linux btrfs
source share
1 answer

Just popped this messy code into my github repository. https://github.com/Lakshmipathi/btrfs-progs/tree/dump_csum This is not an official code. I tested files between 100 and 50 GB in size. They seem to fit.

Using:

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

will create a csumdump file at the destination.

Example:

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

will create an output file named '/btrfs/50gbfile1.csumdump' with csum file blocks.

Note. I tried this for training / learning purposes, so it comes with all the usual failures. Planning to clear this code this week.

If you plan to use, I would recommend that you test the following cases:

 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 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. 
+1
source share

All Articles