public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: pg@btrfs.list.sabi.co.UK (Peter Grandi)
To: Linux fs Btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: test if a subvolume is a snapshot?
Date: Fri, 8 Sep 2017 12:37:12 +0100	[thread overview]
Message-ID: <22962.33000.942912.745015@tree.ty.sabi.co.uk> (raw)
In-Reply-To: <20170908085446.GA7876@rus.uni-stuttgart.de>

> How can I test if a subvolume is a snapshot? [ ... ]

This question is based on the assumption that "snapshot" is a
distinct type of subvolume and not just an operation that
creates a subvolume with reflinked contents.

Unfortunately Btrfs does indeed make snapshots a distinct type
of subvolume... In my 4.4 kernel/progs version of Btrfs it seems
that the 'Parent UUID' is that of the source of the snapshot,
and the source of a snapshot somehow comes with a list to all
the snapshots taken from it:

  #  ls /fs/sda7
  =        @170826  @170829  @170901  @170903  @170905  @170907
  @170825  @170828  @170830  @170902  @170904  @170906  lost+found

  #  btrfs subvolume list /fs/sda7
  ID 431 gen 532441 top level 5 path =
  ID 1619 gen 524915 top level 5 path @170825
  ID 1649 gen 524915 top level 5 path @170826
  ID 1651 gen 524915 top level 5 path @170828
  ID 1652 gen 524915 top level 5 path @170829
  ID 1654 gen 524915 top level 5 path @170830
  ID 1655 gen 523316 top level 5 path @170901
  ID 1656 gen 524034 top level 5 path @170902
  ID 1658 gen 525628 top level 5 path @170903
  ID 1659 gen 527121 top level 5 path @170904
  ID 1660 gen 528719 top level 5 path @170905
  ID 1665 gen 530565 top level 5 path @170906
  ID 1666 gen 532217 top level 5 path @170907

  #  btrfs subvolume show /fs/sda7/= | egrep 'UUID|Parent|Top level|Snap|@'
	  UUID:                   cb99579f-64e5-e94c-b22c-41dcc397c37f
	  Parent UUID:            -
	  Received UUID:          -
	  Parent ID:              5
	  Top level ID:           5
	  Snapshot(s):
				  @170825
				  @170826
				  @170828
				  @170829
				  @170830
				  @170901
				  @170902
				  @170903
				  @170904
				  @170905
				  @170906
				  @170907

  #  btrfs subvolume show /fs/sda7/@170901 | egrep 'UUID|Parent|Top level|Snap|@'
  /fs/sda7/@170901
	  Name:                   @170901
	  UUID:                   851f8ef3-c2af-4b46-89af-0193fd4e6fc4
	  Parent UUID:            cb99579f-64e5-e94c-b22c-41dcc397c37f
	  Received UUID:          -
	  Parent ID:              5
	  Top level ID:           5
	  Snapshot(s):

Note that with typical Btrfs consistency "Parent UUID" is that
the source of the snapshot, while "Parent ID" is that of the
upper level subvolume, and in the "flat" layout for this volume
the snapshot parent is '/fs/sda7/=' and the upper level is
'/fs/sda7' instead.

The different results that you get make me suspect that the
top-level subvolume is "special".

  reply	other threads:[~2017-09-08 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08  8:54 test if a subvolume is a snapshot? Ulli Horlacher
2017-09-08 11:37 ` Peter Grandi [this message]
2017-09-08 13:10 ` David Sterba
2017-09-08 15:25   ` Tomasz Kłoczko
2017-09-08 15:38     ` Hugo Mills
2017-09-08 16:12       ` Tomasz Kłoczko
2017-09-08 16:24         ` Hugo Mills
2017-09-08 16:39       ` David Sterba
2017-09-08 18:09         ` Tomasz Kłoczko
2017-09-08 18:44           ` David Sterba
2017-09-08 19:06           ` Austin S. Hemmelgarn
2017-09-08 20:54             ` Tomasz Kłoczko
2017-09-11 12:44               ` Austin S. Hemmelgarn
2017-09-08 16:27     ` David Sterba
2017-09-08 18:41   ` Ulli Horlacher
2017-09-08 18:53     ` David Sterba

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=22962.33000.942912.745015@tree.ty.sabi.co.uk \
    --to=pg@btrfs.list.sabi.co.uk \
    --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