mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 18:11:00 +03:00
d2734cce68
Details about the motivation of this feature and its usage can be found in this blogpost: https://sdimitro.github.io/post/zpool-checkpoint/ A lightning talk of this feature can be found here: https://www.youtube.com/watch?v=fPQA8K40jAM Implementation details can be found in big block comment of spa_checkpoint.c Side-changes that are relevant to this commit but not explained elsewhere: * renames members of "struct metaslab trees to be shorter without losing meaning * space_map_{alloc,truncate}() accept a block size as a parameter. The reason is that in the current state all space maps that we allocate through the DMU use a global tunable (space_map_blksz) which defauls to 4KB. This is ok for metaslab space maps in terms of bandwirdth since they are scattered all over the disk. But for other space maps this default is probably not what we want. Examples are device removal's vdev_obsolete_sm or vdev_chedkpoint_sm from this review. Both of these have a 1:1 relationship with each vdev and could benefit from a bigger block size. Porting notes: * The part of dsl_scan_sync() which handles async destroys has been moved into the new dsl_process_async_destroys() function. * Remove "VERIFY(!(flags & FWRITE))" in "kernel.c" so zhack can write to block device backed pools. * ZTS: * Fix get_txg() in zpool_sync_001_pos due to "checkpoint_txg". * Don't use large dd block sizes on /dev/urandom under Linux in checkpoint_capacity. * Adopt Delphix-OS's setting of 4 (spa_asize_inflation = SPA_DVAS_PER_BP + 1) for the checkpoint_capacity test to speed its attempts to fill the pool * Create the base and nested pools with sync=disabled to speed up the "setup" phase. * Clear labels in test pool between checkpoint tests to avoid duplicate pool issues. * The import_rewind_device_replaced test has been marked as "known to fail" for the reasons listed in its DISCLAIMER. * New module parameters: zfs_spa_discard_memory_limit, zfs_remove_max_bytes_pause (not documented - debugging only) vdev_max_ms_count (formerly metaslabs_per_vdev) vdev_min_ms_count Authored by: Serapheim Dimitropoulos <serapheim.dimitro@delphix.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: John Kennedy <john.kennedy@delphix.com> Reviewed by: Dan Kimmel <dan.kimmel@delphix.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Approved by: Richard Lowe <richlowe@richlowe.net> Ported-by: Tim Chase <tim@chase2k.com> Signed-off-by: Tim Chase <tim@chase2k.com> OpenZFS-issue: https://illumos.org/issues/9166 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/7159fdb8 Closes #7570
126 lines
4.5 KiB
C
126 lines
4.5 KiB
C
/*
|
|
* CDDL HEADER START
|
|
*
|
|
* The contents of this file are subject to the terms of the
|
|
* Common Development and Distribution License (the "License").
|
|
* You may not use this file except in compliance with the License.
|
|
*
|
|
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
|
|
* or http://www.opensolaris.org/os/licensing.
|
|
* See the License for the specific language governing permissions
|
|
* and limitations under the License.
|
|
*
|
|
* When distributing Covered Code, include this CDDL HEADER in each
|
|
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
|
|
* If applicable, add the following below this CDDL HEADER, with the
|
|
* fields enclosed by brackets "[]" replaced with your own identifying
|
|
* information: Portions Copyright [yyyy] [name of copyright owner]
|
|
*
|
|
* CDDL HEADER END
|
|
*/
|
|
/*
|
|
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
|
* Use is subject to license terms.
|
|
*/
|
|
|
|
/*
|
|
* Copyright (c) 2013, 2017 by Delphix. All rights reserved.
|
|
*/
|
|
|
|
#ifndef _SYS_RANGE_TREE_H
|
|
#define _SYS_RANGE_TREE_H
|
|
|
|
#include <sys/avl.h>
|
|
#include <sys/dmu.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define RANGE_TREE_HISTOGRAM_SIZE 64
|
|
|
|
typedef struct range_tree_ops range_tree_ops_t;
|
|
|
|
/*
|
|
* Note: the range_tree may not be accessed concurrently; consumers
|
|
* must provide external locking if required.
|
|
*/
|
|
typedef struct range_tree {
|
|
avl_tree_t rt_root; /* offset-ordered segment AVL tree */
|
|
uint64_t rt_space; /* sum of all segments in the map */
|
|
uint64_t rt_gap; /* allowable inter-segment gap */
|
|
range_tree_ops_t *rt_ops;
|
|
|
|
/* rt_avl_compare should only be set if rt_arg is an AVL tree */
|
|
void *rt_arg;
|
|
int (*rt_avl_compare)(const void *, const void *);
|
|
|
|
|
|
/*
|
|
* The rt_histogram maintains a histogram of ranges. Each bucket,
|
|
* rt_histogram[i], contains the number of ranges whose size is:
|
|
* 2^i <= size of range in bytes < 2^(i+1)
|
|
*/
|
|
uint64_t rt_histogram[RANGE_TREE_HISTOGRAM_SIZE];
|
|
} range_tree_t;
|
|
|
|
typedef struct range_seg {
|
|
avl_node_t rs_node; /* AVL node */
|
|
avl_node_t rs_pp_node; /* AVL picker-private node */
|
|
uint64_t rs_start; /* starting offset of this segment */
|
|
uint64_t rs_end; /* ending offset (non-inclusive) */
|
|
uint64_t rs_fill; /* actual fill if gap mode is on */
|
|
} range_seg_t;
|
|
|
|
struct range_tree_ops {
|
|
void (*rtop_create)(range_tree_t *rt, void *arg);
|
|
void (*rtop_destroy)(range_tree_t *rt, void *arg);
|
|
void (*rtop_add)(range_tree_t *rt, range_seg_t *rs, void *arg);
|
|
void (*rtop_remove)(range_tree_t *rt, range_seg_t *rs, void *arg);
|
|
void (*rtop_vacate)(range_tree_t *rt, void *arg);
|
|
};
|
|
|
|
typedef void range_tree_func_t(void *arg, uint64_t start, uint64_t size);
|
|
|
|
void range_tree_init(void);
|
|
void range_tree_fini(void);
|
|
range_tree_t *range_tree_create_impl(range_tree_ops_t *ops, void *arg,
|
|
int (*avl_compare) (const void *, const void *), uint64_t gap);
|
|
range_tree_t *range_tree_create(range_tree_ops_t *ops, void *arg);
|
|
void range_tree_destroy(range_tree_t *rt);
|
|
boolean_t range_tree_contains(range_tree_t *rt, uint64_t start, uint64_t size);
|
|
range_seg_t *range_tree_find(range_tree_t *rt, uint64_t start, uint64_t size);
|
|
void range_tree_resize_segment(range_tree_t *rt, range_seg_t *rs,
|
|
uint64_t newstart, uint64_t newsize);
|
|
uint64_t range_tree_space(range_tree_t *rt);
|
|
boolean_t range_tree_is_empty(range_tree_t *rt);
|
|
void range_tree_verify(range_tree_t *rt, uint64_t start, uint64_t size);
|
|
void range_tree_swap(range_tree_t **rtsrc, range_tree_t **rtdst);
|
|
void range_tree_stat_verify(range_tree_t *rt);
|
|
uint64_t range_tree_min(range_tree_t *rt);
|
|
uint64_t range_tree_max(range_tree_t *rt);
|
|
uint64_t range_tree_span(range_tree_t *rt);
|
|
|
|
void range_tree_add(void *arg, uint64_t start, uint64_t size);
|
|
void range_tree_remove(void *arg, uint64_t start, uint64_t size);
|
|
void range_tree_remove_fill(range_tree_t *rt, uint64_t start, uint64_t size);
|
|
void range_tree_adjust_fill(range_tree_t *rt, range_seg_t *rs, int64_t delta);
|
|
void range_tree_clear(range_tree_t *rt, uint64_t start, uint64_t size);
|
|
|
|
void range_tree_vacate(range_tree_t *rt, range_tree_func_t *func, void *arg);
|
|
void range_tree_walk(range_tree_t *rt, range_tree_func_t *func, void *arg);
|
|
range_seg_t *range_tree_first(range_tree_t *rt);
|
|
|
|
void rt_avl_create(range_tree_t *rt, void *arg);
|
|
void rt_avl_destroy(range_tree_t *rt, void *arg);
|
|
void rt_avl_add(range_tree_t *rt, range_seg_t *rs, void *arg);
|
|
void rt_avl_remove(range_tree_t *rt, range_seg_t *rs, void *arg);
|
|
void rt_avl_vacate(range_tree_t *rt, void *arg);
|
|
extern struct range_tree_ops rt_avl_ops;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SYS_RANGE_TREE_H */
|