]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zil.c
cstyle: Resolve C style issues
[mirror_zfs.git] / module / zfs / zil.c
index c9ff1f650209933e88ad48bd572d6de49b3379a3..b69a7bf56eaf63265fd3e92abf50c42759ee8ce8 100644 (file)
  * See zil.h for more information about these fields.
  */
 zil_stats_t zil_stats = {
-       { "zil_commit_count",              KSTAT_DATA_UINT64 },
-       { "zil_commit_writer_count",       KSTAT_DATA_UINT64 },
-       { "zil_itx_count",                 KSTAT_DATA_UINT64 },
-       { "zil_itx_indirect_count",        KSTAT_DATA_UINT64 },
-       { "zil_itx_indirect_bytes",        KSTAT_DATA_UINT64 },
-       { "zil_itx_copied_count",          KSTAT_DATA_UINT64 },
-       { "zil_itx_copied_bytes",          KSTAT_DATA_UINT64 },
-       { "zil_itx_needcopy_count",        KSTAT_DATA_UINT64 },
-       { "zil_itx_needcopy_bytes",        KSTAT_DATA_UINT64 },
-       { "zil_itx_metaslab_normal_count", KSTAT_DATA_UINT64 },
-       { "zil_itx_metaslab_normal_bytes", KSTAT_DATA_UINT64 },
-       { "zil_itx_metaslab_slog_count",   KSTAT_DATA_UINT64 },
-       { "zil_itx_metaslab_slog_bytes",   KSTAT_DATA_UINT64 },
+       { "zil_commit_count",                   KSTAT_DATA_UINT64 },
+       { "zil_commit_writer_count",            KSTAT_DATA_UINT64 },
+       { "zil_itx_count",                      KSTAT_DATA_UINT64 },
+       { "zil_itx_indirect_count",             KSTAT_DATA_UINT64 },
+       { "zil_itx_indirect_bytes",             KSTAT_DATA_UINT64 },
+       { "zil_itx_copied_count",               KSTAT_DATA_UINT64 },
+       { "zil_itx_copied_bytes",               KSTAT_DATA_UINT64 },
+       { "zil_itx_needcopy_count",             KSTAT_DATA_UINT64 },
+       { "zil_itx_needcopy_bytes",             KSTAT_DATA_UINT64 },
+       { "zil_itx_metaslab_normal_count",      KSTAT_DATA_UINT64 },
+       { "zil_itx_metaslab_normal_bytes",      KSTAT_DATA_UINT64 },
+       { "zil_itx_metaslab_slog_count",        KSTAT_DATA_UINT64 },
+       { "zil_itx_metaslab_slog_bytes",        KSTAT_DATA_UINT64 },
 };
 
 static kstat_t *zil_ksp;
 
 /*
- * This global ZIL switch affects all pools
+ * Disable intent logging replay.  This global ZIL switch affects all pools.
  */
-int zil_replay_disable = 0;    /* disable intent logging replay */
+int zil_replay_disable = 0;
 
 /*
  * Tunable parameter for debugging or performance analysis.  Setting
@@ -319,7 +319,7 @@ zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
        char *lrbuf, *lrp;
        int error = 0;
 
-       bzero(&next_blk, sizeof(blkptr_t));
+       bzero(&next_blk, sizeof (blkptr_t));
 
        /*
         * Old logs didn't record the maximum zh_claim_lr_seq.
@@ -913,7 +913,7 @@ zil_lwb_write_init(zilog_t *zilog, lwb_t *lwb)
                }
                lwb->lwb_zio = zio_rewrite(zilog->zl_root_zio, zilog->zl_spa,
                    0, &lwb->lwb_blk, lwb->lwb_buf, BP_GET_LSIZE(&lwb->lwb_blk),
-                   zil_lwb_write_done, lwb, ZIO_PRIORITY_LOG_WRITE,
+                   zil_lwb_write_done, lwb, ZIO_PRIORITY_SYNC_WRITE,
                    ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE |
                    ZIO_FLAG_FASTWRITE, &zb);
        }
@@ -922,6 +922,7 @@ zil_lwb_write_init(zilog_t *zilog, lwb_t *lwb)
 
 /*
  * Define a limited set of intent log block sizes.
+ *
  * These must be a multiple of 4KB. Note only the amount used (again
  * aligned to 4KB) actually gets written. However, we can't always just
  * allocate SPA_MAXBLOCKSIZE as the slog space could be exhausted.
@@ -1016,13 +1017,10 @@ zil_lwb_write_start(zilog_t *zilog, lwb_t *lwb)
        use_slog = USE_SLOG(zilog);
        error = zio_alloc_zil(spa, txg, bp, zil_blksz,
            USE_SLOG(zilog));
-       if (use_slog)
-       {
+       if (use_slog) {
                ZIL_STAT_BUMP(zil_itx_metaslab_slog_count);
                ZIL_STAT_INCR(zil_itx_metaslab_slog_bytes, lwb->lwb_nused);
-       }
-       else
-       {
+       } else {
                ZIL_STAT_BUMP(zil_itx_metaslab_normal_count);
                ZIL_STAT_INCR(zil_itx_metaslab_normal_bytes, lwb->lwb_nused);
        }
@@ -1133,12 +1131,14 @@ zil_lwb_commit(zilog_t *zilog, itx_t *itx, lwb_t *lwb)
                                dbuf = lr_buf + reclen;
                                lrw->lr_common.lrc_reclen += dlen;
                                ZIL_STAT_BUMP(zil_itx_needcopy_count);
-                               ZIL_STAT_INCR(zil_itx_needcopy_bytes, lrw->lr_length);
+                               ZIL_STAT_INCR(zil_itx_needcopy_bytes,
+                                   lrw->lr_length);
                        } else {
                                ASSERT(itx->itx_wr_state == WR_INDIRECT);
                                dbuf = NULL;
                                ZIL_STAT_BUMP(zil_itx_indirect_count);
-                               ZIL_STAT_INCR(zil_itx_indirect_bytes, lrw->lr_length);
+                               ZIL_STAT_INCR(zil_itx_indirect_bytes,
+                                   lrw->lr_length);
                        }
                        error = zilog->zl_get_data(
                            itx->itx_private, lrw, dbuf, lwb->lwb_zio);
@@ -1183,6 +1183,8 @@ zil_itx_create(uint64_t txtype, size_t lrsize)
        itx->itx_sod = lrsize; /* if write & WR_NEED_COPY will be increased */
        itx->itx_lr.lrc_seq = 0;        /* defensive */
        itx->itx_sync = B_TRUE;         /* default is synchronous */
+       itx->itx_callback = NULL;
+       itx->itx_callback_data = NULL;
 
        return (itx);
 }
@@ -1208,6 +1210,8 @@ zil_itxg_clean(itxs_t *itxs)
 
        list = &itxs->i_sync_list;
        while ((itx = list_head(list)) != NULL) {
+               if (itx->itx_callback != NULL)
+                       itx->itx_callback(itx->itx_callback_data);
                list_remove(list, itx);
                kmem_free(itx, offsetof(itx_t, itx_lr) +
                    itx->itx_lr.lrc_reclen);
@@ -1218,6 +1222,8 @@ zil_itxg_clean(itxs_t *itxs)
        while ((ian = avl_destroy_nodes(t, &cookie)) != NULL) {
                list = &ian->ia_list;
                while ((itx = list_head(list)) != NULL) {
+                       if (itx->itx_callback != NULL)
+                               itx->itx_callback(itx->itx_callback_data);
                        list_remove(list, itx);
                        kmem_free(itx, offsetof(itx_t, itx_lr) +
                            itx->itx_lr.lrc_reclen);
@@ -1284,6 +1290,8 @@ zil_remove_async(zilog_t *zilog, uint64_t oid)
                mutex_exit(&itxg->itxg_lock);
        }
        while ((itx = list_head(&clean_list)) != NULL) {
+               if (itx->itx_callback != NULL)
+                       itx->itx_callback(itx->itx_callback_data);
                list_remove(&clean_list, itx);
                kmem_free(itx, offsetof(itx_t, itx_lr) +
                    itx->itx_lr.lrc_reclen);
@@ -1335,7 +1343,8 @@ zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx)
                }
                ASSERT(itxg->itxg_sod == 0);
                itxg->itxg_txg = txg;
-               itxs = itxg->itxg_itxs = kmem_zalloc(sizeof (itxs_t), KM_PUSHPAGE);
+               itxs = itxg->itxg_itxs = kmem_zalloc(sizeof (itxs_t),
+                   KM_PUSHPAGE);
 
                list_create(&itxs->i_sync_list, sizeof (itx_t),
                    offsetof(itx_t, itx_node));
@@ -1355,7 +1364,8 @@ zil_itx_assign(zilog_t *zilog, itx_t *itx, dmu_tx_t *tx)
 
                ian = avl_find(t, &foid, &where);
                if (ian == NULL) {
-                       ian = kmem_alloc(sizeof (itx_async_node_t), KM_PUSHPAGE);
+                       ian = kmem_alloc(sizeof (itx_async_node_t),
+                           KM_PUSHPAGE);
                        list_create(&ian->ia_list, sizeof (itx_t),
                            offsetof(itx_t, itx_node));
                        ian->ia_foid = foid;
@@ -1529,15 +1539,13 @@ zil_commit_writer(zilog_t *zilog)
        }
 
        DTRACE_PROBE1(zil__cw1, zilog_t *, zilog);
-       while ((itx = list_head(&zilog->zl_itx_commit_list))) {
+       for (itx = list_head(&zilog->zl_itx_commit_list); itx != NULL;
+           itx = list_next(&zilog->zl_itx_commit_list, itx)) {
                txg = itx->itx_lr.lrc_txg;
                ASSERT(txg);
 
                if (txg > spa_last_synced_txg(spa) || txg > spa_freeze_txg(spa))
                        lwb = zil_lwb_commit(zilog, itx, lwb);
-               list_remove(&zilog->zl_itx_commit_list, itx);
-               kmem_free(itx, offsetof(itx_t, itx_lr)
-                   + itx->itx_lr.lrc_reclen);
        }
        DTRACE_PROBE1(zil__cw2, zilog_t *, zilog);
 
@@ -1559,6 +1567,17 @@ zil_commit_writer(zilog_t *zilog)
        if (error || lwb == NULL)
                txg_wait_synced(zilog->zl_dmu_pool, 0);
 
+       while ((itx = list_head(&zilog->zl_itx_commit_list))) {
+               txg = itx->itx_lr.lrc_txg;
+               ASSERT(txg);
+
+               if (itx->itx_callback != NULL)
+                       itx->itx_callback(itx->itx_callback_data);
+               list_remove(&zilog->zl_itx_commit_list, itx);
+               kmem_free(itx, offsetof(itx_t, itx_lr)
+                   + itx->itx_lr.lrc_reclen);
+       }
+
        mutex_enter(&zilog->zl_lock);
 
        /*
@@ -1726,7 +1745,7 @@ zil_init(void)
            sizeof (struct lwb), 0, NULL, NULL, NULL, NULL, NULL, 0);
 
        zil_ksp = kstat_create("zfs", 0, "zil", "misc",
-           KSTAT_TYPE_NAMED, sizeof(zil_stats) / sizeof(kstat_named_t),
+           KSTAT_TYPE_NAMED, sizeof (zil_stats) / sizeof (kstat_named_t),
            KSTAT_FLAG_VIRTUAL);
 
        if (zil_ksp != NULL) {