1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2018, 2019 by Delphix. All rights reserved. 24 */ 25 26 #ifndef _SYS_SPA_LOG_SPACEMAP_H 27 #define _SYS_SPA_LOG_SPACEMAP_H 28 29 #include <sys/avl.h> 30 31 typedef struct log_summary_entry { 32 uint64_t lse_start; /* start TXG */ 33 uint64_t lse_mscount; /* # of metaslabs needed to be flushed */ 34 uint64_t lse_blkcount; /* blocks held by this entry */ 35 list_node_t lse_node; 36 } log_summary_entry_t; 37 38 typedef struct spa_unflushed_stats { 39 /* used for memory heuristic */ 40 uint64_t sus_memused; /* current memory used for unflushed trees */ 41 42 /* used for block heuristic */ 43 uint64_t sus_blocklimit; /* max # of log blocks allowed */ 44 uint64_t sus_nblocks; /* # of blocks in log space maps currently */ 45 } spa_unflushed_stats_t; 46 47 typedef struct spa_log_sm { 48 uint64_t sls_sm_obj; /* space map object ID */ 49 uint64_t sls_txg; /* txg logged on the space map */ 50 uint64_t sls_nblocks; /* number of blocks in this log */ 51 uint64_t sls_mscount; /* # of metaslabs flushed in the log's txg */ 52 avl_node_t sls_node; /* node in spa_sm_logs_by_txg */ 53 } spa_log_sm_t; 54 55 int spa_ld_log_spacemaps(spa_t *); 56 57 void spa_generate_syncing_log_sm(spa_t *, dmu_tx_t *); 58 void spa_flush_metaslabs(spa_t *, dmu_tx_t *); 59 void spa_sync_close_syncing_log_sm(spa_t *); 60 61 void spa_cleanup_old_sm_logs(spa_t *, dmu_tx_t *); 62 63 uint64_t spa_log_sm_blocklimit(spa_t *); 64 void spa_log_sm_set_blocklimit(spa_t *); 65 uint64_t spa_log_sm_nblocks(spa_t *); 66 uint64_t spa_log_sm_memused(spa_t *); 67 68 void spa_log_sm_decrement_mscount(spa_t *, uint64_t); 69 void spa_log_sm_increment_current_mscount(spa_t *); 70 71 void spa_log_summary_add_flushed_metaslab(spa_t *); 72 void spa_log_summary_decrement_mscount(spa_t *, uint64_t); 73 void spa_log_summary_decrement_blkcount(spa_t *, uint64_t); 74 75 boolean_t spa_flush_all_logs_requested(spa_t *); 76 77 extern int zfs_keep_log_spacemaps_at_export; 78 79 #endif /* _SYS_SPA_LOG_SPACEMAP_H */ 80