15cabbc6bSPrashanth Sreenivasa /* 25cabbc6bSPrashanth Sreenivasa * CDDL HEADER START 35cabbc6bSPrashanth Sreenivasa * 45cabbc6bSPrashanth Sreenivasa * This file and its contents are supplied under the terms of the 55cabbc6bSPrashanth Sreenivasa * Common Development and Distribution License ("CDDL"), version 1.0. 65cabbc6bSPrashanth Sreenivasa * You may only use this file in accordance with the terms of version 75cabbc6bSPrashanth Sreenivasa * 1.0 of the CDDL. 85cabbc6bSPrashanth Sreenivasa * 95cabbc6bSPrashanth Sreenivasa * A full copy of the text of the CDDL should have accompanied this 105cabbc6bSPrashanth Sreenivasa * source. A copy of the CDDL is also available via the Internet at 115cabbc6bSPrashanth Sreenivasa * http://www.illumos.org/license/CDDL. 125cabbc6bSPrashanth Sreenivasa * 135cabbc6bSPrashanth Sreenivasa * CDDL HEADER END 145cabbc6bSPrashanth Sreenivasa */ 155cabbc6bSPrashanth Sreenivasa 165cabbc6bSPrashanth Sreenivasa /* 1786714001SSerapheim Dimitropoulos * Copyright (c) 2014, 2017 by Delphix. All rights reserved. 185cabbc6bSPrashanth Sreenivasa */ 195cabbc6bSPrashanth Sreenivasa 205cabbc6bSPrashanth Sreenivasa #ifndef _SYS_VDEV_REMOVAL_H 215cabbc6bSPrashanth Sreenivasa #define _SYS_VDEV_REMOVAL_H 225cabbc6bSPrashanth Sreenivasa 235cabbc6bSPrashanth Sreenivasa #include <sys/spa.h> 245cabbc6bSPrashanth Sreenivasa #include <sys/bpobj.h> 255cabbc6bSPrashanth Sreenivasa #include <sys/vdev_indirect_mapping.h> 265cabbc6bSPrashanth Sreenivasa #include <sys/vdev_indirect_births.h> 275cabbc6bSPrashanth Sreenivasa 285cabbc6bSPrashanth Sreenivasa #ifdef __cplusplus 295cabbc6bSPrashanth Sreenivasa extern "C" { 305cabbc6bSPrashanth Sreenivasa #endif 315cabbc6bSPrashanth Sreenivasa 325cabbc6bSPrashanth Sreenivasa typedef struct spa_vdev_removal { 333a4b1be9SMatthew Ahrens uint64_t svr_vdev_id; 345cabbc6bSPrashanth Sreenivasa uint64_t svr_max_offset_to_sync[TXG_SIZE]; 355cabbc6bSPrashanth Sreenivasa /* Thread performing a vdev removal. */ 365cabbc6bSPrashanth Sreenivasa kthread_t *svr_thread; 375cabbc6bSPrashanth Sreenivasa /* Segments left to copy from the current metaslab. */ 385cabbc6bSPrashanth Sreenivasa range_tree_t *svr_allocd_segs; 395cabbc6bSPrashanth Sreenivasa kmutex_t svr_lock; 405cabbc6bSPrashanth Sreenivasa kcondvar_t svr_cv; 415cabbc6bSPrashanth Sreenivasa boolean_t svr_thread_exit; 425cabbc6bSPrashanth Sreenivasa 435cabbc6bSPrashanth Sreenivasa /* 445cabbc6bSPrashanth Sreenivasa * New mappings to write out each txg. 455cabbc6bSPrashanth Sreenivasa */ 465cabbc6bSPrashanth Sreenivasa list_t svr_new_segments[TXG_SIZE]; 475cabbc6bSPrashanth Sreenivasa 485cabbc6bSPrashanth Sreenivasa /* 495cabbc6bSPrashanth Sreenivasa * Ranges that were freed while a mapping was in flight. This is 505cabbc6bSPrashanth Sreenivasa * a subset of the ranges covered by vdev_im_new_segments. 515cabbc6bSPrashanth Sreenivasa */ 525cabbc6bSPrashanth Sreenivasa range_tree_t *svr_frees[TXG_SIZE]; 535cabbc6bSPrashanth Sreenivasa 545cabbc6bSPrashanth Sreenivasa /* 555cabbc6bSPrashanth Sreenivasa * Number of bytes which we have finished our work for 565cabbc6bSPrashanth Sreenivasa * in each txg. This could be data copied (which will be part of 575cabbc6bSPrashanth Sreenivasa * the mappings in vdev_im_new_segments), or data freed before 585cabbc6bSPrashanth Sreenivasa * we got around to copying it. 595cabbc6bSPrashanth Sreenivasa */ 605cabbc6bSPrashanth Sreenivasa uint64_t svr_bytes_done[TXG_SIZE]; 615cabbc6bSPrashanth Sreenivasa 625cabbc6bSPrashanth Sreenivasa /* List of leaf zap objects to be unlinked */ 635cabbc6bSPrashanth Sreenivasa nvlist_t *svr_zaplist; 645cabbc6bSPrashanth Sreenivasa } spa_vdev_removal_t; 655cabbc6bSPrashanth Sreenivasa 665cabbc6bSPrashanth Sreenivasa typedef struct spa_condensing_indirect { 675cabbc6bSPrashanth Sreenivasa /* 685cabbc6bSPrashanth Sreenivasa * New mappings to write out each txg. 695cabbc6bSPrashanth Sreenivasa */ 705cabbc6bSPrashanth Sreenivasa list_t sci_new_mapping_entries[TXG_SIZE]; 715cabbc6bSPrashanth Sreenivasa 725cabbc6bSPrashanth Sreenivasa vdev_indirect_mapping_t *sci_new_mapping; 735cabbc6bSPrashanth Sreenivasa } spa_condensing_indirect_t; 745cabbc6bSPrashanth Sreenivasa 755cabbc6bSPrashanth Sreenivasa extern int spa_remove_init(spa_t *); 765cabbc6bSPrashanth Sreenivasa extern void spa_restart_removal(spa_t *); 775cabbc6bSPrashanth Sreenivasa extern int spa_condense_init(spa_t *); 785cabbc6bSPrashanth Sreenivasa extern void spa_condense_fini(spa_t *); 79667ec66fSSerapheim Dimitropoulos extern void spa_start_indirect_condensing_thread(spa_t *); 805cabbc6bSPrashanth Sreenivasa extern void spa_vdev_condense_suspend(spa_t *); 815cabbc6bSPrashanth Sreenivasa extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t); 8286714001SSerapheim Dimitropoulos extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t); 835cabbc6bSPrashanth Sreenivasa extern int spa_removal_get_stats(spa_t *, pool_removal_stat_t *); 845cabbc6bSPrashanth Sreenivasa extern void svr_sync(spa_t *spa, dmu_tx_t *tx); 855cabbc6bSPrashanth Sreenivasa extern void spa_vdev_remove_suspend(spa_t *); 865cabbc6bSPrashanth Sreenivasa extern int spa_vdev_remove_cancel(spa_t *); 875cabbc6bSPrashanth Sreenivasa extern void spa_vdev_removal_destroy(spa_vdev_removal_t *svr); 885cabbc6bSPrashanth Sreenivasa 89*cfd63e1bSMatthew Ahrens extern int vdev_removal_max_span; 90*cfd63e1bSMatthew Ahrens extern int zfs_remove_max_segment; 91*cfd63e1bSMatthew Ahrens 925cabbc6bSPrashanth Sreenivasa #ifdef __cplusplus 935cabbc6bSPrashanth Sreenivasa } 945cabbc6bSPrashanth Sreenivasa #endif 955cabbc6bSPrashanth Sreenivasa 965cabbc6bSPrashanth Sreenivasa #endif /* _SYS_VDEV_REMOVAL_H */ 97