openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.33k stars 1.72k forks source link

Recursive option for zfs diff and diff of snapshot on unmounted dataset #12024

Open fredcooke opened 3 years ago

fredcooke commented 3 years ago

Describe the feature would like to see added to OpenZFS

  1. Ability to diff snapshots on unmounted datasets
  2. Ability to recursively diff snapshots down dataset hierarchies

How will this feature improve OpenZFS?

Additional context

I have a dataset hierarchy with different properties such as copies=2, encryption=on, compression=lz4 etc and various combinations by inheritance depending on the data stored within.

I'm creating snapshots of the top level container dataset in order to sync to an external zpool on a usb drive as a passive slave/backup that isn't used for reads.

I ran a diff between snapshot one and snapshot two hoping to see all files changed/added between the two, but instead it failed with:

Cannot diff an unmounted snapshot: operation not applicable to datasets of this type

Issue 1: I can't figure out any reason why that would be the case, ZFS has enough knowledge to mount that data set if I ask it to and the snapshots are not mounted at all anyway (except in the hidden .zfs dir, maybe that's how this is implemented?) so I would expect the diff could be run between the two irrespective of state of mount or not.

That top level dataset is purely used for snapshots that are NOT the whole zpool to aid in mixing datasets from different pools into others without collision. Under that dataset are public (no additional config) and private (encrypted=on parent) so I'm then forced to diff the two halves of the tree separately which works, but:

Issue 2: Instead of full output I just get M on the dataset I was diffing. Well, yes, I know it's different, hence diffing it :-D But the differences are somewhere in the tree below and I forgot what I copied, hence creating snapshot2 in the first place, to help me find what I changed without a heavy diff -rq or something.

It wouldn't be a huge amount of work to go through each part of the tree and diff with the same snapshot name in a script and that's what I'll do after I hit submit on this issue, but it feels like it'd be better placed as a -r or -R option in zfs diff to me.

Thanks for your consideration and work thus far, awesome tool :-)

fredcooke commented 3 years ago

Clarification: I'd much rather contribute this as a change to OpenZFS than write my own scripts to work around it. If anyone is willing to mentor me through that process, that'd be great. Otherwise I'll take a stab when I get a block of time big enough to delve into the guts of this billion dollar zettabyte++ thing.