From: Hans van Kranenburg <Hans.van.Kranenburg@mendix.com>
To: "Holger Hoffstätte" <holger@applied-asynchrony.com>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Curious problem: btrfs device stats & unpriviliged access
Date: Mon, 8 Oct 2018 20:02:01 +0000 [thread overview]
Message-ID: <faab0e97-c853-11dd-243d-021232b0783a@mendix.com> (raw)
In-Reply-To: <c13f4c95-ab2e-911d-6476-7f93f9c1e2c9@applied-asynchrony.com>
On 10/08/2018 06:37 PM, Holger Hoffstätte wrote:
> On 10/08/18 17:46, Hans van Kranenburg wrote:
> <snip>
>> fs.devices() also looks for dev_items in the chunk tree:
>>
>> https://github.com/knorrie/python-btrfs/blob/master/btrfs/ctree.py#L481
>>
>> So, BOOM! you need root.
>>
>> Or just start a 0, ignore errors and start trying all devids until you
>> found num_devices amount of them that work, yolo.
>
> Since I need to walk /sys/fs/btrfs/ anyway I *think* I can just look
> at the entries in /sys/fs/btrfs/<fsid>/devices/ and query them all
> directly.
But, you still need root for that right? The progs code does a RO open
directly on the block device.
-$ btrfs dev stats /dev/xvdb
ERROR: cannot open /dev/xvdb: Permission denied
ERROR: '/dev/xvdb' is not a mounted btrfs device
stat("/dev/loop0", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0
stat("/dev/loop0", {st_mode=S_IFBLK|0660, st_rdev=makedev(7, 0), ...}) = 0
open("/dev/loop0", O_RDONLY) = -1 EACCES (Permission denied)
But:
-# btrfs dev stats /dev/xvdb
[/dev/xvdb].write_io_errs 0
[/dev/xvdb].read_io_errs 0
[/dev/xvdb].flush_io_errs 0
[/dev/xvdb].corruption_errs 0
[/dev/xvdb].generation_errs 0
> The skeleton btrfs_exporter already responds to http requests and
> returns dummy metrics, using the official python client library.
> I've found a nice little python sysfs scraper and now only need to
> figure out how best to map the btrfs info in sysfs to useful metrics.
> The privileged access issue would only have come into play much later,
> but it seems I can avoid it after all, which is great.
> I'm also (re-)learning python in the process, so that's the actual
> thing slowing me down..
:)
--
Hans van Kranenburg
next prev parent reply other threads:[~2018-10-08 20:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-08 14:27 Curious problem: btrfs device stats & unpriviliged access Holger Hoffstätte
2018-10-08 14:40 ` Hans van Kranenburg
2018-10-08 14:54 ` Hans van Kranenburg
2018-10-08 15:29 ` Holger Hoffstätte
2018-10-08 15:46 ` Hans van Kranenburg
2018-10-08 16:37 ` Holger Hoffstätte
2018-10-08 20:02 ` Hans van Kranenburg [this message]
2019-10-23 14:24 ` Holger Hoffstätte
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=faab0e97-c853-11dd-243d-021232b0783a@mendix.com \
--to=hans.van.kranenburg@mendix.com \
--cc=holger@applied-asynchrony.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;
as well as URLs for NNTP newsgroup(s).