aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2023-10-30 13:43:44 +0100
committerDavid Sterba <dsterba@suse.com>2023-11-03 18:04:37 +0100
commitb1e2de452a8acd67e11ca65c25527535aa0b42e0 (patch)
tree80f5be363ace3067123eea9c1cdd9131235253e9
parentf240c6114d616e18424204c7a3055fa1751fbc25 (diff)
downloadbtrfs-progs-b1e2de452a8acd67e11ca65c25527535aa0b42e0.tar.gz
btrfs-progs: mkfs: print zone count for each device
In zoned mode print zone count for each device, the zone size must be the same so it's sufficient to print it in the summary. $ mkfs.btrfs -O zoned /dev/nullb[0-3] ... Zoned device: yes Zone size: 16.00MiB ... Devices: ID SIZE ZONES PATH 1 512.00MiB 32 /dev/nullb0 2 256.00MiB 16 /dev/nullb1 3 1.00GiB 64 /dev/nullb2 4 2.00GiB 128 /dev/nullb3 Issue: #693 Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--mkfs/main.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/mkfs/main.c b/mkfs/main.c
index 2c24b27e..d984c995 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -57,6 +57,7 @@
#include "common/box.h"
#include "common/units.h"
#include "common/string-utils.h"
+#include "common/string-table.h"
#include "cmds/commands.h"
#include "check/qgroup-verify.h"
#include "mkfs/common.h"
@@ -486,11 +487,13 @@ static int _cmp_device_by_id(void *priv, struct list_head *a,
list_entry(b, struct btrfs_device, dev_list)->devid;
}
-static void list_all_devices(struct btrfs_root *root)
+static void list_all_devices(struct btrfs_root *root, bool is_zoned)
{
struct btrfs_fs_devices *fs_devices;
struct btrfs_device *device;
int number_of_devices = 0;
+ struct string_table *tab;
+ int row, col;
fs_devices = root->fs_info->fs_devices;
@@ -501,15 +504,31 @@ static void list_all_devices(struct btrfs_root *root)
printf("Number of devices: %d\n", number_of_devices);
printf("Devices:\n");
- printf(" ID SIZE PATH\n");
+ if (is_zoned)
+ tab = table_create(4, number_of_devices + 1);
+ else
+ tab = table_create(3, number_of_devices + 1);
+ tab->spacing = STRING_TABLE_SPACING_2;
+ col = 0;
+ table_printf(tab, col++, 0, "> ID");
+ table_printf(tab, col++, 0, "> SIZE");
+ if (is_zoned)
+ table_printf(tab, col++, 0, ">ZONES");
+ table_printf(tab, col++, 0, "<PATH");
+
+ row = 1;
list_for_each_entry(device, &fs_devices->devices, dev_list) {
- printf(" %3llu %10s %s\n",
- device->devid,
- pretty_size(device->total_bytes),
- device->name);
- }
-
+ col = 0;
+ table_printf(tab, col++, row, ">%llu", device->devid);
+ table_printf(tab, col++, row, ">%s", pretty_size(device->total_bytes));
+ if (is_zoned)
+ table_printf(tab, col++, row, ">%u", device->zone_info->nr_zones);
+ table_printf(tab, col++, row, "<%s", device->name);
+ row++;
+ }
+ table_dump(tab);
printf("\n");
+ table_free(tab);
}
static bool is_temp_block_group(struct extent_buffer *node,
@@ -2016,7 +2035,7 @@ raid_groups:
printf("Checksum: %s\n",
btrfs_super_csum_name(mkfs_cfg.csum_type));
- list_all_devices(root);
+ list_all_devices(root, opt_zoned);
if (mkfs_cfg.csum_type == BTRFS_CSUM_TYPE_SHA256) {
printf(