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