mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Introduce a flag to skip comparing the local mac when raw sending
Raw receiving a snapshot back to the originating dataset is currently impossible because of user accounting being present in the originating dataset. One solution would be resetting user accounting when raw receiving on the receiving dataset. However, to recalculate it we would have to dirty all dnodes, which may not be preferable on big datasets. Instead, we rely on the os_phys flag OBJSET_FLAG_USERACCOUNTING_COMPLETE to indicate that user accounting is incomplete when raw receiving. Thus, on the next mount of the receiving dataset the local mac protecting user accounting is zeroed out. The flag is then cleared when user accounting of the raw received snapshot is calculated. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #12981 Closes #10523 Closes #11221 Closes #11294 Closes #12594 Issue #11300
This commit is contained in:
@@ -1065,11 +1065,26 @@ zio_crypt_do_objset_hmacs(zio_crypt_key_t *key, void *data, uint_t datalen,
|
||||
|
||||
bcopy(raw_portable_mac, portable_mac, ZIO_OBJSET_MAC_LEN);
|
||||
|
||||
/*
|
||||
* This is necessary here as we check next whether
|
||||
* OBJSET_FLAG_USERACCOUNTING_COMPLETE is set in order to
|
||||
* decide if the local_mac should be zeroed out. That flag will always
|
||||
* be set by dmu_objset_id_quota_upgrade_cb() and
|
||||
* dmu_objset_userspace_upgrade_cb() if useraccounting has been
|
||||
* completed.
|
||||
*/
|
||||
intval = osp->os_flags;
|
||||
if (should_bswap)
|
||||
intval = BSWAP_64(intval);
|
||||
boolean_t uacct_incomplete =
|
||||
!(intval & OBJSET_FLAG_USERACCOUNTING_COMPLETE);
|
||||
|
||||
/*
|
||||
* The local MAC protects the user, group and project accounting.
|
||||
* If these objects are not present, the local MAC is zeroed out.
|
||||
*/
|
||||
if ((datalen >= OBJSET_PHYS_SIZE_V3 &&
|
||||
if (uacct_incomplete ||
|
||||
(datalen >= OBJSET_PHYS_SIZE_V3 &&
|
||||
osp->os_userused_dnode.dn_type == DMU_OT_NONE &&
|
||||
osp->os_groupused_dnode.dn_type == DMU_OT_NONE &&
|
||||
osp->os_projectused_dnode.dn_type == DMU_OT_NONE) ||
|
||||
|
||||
@@ -1203,11 +1203,26 @@ zio_crypt_do_objset_hmacs(zio_crypt_key_t *key, void *data, uint_t datalen,
|
||||
|
||||
bcopy(raw_portable_mac, portable_mac, ZIO_OBJSET_MAC_LEN);
|
||||
|
||||
/*
|
||||
* This is necessary here as we check next whether
|
||||
* OBJSET_FLAG_USERACCOUNTING_COMPLETE is set in order to
|
||||
* decide if the local_mac should be zeroed out. That flag will always
|
||||
* be set by dmu_objset_id_quota_upgrade_cb() and
|
||||
* dmu_objset_userspace_upgrade_cb() if useraccounting has been
|
||||
* completed.
|
||||
*/
|
||||
intval = osp->os_flags;
|
||||
if (should_bswap)
|
||||
intval = BSWAP_64(intval);
|
||||
boolean_t uacct_incomplete =
|
||||
!(intval & OBJSET_FLAG_USERACCOUNTING_COMPLETE);
|
||||
|
||||
/*
|
||||
* The local MAC protects the user, group and project accounting.
|
||||
* If these objects are not present, the local MAC is zeroed out.
|
||||
*/
|
||||
if ((datalen >= OBJSET_PHYS_SIZE_V3 &&
|
||||
if (uacct_incomplete ||
|
||||
(datalen >= OBJSET_PHYS_SIZE_V3 &&
|
||||
osp->os_userused_dnode.dn_type == DMU_OT_NONE &&
|
||||
osp->os_groupused_dnode.dn_type == DMU_OT_NONE &&
|
||||
osp->os_projectused_dnode.dn_type == DMU_OT_NONE) ||
|
||||
|
||||
@@ -655,8 +655,13 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
|
||||
DNODE_FLAG_USEROBJUSED_ACCOUNTED;
|
||||
mutex_exit(&dn->dn_mtx);
|
||||
dmu_objset_userquota_get_ids(dn, B_FALSE, tx);
|
||||
} else {
|
||||
/* Once we account for it, we should always account for it */
|
||||
} else if (!(os->os_encrypted && dmu_objset_is_receiving(os))) {
|
||||
/*
|
||||
* Once we account for it, we should always account for it,
|
||||
* except for the case of a raw receive. We will not be able
|
||||
* to account for it until the receiving dataset has been
|
||||
* mounted.
|
||||
*/
|
||||
ASSERT(!(dn->dn_phys->dn_flags &
|
||||
DNODE_FLAG_USERUSED_ACCOUNTED));
|
||||
ASSERT(!(dn->dn_phys->dn_flags &
|
||||
|
||||
@@ -2007,14 +2007,6 @@ dsl_crypto_recv_raw_objset_check(dsl_dataset_t *ds, dsl_dataset_t *fromds,
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
|
||||
/*
|
||||
* Useraccounting is not portable and must be done with the keys loaded.
|
||||
* Therefore, whenever we do any kind of receive the useraccounting
|
||||
* must not be present.
|
||||
*/
|
||||
ASSERT0(os->os_flags & OBJSET_FLAG_USERACCOUNTING_COMPLETE);
|
||||
ASSERT0(os->os_flags & OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE);
|
||||
|
||||
mdn = DMU_META_DNODE(os);
|
||||
|
||||
/*
|
||||
@@ -2106,6 +2098,7 @@ dsl_crypto_recv_raw_objset_sync(dsl_dataset_t *ds, dmu_objset_type_t ostype,
|
||||
arc_release(os->os_phys_buf, &os->os_phys_buf);
|
||||
bcopy(portable_mac, os->os_phys->os_portable_mac, ZIO_OBJSET_MAC_LEN);
|
||||
bzero(os->os_phys->os_local_mac, ZIO_OBJSET_MAC_LEN);
|
||||
os->os_flags &= ~OBJSET_FLAG_USERACCOUNTING_COMPLETE;
|
||||
os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
|
||||
|
||||
/* set metadnode compression and checksum */
|
||||
|
||||
Reference in New Issue
Block a user