xref: /freebsd/sys/contrib/openzfs/module/os/linux/zfs/spa_misc_os.c (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
26  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
27  * Copyright 2013 Saso Kiselkov. All rights reserved.
28  * Copyright (c) 2017 Datto Inc.
29  * Copyright (c) 2017, Intel Corporation.
30  */
31 
32 #include <sys/zfs_context.h>
33 #include <sys/spa_impl.h>
34 #include <sys/spa.h>
35 #include <sys/txg.h>
36 #include <sys/unique.h>
37 #include <sys/dsl_pool.h>
38 #include <sys/dsl_dir.h>
39 #include <sys/dsl_prop.h>
40 #include <sys/fm/util.h>
41 #include <sys/dsl_scan.h>
42 #include <sys/fs/zfs.h>
43 #include <sys/kstat.h>
44 #include "zfs_prop.h"
45 
46 
47 int
param_set_deadman_failmode(const char * val,zfs_kernel_param_t * kp)48 param_set_deadman_failmode(const char *val, zfs_kernel_param_t *kp)
49 {
50 	int error;
51 
52 	error = -param_set_deadman_failmode_common(val);
53 	if (error == 0)
54 		error = param_set_charp(val, kp);
55 
56 	return (error);
57 }
58 
59 int
param_set_deadman_ziotime(const char * val,zfs_kernel_param_t * kp)60 param_set_deadman_ziotime(const char *val, zfs_kernel_param_t *kp)
61 {
62 	int error;
63 
64 	error = spl_param_set_u64(val, kp);
65 	if (error < 0)
66 		return (SET_ERROR(error));
67 
68 	spa_set_deadman_ziotime(MSEC2NSEC(zfs_deadman_ziotime_ms));
69 
70 	return (0);
71 }
72 
73 int
param_set_deadman_synctime(const char * val,zfs_kernel_param_t * kp)74 param_set_deadman_synctime(const char *val, zfs_kernel_param_t *kp)
75 {
76 	int error;
77 
78 	error = spl_param_set_u64(val, kp);
79 	if (error < 0)
80 		return (SET_ERROR(error));
81 
82 	spa_set_deadman_synctime(MSEC2NSEC(zfs_deadman_synctime_ms));
83 
84 	return (0);
85 }
86 
87 int
param_set_slop_shift(const char * buf,zfs_kernel_param_t * kp)88 param_set_slop_shift(const char *buf, zfs_kernel_param_t *kp)
89 {
90 	unsigned long val;
91 	int error;
92 
93 	error = kstrtoul(buf, 0, &val);
94 	if (error)
95 		return (SET_ERROR(error));
96 
97 	if (val < 1 || val > 31)
98 		return (SET_ERROR(-EINVAL));
99 
100 	error = param_set_int(buf, kp);
101 	if (error < 0)
102 		return (SET_ERROR(error));
103 
104 	return (0);
105 }
106 
107 int
param_set_active_allocator(const char * val,zfs_kernel_param_t * kp)108 param_set_active_allocator(const char *val, zfs_kernel_param_t *kp)
109 {
110 	int error;
111 
112 	error = -param_set_active_allocator_common(val);
113 	if (error == 0)
114 		error = param_set_charp(val, kp);
115 
116 	return (error);
117 }
118 
119 const char *
spa_history_zone(void)120 spa_history_zone(void)
121 {
122 	return ("linux");
123 }
124 
125 void
spa_import_os(spa_t * spa)126 spa_import_os(spa_t *spa)
127 {
128 	(void) spa;
129 }
130 
131 void
spa_export_os(spa_t * spa)132 spa_export_os(spa_t *spa)
133 {
134 	(void) spa;
135 }
136 
137 void
spa_activate_os(spa_t * spa)138 spa_activate_os(spa_t *spa)
139 {
140 	(void) spa;
141 }
142 
143 void
spa_deactivate_os(spa_t * spa)144 spa_deactivate_os(spa_t *spa)
145 {
146 	(void) spa;
147 }
148