summaryrefslogtreecommitdiff
path: root/cmds-fi-usage.c
Commit message (Collapse)AuthorAge
* btrfs-progs: fi usage: change to output more info without root privilegeMisono Tomohiro2018-06-07
| | | | | | | | | | | | | | | | Although per device usage cannot be shown without root privilege, per profile usage can be shown. To achieve this, we just basically need to remove the check of nullness of chunkinfo in print_filesystem_usage_by_chunk(), because other functions except print_unused() properly handles chunkinfo by chunkcount, which is 0 if chunkinfo is null. As a result, "fi usage" always includes the information of "fi df". Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: change warning message more appropriatelyMisono Tomohiro2018-06-07
| | | | | | | | | | | | "fi usage" shows the warning "RAID5/6 numbers will be incorrect" when running without root privilege even if raid5/6 is not used. What happens is it cannot get the per device profile usage info, so change the message more appropriately. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> [ adjust message ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: treewide: Replace strerror(errno) with %m.Rosen Penev2018-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As btrfs is specific to Linux, %m can be used instead of strerror(errno) in format strings. This has some size reduction benefits for embedded systems. glibc, musl, and uclibc-ng all support %m as a modifier to printf. A quick glance at the BIONIC libc source indicates that it has support for %m as well. BSDs and Windows do not but I do believe them to be beyond the scope of btrfs-progs. Compiled sizes on Ubuntu 16.04: Before: 3916512 btrfs 233688 libbtrfs.so.0.1 4899 bcp 2367672 btrfs-convert 2208488 btrfs-corrupt-block 13302 btrfs-debugfs 2152160 btrfs-debug-tree 2136024 btrfs-find-root 2287592 btrfs-image 2144600 btrfs-map-logical 2130760 btrfs-select-super 2152608 btrfstune 2131760 btrfs-zero-log 2277752 mkfs.btrfs 9166 show-blocks After: 3908744 btrfs 233256 libbtrfs.so.0.1 4899 bcp 2366560 btrfs-convert 2207432 btrfs-corrupt-block 13302 btrfs-debugfs 2151104 btrfs-debug-tree 2134968 btrfs-find-root 2281864 btrfs-image 2143536 btrfs-map-logical 2129704 btrfs-select-super 2151552 btrfstune 2130696 btrfs-zero-log 2276272 mkfs.btrfs 9166 show-blocks Total savings: 23928 (24 kilo)bytes Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: don't use __u8 for fsid buffersDavid Sterba2017-11-14
| | | | | | | The underscore types are for ioctl structures and should not be used for regular code that does not need them. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi: enable fi usage for filesystem on top of seed deviceMisono, Tomohiro2017-11-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently "fi usage" (and "dev usage") cannot run for the filesystem using the seed device. This is because FS_INFO ioctl returns the number of devices excluding seeds, but load_device_info() tries to access valid device from devid 0 to max_id, and results in accessing seeds too (thus causing mismatching number of devices). Since only the size of non-seed devices matters, fix this by just skipping seed device by checking device's fsid and comparing it to the fsid obtained by FS_INFO ioctl. Anand Jain: %fi_args.num_devices provides number of devices excluding the seed device. So when looping through the device list for a given fsid, determine if the given device is a seed device by reading its superblock and then skip it if its a seed device. Reading of the superblock is done by the function dev_to_fsid() which can fail if the user is not root OR if the device has media errors as well. So skip the seed check altogether if we fail to know the device superblock and thus the fsid. With this now we are able to view the btrfs fi usage when the device is bad. Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi: move dev_to_fsid to cmds-fi-usage for later useMisono, Tomohiro2017-11-14
| | | | | | | | | Move dev_to_fsid() from cmds-filesystem.c to cmds-fi-usage.c in order to call it from both "fi show" and "fi usage". Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: device usage: don't calculate slack on missing devicePatrik Lundquist2017-09-08
| | | | | | | | Print Device slack: 0.00B instead of Device slack: 16.00EiB Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from print_device_chunksDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from print_device_sizesDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from get_raid56_usedDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move help defines to own headerDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce kernel sizes to cleanup large intermediate numberQu Wenruo2017-03-08
| | | | | | | | | | | Large numbers like (1024 * 1024 * 1024) may cost reader/reviewer to waste one second to convert to 1G. Introduce kernel include/linux/sizes.h to replace any intermediate number larger than 4096 (not including 4096) to SZ_*. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: enable negative numbers for unallocated device spaceDavid Sterba2017-01-25
| | | | | | | | | | | | | | | The unallocated space is not calculated correctly when a device deltion/replace is in progress. This appears as huge number, EiB-sized. It's really a negative number, because we don't have entire information available and mixing numbers that do and don't take the deleted device size into account. We have to query search ioctl to retrieve the missing information, also this requires root access for the ioctl, so we still need a workaround for non-root case. Here the negative numbers seem to be a bit more practical than EiB numbers. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: improved error handling in load_device_infoDavid Sterba2016-09-21
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: do not set optind if not necessaryDavid Sterba2016-07-13
| | | | | | | 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>
* btrfs-progs: device usage: report slack spaceDavid Sterba2016-06-01
| | | | | | | | | 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>
* btrfs-progs: typo review of strings and commentsNicholas D Steeves2016-06-01
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use ioctl search headers everywhereDavid Sterba2016-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: fi usage: support mixed blockgroupsDavid Sterba2016-01-13
| | | | | | | | 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>
* btrfs-porgs: fi usage: rename variable to avoid shadowingDavid Sterba2016-01-12
| | | | | | Reported by gcc -Wshadow . Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check for negative return value from ioctlDavid Sterba2016-01-12
| | | | | | | 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>
* btrfs-progs: remove unnecessary errno temp variablesDavid Sterba2016-01-12
| | | | | | | We can read errno directly if it's not clobbered by any intermediate calls. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: cmd fi usage: switch to common error message wrapperDavid Sterba2016-01-12
| | | | | | Message texts were adjusted. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: use NULL instead of 0Byongho Lee2016-01-12
| | | | | | | 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>
* btrfs-progs: utils: rename helpinfo unit vairablesDavid Sterba2015-11-06
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: print header and footer separation lineDavid Sterba2015-11-03
| | | | | | | Print the full row width and change to '-' as we're not using '=' anywhere. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: string table: add specifier for fillup charDavid Sterba2015-11-03
| | | | | | | 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>
* btrfs-progs: fi usage: print device id column in the tabular output<F2>David Sterba2015-11-03
| | | | | | | | | | | | | | | 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>
* btrfs-progs: fi usage: cleanup, replace space info starting column constantDavid Sterba2015-11-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: cleanup, replace header constantDavid Sterba2015-11-03
| | | | | | | 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>
* btrfs-progs: fi usage: properly count real space infosDavid Sterba2015-11-03
| | | | | | | | 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>
* btrfs-progs: fi usage: print path header in the tabular modeDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: cleanup, print header in one goDavid Sterba2015-11-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi usage: do not print global block reserveDavid Sterba2015-11-02
| | | | | | | 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>
* btrfs-progs: filesystem: use btrfs_open_dir for btrfs filesystem commandZhao Lei2015-11-02
| | | | | | | | | | | | | | | | | | | | | | 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>
* btrfs-progs: fix error checking in load_device_infoDavid Sterba2015-10-02
| | | | | | | | | | | 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>
* btrfs-progs: Use common unit parser for btrfs filesystem commandZhao Lei2015-09-01
| | | | | | | | | | 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>
* btrfs-progs: cleanup, rename *disk_usage* files to usageDavid Sterba2015-04-22
Signed-off-by: David Sterba <dsterba@suse.cz>