diff options
author | Matthew Ahrens <[email protected]> | 2018-04-17 11:06:54 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-04-17 11:06:54 -0700 |
commit | 0c03d21ac99ebdbefe65c319fc3712928c40af78 (patch) | |
tree | 5ec1e603a374a089fcd5b1c5b673974a5e687c1b /include/sys | |
parent | b40d45bc6c0e908c4d1086ac8ac3dcd1f7178d2a (diff) |
assertion in arc_release() during encrypted receive
In the existing code, when doing a raw (encrypted) zfs receive,
we call arc_convert_to_raw() from open context. This creates a
race condition between arc_release()/arc_change_state() and
writing out the block from syncing context (arc_write_ready/done()).
This change makes it so that when we are doing a raw (encrypted)
zfs receive, we save the crypt parameters (salt, iv, mac) of dnode
blocks in the dbuf_dirty_record_t, and call arc_convert_to_raw()
from syncing context when writing out the block of dnodes.
Additionally, we can eliminate dr_raw and associated setters, and
instead know that dnode blocks are always raw when doing a zfs
receive (see the new field os_raw_receive).
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Tom Caputi <[email protected]>
Signed-off-by: Matthew Ahrens <[email protected]>
Closes #7424
Closes #7429
Diffstat (limited to 'include/sys')
-rw-r--r-- | include/sys/dbuf.h | 11 | ||||
-rw-r--r-- | include/sys/dmu.h | 10 | ||||
-rw-r--r-- | include/sys/dmu_objset.h | 1 |
3 files changed, 13 insertions, 9 deletions
diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h index 32f036862..ddce7deef 100644 --- a/include/sys/dbuf.h +++ b/include/sys/dbuf.h @@ -147,7 +147,16 @@ typedef struct dbuf_dirty_record { override_states_t dr_override_state; uint8_t dr_copies; boolean_t dr_nopwrite; - boolean_t dr_raw; + boolean_t dr_has_raw_params; + + /* + * If dr_has_raw_params is set, the following crypt + * params will be set on the BP that's written. + */ + boolean_t dr_byteorder; + uint8_t dr_salt[ZIO_DATA_SALT_LEN]; + uint8_t dr_iv[ZIO_DATA_IV_LEN]; + uint8_t dr_mac[ZIO_DATA_MAC_LEN]; } dl; } dt; } dbuf_dirty_record_t; diff --git a/include/sys/dmu.h b/include/sys/dmu.h index ccc07006d..119584365 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -472,7 +472,6 @@ void dmu_object_set_checksum(objset_t *os, uint64_t object, uint8_t checksum, void dmu_object_set_compress(objset_t *os, uint64_t object, uint8_t compress, dmu_tx_t *tx); -int dmu_object_dirty_raw(objset_t *os, uint64_t object, dmu_tx_t *tx); int dmu_object_remap_indirects(objset_t *os, uint64_t object, uint64_t txg); @@ -715,7 +714,8 @@ struct blkptr *dmu_buf_get_blkptr(dmu_buf_t *db); * (ie. you've called dmu_tx_hold_object(tx, db->db_object)). */ void dmu_buf_will_dirty(dmu_buf_t *db, dmu_tx_t *tx); -void dmu_buf_will_change_crypt_params(dmu_buf_t *db, dmu_tx_t *tx); +void dmu_buf_set_crypt_params(dmu_buf_t *db_fake, boolean_t byteorder, + const uint8_t *salt, const uint8_t *iv, const uint8_t *mac, dmu_tx_t *tx); /* * You must create a transaction, then hold the objects which you will @@ -794,10 +794,7 @@ int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_tx_t *tx); int dmu_free_long_range(objset_t *os, uint64_t object, uint64_t offset, uint64_t size); -int dmu_free_long_range_raw(objset_t *os, uint64_t object, uint64_t offset, - uint64_t size); int dmu_free_long_object(objset_t *os, uint64_t object); -int dmu_free_long_object_raw(objset_t *os, uint64_t object); /* * Convenience functions. @@ -837,9 +834,6 @@ void dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, void dmu_assign_arcbuf_by_dbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf, dmu_tx_t *tx); #define dmu_assign_arcbuf dmu_assign_arcbuf_by_dbuf -int dmu_convert_mdn_block_to_raw(objset_t *os, uint64_t firstobj, - boolean_t byteorder, const uint8_t *salt, const uint8_t *iv, - const uint8_t *mac, dmu_tx_t *tx); void dmu_copy_from_buf(objset_t *os, uint64_t object, uint64_t offset, dmu_buf_t *handle, dmu_tx_t *tx); #ifdef HAVE_UIO_ZEROCOPY diff --git a/include/sys/dmu_objset.h b/include/sys/dmu_objset.h index 54fe37e61..57872d8db 100644 --- a/include/sys/dmu_objset.h +++ b/include/sys/dmu_objset.h @@ -139,6 +139,7 @@ struct objset { uint64_t os_flags; uint64_t os_freed_dnodes; boolean_t os_rescan_dnodes; + boolean_t os_raw_receive; /* os_phys_buf should be written raw next txg */ boolean_t os_next_write_raw[TXG_SIZE]; |