Print this page
usr/src/cmd/zpool/zpool_util.c
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/zfs/zpool_prop.c
+++ new/usr/src/common/zfs/zpool_prop.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
|
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 +
21 22 /*
22 23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 - * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
25 25 * Copyright (c) 2014 Integros [integros.com]
26 + * Copyright 2017 Nexenta Systems, Inc.
26 27 */
27 28
28 29 #include <sys/zio.h>
29 30 #include <sys/spa.h>
31 +#include <sys/special.h>
30 32 #include <sys/zfs_acl.h>
31 33 #include <sys/zfs_ioctl.h>
32 34 #include <sys/fs/zfs.h>
33 35
34 36 #include "zfs_prop.h"
35 37
36 38 #if defined(_KERNEL)
37 39 #include <sys/systm.h>
38 40 #else
39 41 #include <stdlib.h>
40 42 #include <string.h>
41 43 #include <ctype.h>
42 44 #endif
43 45
44 46 static zprop_desc_t zpool_prop_table[ZPOOL_NUM_PROPS];
45 47
46 48 zprop_desc_t *
47 49 zpool_prop_get_table(void)
48 50 {
49 51 return (zpool_prop_table);
50 52 }
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
51 53
52 54 void
53 55 zpool_prop_init(void)
54 56 {
55 57 static zprop_index_t boolean_table[] = {
56 58 { "off", 0},
57 59 { "on", 1},
58 60 { NULL }
59 61 };
60 62
63 + static zprop_index_t meta_placement_table[] = {
64 + { "off", META_PLACEMENT_OFF},
65 + { "on", META_PLACEMENT_ON},
66 + { "dual", META_PLACEMENT_DUAL},
67 + { NULL }
68 + };
69 +
61 70 static zprop_index_t failuremode_table[] = {
62 71 { "wait", ZIO_FAILURE_MODE_WAIT },
63 72 { "continue", ZIO_FAILURE_MODE_CONTINUE },
64 73 { "panic", ZIO_FAILURE_MODE_PANIC },
65 74 { NULL }
66 75 };
67 76
77 + static zprop_index_t sync_to_special_table[] = {
78 + { "disabled", SYNC_TO_SPECIAL_DISABLED },
79 + { "standard", SYNC_TO_SPECIAL_STANDARD },
80 + { "balanced", SYNC_TO_SPECIAL_BALANCED },
81 + { "always", SYNC_TO_SPECIAL_ALWAYS},
82 + { NULL }
83 + };
84 +
85 + /*
86 + * NOTE: When either adding or changing a property make sure
87 + * to update the zfs-tests zpool_get configuration file
88 + * at usr/src/test/zfs-tests/tests/functional/cli_root/zpool_get/
89 + * zpool_get.cfg
90 + */
91 +
68 92 /* string properties */
69 93 zprop_register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT,
70 94 ZFS_TYPE_POOL, "<path>", "ALTROOT");
71 95 zprop_register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT,
72 96 ZFS_TYPE_POOL, "<filesystem>", "BOOTFS");
73 97 zprop_register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL,
74 98 PROP_DEFAULT, ZFS_TYPE_POOL, "<file> | none", "CACHEFILE");
75 99 zprop_register_string(ZPOOL_PROP_COMMENT, "comment", NULL,
76 100 PROP_DEFAULT, ZFS_TYPE_POOL, "<comment-string>", "COMMENT");
77 101
78 102 /* readonly number properties */
79 103 zprop_register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY,
80 104 ZFS_TYPE_POOL, "<size>", "SIZE");
81 105 zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY,
82 106 ZFS_TYPE_POOL, "<size>", "FREE");
83 107 zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY,
84 108 ZFS_TYPE_POOL, "<size>", "FREEING");
85 109 zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY,
86 110 ZFS_TYPE_POOL, "<size>", "LEAKED");
87 111 zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
88 112 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC");
89 113 zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,
90 114 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ");
91 115 zprop_register_number(ZPOOL_PROP_FRAGMENTATION, "fragmentation", 0,
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
92 116 PROP_READONLY, ZFS_TYPE_POOL, "<percent>", "FRAG");
93 117 zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
94 118 ZFS_TYPE_POOL, "<size>", "CAP");
95 119 zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,
96 120 ZFS_TYPE_POOL, "<guid>", "GUID");
97 121 zprop_register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY,
98 122 ZFS_TYPE_POOL, "<state>", "HEALTH");
99 123 zprop_register_number(ZPOOL_PROP_DEDUPRATIO, "dedupratio", 0,
100 124 PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>",
101 125 "DEDUP");
126 + zprop_register_index(ZPOOL_PROP_DDTCAPPED, "ddt_capped", 0,
127 + PROP_READONLY, ZFS_TYPE_POOL, "off | on", "DDT_CAPPED",
128 + boolean_table);
102 129
103 130 /* system partition size */
104 131 zprop_register_number(ZPOOL_PROP_BOOTSIZE, "bootsize", 0, PROP_ONETIME,
105 132 ZFS_TYPE_POOL, "<size>", "BOOTSIZE");
106 133
107 134 /* default number properties */
108 135 zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
109 136 PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION");
110 137 zprop_register_number(ZPOOL_PROP_DEDUPDITTO, "dedupditto", 0,
111 138 PROP_DEFAULT, ZFS_TYPE_POOL, "<threshold (min 100)>", "DEDUPDITTO");
139 + zprop_register_number(ZPOOL_PROP_DEDUPMETA_DITTO, "dedup_meta_ditto", 0,
140 + PROP_DEFAULT, ZFS_TYPE_POOL, "<number of copies>",
141 + "DEDUP_META_DITTO");
142 + zprop_register_number(ZPOOL_PROP_DEDUP_LO_BEST_EFFORT,
143 + "dedup_lo_best_effort", 60, PROP_DEFAULT, ZFS_TYPE_POOL,
144 + "0-100", "DEDUP_LO_BEST_EFFORT");
145 + zprop_register_number(ZPOOL_PROP_DEDUP_HI_BEST_EFFORT,
146 + "dedup_hi_best_effort", 80, PROP_DEFAULT, ZFS_TYPE_POOL,
147 + "0-100", "DEDUP_HI_BEST_EFFORT");
148 + zprop_register_number(ZPOOL_PROP_SCRUB_PRIO,
149 + "scrubprio", 5, PROP_DEFAULT, ZFS_TYPE_POOL,
150 + "0-100", "SCRUB_PRIO");
151 + zprop_register_number(ZPOOL_PROP_RESILVER_PRIO,
152 + "resilverprio", 10, PROP_DEFAULT, ZFS_TYPE_POOL,
153 + "0-100", "RESILVER_PRIO");
112 154
113 155 /* default index (boolean) properties */
114 156 zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1,
115 157 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION",
116 158 boolean_table);
117 - zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0,
159 + zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 1,
118 160 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table);
119 161 zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0,
120 162 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS",
121 163 boolean_table);
122 164 zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0,
123 165 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table);
124 166 zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0,
125 167 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table);
168 + zprop_register_index(ZPOOL_PROP_DDT_DESEGREGATION, "ddt_desegregation",
169 + 0, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DDT_DESEG",
170 + boolean_table);
171 + zprop_register_index(ZPOOL_PROP_DEDUP_BEST_EFFORT, "dedup_best_effort",
172 + 0, PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DEDUP_BEST_EFFORT",
173 + boolean_table);
126 174
175 + zprop_register_index(ZPOOL_PROP_META_PLACEMENT, "meta_placement", 0,
176 + PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "META_PLCMNT",
177 + boolean_table);
178 + zprop_register_index(ZPOOL_PROP_SYNC_TO_SPECIAL, "sync_to_special",
179 + SYNC_TO_SPECIAL_STANDARD, PROP_DEFAULT, ZFS_TYPE_POOL,
180 + "disabled | standard | balanced | always", "SYNC_TO_SPECIAL",
181 + sync_to_special_table);
182 + zprop_register_index(ZPOOL_PROP_DDT_META_TO_METADEV,
183 + "ddt_meta_to_metadev", META_PLACEMENT_OFF, PROP_DEFAULT,
184 + ZFS_TYPE_POOL, "on | dual | off",
185 + "DDTMETA_TO_MD", meta_placement_table);
186 + zprop_register_index(ZPOOL_PROP_ZFS_META_TO_METADEV,
187 + "zfs_meta_to_metadev", META_PLACEMENT_OFF, PROP_DEFAULT,
188 + ZFS_TYPE_POOL, "on | dual | off",
189 + "ZFSMETA_TO_MD", meta_placement_table);
190 +
127 191 /* default index properties */
128 192 zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode",
129 193 ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL,
130 194 "wait | continue | panic", "FAILMODE", failuremode_table);
195 + zprop_register_index(ZPOOL_PROP_FORCETRIM, "forcetrim",
196 + SPA_FORCE_TRIM_OFF, PROP_DEFAULT, ZFS_TYPE_POOL,
197 + "on | off", "FORCETRIM", boolean_table);
198 + zprop_register_index(ZPOOL_PROP_AUTOTRIM, "autotrim",
199 + SPA_AUTO_TRIM_OFF, PROP_DEFAULT, ZFS_TYPE_POOL,
200 + "on | off", "AUTOTRIM", boolean_table);
131 201
202 + /* special device status (enabled/disabled) */
203 + zprop_register_index(ZPOOL_PROP_ENABLESPECIAL, "enablespecial", 0,
204 + PROP_READONLY, ZFS_TYPE_POOL, "on | off", "ENABLESPECIAL",
205 + boolean_table);
206 +
207 + /* pool's min watermark in percents (for write cache) */
208 + zprop_register_number(ZPOOL_PROP_MINWATERMARK, "min-watermark",
209 + 20, PROP_DEFAULT, ZFS_TYPE_POOL,
210 + "<watermark 0-100%>", "MINWATERMARK");
211 +
212 + /* pool's low watermark in percents (for write cache) */
213 + zprop_register_number(ZPOOL_PROP_LOWATERMARK, "low-watermark",
214 + 60, PROP_DEFAULT, ZFS_TYPE_POOL,
215 + "<watermark 0-100%>", "LOWATERMARK");
216 +
217 + /* pool's high watermark in percents (for write cache) */
218 + zprop_register_number(ZPOOL_PROP_HIWATERMARK, "high-watermark",
219 + 80, PROP_DEFAULT, ZFS_TYPE_POOL,
220 + "<watermark 0-100%>", "HIWATERMARK");
221 +
222 + zprop_register_number(ZPOOL_PROP_SMALL_DATA_TO_METADEV,
223 + "small_data_to_metadev", 0, PROP_DEFAULT, ZFS_TYPE_POOL,
224 + "Threshold to route to md", "SMALLDATA_TO_MD");
225 +
132 226 /* hidden properties */
133 227 zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,
134 228 PROP_READONLY, ZFS_TYPE_POOL, "NAME");
135 229 zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE, "maxblocksize",
136 230 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE");
137 231 }
138 232
139 233 /*
140 234 * Given a property name and its type, returns the corresponding property ID.
141 235 */
142 236 zpool_prop_t
143 237 zpool_name_to_prop(const char *propname)
144 238 {
145 239 return (zprop_name_to_prop(propname, ZFS_TYPE_POOL));
146 240 }
147 241
148 242 /*
149 243 * Given a pool property ID, returns the corresponding name.
150 244 * Assuming the pool propety ID is valid.
151 245 */
152 246 const char *
153 247 zpool_prop_to_name(zpool_prop_t prop)
154 248 {
155 249 return (zpool_prop_table[prop].pd_name);
156 250 }
157 251
158 252 zprop_type_t
159 253 zpool_prop_get_type(zpool_prop_t prop)
160 254 {
161 255 return (zpool_prop_table[prop].pd_proptype);
162 256 }
163 257
164 258 boolean_t
165 259 zpool_prop_readonly(zpool_prop_t prop)
166 260 {
167 261 return (zpool_prop_table[prop].pd_attr == PROP_READONLY);
168 262 }
169 263
170 264 const char *
171 265 zpool_prop_default_string(zpool_prop_t prop)
172 266 {
173 267 return (zpool_prop_table[prop].pd_strdefault);
174 268 }
175 269
176 270 uint64_t
177 271 zpool_prop_default_numeric(zpool_prop_t prop)
178 272 {
179 273 return (zpool_prop_table[prop].pd_numdefault);
180 274 }
181 275
182 276 /*
183 277 * Returns true if this is a valid feature@ property.
184 278 */
185 279 boolean_t
186 280 zpool_prop_feature(const char *name)
187 281 {
188 282 static const char *prefix = "feature@";
189 283 return (strncmp(name, prefix, strlen(prefix)) == 0);
190 284 }
191 285
192 286 /*
193 287 * Returns true if this is a valid unsupported@ property.
194 288 */
195 289 boolean_t
196 290 zpool_prop_unsupported(const char *name)
197 291 {
198 292 static const char *prefix = "unsupported@";
199 293 return (strncmp(name, prefix, strlen(prefix)) == 0);
200 294 }
201 295
202 296 int
203 297 zpool_prop_string_to_index(zpool_prop_t prop, const char *string,
204 298 uint64_t *index)
205 299 {
206 300 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL));
207 301 }
208 302
209 303 int
210 304 zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index,
211 305 const char **string)
212 306 {
213 307 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));
214 308 }
215 309
216 310 uint64_t
217 311 zpool_prop_random_value(zpool_prop_t prop, uint64_t seed)
218 312 {
219 313 return (zprop_random_value(prop, seed, ZFS_TYPE_POOL));
220 314 }
221 315
222 316 #ifndef _KERNEL
223 317
224 318 const char *
225 319 zpool_prop_values(zpool_prop_t prop)
226 320 {
227 321 return (zpool_prop_table[prop].pd_values);
228 322 }
229 323
230 324 const char *
231 325 zpool_prop_column_name(zpool_prop_t prop)
232 326 {
233 327 return (zpool_prop_table[prop].pd_colname);
234 328 }
235 329
236 330 boolean_t
237 331 zpool_prop_align_right(zpool_prop_t prop)
238 332 {
239 333 return (zpool_prop_table[prop].pd_rightalign);
240 334 }
241 335 #endif
|
↓ open down ↓ |
100 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX