Linux-BTRFS Archive mirror
 help / color / mirror / Atom feed
From: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
To: linux-btrfs@vger.kernel.org
Subject: list all subvolumes below given path?
Date: Tue, 14 May 2024 09:22:38 +0200	[thread overview]
Message-ID: <20240514072238.GA110925@tik.uni-stuttgart.de> (raw)


I need to know all subvolumes below a given path.

An example:

/local/test is a subvolume of /local and contains some subvolumes itself:

root@fex:/local/test# mount | grep /local
/dev/sde1 on /local type btrfs (rw,relatime,space_cache,user_subvol_rm_allowed,subvolid=5,subvol=/)


This works but it is very slow on BIG filesystems:

root@fex:/local/test# find . -inum 256
.
./sv1
./sv1/sv1_1
./sv1/sv1_1/ss
./sv1/sv1_2
./sv2


This does not list sub-subvolumes and it contains the whole path up to the
btrfs root subvolume:

root@fex:/local/test# btrfs subvolume list -o .
ID 62531 gen 6079120 top level 62530 path test/sv1
ID 62532 gen 6079120 top level 62530 path test/sv2


This lists all subvolumes of the filesystem:

root@fex:/local/test# btrfs subvolume list .
ID 350 gen 6079851 top level 5 path home
ID 505 gen 6079123 top level 350 path home/smc/test
ID 621 gen 6079123 top level 350 path home/framstag/blubb
ID 2524 gen 3666531 top level 621 path home/framstag/blubb/.snapshot/2017-12-02_1026.test
ID 18082 gen 3666531 top level 621 path home/framstag/blubb/.snapshot/2019-07-18_0139.test
ID 18091 gen 6079833 top level 5 path tmp/test
ID 27760 gen 3666531 top level 621 path home/framstag/blubb/.snapshot/2020-07-10_1123.test
ID 36104 gen 3666531 top level 621 path home/framstag/blubb/.snapshot/2021-05-31_1052.test
ID 60430 gen 5849702 top level 621 path home/framstag/blubb/.snapshot/2024-02-16_1148.test
ID 62480 gen 6073978 top level 350 path home/.snapshot/2024-05-11_0000.daily
ID 62504 gen 6073978 top level 350 path home/.snapshot/2024-05-12_0000.weekly
ID 62530 gen 6079831 top level 5 path test
ID 62531 gen 6079120 top level 62530 path sv1
ID 62532 gen 6079120 top level 62530 path sv2
ID 62533 gen 6079120 top level 62531 path sv1/sv1_1
ID 62534 gen 6079120 top level 62531 path sv1/sv1_2
ID 62540 gen 6076249 top level 350 path home/.snapshot/2024-05-13_0000.daily
ID 62545 gen 6076377 top level 62533 path sv1/sv1_1/ss
ID 62565 gen 6078533 top level 350 path home/.snapshot/2024-05-13_2100.hourly
ID 62566 gen 6078643 top level 350 path home/.snapshot/2024-05-13_2200.hourly
ID 62567 gen 6078751 top level 350 path home/.snapshot/2024-05-13_2300.hourly
ID 62568 gen 6078859 top level 350 path home/.snapshot/2024-05-14_0000.daily
ID 62569 gen 6078967 top level 350 path home/.snapshot/2024-05-14_0100.hourly
ID 62570 gen 6079075 top level 350 path home/.snapshot/2024-05-14_0200.hourly
ID 62571 gen 6079183 top level 350 path home/.snapshot/2024-05-14_0300.hourly
ID 62572 gen 6079292 top level 350 path home/.snapshot/2024-05-14_0400.hourly
ID 62573 gen 6079401 top level 350 path home/.snapshot/2024-05-14_0500.hourly
ID 62574 gen 6079509 top level 350 path home/.snapshot/2024-05-14_0600.hourly
ID 62575 gen 6079617 top level 350 path home/.snapshot/2024-05-14_0700.hourly
ID 62576 gen 6079725 top level 350 path home/.snapshot/2024-05-14_0800.hourly
ID 62577 gen 6079833 top level 350 path home/.snapshot/2024-05-14_0900.hourly

How do I know which subvolumes are below $PWD ?


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    https://www.tik.uni-stuttgart.de/
REF:<20240514072238.GA110925@tik.uni-stuttgart.de>

             reply	other threads:[~2024-05-14  7:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14  7:22 Ulli Horlacher [this message]
2024-05-14  8:11 ` list all subvolumes below given path? Andrei Borzenkov
2024-05-14  9:33   ` 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=20240514072238.GA110925@tik.uni-stuttgart.de \
    --to=framstag@rus.uni-stuttgart.de \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).