Skip to content

Allow rewrite skip cloned and snapshotted blocks#18179

Open
amotin wants to merge 1 commit intoopenzfs:masterfrom
amotin:rewrite_cs
Open

Allow rewrite skip cloned and snapshotted blocks#18179
amotin wants to merge 1 commit intoopenzfs:masterfrom
amotin:rewrite_cs

Conversation

@amotin
Copy link
Member

@amotin amotin commented Feb 5, 2026

Rewrite of cloned and snapshotted blocks can allocate additional space, that may be undesired. In some cases it may have sense to still rewrite snapshotted blocks, expecting the snapshots to rotate with time, freeing space. In other cases rewrite of cloned blocks may be acceptable, despite persistent space usage increase. For this reason add them as separate flags to zfs rewrite.

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:

@amotin amotin force-pushed the rewrite_cs branch 2 times, most recently from e889c3f to 5c3b905 Compare February 5, 2026 19:48
Copy link
Member

@robn robn left a comment

Choose a reason for hiding this comment

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

This works for me! Some small thoughts in comments, but nothing to stop it I think.

EXPORT_SYMBOL(dmu_objset_projectquota_present);
EXPORT_SYMBOL(dmu_objset_projectquota_upgradable);
EXPORT_SYMBOL(dmu_objset_id_quota_upgrade);
EXPORT_SYMBOL(dmu_objset_block_is_shared);
Copy link
Member

Choose a reason for hiding this comment

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

It hardly matters, but should we wait on exporting it until something external needs it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am open to any formal recommendations. Last I heard this is not needed any more, so I'd be happy if we remove all of them at once.

Copy link
Contributor

@behlendorf behlendorf Feb 6, 2026

Choose a reason for hiding this comment

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

Some of them are needed by Lustre. Tony has PR #18161 open which updates the CI to include a test Lustre build so we don't accidentally break things. Once that's in place, I think it does make a lot of sense to whittle these down to what they actually need (and maybe a few interfaces they should switch too).

* Returns B_TRUE if block should be skipped.
*/
static boolean_t
zfs_rewrite_skip(dmu_buf_t *db, objset_t *os, uint64_t flags)
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we need to consider if rewriting would increase the number of DVAs before skipping (ie, they rewrite after increasing copies=).

If the user is increasing copies=, then they're presumably rewriting to try an improve their redundancy. Is the intent of "skip" clear in that case? In particular brt_maybe_exists() is allowed to return true if the block is not actually cloned at all. So, we might actually skip a rewrite on a non-cloned block that would have actually increased the redundancy on the block.

Personally I think its too fuzzy and weird a case to bother doing much about, but I might put something in the manpage that says the skip flags are advisory and ultimately ZFS will decide whether or not to rewrite a "skipped" block. And, possibly a separate thing to say "maybe don't skip if you're changing copies=". I mean, is anyone really changing copies= anyway? Yes, but not often surely!

Copy link
Member Author

Choose a reason for hiding this comment

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

I was (and still am) thinking about adding an option to make rewrite conditional on properties match. But while for copies and checksum it is easy, for some others it is not. So I haven't decided yet.

Meanwhile, if somebody requests to not rewrite snapshots or clones, I am not sure there should be high expectations already.

Rewrite of cloned and snapshotted blocks can allocate additional
space, that may be undesired.  In some cases it may have sense
to still rewrite snapshotted blocks, expecting the snapshots to
rotate with time, freeing space.  In other cases rewrite of cloned
blocks may be acceptable, despite persistent space usage increase.
For this reason add them as separate flags to `zfs rewrite`.

Signed-off-by: Alexander Motin <[email protected]>
@behlendorf behlendorf added the Status: Accepted Ready to integrate (reviewed, tested) label Feb 6, 2026
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.

4 participants