linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
To: linux-btrfs@vger.kernel.org
Subject: Re: find subvolume directories
Date: Tue, 16 Jul 2019 13:04:45 +0200	[thread overview]
Message-ID: <20190716110445.GA11010@tik.uni-stuttgart.de> (raw)
In-Reply-To: <20190712231705.GA16856@tik.uni-stuttgart.de>

On Sat 2019-07-13 (01:17), Ulli Horlacher wrote:
> I need to find (all) subvolume directories.
> I know, btrfs subvolumes root directories have inode #256, but a
> "find / -inum 256" is horrible slow!

Because it scans also non-btrfs filesystems. This is especially a bad idea
for nfs.

I have now implemented the search for inode 256 in Perl using the algorithm: 

- get a list of all mounted filesystems (via df)
- for each btrfs filesystem do a recursive search for directories with
  inode 256
- stop recursion if the directory is on another (mounted) filesystem


This speeds up the search:

root@trulla:/opt/btrfs-tools/bin# sysinfo 
System:        Linux trulla 4.4.180-94.97-default x86_64
Distribution:  SUSE Linux Enterprise Server 12 SP3
Hardware:      VMware, Inc. VMware Virtual Platform None (VMware)
CPU:           Intel(R) Xeon(R) CPU E5-2680 v4 @ 2.40GHz, 1 x 2394 MHz
RAM:           1024 MB

root@trulla:/opt/btrfs-tools/bin# dropfscache;time btrfs_list -r
ACCESS-MODE SUBVOLUME <- SNAPSHOT-PARENT
rw / <- -
rw /.snapshots
ro /.snapshots/1065/snapshot <- /
ro /.snapshots/1066/snapshot <- /
ro /.snapshots/1089/snapshot <- /
ro /.snapshots/1090/snapshot <- /
ro /.snapshots/1103/snapshot <- /
ro /.snapshots/1104/snapshot <- /
ro /.snapshots/1107/snapshot <- /
ro /.snapshots/1108/snapshot <- /
ro /.snapshots/1127/snapshot <- /
ro /.snapshots/1128/snapshot <- /
ro /.snapshots/1131/snapshot <- /
ro /.snapshots/1132/snapshot <- /
ro /.snapshots/1133/snapshot <- /
ro /.snapshots/1134/snapshot <- /
ro /.snapshots/1135/snapshot <- /
ro /.snapshots/1136/snapshot <- /
ro /.snapshots/1137/snapshot <- /
ro /.snapshots/1138/snapshot <- /
ro /.snapshots/1139/snapshot <- /
ro /.snapshots/1140/snapshot <- /
rw /.snapshots/128/snapshot <- -
rw /home
rw /home/tux/blubb
rw /mnt/tmp
ro /mnt/tmp/ss
rw /opt
ro /opt/.snapshot/2019-07-11_0000.daily <- /opt
ro /opt/.snapshot/2019-07-12_0000.daily <- /opt
ro /opt/.snapshot/2019-07-13_0000.daily <- /opt
ro /opt/.snapshot/2019-07-15_0000.daily <- /opt
ro /opt/.snapshot/2019-07-16_0000.daily <- /opt
ro /opt/.snapshot/2019-07-16_1100.hourly <- /opt
ro /opt/.snapshot/2019-07-16_1200.hourly <- /opt
rw /srv
rw /tmp
rw /tmp/blubb
ro /tmp/blubb/.snapshot/2017-09-20_1801.test <- /tmp/blubb
ro /tmp/blubb/.snapshot/2017-12-02_0940.test <- /tmp/blubb
ro /tmp/blubb/.snapshot/2018-01-11_1415.test <- /tmp/blubb
ro /tmp/test
rw /usr/local
rw /var/crash
rw /var/lib/machines
rw /var/log
rw /var/opt
rw /var/spool
rw /var/tmp

real    0m4.301s
user    0m1.352s
sys     0m1.438s


(dropfscache drops the filesystem cache to have a reproducable test)

-- 
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:    http://www.tik.uni-stuttgart.de/
REF:<20190712231705.GA16856@tik.uni-stuttgart.de>

  parent reply	other threads:[~2019-07-16 11:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-12 23:17 find subvolume directories Ulli Horlacher
2019-07-13  3:59 ` Andrei Borzenkov
2019-07-13  8:27   ` Ulli Horlacher
2019-07-13 11:10     ` Andrei Borzenkov
2019-07-13 11:28       ` Ulli Horlacher
2019-07-13 15:08         ` Andrei Borzenkov
2019-07-15 13:22         ` Piotr Szymaniak
2019-07-15 22:40           ` Ulli Horlacher
2019-07-15 23:58             ` [RFC] a standard user-friendly way to find a snapshot in nested subvolumes [was: find subvolume directories] Nicholas D Steeves
2019-07-16  0:41               ` Ulli Horlacher
2019-07-15 11:39       ` find subvolume directories Ulli Horlacher
2019-07-15 11:33 ` Ulli Horlacher
2019-07-16 11:04 ` Ulli Horlacher [this message]
2019-07-18 12:00 ` Axel Burri
2019-07-18 17:48   ` Andrei Borzenkov
2019-07-22 12:36     ` Axel Burri
2019-07-20  9:27   ` 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=20190716110445.GA11010@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 NNTP newsgroup(s).