]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
cmd_fs: calculate size based on bucket count for data types BCH_DATA_free, BCH_DATA_n...
authorPhilip Laube <philip.laube.dev@xyz.de>
Wed, 6 Dec 2023 18:29:26 +0000 (19:29 +0100)
committerPhilip Laube <philip.laube.dev@xyz.de>
Thu, 7 Dec 2023 19:47:09 +0000 (20:47 +0100)
Signed-off-by: Philip Laube <philip.laube.dev@xyz.de>
cmd_fs.c

index a828f39b7c1b172f5e94bced46959292de8a05c7..b5c8ab3a69be3f1833640e5934c89dcb6fcb77c0 100644 (file)
--- a/cmd_fs.c
+++ b/cmd_fs.c
@@ -39,10 +39,22 @@ static void dev_usage_type_to_text(struct printbuf *out,
                                   struct bch_ioctl_dev_usage_v2 *u,
                                   enum bch_data_type type)
 {
+       u64 sectors = 0;
+       switch (type) {
+       case BCH_DATA_free:
+       case BCH_DATA_need_discard:
+       case BCH_DATA_need_gc_gens:
+               /* sectors are 0 for these types so calculate sectors for them */
+               sectors = u->d[type].buckets * u->bucket_size;
+               break;
+       default:
+               sectors = u->d[type].sectors;
+       }
+
        __dev_usage_type_to_text(out, bch2_data_types[type],
                        u->bucket_size,
                        u->d[type].buckets,
-                       u->d[type].sectors,
+                       sectors,
                        u->d[type].fragmented);
 }