kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

Difference between `parent` and `top level`? #726

Open korpe1 opened 6 months ago

korpe1 commented 6 months ago

Hello, I can't find from the docs, what is the difference between parent and top level IDs in context of the subvolume list command? To me them seems be the same.

sudo btrfs subvolume list -p /
ID 256 gen 00000 parent 5 top level 5 path root
ID 257 gen 00000 parent 5 top level 5 path home
ID 256 gen 00000 parent 257 top level 257 path /var/lib/machines
...

I found only the following and it doesn't help at all:

For every subvolume the following information is shown by default:

ID ID gen generation top level parent_ID path path

where ID is subvolume's (root)id, generation is an internal counter which is updated every transaction, parent_ID is the same as the parent subvolume's id, and path is the relative path of the subvolume to the top level subvolume. The subvolume's ID may be used by the subvolume set-default command, or at mount time via the subvolid= option.

...

Field selection:

-p print the parent ID (parent here means the subvolume which contains this subvolume).

https://github.com/kdave/btrfs-progs/blob/devel/Documentation/btrfs-subvolume.rst

korpe1 commented 6 months ago

Also:

sudo btrfs subvolume show /
root
    Name:           root
    UUID:           000000000000000000000000000
    Parent UUID:        -
    Received UUID:      -
    Creation time:      2023-01-01 20:14:50 +0300
    Subvolume ID:       257
    Generation:         00000
    Gen at creation:    0
    Parent ID:      5
    Top level ID:       5
    Flags:          -
    Send transid:       0
    Send time:      2023-06-10 20:11:30 +0300
    Receive transid:    0
    Receive time:       -
    Snapshot(s):
    Parent ID:      5
    Top level ID:       5
Forza-tng commented 3 months ago

@korpe1 I suppose in your case it is no difference. In btrfs it's possible to nest subvolumes in several levels.

top level > subvol a > subvol b > c

Though I must admit it isn't overly clear how this is supposed to be shown. The values for top level always equal parent on my system too.

ID 95008 gen 2386959 parent 303 top level 303 path volume/src/alpine
ID 124869 gen 2308785 parent 303 top level 303 path volume/src/aarch64
ID 133705 gen 2308324 parent 95008 top level 95008 path volume/src/alpine/linux-6.6.10-gentoo