Skip to content

Allow zdb -r to understand object ids as well - #16307

Merged
behlendorf merged 1 commit into
openzfs:masterfrom
KlaraSystems:zdb_r
Dec 18, 2025
Merged

behlendorf merged 1 commit into
openzfs:masterfrom
KlaraSystems:zdb_r

Conversation

@allanjude

Copy link
Copy Markdown
Contributor

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

Motivation and Context

Previously I created: zdb -r pool/dataset path/to/file /tmp/recover.dat

But it turns out, if there is a problem with a directory, you might want to recover a file by its inode number instead

Description

If the argument is a number, thread it as the object-id instead of a filename

How Has This Been Tested?

Manually

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:

Comment thread cmd/zdb/zdb.c Outdated
@behlendorf behlendorf added the Status: Revision Needed Changes are required for the PR to be accepted label Aug 16, 2024
@github-actions github-actions Bot removed the Status: Revision Needed Changes are required for the PR to be accepted label Nov 17, 2025
@allanjude

Copy link
Copy Markdown
Contributor Author

@kithrup made some changes to this, so it now uses -O instead, and that should solve things. Can folks look again now?

@behlendorf

Copy link
Copy Markdown
Contributor

I'm happy to take another look, but could you first rebase this on master and resolve the build issue.

  cmd/zdb/zdb.c: In function ‘usage’:
  cmd/zdb/zdb.c:724:13: error: format ‘%s’ expects a matching ‘char *’ argument [-Werror=format=]
    724 |             "Usage:\t%s [-AbcdDFGhikLMPsvXy] [-e [-V] [-p  ...]] "
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  cmd/zdb/zdb.c:745:17: note: format string is defined here
    745 |             "\t%s -S [-AP] [-e [-V] [-p  ...]] [-U ] "
        |                ~^
        |                 |
        |                 char *

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Dec 9, 2025
@kithrup

kithrup commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

I'm happy to take another look, but could you first rebase this on master and resolve the build issue.

Done, thanks!

@kithrup
kithrup force-pushed the zdb_r branch 2 times, most recently from 01bb2ad to 77735cf Compare December 17, 2025 11:31
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Sean Eric Fagan 
@behlendorf behlendorf added Status: Accepted Ready to integrate (reviewed, tested) and removed Status: Code Review Needed Ready for review and testing labels Dec 17, 2025
@behlendorf
behlendorf requested review from akashb-22 and robn December 17, 2025 22:00

@akashb-22 akashb-22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@behlendorf
behlendorf merged commit 1d43387 into openzfs:master Dec 18, 2025
41 of 42 checks passed
kithrup pushed a commit to KlaraSystems/zfs that referenced this pull request Jan 19, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
(cherry picked from commit 1d43387)
amotin pushed a commit to amotin/zfs that referenced this pull request Jan 29, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
mcmilk pushed a commit to mcmilk/zfs that referenced this pull request Jan 31, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
amotin pushed a commit to amotin/zfs that referenced this pull request Feb 3, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
lundman pushed a commit to openzfsonosx/openzfs-fork that referenced this pull request Feb 5, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
tonyhutter pushed a commit that referenced this pull request Feb 5, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes #16307
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Feb 23, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Feb 23, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
allanjude added a commit to KlaraSystems/zfs that referenced this pull request Feb 27, 2026
"zdb -r -O pool/dataset obj-id destination" will copy
the file with object-id obj-id to the named destination;
without -O it'll still be interpreted as a pathname.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf 
Reviewed-by: Akash B 
Signed-off-by: Sean Eric Fagan 
Closes openzfs#16307
(cherry picked from commit 1d43387)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Accepted Ready to integrate (reviewed, tested)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants