Skip to content

Conversation

@Adi-Goll
Copy link
Contributor

@Adi-Goll Adi-Goll commented Nov 11, 2025

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 calling zfs_nicenum() and zfs_nicebytes(). Other files changed update the call to/header declaration of dump_ddt_stat() to include a new variable: boolean_t parsable, indicating whether or not -p was used

This PR also includes updates to the ABI files because the function header for zpool_dump_ddt() was modified to include a new parameter which indicates if the -p flag was used.

Fixes #11626

How Has This Been Tested?

Before this PR, when -p wasn't supported (equivalent of running the command with just -D):

zpool status -D -p testpool
  pool: testpool
 state: ONLINE
config:

	NAME                       STATE     READ WRITE CKSUM
	testpool                   ONLINE       0     0     0
	  mirror-0                 ONLINE       0     0     0
	    /tmp/zdisks/disk1.img  ONLINE       0     0     0
	    /tmp/zdisks/disk2.img  ONLINE       0     0     0

errors: No known data errors

 dedup: DDT entries 317, size 118K on disk, 96K in core

bucket              allocated                       referenced
______   ______________________________   ______________________________
refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
------   ------   -----   -----   -----   ------   -----   -----   -----
     1      317   39.6M   39.6M   39.6M      317   39.6M   39.6M   39.6M
 Total      317   39.6M   39.6M   39.6M      317   39.6M   39.6M   39.6M

After this PR:

zpool status -D -p testpool
  pool: testpool
 state: ONLINE
config:

	NAME                       STATE     READ WRITE CKSUM
	testpool                   ONLINE       0     0     0
	  mirror-0                 ONLINE       0     0     0
	    /tmp/zdisks/disk1.img  ONLINE       0     0     0
	    /tmp/zdisks/disk2.img  ONLINE       0     0     0

errors: No known data errors

 dedup: DDT entries 317, size 121344 on disk, 98304 in core

bucket              allocated                       referenced
______   ______________________________   ______________________________
refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
------   ------   -----   -----   -----   ------   -----   -----   -----
     1      317   41549   41549   41549      317   41549   41549   41549
 Total      317   41549   41549   41549      317   41549   41549   41549

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@Adi-Goll Adi-Goll marked this pull request as draft November 13, 2025 18:10
@github-actions github-actions bot added the Status: Work in Progress Not yet ready for general review label Nov 13, 2025
@Adi-Goll Adi-Goll force-pushed the adding-pflag-for-ddt-dump branch 2 times, most recently from 470a20d to e05bd74 Compare November 16, 2025 08:22
@Adi-Goll Adi-Goll marked this pull request as ready for review November 16, 2025 08:25
@github-actions github-actions bot added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Nov 16, 2025
@Adi-Goll Adi-Goll marked this pull request as draft November 16, 2025 08:27
@github-actions github-actions bot added Status: Work in Progress Not yet ready for general review and removed Status: Code Review Needed Ready for review and testing labels Nov 16, 2025
@Adi-Goll Adi-Goll force-pushed the adding-pflag-for-ddt-dump branch from e05bd74 to 1d3713c Compare November 16, 2025 08:44
@Adi-Goll Adi-Goll marked this pull request as ready for review November 16, 2025 08:45
@github-actions github-actions bot added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Nov 16, 2025
@Adi-Goll Adi-Goll force-pushed the adding-pflag-for-ddt-dump branch 2 times, most recently from 449d460 to 7ddd5b0 Compare November 17, 2025 17:21
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 calling zfs_nicenum() and zfs_nicebytes().

Signed-off-by: Adi Gollamudi <[email protected]>
Fixes openzfs#11626
Boolean_t paramater "parsable" was added to zpool_dump_ddt(). This
updates ABI files accordingly.

Signed-off-by: Adi Gollamudi <[email protected]>
@Adi-Goll Adi-Goll force-pushed the adding-pflag-for-ddt-dump branch from 7ddd5b0 to 99578b7 Compare November 18, 2025 02:59
@Adi-Goll Adi-Goll marked this pull request as draft November 19, 2025 07:12
@github-actions github-actions bot added Status: Work in Progress Not yet ready for general review and removed Status: Code Review Needed Ready for review and testing labels Nov 19, 2025
@Adi-Goll Adi-Goll marked this pull request as ready for review November 19, 2025 09:41
@github-actions github-actions bot added Status: Code Review Needed Ready for review and testing and removed Status: Work in Progress Not yet ready for general review labels Nov 19, 2025
@Adi-Goll
Copy link
Contributor Author

Adi-Goll commented Dec 3, 2025

@amotin @behlendorf No worries if there are more pressing reviews going on right now, but I just wanted to follow up on this.

fmt_num(parsable, dds->dds_ref_blocks, ref_blocks, sizeof (ref_blocks));
fmt_bytes(parsable, dds->dds_ref_lsize, ref_lsize, sizeof (ref_lsize));
fmt_bytes(parsable, dds->dds_ref_psize, ref_psize, sizeof (ref_psize));
fmt_bytes(parsable, dds->dds_ref_dsize, ref_dsize, sizeof (ref_dsize));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to use the existing zfs_nicenum_format() function here and either specify the ZFS_NICENUM_BYTES or ZFS_NICENUM_RAW for the formatting.

(void) printf("%s: object=%llu\n", name,
(u_longlong_t)ddt->ddt_object[type][class]);
zpool_dump_ddt(NULL, &ddt->ddt_histogram[type][class]);
zpool_dump_ddt(NULL, &ddt->ddt_histogram[type][class], B_TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to honor the -P / --parseable flag here and below. Something like:

	zpool_dump_ddt(NULL, &ddt->ddt_histogram[type][class], dump_opt['P'] > 0);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Code Review Needed Ready for review and testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zpool status -D dedup table does not support raw bytes -p output

2 participants