1 /* 2 * Copyright (c) 2020 iXsystems, Inc. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28 #include <sys/cdefs.h> 29 __FBSDID("$FreeBSD$"); 30 31 #include <sys/types.h> 32 #include <sys/param.h> 33 #include <sys/systm.h> 34 #include <sys/conf.h> 35 #include <sys/kernel.h> 36 #include <sys/lock.h> 37 #include <sys/malloc.h> 38 #include <sys/mutex.h> 39 #include <sys/proc.h> 40 #include <sys/errno.h> 41 #include <sys/uio.h> 42 #include <sys/buf.h> 43 #include <sys/file.h> 44 #include <sys/kmem.h> 45 #include <sys/conf.h> 46 #include <sys/cmn_err.h> 47 #include <sys/stat.h> 48 #include <sys/zfs_ioctl.h> 49 #include <sys/zfs_vfsops.h> 50 #include <sys/zfs_znode.h> 51 #include <sys/zap.h> 52 #include <sys/spa.h> 53 #include <sys/spa_impl.h> 54 #include <sys/vdev.h> 55 #include <sys/vdev_impl.h> 56 #include <sys/dmu.h> 57 #include <sys/dsl_dir.h> 58 #include <sys/dsl_dataset.h> 59 #include <sys/dsl_prop.h> 60 #include <sys/dsl_deleg.h> 61 #include <sys/dmu_objset.h> 62 #include <sys/dmu_impl.h> 63 #include <sys/dmu_tx.h> 64 #include <sys/sunddi.h> 65 #include <sys/policy.h> 66 #include <sys/zone.h> 67 #include <sys/nvpair.h> 68 #include <sys/mount.h> 69 #include <sys/taskqueue.h> 70 #include <sys/sdt.h> 71 #include <sys/fs/zfs.h> 72 #include <sys/zfs_ctldir.h> 73 #include <sys/zfs_dir.h> 74 #include <sys/zfs_onexit.h> 75 #include <sys/zvol.h> 76 #include <sys/dsl_scan.h> 77 #include <sys/dmu_objset.h> 78 #include <sys/dmu_send.h> 79 #include <sys/dsl_destroy.h> 80 #include <sys/dsl_bookmark.h> 81 #include <sys/dsl_userhold.h> 82 #include <sys/zfeature.h> 83 #include <sys/zcp.h> 84 #include <sys/zio_checksum.h> 85 #include <sys/vdev_removal.h> 86 #include <sys/dsl_crypt.h> 87 88 #include <sys/zfs_ioctl_compat.h> 89 #include <sys/zfs_context.h> 90 91 #include <sys/arc_impl.h> 92 #include <sys/dsl_pool.h> 93 94 95 /* BEGIN CSTYLED */ 96 SYSCTL_DECL(_vfs_zfs); 97 SYSCTL_NODE(_vfs_zfs, OID_AUTO, arc, CTLFLAG_RW, 0, "ZFS adaptive replacement cache"); 98 SYSCTL_NODE(_vfs_zfs, OID_AUTO, condense, CTLFLAG_RW, 0, "ZFS condense"); 99 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dbuf, CTLFLAG_RW, 0, "ZFS disk buf cache"); 100 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dbuf_cache, CTLFLAG_RW, 0, "ZFS disk buf cache"); 101 SYSCTL_NODE(_vfs_zfs, OID_AUTO, deadman, CTLFLAG_RW, 0, "ZFS deadman"); 102 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dedup, CTLFLAG_RW, 0, "ZFS dedup"); 103 SYSCTL_NODE(_vfs_zfs, OID_AUTO, l2arc, CTLFLAG_RW, 0, "ZFS l2arc"); 104 SYSCTL_NODE(_vfs_zfs, OID_AUTO, livelist, CTLFLAG_RW, 0, "ZFS livelist"); 105 SYSCTL_NODE(_vfs_zfs, OID_AUTO, lua, CTLFLAG_RW, 0, "ZFS lua"); 106 SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); 107 SYSCTL_NODE(_vfs_zfs, OID_AUTO, mg, CTLFLAG_RW, 0, "ZFS metaslab group"); 108 SYSCTL_NODE(_vfs_zfs, OID_AUTO, multihost, CTLFLAG_RW, 0, "ZFS multihost protection"); 109 SYSCTL_NODE(_vfs_zfs, OID_AUTO, prefetch, CTLFLAG_RW, 0, "ZFS prefetch"); 110 SYSCTL_NODE(_vfs_zfs, OID_AUTO, reconstruct, CTLFLAG_RW, 0, "ZFS reconstruct"); 111 SYSCTL_NODE(_vfs_zfs, OID_AUTO, recv, CTLFLAG_RW, 0, "ZFS receive"); 112 SYSCTL_NODE(_vfs_zfs, OID_AUTO, send, CTLFLAG_RW, 0, "ZFS send"); 113 SYSCTL_NODE(_vfs_zfs, OID_AUTO, spa, CTLFLAG_RW, 0, "ZFS space allocation"); 114 SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RW, 0, "ZFS TRIM"); 115 SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS transaction group"); 116 SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV"); 117 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zevent, CTLFLAG_RW, 0, "ZFS event"); 118 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zil, CTLFLAG_RW, 0, "ZFS ZIL"); 119 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zio, CTLFLAG_RW, 0, "ZFS ZIO"); 120 121 SYSCTL_NODE(_vfs_zfs_livelist, OID_AUTO, condense, CTLFLAG_RW, 0, 122 "ZFS livelist condense"); 123 SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); 124 SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, 125 "ZFS VDEV mirror"); 126 127 SYSCTL_DECL(_vfs_zfs_version); 128 SYSCTL_CONST_STRING(_vfs_zfs_version, OID_AUTO, module, CTLFLAG_RD, 129 (ZFS_META_VERSION "-" ZFS_META_RELEASE), "OpenZFS module version"); 130 131 extern arc_state_t ARC_anon; 132 extern arc_state_t ARC_mru; 133 extern arc_state_t ARC_mru_ghost; 134 extern arc_state_t ARC_mfu; 135 extern arc_state_t ARC_mfu_ghost; 136 extern arc_state_t ARC_l2c_only; 137 138 /* 139 * minimum lifespan of a prefetch block in clock ticks 140 * (initialized in arc_init()) 141 */ 142 143 /* arc.c */ 144 145 /* legacy compat */ 146 extern uint64_t l2arc_write_max; /* def max write size */ 147 extern uint64_t l2arc_write_boost; /* extra warmup write */ 148 extern uint64_t l2arc_headroom; /* # of dev writes */ 149 extern uint64_t l2arc_headroom_boost; 150 extern uint64_t l2arc_feed_secs; /* interval seconds */ 151 extern uint64_t l2arc_feed_min_ms; /* min interval msecs */ 152 extern int l2arc_noprefetch; /* don't cache prefetch bufs */ 153 extern int l2arc_feed_again; /* turbo warmup */ 154 extern int l2arc_norw; /* no reads during writes */ 155 156 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, CTLFLAG_RW, 157 &l2arc_write_max, 0, "max write size (LEGACY)"); 158 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, CTLFLAG_RW, 159 &l2arc_write_boost, 0, "extra write during warmup (LEGACY)"); 160 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, CTLFLAG_RW, 161 &l2arc_headroom, 0, "number of dev writes (LEGACY)"); 162 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, CTLFLAG_RW, 163 &l2arc_feed_secs, 0, "interval seconds (LEGACY)"); 164 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, CTLFLAG_RW, 165 &l2arc_feed_min_ms, 0, "min interval milliseconds (LEGACY)"); 166 167 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, CTLFLAG_RW, 168 &l2arc_noprefetch, 0, "don't cache prefetch bufs (LEGACY)"); 169 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, CTLFLAG_RW, 170 &l2arc_feed_again, 0, "turbo warmup (LEGACY)"); 171 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, CTLFLAG_RW, 172 &l2arc_norw, 0, "no reads during writes (LEGACY)"); 173 #if 0 174 extern int zfs_compressed_arc_enabled; 175 SYSCTL_INT(_vfs_zfs, OID_AUTO, compressed_arc_enabled, CTLFLAG_RW, 176 &zfs_compressed_arc_enabled, 1, "compressed arc buffers (LEGACY)"); 177 #endif 178 179 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_size, CTLFLAG_RD, 180 &ARC_anon.arcs_size.rc_count, 0, "size of anonymous state"); 181 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD, 182 &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 183 "size of anonymous state"); 184 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD, 185 &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 186 "size of anonymous state"); 187 188 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_size, CTLFLAG_RD, 189 &ARC_mru.arcs_size.rc_count, 0, "size of mru state"); 190 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD, 191 &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 192 "size of metadata in mru state"); 193 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD, 194 &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 195 "size of data in mru state"); 196 197 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_size, CTLFLAG_RD, 198 &ARC_mru_ghost.arcs_size.rc_count, 0, "size of mru ghost state"); 199 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD, 200 &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 201 "size of metadata in mru ghost state"); 202 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD, 203 &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 204 "size of data in mru ghost state"); 205 206 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_size, CTLFLAG_RD, 207 &ARC_mfu.arcs_size.rc_count, 0, "size of mfu state"); 208 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD, 209 &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 210 "size of metadata in mfu state"); 211 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD, 212 &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 213 "size of data in mfu state"); 214 215 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_size, CTLFLAG_RD, 216 &ARC_mfu_ghost.arcs_size.rc_count, 0, "size of mfu ghost state"); 217 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD, 218 &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 219 "size of metadata in mfu ghost state"); 220 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD, 221 &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 222 "size of data in mfu ghost state"); 223 224 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2c_only_size, CTLFLAG_RD, 225 &ARC_l2c_only.arcs_size.rc_count, 0, "size of mru state"); 226 227 static int 228 sysctl_vfs_zfs_arc_no_grow_shift(SYSCTL_HANDLER_ARGS) 229 { 230 uint32_t val; 231 int err; 232 233 val = arc_no_grow_shift; 234 err = sysctl_handle_32(oidp, &val, 0, req); 235 if (err != 0 || req->newptr == NULL) 236 return (err); 237 238 if (val >= arc_shrink_shift) 239 return (EINVAL); 240 241 arc_no_grow_shift = val; 242 return (0); 243 } 244 245 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift, CTLTYPE_U32 | CTLFLAG_RWTUN, 246 0, sizeof (uint32_t), sysctl_vfs_zfs_arc_no_grow_shift, "U", 247 "log2(fraction of ARC which must be free to allow growing)"); 248 249 int 250 param_set_arc_long(SYSCTL_HANDLER_ARGS) 251 { 252 int err; 253 254 err = sysctl_handle_long(oidp, arg1, 0, req); 255 if (err != 0 || req->newptr == NULL) 256 return (err); 257 258 arc_tuning_update(B_TRUE); 259 260 return (0); 261 } 262 263 int 264 param_set_arc_int(SYSCTL_HANDLER_ARGS) 265 { 266 int err; 267 268 err = sysctl_handle_int(oidp, arg1, 0, req); 269 if (err != 0 || req->newptr == NULL) 270 return (err); 271 272 arc_tuning_update(B_TRUE); 273 274 return (0); 275 } 276 277 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, CTLTYPE_ULONG | CTLFLAG_RWTUN, 278 &zfs_arc_min, sizeof (zfs_arc_min), param_set_arc_long, "LU", 279 "min arc size (LEGACY)"); 280 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, CTLTYPE_ULONG | CTLFLAG_RWTUN, 281 &zfs_arc_max, sizeof (zfs_arc_max), param_set_arc_long, "LU", 282 "max arc size (LEGACY)"); 283 284 /* dbuf.c */ 285 286 287 /* dmu.c */ 288 289 /* dmu_zfetch.c */ 290 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH (LEGACY)"); 291 292 /* max bytes to prefetch per stream (default 8MB) */ 293 extern uint32_t zfetch_max_distance; 294 SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_distance, CTLFLAG_RWTUN, 295 &zfetch_max_distance, 0, "Max bytes to prefetch per stream (LEGACY)"); 296 297 /* max bytes to prefetch indirects for per stream (default 64MB) */ 298 extern uint32_t zfetch_max_idistance; 299 SYSCTL_UINT(_vfs_zfs_prefetch, OID_AUTO, max_idistance, CTLFLAG_RWTUN, 300 &zfetch_max_idistance, 0, "Max bytes to prefetch indirects for per stream"); 301 302 /* dsl_pool.c */ 303 304 /* dnode.c */ 305 extern int zfs_default_bs; 306 SYSCTL_INT(_vfs_zfs, OID_AUTO, default_bs, CTLFLAG_RWTUN, 307 &zfs_default_bs, 0, "Default dnode block shift"); 308 309 extern int zfs_default_ibs; 310 SYSCTL_INT(_vfs_zfs, OID_AUTO, default_ibs, CTLFLAG_RWTUN, 311 &zfs_default_ibs, 0, "Default dnode indirect block shift"); 312 313 314 /* dsl_scan.c */ 315 316 /* metaslab.c */ 317 318 /* 319 * In pools where the log space map feature is not enabled we touch 320 * multiple metaslabs (and their respective space maps) with each 321 * transaction group. Thus, we benefit from having a small space map 322 * block size since it allows us to issue more I/O operations scattered 323 * around the disk. So a sane default for the space map block size 324 * is 8~16K. 325 */ 326 extern int zfs_metaslab_sm_blksz_no_log; 327 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_no_log, CTLFLAG_RDTUN, 328 &zfs_metaslab_sm_blksz_no_log, 0, 329 "Block size for space map in pools with log space map disabled. " 330 "Power of 2 and greater than 4096."); 331 332 /* 333 * When the log space map feature is enabled, we accumulate a lot of 334 * changes per metaslab that are flushed once in a while so we benefit 335 * from a bigger block size like 128K for the metaslab space maps. 336 */ 337 extern int zfs_metaslab_sm_blksz_with_log; 338 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_with_log, CTLFLAG_RDTUN, 339 &zfs_metaslab_sm_blksz_with_log, 0, 340 "Block size for space map in pools with log space map enabled. " 341 "Power of 2 and greater than 4096."); 342 343 /* 344 * The in-core space map representation is more compact than its on-disk form. 345 * The zfs_condense_pct determines how much more compact the in-core 346 * space map representation must be before we compact it on-disk. 347 * Values should be greater than or equal to 100. 348 */ 349 extern int zfs_condense_pct; 350 SYSCTL_INT(_vfs_zfs, OID_AUTO, condense_pct, CTLFLAG_RWTUN, 351 &zfs_condense_pct, 0, 352 "Condense on-disk spacemap when it is more than this many percents" 353 " of in-memory counterpart"); 354 355 extern int zfs_remove_max_segment; 356 SYSCTL_INT(_vfs_zfs, OID_AUTO, remove_max_segment, CTLFLAG_RWTUN, 357 &zfs_remove_max_segment, 0, "Largest contiguous segment ZFS will attempt to" 358 " allocate when removing a device"); 359 360 extern int zfs_removal_suspend_progress; 361 SYSCTL_INT(_vfs_zfs, OID_AUTO, removal_suspend_progress, CTLFLAG_RWTUN, 362 &zfs_removal_suspend_progress, 0, "Ensures certain actions can happen while" 363 " in the middle of a removal"); 364 365 366 /* 367 * Minimum size which forces the dynamic allocator to change 368 * it's allocation strategy. Once the space map cannot satisfy 369 * an allocation of this size then it switches to using more 370 * aggressive strategy (i.e search by size rather than offset). 371 */ 372 extern uint64_t metaslab_df_alloc_threshold; 373 SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, CTLFLAG_RWTUN, 374 &metaslab_df_alloc_threshold, 0, 375 "Minimum size which forces the dynamic allocator to change it's allocation strategy"); 376 377 /* 378 * The minimum free space, in percent, which must be available 379 * in a space map to continue allocations in a first-fit fashion. 380 * Once the space map's free space drops below this level we dynamically 381 * switch to using best-fit allocations. 382 */ 383 extern int metaslab_df_free_pct; 384 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, df_free_pct, CTLFLAG_RWTUN, 385 &metaslab_df_free_pct, 0, 386 "The minimum free space, in percent, which must be available in a " 387 "space map to continue allocations in a first-fit fashion"); 388 389 /* 390 * Percentage of all cpus that can be used by the metaslab taskq. 391 */ 392 extern int metaslab_load_pct; 393 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, load_pct, CTLFLAG_RWTUN, 394 &metaslab_load_pct, 0, 395 "Percentage of cpus that can be used by the metaslab taskq"); 396 397 /* 398 * Max number of metaslabs per group to preload. 399 */ 400 extern int metaslab_preload_limit; 401 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, preload_limit, CTLFLAG_RWTUN, 402 &metaslab_preload_limit, 0, 403 "Max number of metaslabs per group to preload"); 404 405 /* refcount.c */ 406 extern int reference_tracking_enable; 407 SYSCTL_INT(_vfs_zfs, OID_AUTO, reference_tracking_enable, CTLFLAG_RDTUN, 408 &reference_tracking_enable, 0, 409 "Track reference holders to refcount_t objects, used mostly by ZFS"); 410 411 /* spa.c */ 412 extern int zfs_ccw_retry_interval; 413 SYSCTL_INT(_vfs_zfs, OID_AUTO, ccw_retry_interval, CTLFLAG_RWTUN, 414 &zfs_ccw_retry_interval, 0, 415 "Configuration cache file write, retry after failure, interval (seconds)"); 416 417 extern uint64_t zfs_max_missing_tvds_cachefile; 418 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, max_missing_tvds_cachefile, CTLFLAG_RWTUN, 419 &zfs_max_missing_tvds_cachefile, 0, 420 "allow importing pools with missing top-level vdevs in cache file"); 421 422 extern uint64_t zfs_max_missing_tvds_scan; 423 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, max_missing_tvds_scan, CTLFLAG_RWTUN, 424 &zfs_max_missing_tvds_scan, 0, 425 "allow importing pools with missing top-level vdevs during scan"); 426 427 /* spa_misc.c */ 428 extern int zfs_flags; 429 static int 430 sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS) 431 { 432 int err, val; 433 434 val = zfs_flags; 435 err = sysctl_handle_int(oidp, &val, 0, req); 436 if (err != 0 || req->newptr == NULL) 437 return (err); 438 439 /* 440 * ZFS_DEBUG_MODIFY must be enabled prior to boot so all 441 * arc buffers in the system have the necessary additional 442 * checksum data. However, it is safe to disable at any 443 * time. 444 */ 445 if (!(zfs_flags & ZFS_DEBUG_MODIFY)) 446 val &= ~ZFS_DEBUG_MODIFY; 447 zfs_flags = val; 448 449 return (0); 450 } 451 452 SYSCTL_PROC(_vfs_zfs, OID_AUTO, debugflags, 453 CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, NULL, 0, 454 sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing."); 455 456 int 457 param_set_deadman_synctime(SYSCTL_HANDLER_ARGS) 458 { 459 unsigned long val; 460 int err; 461 462 val = zfs_deadman_synctime_ms; 463 err = sysctl_handle_long(oidp, &val, 0, req); 464 if (err != 0 || req->newptr == NULL) 465 return (err); 466 zfs_deadman_synctime_ms = val; 467 468 spa_set_deadman_synctime(MSEC2NSEC(zfs_deadman_synctime_ms)); 469 470 return (0); 471 } 472 473 int 474 param_set_deadman_ziotime(SYSCTL_HANDLER_ARGS) 475 { 476 unsigned long val; 477 int err; 478 479 val = zfs_deadman_ziotime_ms; 480 err = sysctl_handle_long(oidp, &val, 0, req); 481 if (err != 0 || req->newptr == NULL) 482 return (err); 483 zfs_deadman_ziotime_ms = val; 484 485 spa_set_deadman_ziotime(MSEC2NSEC(zfs_deadman_synctime_ms)); 486 487 return (0); 488 } 489 490 int 491 param_set_deadman_failmode(SYSCTL_HANDLER_ARGS) 492 { 493 char buf[16]; 494 int rc; 495 496 if (req->newptr == NULL) 497 strlcpy(buf, zfs_deadman_failmode, sizeof (buf)); 498 499 rc = sysctl_handle_string(oidp, buf, sizeof (buf), req); 500 if (rc || req->newptr == NULL) 501 return (rc); 502 if (strcmp(buf, zfs_deadman_failmode) == 0) 503 return (0); 504 if (!strcmp(buf, "wait")) 505 zfs_deadman_failmode = "wait"; 506 if (!strcmp(buf, "continue")) 507 zfs_deadman_failmode = "continue"; 508 if (!strcmp(buf, "panic")) 509 zfs_deadman_failmode = "panic"; 510 511 return (-param_set_deadman_failmode_common(buf)); 512 } 513 514 515 /* spacemap.c */ 516 extern int space_map_ibs; 517 SYSCTL_INT(_vfs_zfs, OID_AUTO, space_map_ibs, CTLFLAG_RWTUN, 518 &space_map_ibs, 0, "Space map indirect block shift"); 519 520 521 /* vdev.c */ 522 int 523 param_set_min_auto_ashift(SYSCTL_HANDLER_ARGS) 524 { 525 uint64_t val; 526 int err; 527 528 val = zfs_vdev_min_auto_ashift; 529 err = sysctl_handle_64(oidp, &val, 0, req); 530 if (err != 0 || req->newptr == NULL) 531 return (SET_ERROR(err)); 532 533 if (val < ASHIFT_MIN || val > zfs_vdev_max_auto_ashift) 534 return (SET_ERROR(EINVAL)); 535 536 zfs_vdev_min_auto_ashift = val; 537 538 return (0); 539 } 540 541 int 542 param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS) 543 { 544 uint64_t val; 545 int err; 546 547 val = zfs_vdev_max_auto_ashift; 548 err = sysctl_handle_64(oidp, &val, 0, req); 549 if (err != 0 || req->newptr == NULL) 550 return (SET_ERROR(err)); 551 552 if (val > ASHIFT_MAX || val < zfs_vdev_min_auto_ashift) 553 return (SET_ERROR(EINVAL)); 554 555 zfs_vdev_max_auto_ashift = val; 556 557 return (0); 558 } 559 560 SYSCTL_PROC(_vfs_zfs, OID_AUTO, min_auto_ashift, CTLTYPE_U64 | CTLFLAG_RWTUN, 561 &zfs_vdev_min_auto_ashift, sizeof (zfs_vdev_min_auto_ashift), 562 param_set_min_auto_ashift, "QU", 563 "Min ashift used when creating new top-level vdev. (LEGACY)"); 564 SYSCTL_PROC(_vfs_zfs, OID_AUTO, max_auto_ashift, CTLTYPE_U64 | CTLFLAG_RWTUN, 565 &zfs_vdev_max_auto_ashift, sizeof (zfs_vdev_max_auto_ashift), 566 param_set_max_auto_ashift, "QU", 567 "Max ashift used when optimizing for logical -> physical sector size on " 568 "new top-level vdevs. (LEGACY)"); 569 570 /* 571 * Since the DTL space map of a vdev is not expected to have a lot of 572 * entries, we default its block size to 4K. 573 */ 574 extern int zfs_vdev_dtl_sm_blksz; 575 SYSCTL_INT(_vfs_zfs, OID_AUTO, dtl_sm_blksz, CTLFLAG_RDTUN, 576 &zfs_vdev_dtl_sm_blksz, 0, 577 "Block size for DTL space map. Power of 2 and greater than 4096."); 578 579 /* 580 * vdev-wide space maps that have lots of entries written to them at 581 * the end of each transaction can benefit from a higher I/O bandwidth 582 * (e.g. vdev_obsolete_sm), thus we default their block size to 128K. 583 */ 584 extern int zfs_vdev_standard_sm_blksz; 585 SYSCTL_INT(_vfs_zfs, OID_AUTO, standard_sm_blksz, CTLFLAG_RDTUN, 586 &zfs_vdev_standard_sm_blksz, 0, 587 "Block size for standard space map. Power of 2 and greater than 4096."); 588 589 extern int vdev_validate_skip; 590 SYSCTL_INT(_vfs_zfs, OID_AUTO, validate_skip, CTLFLAG_RDTUN, 591 &vdev_validate_skip, 0, 592 "Enable to bypass vdev_validate()."); 593 594 595 /* vdev_cache.c */ 596 597 /* vdev_mirror.c */ 598 /* 599 * The load configuration settings below are tuned by default for 600 * the case where all devices are of the same rotational type. 601 * 602 * If there is a mixture of rotating and non-rotating media, setting 603 * non_rotating_seek_inc to 0 may well provide better results as it 604 * will direct more reads to the non-rotating vdevs which are more 605 * likely to have a higher performance. 606 */ 607 608 609 /* vdev_queue.c */ 610 #define ZFS_VDEV_QUEUE_KNOB_MIN(name) \ 611 extern uint32_t zfs_vdev_ ## name ## _min_active; \ 612 SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _min_active, CTLFLAG_RWTUN,\ 613 &zfs_vdev_ ## name ## _min_active, 0, \ 614 "Initial number of I/O requests of type " #name \ 615 " active for each device"); 616 617 #define ZFS_VDEV_QUEUE_KNOB_MAX(name) \ 618 extern uint32_t zfs_vdev_ ## name ## _max_active; \ 619 SYSCTL_UINT(_vfs_zfs_vdev, OID_AUTO, name ## _max_active, CTLFLAG_RWTUN, \ 620 &zfs_vdev_ ## name ## _max_active, 0, \ 621 "Maximum number of I/O requests of type " #name \ 622 " active for each device"); 623 624 625 #undef ZFS_VDEV_QUEUE_KNOB 626 627 extern uint32_t zfs_vdev_max_active; 628 SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, CTLFLAG_RWTUN, 629 &zfs_vdev_max_active, 0, 630 "The maximum number of I/Os of all types active for each device. (LEGACY)"); 631 632 extern int zfs_vdev_def_queue_depth; 633 SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, def_queue_depth, CTLFLAG_RWTUN, 634 &zfs_vdev_def_queue_depth, 0, 635 "Default queue depth for each allocator"); 636 637 /*extern uint64_t zfs_multihost_history; 638 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, multihost_history, CTLFLAG_RWTUN, 639 &zfs_multihost_history, 0, 640 "Historical staticists for the last N multihost updates");*/ 641 642 #ifdef notyet 643 SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, trim_on_init, CTLFLAG_RW, 644 &vdev_trim_on_init, 0, "Enable/disable full vdev trim on initialisation"); 645 #endif 646 647 648 /* zio.c */ 649 #if defined(__LP64__) 650 int zio_use_uma = 1; 651 #else 652 int zio_use_uma = 0; 653 #endif 654 655 SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, use_uma, CTLFLAG_RDTUN, &zio_use_uma, 0, 656 "Use uma(9) for ZIO allocations"); 657 SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, CTLFLAG_RDTUN, &zio_exclude_metadata, 0, 658 "Exclude metadata buffers from dumps as well"); 659 660 int 661 param_set_slop_shift(SYSCTL_HANDLER_ARGS) 662 { 663 int val; 664 int err; 665 666 val = *(int *)arg1; 667 668 err = sysctl_handle_int(oidp, &val, 0, req); 669 if (err != 0 || req->newptr == NULL) 670 return (err); 671 672 if (val < 1 || val > 31) 673 return (EINVAL); 674 675 *(int *)arg1 = val; 676 677 return (0); 678 } 679 680 int 681 param_set_multihost_interval(SYSCTL_HANDLER_ARGS) 682 { 683 int err; 684 685 err = sysctl_handle_long(oidp, arg1, 0, req); 686 if (err != 0 || req->newptr == NULL) 687 return (err); 688 689 if (spa_mode_global != SPA_MODE_UNINIT) 690 mmp_signal_all_threads(); 691 692 return (0); 693 } 694