1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * CDDL HEADER START 4 * 5 * This file and its contents are supplied under the terms of the 6 * Common Development and Distribution License ("CDDL"), version 1.0. 7 * You may only use this file in accordance with the terms of version 8 * 1.0 of the CDDL. 9 * 10 * A full copy of the text of the CDDL should have accompanied this 11 * source. A copy of the CDDL is also available via the Internet at 12 * http://www.illumos.org/license/CDDL. 13 * 14 * CDDL HEADER END 15 */ 16 17 /* 18 * Copyright (c) 2014, 2019 by Delphix. All rights reserved. 19 */ 20 21 #ifndef _SYS_VDEV_REMOVAL_H 22 #define _SYS_VDEV_REMOVAL_H 23 24 #include <sys/spa.h> 25 #include <sys/bpobj.h> 26 #include <sys/vdev_indirect_mapping.h> 27 #include <sys/vdev_indirect_births.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 typedef struct spa_vdev_removal { 34 uint64_t svr_vdev_id; 35 uint64_t svr_max_offset_to_sync[TXG_SIZE]; 36 /* Thread performing a vdev removal. */ 37 kthread_t *svr_thread; 38 /* Segments left to copy from the current metaslab. */ 39 zfs_range_tree_t *svr_allocd_segs; 40 kmutex_t svr_lock; 41 kcondvar_t svr_cv; 42 boolean_t svr_thread_exit; 43 44 /* 45 * New mappings to write out each txg. 46 */ 47 list_t svr_new_segments[TXG_SIZE]; 48 49 /* 50 * Ranges that were freed while a mapping was in flight. This is 51 * a subset of the ranges covered by vdev_im_new_segments. 52 */ 53 zfs_range_tree_t *svr_frees[TXG_SIZE]; 54 55 /* 56 * Number of bytes which we have finished our work for 57 * in each txg. This could be data copied (which will be part of 58 * the mappings in vdev_im_new_segments), or data freed before 59 * we got around to copying it. 60 */ 61 uint64_t svr_bytes_done[TXG_SIZE]; 62 63 /* List of leaf zap objects to be unlinked */ 64 nvlist_t *svr_zaplist; 65 } spa_vdev_removal_t; 66 67 typedef struct spa_condensing_indirect { 68 /* 69 * New mappings to write out each txg. 70 */ 71 list_t sci_new_mapping_entries[TXG_SIZE]; 72 73 vdev_indirect_mapping_t *sci_new_mapping; 74 } spa_condensing_indirect_t; 75 76 extern int spa_remove_init(spa_t *); 77 extern void spa_restart_removal(spa_t *); 78 extern int spa_condense_init(spa_t *); 79 extern void spa_condense_fini(spa_t *); 80 extern void spa_start_indirect_condensing_thread(spa_t *); 81 extern void spa_vdev_condense_suspend(spa_t *); 82 extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t); 83 extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t); 84 extern int spa_removal_get_stats(spa_t *, pool_removal_stat_t *); 85 extern void svr_sync(spa_t *, dmu_tx_t *); 86 extern void spa_vdev_remove_suspend(spa_t *); 87 extern int spa_vdev_remove_cancel(spa_t *); 88 extern void spa_vdev_removal_destroy(spa_vdev_removal_t *); 89 extern uint64_t spa_remove_max_segment(spa_t *); 90 91 extern uint_t vdev_removal_max_span; 92 93 #ifdef __cplusplus 94 } 95 #endif 96 97 #endif /* _SYS_VDEV_REMOVAL_H */ 98