]> granicus.if.org Git - zfs/commitdiff
Change os->os_next_write_raw to work per txg
authorTom Caputi <tcaputi@datto.com>
Thu, 1 Feb 2018 20:37:24 +0000 (15:37 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 2 Feb 2018 19:44:53 +0000 (11:44 -0800)
Currently, os_next_write_raw is a single boolean used for determining
whether or not the next call to dmu_objset_sync() should write out
the objset_phys_t as a raw buffer. Since the boolean is not associated
with a txg, the work simply happens during the next txg, which is not
necessarily the correct one. In the current implementation this issue
was misdiagnosed, resulting in a small hack in dmu_objset_sync() which
seemed to resolve the problem.

This patch changes os_next_write_raw to be an array of booleans, one
for each txg in TXG_OFF and removes the hack.

Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes #6864

include/sys/dmu_objset.h
module/zfs/dbuf.c
module/zfs/dmu_objset.c
module/zfs/dsl_crypt.c
module/zfs/dsl_dataset.c
module/zfs/zil.c

index f3013ad13d2dd75851efad43bfaefa1e1d257214..7ee992f3116e89de2ce78a665e5f3f1144302324 100644 (file)
@@ -127,7 +127,7 @@ struct objset {
        boolean_t os_rescan_dnodes;
 
        /* os_phys_buf should be written raw next txg */
-       boolean_t os_next_write_raw;
+       boolean_t os_next_write_raw[TXG_SIZE];
 
        /* Protected by os_obj_lock */
        kmutex_t os_obj_lock;
index 87b9ba46153802f45bd801aa01b383c0ab853ec4..3668ea31533c672ec232e465a71e1e0f58e061e2 100644 (file)
@@ -2218,6 +2218,7 @@ dmu_buf_will_change_crypt_params(dmu_buf_t *db_fake, dmu_tx_t *tx)
        ASSERT3P(dr, !=, NULL);
        ASSERT3U(dr->dr_txg, ==, tx->tx_txg);
        dr->dt.dl.dr_raw = B_TRUE;
+       db->db_objset->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
 }
 
 #pragma weak dmu_buf_fill_done = dbuf_fill_done
index 2b069b6ced028cc9eba28d58445300404e5c4062..befce9be6bc8457496208d059148384761d41924 100644 (file)
@@ -1508,9 +1508,9 @@ dmu_objset_sync(objset_t *os, zio_t *pio, dmu_tx_t *tx)
         * the os_phys_buf raw. Neither of these actions will effect the MAC
         * at this point.
         */
-       if (arc_is_unauthenticated(os->os_phys_buf) || os->os_next_write_raw) {
+       if (os->os_next_write_raw[tx->tx_txg & TXG_MASK]) {
                ASSERT(os->os_encrypted);
-               os->os_next_write_raw = B_FALSE;
+               os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_FALSE;
                arc_convert_to_raw(os->os_phys_buf,
                    os->os_dsl_dataset->ds_object, ZFS_HOST_BYTEORDER,
                    DMU_OT_OBJSET, NULL, NULL, NULL);
index cb13d2cdca6d5a312aecba535c651909b281aad5..6a63d54cadb30a0cc138fe78380e6f0c4ac37b4f 100644 (file)
@@ -2177,7 +2177,7 @@ dsl_crypto_recv_key_sync(void *arg, dmu_tx_t *tx)
        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_next_write_raw = B_TRUE;
+       os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
 
        /* set metadnode compression and checksum */
        mdn->dn_compress = compress;
index 36ceaf17583f259c662f686b8ec2c03038f311f8..3c329f20783eb11d783620cf44c86beb706e90be 100644 (file)
@@ -941,7 +941,7 @@ dsl_dataset_zero_zil(dsl_dataset_t *ds, dmu_tx_t *tx)
 
                bzero(&os->os_zil_header, sizeof (os->os_zil_header));
                if (os->os_encrypted)
-                       os->os_next_write_raw = B_TRUE;
+                       os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
 
                zio = zio_root(dp->dp_spa, NULL, NULL, ZIO_FLAG_MUSTSUCCEED);
                dsl_dataset_sync(ds, zio, tx);
index 234ce956aedaac68c0de0ef69914dcfea1a2acf6..d7bb33ab05089c61c0e4e28ba9ab6a39e51fa1be 100644 (file)
@@ -796,7 +796,7 @@ zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
                        zio_free_zil(zilog->zl_spa, first_txg, &zh->zh_log);
                BP_ZERO(&zh->zh_log);
                if (os->os_encrypted)
-                       os->os_next_write_raw = B_TRUE;
+                       os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
                dsl_dataset_dirty(dmu_objset_ds(os), tx);
                dmu_objset_disown(os, B_FALSE, FTAG);
                return (0);
@@ -820,7 +820,7 @@ zil_claim(dsl_pool_t *dp, dsl_dataset_t *ds, void *txarg)
                        zh->zh_flags |= ZIL_REPLAY_NEEDED;
                zh->zh_flags |= ZIL_CLAIM_LR_SEQ_VALID;
                if (os->os_encrypted)
-                       os->os_next_write_raw = B_TRUE;
+                       os->os_next_write_raw[tx->tx_txg & TXG_MASK] = B_TRUE;
                dsl_dataset_dirty(dmu_objset_ds(os), tx);
        }