Hi Andrei,

On 2021-03-29 18:30, Andrei Borzenkov wrote:
On 29.03.2021 16:16, Claudius Heine wrote:

I am currently investigating the possibility to use `btrfs-stream` files
(generated by `btrfs send`) for deploying a image based update to
systems (probably embedded ones).

One of the issues I encountered here is that btrfs-send does not use any
diff algorithm on files that have changed from one snapshot to the next.

btrfs send works on block level. It sends blocks that differ between two

Are you sure?

I did a test with a 32MiB random file. I created one snapshot, then changed (not deleted or added) one byte in that file and then created a snapshot again. `btrfs send` created a >32MiB `btrfs-stream` file. If it would be only block based, then I would have expected that it would just contain the changed block, not the whole file. And if I use a smaller file on the same file system, then the `btrfs-stream` is smaller as well.

I looked into those `btrfs-stream` files using [1] and also [2] as well as the code. While I haven't understood everything there yet, it currently looks to me like it is file based.

One way to implement this would be to add some sort of 'patch' command
to the `btrfs-stream` format.

This would require reading complete content of both snapshots instead if
just computing block diff using metadata. Unless I misunderstand what
you mean.
I think I should only need access to the old snapshot as well as the `btrfs-stream` file. But I currently don't have a complete PoC of this ready.


[1] https://github.com/sysnux/btrfs-snapshots-diff
[2] https://btrfs.wiki.kernel.org/index.php/Design_notes_on_Send/Receive

Reply via email to