fee391e33a
- update to upstream 3.14.1 - mkfs: - fix TRIM detection - do not zero-out end of device unconditionally - no crash with --features option - fsck: - clear log tree in repair mode - check reloc roots - btrfs - reworked space reporting (bnc#873106) - btrfs fi usage - new command - btrfs dev usage - new command - btrfs fi df - enhanced output with GlobalReserve - Removed patches: * 0001-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch - Added patches: * 0001-Btrfs-progs-fix-check-to-test-trim-support.patch * 0002-Btrfs-progs-fsck-fix-double-free-memory-crash.patch * 0003-Btrfs-progs-mkfs-Remove-zero_end-1-since-it-has-been.patch * 0004-btrfs-progs-fix-wrong-max-system-array-size-check-in.patch * 0005-btrfs-progs-move-arg_strtou64-to-a-separate-file-for.patch * 0006-Btrfs-progs-fsck-clear-out-log-tree-in-repair-mode.patch * 0007-Btrfs-progs-fsck-avoid-pinning-same-block-several-ti.patch * 0008-Btrfs-progs-fsck-add-ability-to-check-reloc-roots.patch * 0009-btrfs-progs-prevent-close_root-if-the-root-to-close-.patch * 0010-btrfs-progs-fix-mkfs.btrfs-segfault-with-features-op.patch * 0011-btrfs-progs-Enhance-the-command-btrfs-filesystem-df.patch * 0012-btrfs-progs-Add-helpers-functions-to-handle-the-prin.patch * 0013-btrfs-progs-Add-command-btrfs-filesystem-disk-usage.patch * 0014-btrfs-progs-Add-btrfs-device-disk-usage-command.patch * 0015-btrfs-progs-cleanup-dead-return-after-usage-for-fi-d.patch * 0016-btrfs-progs-Fix-memleak-in-get_raid56_used.patch * 0017-Btrfs-progs-fi-usage-free-memory-if-realloc-fails.patch * 0018-btrfs-progs-read-global-reserve-size-from-space-info.patch * 0019-btrfs-progs-add-original-df-and-rename-disk_usage-to.patch * 0020-btrfs-progs-move-device-usage-to-cmds-device-more-cl.patch * 0021-btrfs-progs-check-if-we-can-t-get-info-from-ioctls-d.patch * 0022-btrfs-progs-zero-out-structures-before-calling-ioctl.patch * 0023-btrfs-progs-print-B-for-bytes.patch * 0024-btrfs-progs-Print-more-info-about-device-sizes.patch * 0025-btrfs-progs-compare-unallocated-space-against-the-co.patch * 0026-btrfs-progs-add-section-of-overall-filesystem-usage.patch * 0027-btrfs-progs-cleanup-filesystem-device-usage-code.patch * 0028-btrfs-progs-extend-pretty-printers-with-unit-mode.patch * 0029-btrfs-progs-replace-df_pretty_sizes-with-pretty_size.patch * 0030-btrfs-progs-clean-up-return-codes-and-paths.patch * 0031-btrfs-progs-move-global-reserve-to-overall-summary.patch (forwarded request 232435 from dsterba) OBS-URL: https://build.opensuse.org/request/show/232437 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=40
234 lines
5.7 KiB
Diff
234 lines
5.7 KiB
Diff
From 2c574dd5564fbe11a9e6e9c707fa907a7418c687 Mon Sep 17 00:00:00 2001
|
|
From: David Sterba <dsterba@suse.cz>
|
|
Date: Mon, 28 Apr 2014 18:55:05 +0200
|
|
Subject: [PATCH 41/42] btrfs-progs: clean up return codes and paths
|
|
|
|
Use the common patterns with one return statement at the end, pass down error
|
|
|
|
Signed-off-by: David Sterba <dsterba@suse.cz>
|
|
---
|
|
cmds-device.c | 27 +++++++++++++--------------
|
|
cmds-fi-disk_usage.c | 39 +++++++++++++++++++++------------------
|
|
2 files changed, 34 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/cmds-device.c b/cmds-device.c
|
|
index eb6b79ca5127..6dd5b05c7651 100644
|
|
--- a/cmds-device.c
|
|
+++ b/cmds-device.c
|
|
@@ -448,10 +448,8 @@ static int _cmd_device_usage(int fd, char *path, int mode)
|
|
|
|
ret = load_chunk_and_device_info(fd, &chunkinfo, &chunkcount, &devinfo,
|
|
&devcount);
|
|
- if (ret) {
|
|
- ret = -1;
|
|
- goto exit;
|
|
- }
|
|
+ if (ret)
|
|
+ goto out;
|
|
|
|
for (i = 0; i < devcount; i++) {
|
|
printf("%s, ID: %llu\n", devinfo[i].path, devinfo[i].devid);
|
|
@@ -461,7 +459,7 @@ static int _cmd_device_usage(int fd, char *path, int mode)
|
|
printf("\n");
|
|
}
|
|
|
|
-exit:
|
|
+out:
|
|
free(devinfo);
|
|
free(chunkinfo);
|
|
|
|
@@ -472,6 +470,7 @@ int cmd_device_usage(int argc, char **argv)
|
|
{
|
|
|
|
int mode = UNITS_HUMAN;
|
|
+ int ret = 0;
|
|
int i, more_than_one = 0;
|
|
|
|
optind = 1;
|
|
@@ -494,28 +493,28 @@ int cmd_device_usage(int argc, char **argv)
|
|
usage(cmd_device_usage_usage);
|
|
|
|
for (i = optind; i < argc ; i++) {
|
|
- int r, fd;
|
|
+ int fd;
|
|
DIR *dirstream = NULL;
|
|
if (more_than_one)
|
|
printf("\n");
|
|
|
|
fd = open_file_or_dir(argv[i], &dirstream);
|
|
if (fd < 0) {
|
|
- fprintf(stderr, "ERROR: can't access to '%s'\n",
|
|
+ fprintf(stderr, "ERROR: can't access '%s'\n",
|
|
argv[1]);
|
|
- return 12;
|
|
+ ret = 1;
|
|
+ goto out;
|
|
}
|
|
|
|
- r = _cmd_device_usage(fd, argv[i], mode);
|
|
+ ret = _cmd_device_usage(fd, argv[i], mode);
|
|
close_file_or_dir(fd, dirstream);
|
|
|
|
- if (r)
|
|
- return r;
|
|
+ if (ret)
|
|
+ goto out;
|
|
more_than_one = 1;
|
|
-
|
|
}
|
|
-
|
|
- return 0;
|
|
+out:
|
|
+ return !!ret;
|
|
}
|
|
|
|
const struct cmd_group device_cmd_group = {
|
|
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
|
|
index d1b8bbddc4d5..7c93247e4f54 100644
|
|
--- a/cmds-fi-disk_usage.c
|
|
+++ b/cmds-fi-disk_usage.c
|
|
@@ -68,7 +68,7 @@ static int add_info_to_list(struct chunk_info **info_ptr,
|
|
if (!res) {
|
|
free(*info_ptr);
|
|
fprintf(stderr, "ERROR: not enough memory\n");
|
|
- return -1;
|
|
+ return -ENOMEM;
|
|
}
|
|
|
|
*info_ptr = res;
|
|
@@ -163,7 +163,7 @@ static int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count
|
|
fprintf(stderr,
|
|
"ERROR: can't perform the search - %s\n",
|
|
strerror(e));
|
|
- return -99;
|
|
+ return ret;
|
|
}
|
|
/* the ioctl returns the number of item it found in nr_items */
|
|
|
|
@@ -179,9 +179,10 @@ static int load_chunk_info(int fd, struct chunk_info **info_ptr, int *info_count
|
|
off += sizeof(*sh);
|
|
item = (struct btrfs_chunk *)(args.buf + off);
|
|
|
|
- if (add_info_to_list(info_ptr, info_count, item)) {
|
|
+ ret = add_info_to_list(info_ptr, info_count, item);
|
|
+ if (ret) {
|
|
*info_ptr = 0;
|
|
- return -100;
|
|
+ return ret;
|
|
}
|
|
|
|
off += sh->len;
|
|
@@ -319,8 +320,9 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
|
double K;
|
|
u64 raid5_used, raid6_used;
|
|
|
|
- if ((sargs = load_space_info(fd, path)) == NULL) {
|
|
- ret = -1;
|
|
+ sargs = load_space_info(fd, path);
|
|
+ if (!sargs) {
|
|
+ ret = 1;
|
|
goto exit;
|
|
}
|
|
|
|
@@ -331,7 +333,7 @@ static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
|
|
"ERROR: couldn't get space info on '%s' - %s\n",
|
|
path, strerror(e));
|
|
|
|
- ret = 19;
|
|
+ ret = 1;
|
|
goto exit;
|
|
}
|
|
get_raid56_used(fd, chunkinfo, chunkcount, &raid5_used, &raid6_used);
|
|
@@ -439,13 +441,13 @@ static int load_device_info(int fd, struct device_info **device_info_ptr,
|
|
return ret;
|
|
if (ret < 0) {
|
|
fprintf(stderr, "ERROR: cannot get filesystem info\n");
|
|
- return -1;
|
|
+ return ret;
|
|
}
|
|
|
|
info = calloc(fi_args.num_devices, sizeof(struct device_info));
|
|
if (!info) {
|
|
fprintf(stderr, "ERROR: not enough memory\n");
|
|
- return -1;
|
|
+ return ret;
|
|
}
|
|
|
|
for (i = 0, ndevs = 0 ; i <= fi_args.max_id ; i++) {
|
|
@@ -460,7 +462,7 @@ static int load_device_info(int fd, struct device_info **device_info_ptr,
|
|
"ERROR: cannot get info about device devid=%d\n",
|
|
i);
|
|
free(info);
|
|
- return -1;
|
|
+ return ret;
|
|
}
|
|
|
|
info[ndevs].devid = dev_info.devid;
|
|
@@ -749,7 +751,7 @@ static int print_filesystem_usage_by_chunk(int fd,
|
|
sargs = load_space_info(fd, path);
|
|
if (!sargs) {
|
|
ret = 1;
|
|
- goto exit;
|
|
+ goto out;
|
|
}
|
|
|
|
if (tabular)
|
|
@@ -759,9 +761,8 @@ static int print_filesystem_usage_by_chunk(int fd,
|
|
_cmd_filesystem_usage_linear(mode, sargs, chunkinfo,
|
|
chunkcount, devinfo, devcount);
|
|
|
|
-exit:
|
|
free(sargs);
|
|
-
|
|
+out:
|
|
return ret;
|
|
}
|
|
|
|
@@ -777,6 +778,7 @@ const char * const cmd_filesystem_usage_usage[] = {
|
|
int cmd_filesystem_usage(int argc, char **argv)
|
|
{
|
|
int mode = UNITS_HUMAN;
|
|
+ int ret = 0;
|
|
int i, more_than_one = 0;
|
|
int tabular = 0;
|
|
|
|
@@ -803,7 +805,6 @@ int cmd_filesystem_usage(int argc, char **argv)
|
|
usage(cmd_filesystem_usage_usage);
|
|
|
|
for (i = optind; i < argc; i++) {
|
|
- int ret;
|
|
int fd;
|
|
DIR *dirstream = NULL;
|
|
struct chunk_info *chunkinfo = NULL;
|
|
@@ -813,9 +814,10 @@ int cmd_filesystem_usage(int argc, char **argv)
|
|
|
|
fd = open_file_or_dir(argv[i], &dirstream);
|
|
if (fd < 0) {
|
|
- fprintf(stderr, "ERROR: can't access to '%s'\n",
|
|
+ fprintf(stderr, "ERROR: can't access '%s'\n",
|
|
argv[1]);
|
|
- return 12;
|
|
+ ret = 1;
|
|
+ goto out;
|
|
}
|
|
if (more_than_one)
|
|
printf("\n");
|
|
@@ -838,11 +840,12 @@ cleanup:
|
|
free(devinfo);
|
|
|
|
if (ret)
|
|
- return ret;
|
|
+ goto out;
|
|
more_than_one = 1;
|
|
}
|
|
|
|
- return 0;
|
|
+out:
|
|
+ return !!ret;
|
|
}
|
|
|
|
void print_device_chunks(int fd, struct device_info *devinfo,
|
|
--
|
|
1.9.0
|
|
|