Commit Graph

25 Commits

Author SHA1 Message Date
David Sterba 7febbc9efe btrfs-progs: fi usage: improved error handling in load_device_info
Signed-off-by: David Sterba <dsterba@suse.com>
2016-09-21 14:12:10 +02:00
David Sterba f551548372 btrfs-progs: do not set optind if not necessary
In the subcommand callbacks that are called just once, we don't need to
explicitly reset optind.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-13 19:41:55 +02:00
David Sterba 66a2e4eee4 btrfs-progs: device usage: report slack space
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>
2016-06-01 14:56:56 +02:00
Nicholas D Steeves bd2cc320af btrfs-progs: typo review of strings and comments
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-06-01 14:56:56 +02:00
David Sterba 1e4abbdf96 btrfs-progs: use ioctl search headers everywhere
Generated by following semantic patch and manually tweaked.

<SmPL>
@@
struct btrfs_ioctl_search_header *SH;
@@
(
- SH->objectid
+ btrfs_search_header_objectid(SH)
|
- SH->offset
+ btrfs_search_header_offset(SH)
|
- SH->transid
+ btrfs_search_header_transid(SH)
|
- SH->len
+ btrfs_search_header_len(SH)
|
- SH->type
+ btrfs_search_header_type(SH)
)
</SmPL>

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=112131
Reported-and-tested-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-11 15:53:16 +02:00
David Sterba b9ec406c0f btrfs-progs: fi usage: support mixed blockgroups
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>
2016-01-13 16:43:13 +01:00
David Sterba 4b9d4fe00f btrfs-porgs: fi usage: rename variable to avoid shadowing
Reported by gcc -Wshadow .

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:57 +01:00
David Sterba ac4ec4d4f4 btrfs-progs: check for negative return value from ioctl
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>
2016-01-12 15:02:55 +01:00
David Sterba 633dc6f80f btrfs-progs: remove unnecessary errno temp variables
We can read errno directly if it's not clobbered by any intermediate
calls.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:55 +01:00
David Sterba 0e1acda2b2 btrfs-progs: cmd fi usage: switch to common error message wrapper
Message texts were adjusted.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-01-12 15:02:53 +01:00
Byongho Lee 83d0a1727b btrfs-progs: use NULL instead of 0
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>
2016-01-12 15:01:05 +01:00
David Sterba 49e0f3e646 btrfs-progs: utils: rename helpinfo unit vairables
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 16:39:49 +01:00
David Sterba c5cb2432bf btrfs-progs: fi usage: print header and footer separation line
Print the full row width and change to '-' as we're not using '='
anywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 01:09:50 +01:00
David Sterba 1de2da5ddd btrfs-progs: string table: add specifier for fillup char
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>
2015-11-03 01:00:23 +01:00
David Sterba 952251481e btrfs-progs: fi usage: print device id column in the tabular output<F2>
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>
2015-11-03 00:19:41 +01:00
David Sterba 258a0e8812 btrfs-progs: fi usage: cleanup, replace space info starting column constant
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:14:38 +01:00
David Sterba ffa899f296 btrfs-progs: fi usage: cleanup, replace header constant
The size of the header is not obvious, let's make it more visible by
replacing it with a varaible.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:14:08 +01:00
David Sterba f3d5694578 btrfs-progs: fi usage: properly count real space infos
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>
2015-11-03 00:14:06 +01:00
David Sterba 7691c2c52b btrfs-progs: fi usage: print path header in the tabular mode
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 18:40:57 +01:00
David Sterba 5205097bac btrfs-progs: fi usage: cleanup, print header in one go
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 18:39:41 +01:00
David Sterba a0c78dca8f btrfs-progs: fi usage: do not print global block reserve
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>
2015-11-02 18:30:32 +01:00
Zhao Lei d0c0f90b38 btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem command
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>
2015-11-02 09:35:00 +01:00
David Sterba 49ac9aa1e8 btrfs-progs: fix error checking in load_device_info
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>
2015-10-02 17:56:43 +02:00
Zhao Lei 665dc49ef6 btrfs-progs: Use common unit parser for btrfs filesystem command
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>
2015-09-01 14:02:48 +02:00
David Sterba c8927d5116 btrfs-progs: cleanup, rename *disk_usage* files to usage
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-22 18:21:48 +02:00