mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
Make zpool status dedup table support raw bytes -p output
Check if -p flag is enabled, and if so print dedup table with raw bytes. Restructure the logic in zutil_pool to check if -p flag is enabled before printing either the bytes or raw numbers. Calls to print the data for DDT now all use zfs_nicenum_format(). Increased DDT histogram column buffers to 32 bytes to prevent truncation when -p is enabled. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Adi Gollamudi <adigollamudi@gmail.com> Closes #11626 Closes #17926
This commit is contained in:
+32
-16
@@ -34,11 +34,16 @@
|
||||
#include <libzutil.h>
|
||||
|
||||
static void
|
||||
dump_ddt_stat(const ddt_stat_t *dds, int h)
|
||||
dump_ddt_stat(const ddt_stat_t *dds, int h, boolean_t parsable)
|
||||
{
|
||||
char refcnt[6];
|
||||
char blocks[6], lsize[6], psize[6], dsize[6];
|
||||
char ref_blocks[6], ref_lsize[6], ref_psize[6], ref_dsize[6];
|
||||
char refcnt[32];
|
||||
char blocks[32], lsize[32], psize[32], dsize[32];
|
||||
char ref_blocks[32], ref_lsize[32], ref_psize[32], ref_dsize[32];
|
||||
|
||||
enum zfs_nicenum_format count_format = parsable ?
|
||||
ZFS_NICENUM_RAW : ZFS_NICENUM_1024;
|
||||
enum zfs_nicenum_format byte_format = parsable ?
|
||||
ZFS_NICENUM_RAW : ZFS_NICENUM_BYTES;
|
||||
|
||||
if (dds == NULL || dds->dds_blocks == 0)
|
||||
return;
|
||||
@@ -46,16 +51,26 @@ dump_ddt_stat(const ddt_stat_t *dds, int h)
|
||||
if (h == -1)
|
||||
(void) strcpy(refcnt, "Total");
|
||||
else
|
||||
zfs_nicenum(1ULL << h, refcnt, sizeof (refcnt));
|
||||
zfs_nicenum_format(1ULL << h, refcnt, sizeof (refcnt),
|
||||
count_format);
|
||||
|
||||
zfs_nicenum(dds->dds_blocks, blocks, sizeof (blocks));
|
||||
zfs_nicebytes(dds->dds_lsize, lsize, sizeof (lsize));
|
||||
zfs_nicebytes(dds->dds_psize, psize, sizeof (psize));
|
||||
zfs_nicebytes(dds->dds_dsize, dsize, sizeof (dsize));
|
||||
zfs_nicenum(dds->dds_ref_blocks, ref_blocks, sizeof (ref_blocks));
|
||||
zfs_nicebytes(dds->dds_ref_lsize, ref_lsize, sizeof (ref_lsize));
|
||||
zfs_nicebytes(dds->dds_ref_psize, ref_psize, sizeof (ref_psize));
|
||||
zfs_nicebytes(dds->dds_ref_dsize, ref_dsize, sizeof (ref_dsize));
|
||||
|
||||
zfs_nicenum_format(dds->dds_blocks, blocks, sizeof (blocks),
|
||||
count_format);
|
||||
zfs_nicenum_format(dds->dds_lsize, lsize, sizeof (lsize),
|
||||
byte_format);
|
||||
zfs_nicenum_format(dds->dds_psize, psize, sizeof (psize),
|
||||
byte_format);
|
||||
zfs_nicenum_format(dds->dds_dsize, dsize, sizeof (dsize),
|
||||
byte_format);
|
||||
zfs_nicenum_format(dds->dds_ref_blocks, ref_blocks,
|
||||
sizeof (ref_blocks), count_format);
|
||||
zfs_nicenum_format(dds->dds_ref_lsize, ref_lsize,
|
||||
sizeof (ref_lsize), byte_format);
|
||||
zfs_nicenum_format(dds->dds_ref_psize, ref_psize,
|
||||
sizeof (ref_psize), byte_format);
|
||||
zfs_nicenum_format(dds->dds_ref_dsize, ref_dsize,
|
||||
sizeof (ref_dsize), byte_format);
|
||||
|
||||
(void) printf("%6s %6s %5s %5s %5s %6s %5s %5s %5s\n",
|
||||
refcnt,
|
||||
@@ -67,7 +82,8 @@ dump_ddt_stat(const ddt_stat_t *dds, int h)
|
||||
* Print the DDT histogram and the column totals.
|
||||
*/
|
||||
void
|
||||
zpool_dump_ddt(const ddt_stat_t *dds_total, const ddt_histogram_t *ddh)
|
||||
zpool_dump_ddt(const ddt_stat_t *dds_total, const ddt_histogram_t *ddh,
|
||||
boolean_t parsable)
|
||||
{
|
||||
int h;
|
||||
|
||||
@@ -91,9 +107,9 @@ zpool_dump_ddt(const ddt_stat_t *dds_total, const ddt_histogram_t *ddh)
|
||||
"------", "-----", "-----", "-----");
|
||||
|
||||
for (h = 0; h < 64; h++)
|
||||
dump_ddt_stat(&ddh->ddh_stat[h], h);
|
||||
dump_ddt_stat(&ddh->ddh_stat[h], h, parsable);
|
||||
|
||||
dump_ddt_stat(dds_total, -1);
|
||||
dump_ddt_stat(dds_total, -1, parsable);
|
||||
|
||||
(void) printf("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user