Skip to content

zstream: add a drop_record subcommand#18275

Open
asomers wants to merge 1 commit intoopenzfs:masterfrom
asomers:zstream_drop_record2
Open

zstream: add a drop_record subcommand#18275
asomers wants to merge 1 commit intoopenzfs:masterfrom
asomers:zstream_drop_record2

Conversation

@asomers
Copy link
Contributor

@asomers asomers commented Mar 2, 2026

It can be used to drop extraneous records in a send stream caused by a corrupt dataset, as in issue #18239 .

Signed-off-by: Alan Somers asomers@gmail.com
Sponsored by: ConnectWise

Motivation and Context

Issue #18239 can cause corrupted files which can still be read or written to, but cannot be received by zfs recv. This change adds a feature to zstream that can filter out the offending records from a stream, allowing the dataset to be migrated with send/recv .

Description

Add a zstream drop_record subcommand. It can be used to drop one or more records from an object in a send stream. So far, all of the only corruption I know of caused by this issue happens at file offset 0xffffffffffff0000, but the drop_record subcommand accepts a record at any offset, so it's use is more general.

How Has This Been Tested?

This new feature was used to successfully migrate a production dataset that had four identically-corrupted objects.

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:

It can be used to drop extraneous records in a send stream caused by a
corrupt dataset, as in issue openzfs#18239 .

Signed-off-by:	Alan Somers <asomers@gmail.com>
Sponsored by:	ConnectWise
Copy link
Contributor

@behlendorf behlendorf left a comment

Choose a reason for hiding this comment

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

Let's add a basic test case for which drops a record and verifies the stream can still be received. There are two existing zstream tests in tests/zfs-tests/tests/functional/rsend/, send-c_zstreamdump.ksh and send-c_zstream_recompress.ksh whch can be used as examples.

Aside from that this change makes good sense to me, and I can see it being handy when you need it.

return (errno);
}
return (0);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If you rebase this on master we can avoid adding yet another copy of dump_record(). I've merged #18284 which adds zstream_util.[ch] to provide some shared utility functions, including dump_record().

@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Mar 6, 2026
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.

2 participants