All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] btrfs-progs: use the new ioctl BTRFS_IOC_GET_CHUNK_INFO
@ 2020-03-15 15:24 Goffredo Baroncelli
  2020-03-15 15:24 ` [PATCH 1/3] btrfs-progs: remove use BLKGETSIZE64 Goffredo Baroncelli
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Goffredo Baroncelli @ 2020-03-15 15:24 UTC (permalink / raw)
  To: linux-btrfs


Hi,

this is a repost of an old patch (~2017). At the time it din't received
any feedback. I repost it hoping that it still be interested.

This patch set is the btrfs-prog related one; another one related to the
kernel is send separately.

This patch set createa a new ioctl BTRFS_IOC_GET_CHUNK_INFO.
The aim is to replace the BTRFS_IOC_TREE_SEARCH ioctl
used by "btrfs fi usage" to obtain information about the 
chunks/block groups. 

The problems in using the BTRFS_IOC_TREE_SEARCH is that it access
the very low data structure of BTRFS. This means: 
1) this would be complicated a possible change of the disk format
2) it requires the root privileges

The BTRFS_IOC_GET_CHUNK_INFO ioctl can be called even from a not root
user: I think that the data exposed are not sensibile data.

These patches allow to use "btrfs fi usage" without root privileges.

before:
-------------------------------------------

$ btrfs fi us /
WARNING: cannot read detailed chunk info, per-device usage will not be shown, run as root
Overall:
    Device size:		 100.00GiB
    Device allocated:		  26.03GiB
    Device unallocated:		  73.97GiB
    Device missing:		     0.00B
    Used:			  17.12GiB
    Free (estimated):		  80.42GiB	(min: 80.42GiB)
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		  53.12MiB	(used: 0.00B)

Data,single: Size:23.00GiB, Used:16.54GiB (71.93%)

Metadata,single: Size:3.00GiB, Used:588.94MiB (19.17%)

System,single: Size:32.00MiB, Used:16.00KiB (0.05%)

after:
-----------------------------------------------
$ ./btrfs fi us /
Overall:
    Device size:		 100.00GiB
    Device allocated:		  26.03GiB
    Device unallocated:		  73.97GiB
    Device missing:		     0.00B
    Used:			  17.12GiB
    Free (estimated):		  80.42GiB	(min: 80.42GiB)
    Data ratio:			      1.00
    Metadata ratio:		      1.00
    Global reserve:		  53.12MiB	(used: 0.00B)

Data,single: Size:23.00GiB, Used:16.54GiB (71.93%)
   /dev/sdd3	  23.00GiB

Metadata,single: Size:3.00GiB, Used:588.94MiB (19.17%)
   /dev/sdd3	   3.00GiB

System,single: Size:32.00MiB, Used:16.00KiB (0.05%)
   /dev/sdd3	  32.00MiB

Unallocated:
   /dev/sdd3	  73.97GiB

Comments are welcome
BR
G.Baroncelli


-- 
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5





^ permalink raw reply	[flat|nested] 8+ messages in thread
* [RFC] btrfs-progs: use the new ioctl BTRFS_IOC_GET_CHUNK_INFO
@ 2017-09-25 20:18 Goffredo Baroncelli
  0 siblings, 0 replies; 8+ messages in thread
From: Goffredo Baroncelli @ 2017-09-25 20:18 UTC (permalink / raw)
  To: linux-btrfs


Hi all,

this patches set uses the new ioctl BTRFS_IOC_GET_CHUNK_INFO to get
information about the chunk (see my other emails). 

The first patch change the function get_partition_size() to avoid
ioctl which would require root privileges (BLKGETSIZE64).
Instead it obtain the information via the sysfs filesystem.

The second patch use the BTRFS_IOC_GET_CHUNK_INFO instead of
TREE_SEARCH_IOCTL. The old code is still in place as fallback
when the kernel doesn't have the new ioctl.

These patches allow to use "btrfs fi usage" without root privileges.

Comments are welcome
BR
G.Baroncelli

--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-03-31 19:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 15:24 [RFC] btrfs-progs: use the new ioctl BTRFS_IOC_GET_CHUNK_INFO Goffredo Baroncelli
2020-03-15 15:24 ` [PATCH 1/3] btrfs-progs: remove use BLKGETSIZE64 Goffredo Baroncelli
2020-03-15 15:24 ` [PATCH 2/3] btrfs-progs: Add BTRFS_IOC_GET_CHUNK_INFO ioctl Goffredo Baroncelli
2020-03-15 15:24 ` [PATCH 3/3] btrfs-progs: use the new ioctl BTRFS_IOC_GET_CHUNK_INFO Goffredo Baroncelli
2020-03-25 20:12 ` [RFC] " Goffredo Baroncelli
2020-03-31 19:17 ` Goffredo Baroncelli
2020-03-31 19:18 ` Goffredo Baroncelli
  -- strict thread matches above, loose matches on Subject: below --
2017-09-25 20:18 Goffredo Baroncelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.