mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-03-10 20:36:21 +03:00
zdb: don't try to load key for unencrypted dataset
Previously using -K/--key on an unencrypted dataset would trip a VERIFY, because the dataset has nowhere to load the key into. Now, just ignore it. This makes zdb much easier to drive when there's a mix of encrypt and non-encrypted datasets, as the key can provided for all of them (at least, assuming the same encryption root, which is a common enough case). Sponsored-by: TrueNAS Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <rob.norris@truenas.com> Closes #18230
This commit is contained in:
parent
b021cb60aa
commit
9f874ad092
@ -3481,15 +3481,26 @@ open_objset(const char *path, const void *tag, objset_t **osp)
|
||||
path, strerror(err));
|
||||
return (err);
|
||||
}
|
||||
dsl_dataset_long_hold(dmu_objset_ds(*osp), tag);
|
||||
dsl_pool_rele(dmu_objset_pool(*osp), tag);
|
||||
|
||||
/* succeeds or dies */
|
||||
zdb_load_key(*osp);
|
||||
/*
|
||||
* Only try to load the key and unlock the dataset if it is
|
||||
* actually encrypted; otherwise we'll just crash. Just
|
||||
* ignore the -K switch entirely otherwise; it's useful to be
|
||||
* able to provide even if it's not needed.
|
||||
*/
|
||||
if ((*osp)->os_encrypted) {
|
||||
dsl_dataset_long_hold(dmu_objset_ds(*osp), tag);
|
||||
dsl_pool_rele(dmu_objset_pool(*osp), tag);
|
||||
|
||||
/* release it all */
|
||||
dsl_dataset_long_rele(dmu_objset_ds(*osp), tag);
|
||||
dsl_dataset_rele(dmu_objset_ds(*osp), tag);
|
||||
/* succeeds or dies */
|
||||
zdb_load_key(*osp);
|
||||
|
||||
/* release it all */
|
||||
dsl_dataset_long_rele(dmu_objset_ds(*osp), tag);
|
||||
dsl_dataset_rele(dmu_objset_ds(*osp), tag);
|
||||
} else {
|
||||
dmu_objset_rele(*osp, tag);
|
||||
}
|
||||
}
|
||||
|
||||
int ds_hold_flags = key_loaded ? DS_HOLD_FLAG_DECRYPT : 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user