From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: find snapshot parent?
Date: Sun, 7 Jul 2019 09:43:34 +0300 [thread overview]
Message-ID: <774d3e3d-bf1a-a3a1-b21c-45a3a353e5bc@suse.com> (raw)
In-Reply-To: <20190706204339.GB13656@tik.uni-stuttgart.de>
On 6.07.19 г. 23:43 ч., Ulli Horlacher wrote:
> On Sat 2019-07-06 (19:57), Nikolay Borisov wrote:
>
>>> And how can I see whether /test/tmp/xx/ss1 is a snapshot at all?
>>> Do all snapshots have a "Parent UUID" and regular subvolumes not?
>>
>> Indeed, only snapshots have a Parent UUID.
>
> Not all:
>
> root@xerus:/test# btrfs subvolume snapshot -r /test /test/ss1
> Create a readonly snapshot of '/test' in '/test/ss1'
>
> root@xerus:/test# btrfs subvolume show /test/ss1
> /test/ss1
> Name: ss1
> UUID: 02bd07bc-0bab-3442-96be-40790e1ba9be
> Parent UUID: -
> Received UUID: -
> Creation time: 2019-07-06 22:37:37 +0200
> Subvolume ID: 1036
> Generation: 9824
> Gen at creation: 9824
> Parent ID: 5
> Top level ID: 5
> Flags: readonly
> Snapshot(s):
>
> root@xerus:/test# btrfs subvolume show /test
> /test is toplevel subvolume
This is really odd, looking at create_pending_snapshot the codes :
memcpy(new_root_item->parent_uuid, root->root_item.uuid,
BTRFS_UUID_SIZE);
And that's not conditional on whether the snapshot is read only or not.
So everytime we creata a snapshot it ought to be receiving the parent's
subvolume UUID in its parent_uuid field. And indeed testing with latest misc-next kernel:
root@ubuntu-virtual:~# btrfs subvol create /media/scratch/subvol10
Create subvolume '/media/scratch/subvol10'
root@ubuntu-virtual:~# btrfs subvol snapshot /media/scratch/subvol10/ /media/scratch/snap-subvol10
Create a snapshot of '/media/scratch/subvol10/' in '/media/scratch/snap-subvol10'
root@ubuntu-virtual:~# btrfs subvol snapshot -r /media/scratch/subvol10/ /media/scratch/snap-subvol10-ro
Create a readonly snapshot of '/media/scratch/subvol10/' in '/media/scratch/snap-subvol10-ro'
root@ubuntu-virtual:~# btrfs subvol show /media/scratch/snap-subvol10
snap-subvol10
Name: snap-subvol10
UUID: 8000e96e-5d6e-3c49-a4d3-5e3868ac6972
Parent UUID: 6352b676-fce5-0945-88d9-745a6ae72783
Received UUID: -
Creation time: 2019-07-07 06:40:15 +0000
Subvolume ID: 262
Generation: 17
Gen at creation: 17
Parent ID: 5
Top level ID: 5
Flags: -
Snapshot(s):
root@ubuntu-virtual:~# btrfs subvol show /media/scratch/snap-subvol10-ro/
snap-subvol10-ro
Name: snap-subvol10-ro
UUID: 8964dab3-37b0-fc4e-b891-69323d3aaea0
Parent UUID: 6352b676-fce5-0945-88d9-745a6ae72783
Received UUID: -
Creation time: 2019-07-07 06:40:26 +0000
Subvolume ID: 263
Generation: 18
Gen at creation: 18
Parent ID: 5
Top level ID: 5
Flags: readonly
Snapshot(s):
Note that the related code hasn't change in a long time.
next prev parent reply other threads:[~2019-07-07 6:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-06 15:53 find snapshot parent? Ulli Horlacher
2019-07-06 16:57 ` Nikolay Borisov
2019-07-06 20:43 ` Ulli Horlacher
2019-07-07 5:27 ` Andrei Borzenkov
2019-07-07 6:43 ` Nikolay Borisov [this message]
2019-07-07 7:37 ` Andrei Borzenkov
2019-07-07 9:12 ` Nikolay Borisov
2019-07-07 22:18 ` Ulli Horlacher
2019-07-08 4:05 ` Andrei Borzenkov
2019-07-06 23:24 ` Ulli Horlacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=774d3e3d-bf1a-a3a1-b21c-45a3a353e5bc@suse.com \
--to=nborisov@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox