1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright (c) 2018 by Delphix. All rights reserved. 24 * Copyright (c) 2018 Datto Inc. 25 */ 26 27 #ifndef _SYS_DATASET_KSTATS_H 28 #define _SYS_DATASET_KSTATS_H 29 30 #include <sys/aggsum.h> 31 #include <sys/dmu.h> 32 #include <sys/kstat.h> 33 34 typedef struct dataset_aggsum_stats_t { 35 aggsum_t das_writes; 36 aggsum_t das_nwritten; 37 aggsum_t das_reads; 38 aggsum_t das_nread; 39 aggsum_t das_nunlinks; 40 aggsum_t das_nunlinked; 41 } dataset_aggsum_stats_t; 42 43 typedef struct dataset_kstat_values { 44 kstat_named_t dkv_ds_name; 45 kstat_named_t dkv_writes; 46 kstat_named_t dkv_nwritten; 47 kstat_named_t dkv_reads; 48 kstat_named_t dkv_nread; 49 /* 50 * nunlinks is initialized to the unlinked set size on mount and 51 * is incremented whenever a new entry is added to the unlinked set 52 */ 53 kstat_named_t dkv_nunlinks; 54 /* 55 * nunlinked is initialized to zero on mount and is incremented when an 56 * entry is removed from the unlinked set 57 */ 58 kstat_named_t dkv_nunlinked; 59 } dataset_kstat_values_t; 60 61 typedef struct dataset_kstats { 62 dataset_aggsum_stats_t dk_aggsums; 63 kstat_t *dk_kstats; 64 } dataset_kstats_t; 65 66 void dataset_kstats_create(dataset_kstats_t *, objset_t *); 67 void dataset_kstats_destroy(dataset_kstats_t *); 68 69 void dataset_kstats_update_write_kstats(dataset_kstats_t *, int64_t); 70 void dataset_kstats_update_read_kstats(dataset_kstats_t *, int64_t); 71 72 void dataset_kstats_update_nunlinks_kstat(dataset_kstats_t *, int64_t); 73 void dataset_kstats_update_nunlinked_kstat(dataset_kstats_t *, int64_t); 74 75 #endif /* _SYS_DATASET_KSTATS_H */ 76