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