Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zdb raidz file layout #16835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

don-brady
Copy link
Contributor

@don-brady don-brady commented Dec 3, 2024

Motivation and Context

It would be nice to be able to visualize how the RAIDZ disk columns for a given file are laid out on disk. For example, one might ponder if the parity is being evenly distributed or are the same disks being used for parity?

Description

This change introduces the --file-layout (-f) option to zdb(8) to display the raidz file layout for a given file. The change leverages the vdev_raidz_map_alloc() function to find the map of how the block data is laid out across the child disks.

A typical column entry looks like:

┌────────────┐
│  D2     43 │
│     6020da │
└────────────┘

Which here represents the logical data column 2 that is 43 sectors high starting at sector 0x6020da. The parity is displayed in inverse text if output is to a terminal (see example below).

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.

An example
FL-RAIDZ2

How Has This Been Tested?

Tested with various flavors of raidz and disk counts.
Tested with ZTS cli_root/zdb suite of tests.

Known Issues/Limitations

  1. Only supports RAIDZ. A follow-on pull request can add support for dRAID.
  2. The check for the last row is not always correct and so the edge connector, like '├', can sometimes show final connector '└' by mistake.
  3. Only supports one top-level RAIDZ

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)
  • 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:

Adding the  --file-layout (-f) option to zdb(8) to display the
raidz file layout for a given file. This leverages the internal
vdev_raidz_map_alloc() function to find the map of how the block
data is laid out across the child disks.

The column entry for each row looks like:
   +------------+
   |  D2     43 |
   |     6020da |
   +------------+
representing here the logical data column 2 that is 43 sectors high
starting at sector 0x6020da.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.

Signed-off-by: Don Brady <[email protected]>
@amotin amotin added the Status: Revision Needed Changes are required for the PR to be accepted label Dec 4, 2024
@tonyhutter
Copy link
Contributor

I just tested this by printing out different objects. Seems to work fine:

$ sudo ./zdb -f tank/dir1 36
      objset: 'tank/dir1'
      object: 36
  block size: 16384
   vdev_type: raidz1
 sector size: 512
 child disks: 3

               V0:DISK-0   V0:DISK-1   V0:DISK-2 
 FILE OFFSET ┌────────────────────────────────────┐
           0 │ ` ` ` ` `    P0     16   D0     16 │
             │  ` ` ` ` `       4cb0f       4cb0f │
             │  D1     16  ` ` ` ` `   ` ` ` ` `  │
             │      4cb10   ` ` ` ` `   ` ` ` ` ` │
             └────────────────────────────────────┘
        4000 │ ` ` ` ` `   ` ` ` ` `    P0     16 │
             │  ` ` ` ` `   ` ` ` ` `       4cb0a │
             │  D0     16   D1     16  ` ` ` ` `  │
             │      4cb0b       4cb0b   ` ` ` ` ` │
             └────────────────────────────────────┘

The scripted mode columns don't align with the values, but I don't know if that matters since it's scripted mode:

$ sudo ./zdb -Hf tank/dir1 36
      objset: 'tank/dir1'
      object: 36
DISK		LBA		COUNT
file2	314127	16
file3	314127	16
file1	314128	16
file3	314122	16
file1	314123	16
file2	314123	16

Some of the edge cases have ASCII art a little off, but again, I don't think it matters:

Empty or small file:

$ sudo ./zdb -f tank/dir1 2
      objset: 'tank/dir1'
      object: 2
  block size: 512
   vdev_type: raidz1
 sector size: 512
 child disks: 3

               V0:DISK-0   V0:DISK-1   V0:DISK-2 
 FILE OFFSET ┌────────────────────────────────────┐

$

Printing out the "ZFS Master node" for a dataset:

$ sudo ./zdb -v  -d tank/dir1
...
         1    1   128K    512  1.50K     512    512  100.00  ZFS master node
...
$ sudo ./zdb -f tank/dir1 1
      objset: 'tank/dir1'
      object: 1
  block size: 512
   vdev_type: raidz1
 sector size: 512
 child disks: 3

               V0:DISK-0   V0:DISK-1   V0:DISK-2 
 FILE OFFSET ┌────────────────────────────────────┐
           0 │ ` ` ` ` `   ` ` ` ` `    P0      1 │
             │  ` ` ` ` `   ` ` ` ` `       4cad8 │
             │  D0      1 │
             │      4cad9 │
             ├────────────────────────────────────┤

@@ -4208,7 +4508,7 @@ dump_objset(objset_t *os)

zdb_nicenum(refdbytes, numbuf, sizeof (numbuf));

if (verbosity >= 4) {
if (verbosity >= 4 || dump_opt['d']) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to add in your commit message that -d also prints this header now.

Comment on lines +253 to +254
.It Fl f , -file-layout
Display the file layout of an object for the disks of a raidz vdev.
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to mention -H here, like:

Display the file layout of an object for the disks of a raidz vdev.
You can optionally pass -H to print the file layout in scripted mode for easy parsing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Revision Needed Changes are required for the PR to be accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants