2014-11-03 14:17:26 +01:00
|
|
|
From 685cfb2cb0a7b402c9074e08d2803e275c6f78eb Mon Sep 17 00:00:00 2001
|
2014-05-02 16:21:40 +02:00
|
|
|
From: David Sterba <dsterba@suse.cz>
|
|
|
|
Date: Thu, 24 Apr 2014 18:32:27 +0200
|
2014-11-03 14:17:26 +01:00
|
|
|
Subject: [PATCH 13/42] btrfs-progs: Print more info about device sizes
|
2014-05-02 16:21:40 +02:00
|
|
|
|
|
|
|
The entire device size may not be available to the filesystem, eg. if
|
|
|
|
it's modified via resize. Print this information if it can be obtained
|
|
|
|
from the DEV_INFO ioctl.
|
|
|
|
|
|
|
|
Print the device ID on the same line as the device name and move size to
|
|
|
|
the next line.
|
|
|
|
|
|
|
|
Sample:
|
|
|
|
/dev/sda7, ID: 3
|
|
|
|
Device size: 10.00GiB
|
2014-09-22 23:20:45 +02:00
|
|
|
FS occupied: 5.00GiB
|
2014-05-02 16:21:40 +02:00
|
|
|
Data,RAID10: 512.00MiB
|
|
|
|
Metadata,RAID10: 512.00MiB
|
|
|
|
System,RAID10: 4.00MiB
|
|
|
|
Unallocated: 9.00GiB
|
|
|
|
|
|
|
|
Signed-off-by: David Sterba <dsterba@suse.cz>
|
|
|
|
---
|
|
|
|
cmds-device.c | 6 +++---
|
2014-11-03 14:17:26 +01:00
|
|
|
cmds-fi-disk_usage.c | 12 +++++++++++-
|
2014-05-02 16:21:40 +02:00
|
|
|
cmds-fi-disk_usage.h | 6 +++++-
|
2014-11-03 14:17:26 +01:00
|
|
|
3 files changed, 19 insertions(+), 5 deletions(-)
|
2014-05-02 16:21:40 +02:00
|
|
|
|
|
|
|
diff --git a/cmds-device.c b/cmds-device.c
|
2014-11-03 14:17:26 +01:00
|
|
|
index 96e6309c0185..f9a23ac644c0 100644
|
2014-05-02 16:21:40 +02:00
|
|
|
--- a/cmds-device.c
|
|
|
|
+++ b/cmds-device.c
|
2014-11-03 14:17:26 +01:00
|
|
|
@@ -486,9 +486,9 @@ static int _cmd_device_usage(int fd, char *path, int mode)
|
2014-05-02 16:21:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < device_info_count; i++) {
|
|
|
|
- printf("%s\t%10s\n", device_info_ptr[i].path,
|
|
|
|
- df_pretty_sizes(device_info_ptr[i].size, mode));
|
|
|
|
-
|
|
|
|
+ printf("%s, ID: %llu\n", device_info_ptr[i].path,
|
|
|
|
+ device_info_ptr[i].devid);
|
|
|
|
+ print_device_sizes(fd, &device_info_ptr[i], mode);
|
|
|
|
print_device_chunks(fd, device_info_ptr[i].devid,
|
|
|
|
device_info_ptr[i].size,
|
|
|
|
info_ptr, info_count,
|
|
|
|
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
|
2014-11-03 14:17:26 +01:00
|
|
|
index f984be838e3b..83a3c6d52cc5 100644
|
2014-05-02 16:21:40 +02:00
|
|
|
--- a/cmds-fi-disk_usage.c
|
|
|
|
+++ b/cmds-fi-disk_usage.c
|
|
|
|
@@ -499,7 +499,8 @@ int load_device_info(int fd, struct device_info **device_info_ptr,
|
|
|
|
|
|
|
|
info[ndevs].devid = dev_info.devid;
|
|
|
|
strcpy(info[ndevs].path, (char *)dev_info.path);
|
|
|
|
- info[ndevs].size = get_partition_size((char *)dev_info.path);
|
|
|
|
+ info[ndevs].device_size = get_partition_size((char *)dev_info.path);
|
2014-11-03 14:17:26 +01:00
|
|
|
+ info[ndevs].size = dev_info.total_bytes;
|
2014-05-02 16:21:40 +02:00
|
|
|
++ndevs;
|
|
|
|
}
|
|
|
|
|
2014-09-22 23:20:45 +02:00
|
|
|
@@ -879,5 +880,14 @@ void print_device_chunks(int fd, u64 devid, u64 total_size,
|
2014-05-02 16:21:40 +02:00
|
|
|
printf(" Unallocated: %*s%10s\n",
|
|
|
|
(int)(20 - strlen("Unallocated")), "",
|
|
|
|
df_pretty_sizes(total_size - allocated, mode));
|
|
|
|
+}
|
|
|
|
|
|
|
|
+void print_device_sizes(int fd, struct device_info *devinfo, int mode)
|
|
|
|
+{
|
|
|
|
+ printf(" Device size: %*s%10s\n",
|
|
|
|
+ (int)(20 - strlen("Device size")), "",
|
|
|
|
+ df_pretty_sizes(devinfo->device_size, mode));
|
2014-09-22 23:20:45 +02:00
|
|
|
+ printf(" FS occupied: %*s%10s\n",
|
2014-05-02 16:21:40 +02:00
|
|
|
+ (int)(20 - strlen("FS occupied")), "",
|
|
|
|
+ df_pretty_sizes(devinfo->size, mode));
|
|
|
|
}
|
|
|
|
diff --git a/cmds-fi-disk_usage.h b/cmds-fi-disk_usage.h
|
|
|
|
index 787b4eb56acf..79cc2a115bc5 100644
|
|
|
|
--- a/cmds-fi-disk_usage.h
|
|
|
|
+++ b/cmds-fi-disk_usage.h
|
|
|
|
@@ -27,7 +27,10 @@ int cmd_filesystem_usage(int argc, char **argv);
|
|
|
|
struct device_info {
|
|
|
|
u64 devid;
|
|
|
|
char path[BTRFS_DEVICE_PATH_NAME_MAX];
|
|
|
|
- u64 size;
|
|
|
|
+ /* Size of the block device */
|
|
|
|
+ u64 device_size;
|
|
|
|
+ /* Size that's occupied by the filesystem, can be changed via resize */
|
|
|
|
+ u64 size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
@@ -50,5 +53,6 @@ char *df_pretty_sizes(u64 size, int mode);
|
|
|
|
void print_device_chunks(int fd, u64 devid, u64 total_size,
|
|
|
|
struct chunk_info *chunks_info_ptr,
|
|
|
|
int chunks_info_count, int mode);
|
|
|
|
+void print_device_sizes(int fd, struct device_info *devinfo, int mode);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
--
|
2014-11-03 14:17:26 +01:00
|
|
|
2.1.1
|
2014-05-02 16:21:40 +02:00
|
|
|
|