Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: find snapshot parent?
Date: Sat, 6 Jul 2019 19:57:34 +0300	[thread overview]
Message-ID: <1e70c50e-54d7-0507-60ad-9c486e3517a9@suse.com> (raw)
In-Reply-To: <20190706155353.GA13656@tik.uni-stuttgart.de>



On 6.07.19 г. 18:53 ч., Ulli Horlacher wrote:
> Is there a standard way to find the path of the subvolume parent of a
> snapshot? 
> 
> For example:
> 
> root@xerus:/test# btrfs sub list /test
> ID 269 gen 9818 top level 5 path tux/test
> ID 1026 gen 9804 top level 1011 path tmp/xx/ss1
> ID 1027 gen 9804 top level 1011 path tmp/xx/ss2
> 
> root@xerus:/test# btrfs subvolume show /test/tmp
> /test/tmp
>         Name:                   tmp
>         UUID:                   5a873eca-9b6c-fc4e-aed5-eb287839d693
>         Parent UUID:            -
>         Received UUID:          -
>         Creation time:          2019-07-04 00:17:11 +0200
>         Subvolume ID:           1011
>         Generation:             9813
>         Gen at creation:        9749
>         Parent ID:              5
>         Top level ID:           5
>         Flags:                  -
>         Snapshot(s):
>                                 xx/ss1
>                                 xx/ss2
> 
> root@xerus:/test# btrfs subvolume show /test/tmp/xx/ss1
> /test/tmp/xx/ss1
>         Name:                   ss1
>         UUID:                   3641bb81-d1fd-4440-8f29-6f17ff9ec4e1
>         Parent UUID:            5a873eca-9b6c-fc4e-aed5-eb287839d693
>         Received UUID:          -
>         Creation time:          2019-07-05 11:13:15 +0200
>         Subvolume ID:           1026
>         Generation:             9804
>         Gen at creation:        9793
>         Parent ID:              1011
>         Top level ID:           1011
>         Flags:                  readonly
>         Snapshot(s):
> 
> Must I call "btrfs subvolume show" for every subvolume to find the
> matching Parent ID/UUID or parse the "Snapshot(s)" section?

That seems to be the way, looking at code for the Snapshot(s) section it
iterates every subvolume and checks if its Parent UUID matches the UUID
of the subvolume - if yes it adds that particular subvol (snapshots are
subvolumes with a parent) to the "SNapshot(s)" section.

> 
> 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.

> 

  reply	other threads:[~2019-07-06 16:57 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 [this message]
2019-07-06 20:43   ` Ulli Horlacher
2019-07-07  5:27     ` Andrei Borzenkov
2019-07-07  6:43     ` Nikolay Borisov
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=1e70c50e-54d7-0507-60ad-9c486e3517a9@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