The total filesystem space on a given device might be smaller than the
device size. We should report that space as well. The original idea was
to report the 'occupied' size but the term was not all clear, so the
logic was reversed to report the slack space.
Signed-off-by: David Sterba <dsterba@suse.com>
Properly account the duplicated block groups and global reserve.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=110111
Reported-by: Chris Murphy <bugzilla@colorremedies.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Handle only negative values returned by ioctl syscalls, with exception
of the device remove. It returns positive values that are handled later.
Signed-off-by: David Sterba <dsterba@suse.com>
Fix the code assigning 0 to pointer instead of NULL.
Signed-off-by: Byongho Lee <bhlee.kernel@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Currently it's one by a single "=", but we might want to use
a different filler, let's make it explicit by "*".
Signed-off-by: David Sterba <dsterba@suse.com>
Example output:
Data Metadata System
Id Path single RAID1 RAID1 Unallocated
1 /dev/sdc2 44.94GiB 7.93GiB 32.00MiB 1.00GiB
2 /dev/sde1 44.94GiB 7.93GiB 32.00MiB 1.00GiB
======== ======== ======== ===========
Total 89.88GiB 7.93GiB 32.00MiB 2.00GiB
Used 74.28GiB 4.44GiB 20.00KiB
Signed-off-by: David Sterba <dsterba@suse.com>
We did not account the column for path but abused the skipped global
block reserve colum instead. Properly count the real infos and manually
added headers.
Signed-off-by: David Sterba <dsterba@suse.com>
Global block reserve is inherently part of metadata and should not be
listed separately in the output of 'fi usage' in the tabular output.
Signed-off-by: David Sterba <dsterba@suse.com>
We can use btrfs_open_dir() to check whether target dir is
in btrfs's mount point before open, instead of checking it in
kernel space of ioctl, and return fuzzy error message.
Before patch:
# (/mnt/tmp is not btrfs mountpoint)
#
# btrfs filesystem df /mnt/tmp
ERROR: couldn't get space info - Inappropriate ioctl for device
ERROR: get_df failed Inappropriate ioctl for device
#
After patch:
# ./btrfs filesystem df /mnt/tmp
ERROR: not btrfs filesystem: /mnt/tmp
#
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
load_device_info queries the FS_INFO ioctl and this may fail with EPERM
on older kernels. The check did not verify the ioctl return value and
incorrectly returned EPERM if it was previously stored in errno.
This fixes 'btrfs fi usage' that will print the overall summary for all
users (provided that the FS_INFO ioctl is already unprivileged).
Signed-off-by: David Sterba <dsterba@suse.com>
Move to use get_unit_mode_from_arg() for cmds-filesystem.c,
to make "btrfs filesystem df/show/usage"'s unit argument same.
Also have cleanup effect: 19 insertions(+), 181 deletions(-)
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>