Skip to content

Commit

Permalink
new approach
Browse files Browse the repository at this point in the history
Signed-off-by: George Amanakis <[email protected]>
  • Loading branch information
gamanakis committed Jul 3, 2021
1 parent 4f92fe0 commit c379a3c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/sys/dmu_objset.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct dmu_tx;
#define OBJSET_FLAG_USERACCOUNTING_COMPLETE (1ULL << 0)
#define OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE (1ULL << 1)
#define OBJSET_FLAG_PROJECTQUOTA_COMPLETE (1ULL << 2)
#define OBJSET_FLAG_USERACCOUNTING_INVALID (1ULL << 3)

/*
* This mask defines the set of flags which are "portable", meaning
Expand Down
12 changes: 11 additions & 1 deletion module/os/freebsd/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,21 @@ 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_INVALID is set in order to
* decide if the local_mac should be zeroed out.
*/
intval = osp->os_flags;
if (should_bswap)
intval = BSWAP_64(intval);

/*
* 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 (osp->os_flags & OBJSET_FLAG_USERACCOUNTING_INVALID ||
(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) ||
Expand Down
12 changes: 11 additions & 1 deletion module/os/linux/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1203,11 +1203,21 @@ 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_INVALID is set in order to
* decide if the local_mac should be zeroed out.
*/
intval = osp->os_flags;
if (should_bswap)
intval = BSWAP_64(intval);

/*
* 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 (intval & OBJSET_FLAG_USERACCOUNTING_INVALID ||
(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) ||
Expand Down
3 changes: 3 additions & 0 deletions module/zfs/dmu_objset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,7 @@ dmu_objset_create_impl_dnstats(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
*/
if (dmu_objset_userused_enabled(os) &&
(!os->os_encrypted || !dmu_objset_is_receiving(os))) {
os->os_phys->os_flags &= ~OBJSET_FLAG_USERACCOUNTING_INVALID;
os->os_phys->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE;
if (dmu_objset_userobjused_enabled(os)) {
ds->ds_feature_activation[
Expand Down Expand Up @@ -2351,6 +2352,7 @@ dmu_objset_userspace_upgrade_cb(objset_t *os)
return (err);

os->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE;
os->os_flags &= ~OBJSET_FLAG_USERACCOUNTING_INVALID;
txg_wait_synced(dmu_objset_pool(os), 0);
return (0);
}
Expand Down Expand Up @@ -2389,6 +2391,7 @@ dmu_objset_id_quota_upgrade_cb(objset_t *os)
return (err);

os->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE;
os->os_flags &= ~OBJSET_FLAG_USERACCOUNTING_INVALID;
if (dmu_objset_userobjused_enabled(os))
os->os_flags |= OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE;
if (dmu_objset_projectquota_enabled(os))
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,10 @@ 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_phys->os_flags &= ~OBJSET_FLAG_USERACCOUNTING_COMPLETE;
os->os_phys->os_flags &= ~OBJSET_FLAG_USEROBJACCOUNTING_COMPLETE;
os->os_phys->os_flags |= OBJSET_FLAG_USERACCOUNTING_INVALID;
os->os_flags = os->os_phys->os_flags;
os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;

/* set metadnode compression and checksum */
Expand Down

0 comments on commit c379a3c

Please sign in to comment.