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