kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

6.5.3: `btrfs device usage <dev>` emits: ERROR: unexpected number of devices: 0 != 1 #697

Closed Polynomial-C closed 8 months ago

Polynomial-C commented 8 months ago

Since commit 88c25674c7c0d0ae90bde07975b7beffbe05b80f the command btrfs device usage <dev> emits the following error message: ERROR: unexpected number of devices: 0 != 1

Here's a complete example:

# btrfs device usage /
ERROR: unexpected number of devices: 0 != 1
/dev/mapper/luks-<UUID>, ID: 1
   Device size:            44.98GiB
   Device slack:              0.00B
   Data,single:            33.01GiB
   Metadata,single:         1.01GiB
   System,single:           4.00MiB
   Unallocated:            10.96GiB

Reverting commit 88c25674c7c0d0ae90bde07975b7beffbe05b80f "fixes" the issue. Kernel version where I have observed this is 6.1.59 (LTS).

kdave commented 8 months ago

Thanks for the report, the fix is below, will be added to devel.

--- a/cmds/filesystem-usage.c
+++ b/cmds/filesystem-usage.c
@@ -807,6 +807,7 @@ static int load_device_info(int fd, struct array *devinfos)
                                device_get_partition_size((const char *)dev_info.path);
                }
                info->size = dev_info.total_bytes;
+               ndevs++;
        }

        if (ndevs != fi_args.num_devices) {