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/types.h> 29 #include <sys/param.h> 30 #include <sys/systm.h> 31 #include <sys/conf.h> 32 #include <sys/kernel.h> 33 #include <sys/lock.h> 34 #include <sys/malloc.h> 35 #include <sys/mutex.h> 36 #include <sys/proc.h> 37 #include <sys/errno.h> 38 #include <sys/uio.h> 39 #include <sys/buf.h> 40 #include <sys/file.h> 41 #include <sys/kmem.h> 42 #include <sys/conf.h> 43 #include <sys/cmn_err.h> 44 #include <sys/stat.h> 45 #include <sys/zfs_ioctl.h> 46 #include <sys/zfs_vfsops.h> 47 #include <sys/zfs_znode.h> 48 #include <sys/zap.h> 49 #include <sys/spa.h> 50 #include <sys/spa_impl.h> 51 #include <sys/vdev.h> 52 #include <sys/vdev_impl.h> 53 #include <sys/arc_os.h> 54 #include <sys/dmu.h> 55 #include <sys/dsl_dir.h> 56 #include <sys/dsl_dataset.h> 57 #include <sys/dsl_prop.h> 58 #include <sys/dsl_deleg.h> 59 #include <sys/dmu_objset.h> 60 #include <sys/dmu_impl.h> 61 #include <sys/dmu_tx.h> 62 #include <sys/sunddi.h> 63 #include <sys/policy.h> 64 #include <sys/zone.h> 65 #include <sys/nvpair.h> 66 #include <sys/mount.h> 67 #include <sys/taskqueue.h> 68 #include <sys/sdt.h> 69 #include <sys/fs/zfs.h> 70 #include <sys/zfs_ctldir.h> 71 #include <sys/zfs_dir.h> 72 #include <sys/zfs_onexit.h> 73 #include <sys/zvol.h> 74 #include <sys/dsl_scan.h> 75 #include <sys/dmu_objset.h> 76 #include <sys/dmu_send.h> 77 #include <sys/dsl_destroy.h> 78 #include <sys/dsl_bookmark.h> 79 #include <sys/dsl_userhold.h> 80 #include <sys/zfeature.h> 81 #include <sys/zcp.h> 82 #include <sys/zio_checksum.h> 83 #include <sys/vdev_removal.h> 84 #include <sys/dsl_crypt.h> 85 86 #include <sys/zfs_ioctl_compat.h> 87 #include <sys/zfs_context.h> 88 89 #include <sys/arc_impl.h> 90 #include <sys/dsl_pool.h> 91 92 #include <sys/vmmeter.h> 93 94 SYSCTL_DECL(_vfs_zfs); 95 SYSCTL_NODE(_vfs_zfs, OID_AUTO, arc, CTLFLAG_RW, 0, 96 "ZFS adaptive replacement cache"); 97 SYSCTL_NODE(_vfs_zfs, OID_AUTO, brt, CTLFLAG_RW, 0, 98 "ZFS Block Reference Table"); 99 SYSCTL_NODE(_vfs_zfs, OID_AUTO, condense, CTLFLAG_RW, 0, "ZFS condense"); 100 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dbuf, CTLFLAG_RW, 0, "ZFS disk buf cache"); 101 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dbuf_cache, CTLFLAG_RW, 0, 102 "ZFS disk buf cache"); 103 SYSCTL_NODE(_vfs_zfs, OID_AUTO, deadman, CTLFLAG_RW, 0, "ZFS deadman"); 104 SYSCTL_NODE(_vfs_zfs, OID_AUTO, dedup, CTLFLAG_RW, 0, "ZFS dedup"); 105 SYSCTL_NODE(_vfs_zfs, OID_AUTO, l2arc, CTLFLAG_RW, 0, "ZFS l2arc"); 106 SYSCTL_NODE(_vfs_zfs, OID_AUTO, livelist, CTLFLAG_RW, 0, "ZFS livelist"); 107 SYSCTL_NODE(_vfs_zfs, OID_AUTO, lua, CTLFLAG_RW, 0, "ZFS lua"); 108 SYSCTL_NODE(_vfs_zfs, OID_AUTO, metaslab, CTLFLAG_RW, 0, "ZFS metaslab"); 109 SYSCTL_NODE(_vfs_zfs, OID_AUTO, mg, CTLFLAG_RW, 0, "ZFS metaslab group"); 110 SYSCTL_NODE(_vfs_zfs, OID_AUTO, multihost, CTLFLAG_RW, 0, 111 "ZFS multihost protection"); 112 SYSCTL_NODE(_vfs_zfs, OID_AUTO, prefetch, CTLFLAG_RW, 0, "ZFS prefetch"); 113 SYSCTL_NODE(_vfs_zfs, OID_AUTO, reconstruct, CTLFLAG_RW, 0, "ZFS reconstruct"); 114 SYSCTL_NODE(_vfs_zfs, OID_AUTO, recv, CTLFLAG_RW, 0, "ZFS receive"); 115 SYSCTL_NODE(_vfs_zfs, OID_AUTO, send, CTLFLAG_RW, 0, "ZFS send"); 116 SYSCTL_NODE(_vfs_zfs, OID_AUTO, spa, CTLFLAG_RW, 0, "ZFS space allocation"); 117 SYSCTL_NODE(_vfs_zfs, OID_AUTO, trim, CTLFLAG_RW, 0, "ZFS TRIM"); 118 SYSCTL_NODE(_vfs_zfs, OID_AUTO, txg, CTLFLAG_RW, 0, "ZFS transaction group"); 119 SYSCTL_NODE(_vfs_zfs, OID_AUTO, vdev, CTLFLAG_RW, 0, "ZFS VDEV"); 120 SYSCTL_NODE(_vfs_zfs, OID_AUTO, vnops, CTLFLAG_RW, 0, "ZFS VNOPS"); 121 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zevent, CTLFLAG_RW, 0, "ZFS event"); 122 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zil, CTLFLAG_RW, 0, "ZFS ZIL"); 123 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zio, CTLFLAG_RW, 0, "ZFS ZIO"); 124 125 SYSCTL_NODE(_vfs_zfs_livelist, OID_AUTO, condense, CTLFLAG_RW, 0, 126 "ZFS livelist condense"); 127 SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, cache, CTLFLAG_RW, 0, "ZFS VDEV Cache"); 128 SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, file, CTLFLAG_RW, 0, "ZFS VDEV file"); 129 SYSCTL_NODE(_vfs_zfs_vdev, OID_AUTO, mirror, CTLFLAG_RD, 0, 130 "ZFS VDEV mirror"); 131 132 SYSCTL_DECL(_vfs_zfs_version); 133 SYSCTL_CONST_STRING(_vfs_zfs_version, OID_AUTO, module, CTLFLAG_RD, 134 (ZFS_META_VERSION "-" ZFS_META_RELEASE), "OpenZFS module version"); 135 136 /* arc.c */ 137 138 int 139 param_set_arc_u64(SYSCTL_HANDLER_ARGS) 140 { 141 int err; 142 143 err = sysctl_handle_64(oidp, arg1, 0, req); 144 if (err != 0 || req->newptr == NULL) 145 return (err); 146 147 arc_tuning_update(B_TRUE); 148 149 return (0); 150 } 151 152 int 153 param_set_arc_int(SYSCTL_HANDLER_ARGS) 154 { 155 int err; 156 157 err = sysctl_handle_int(oidp, arg1, 0, req); 158 if (err != 0 || req->newptr == NULL) 159 return (err); 160 161 arc_tuning_update(B_TRUE); 162 163 return (0); 164 } 165 166 int 167 param_set_arc_max(SYSCTL_HANDLER_ARGS) 168 { 169 unsigned long val; 170 int err; 171 172 val = zfs_arc_max; 173 err = sysctl_handle_64(oidp, &val, 0, req); 174 if (err != 0 || req->newptr == NULL) 175 return (SET_ERROR(err)); 176 177 if (val != 0 && (val < MIN_ARC_MAX || val <= arc_c_min || 178 val >= arc_all_memory())) 179 return (SET_ERROR(EINVAL)); 180 181 zfs_arc_max = val; 182 arc_tuning_update(B_TRUE); 183 184 /* Update the sysctl to the tuned value */ 185 if (val != 0) 186 zfs_arc_max = arc_c_max; 187 188 return (0); 189 } 190 191 /* BEGIN CSTYLED */ 192 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_max, 193 CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 194 NULL, 0, param_set_arc_max, "LU", 195 "Maximum ARC size in bytes (LEGACY)"); 196 /* END CSTYLED */ 197 198 int 199 param_set_arc_min(SYSCTL_HANDLER_ARGS) 200 { 201 unsigned long val; 202 int err; 203 204 val = zfs_arc_min; 205 err = sysctl_handle_64(oidp, &val, 0, req); 206 if (err != 0 || req->newptr == NULL) 207 return (SET_ERROR(err)); 208 209 if (val != 0 && (val < 2ULL << SPA_MAXBLOCKSHIFT || val > arc_c_max)) 210 return (SET_ERROR(EINVAL)); 211 212 zfs_arc_min = val; 213 arc_tuning_update(B_TRUE); 214 215 /* Update the sysctl to the tuned value */ 216 if (val != 0) 217 zfs_arc_min = arc_c_min; 218 219 return (0); 220 } 221 222 /* BEGIN CSTYLED */ 223 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_min, 224 CTLTYPE_ULONG | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 225 NULL, 0, param_set_arc_min, "LU", 226 "Minimum ARC size in bytes (LEGACY)"); 227 /* END CSTYLED */ 228 229 extern uint_t zfs_arc_free_target; 230 231 int 232 param_set_arc_free_target(SYSCTL_HANDLER_ARGS) 233 { 234 uint_t val; 235 int err; 236 237 val = zfs_arc_free_target; 238 err = sysctl_handle_int(oidp, &val, 0, req); 239 if (err != 0 || req->newptr == NULL) 240 return (err); 241 242 if (val < minfree) 243 return (EINVAL); 244 if (val > vm_cnt.v_page_count) 245 return (EINVAL); 246 247 zfs_arc_free_target = val; 248 249 return (0); 250 } 251 252 /* 253 * NOTE: This sysctl is CTLFLAG_RW not CTLFLAG_RWTUN due to its dependency on 254 * pagedaemon initialization. 255 */ 256 /* BEGIN CSTYLED */ 257 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_free_target, 258 CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_MPSAFE, 259 NULL, 0, param_set_arc_free_target, "IU", 260 "Desired number of free pages below which ARC triggers reclaim" 261 " (LEGACY)"); 262 /* END CSTYLED */ 263 264 int 265 param_set_arc_no_grow_shift(SYSCTL_HANDLER_ARGS) 266 { 267 int err, val; 268 269 val = arc_no_grow_shift; 270 err = sysctl_handle_int(oidp, &val, 0, req); 271 if (err != 0 || req->newptr == NULL) 272 return (err); 273 274 if (val < 0 || val >= arc_shrink_shift) 275 return (EINVAL); 276 277 arc_no_grow_shift = val; 278 279 return (0); 280 } 281 282 /* BEGIN CSTYLED */ 283 SYSCTL_PROC(_vfs_zfs, OID_AUTO, arc_no_grow_shift, 284 CTLTYPE_INT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 285 NULL, 0, param_set_arc_no_grow_shift, "I", 286 "log2(fraction of ARC which must be free to allow growing) (LEGACY)"); 287 /* END CSTYLED */ 288 289 extern uint64_t l2arc_write_max; 290 291 /* BEGIN CSTYLED */ 292 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_max, 293 CTLFLAG_RWTUN, &l2arc_write_max, 0, 294 "Max write bytes per interval (LEGACY)"); 295 /* END CSTYLED */ 296 297 extern uint64_t l2arc_write_boost; 298 299 /* BEGIN CSTYLED */ 300 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_write_boost, 301 CTLFLAG_RWTUN, &l2arc_write_boost, 0, 302 "Extra write bytes during device warmup (LEGACY)"); 303 /* END CSTYLED */ 304 305 extern uint64_t l2arc_headroom; 306 307 /* BEGIN CSTYLED */ 308 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom, 309 CTLFLAG_RWTUN, &l2arc_headroom, 0, 310 "Number of max device writes to precache (LEGACY)"); 311 /* END CSTYLED */ 312 313 extern uint64_t l2arc_headroom_boost; 314 315 /* BEGIN CSTYLED */ 316 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_headroom_boost, 317 CTLFLAG_RWTUN, &l2arc_headroom_boost, 0, 318 "Compressed l2arc_headroom multiplier (LEGACY)"); 319 /* END CSTYLED */ 320 321 extern uint64_t l2arc_feed_secs; 322 323 /* BEGIN CSTYLED */ 324 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_secs, 325 CTLFLAG_RWTUN, &l2arc_feed_secs, 0, 326 "Seconds between L2ARC writing (LEGACY)"); 327 /* END CSTYLED */ 328 329 extern uint64_t l2arc_feed_min_ms; 330 331 /* BEGIN CSTYLED */ 332 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, l2arc_feed_min_ms, 333 CTLFLAG_RWTUN, &l2arc_feed_min_ms, 0, 334 "Min feed interval in milliseconds (LEGACY)"); 335 /* END CSTYLED */ 336 337 extern int l2arc_noprefetch; 338 339 /* BEGIN CSTYLED */ 340 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_noprefetch, 341 CTLFLAG_RWTUN, &l2arc_noprefetch, 0, 342 "Skip caching prefetched buffers (LEGACY)"); 343 /* END CSTYLED */ 344 345 extern int l2arc_feed_again; 346 347 /* BEGIN CSTYLED */ 348 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_feed_again, 349 CTLFLAG_RWTUN, &l2arc_feed_again, 0, 350 "Turbo L2ARC warmup (LEGACY)"); 351 /* END CSTYLED */ 352 353 extern int l2arc_norw; 354 355 /* BEGIN CSTYLED */ 356 SYSCTL_INT(_vfs_zfs, OID_AUTO, l2arc_norw, 357 CTLFLAG_RWTUN, &l2arc_norw, 0, 358 "No reads during writes (LEGACY)"); 359 /* END CSTYLED */ 360 361 static int 362 param_get_arc_state_size(SYSCTL_HANDLER_ARGS) 363 { 364 arc_state_t *state = (arc_state_t *)arg1; 365 int64_t val; 366 367 val = zfs_refcount_count(&state->arcs_size[ARC_BUFC_DATA]) + 368 zfs_refcount_count(&state->arcs_size[ARC_BUFC_METADATA]); 369 return (sysctl_handle_64(oidp, &val, 0, req)); 370 } 371 372 extern arc_state_t ARC_anon; 373 374 /* BEGIN CSTYLED */ 375 SYSCTL_PROC(_vfs_zfs, OID_AUTO, anon_size, 376 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 377 &ARC_anon, 0, param_get_arc_state_size, "Q", 378 "size of anonymous state"); 379 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_metadata_esize, CTLFLAG_RD, 380 &ARC_anon.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 381 "size of evictable metadata in anonymous state"); 382 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, anon_data_esize, CTLFLAG_RD, 383 &ARC_anon.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 384 "size of evictable data in anonymous state"); 385 /* END CSTYLED */ 386 387 extern arc_state_t ARC_mru; 388 389 /* BEGIN CSTYLED */ 390 SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_size, 391 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 392 &ARC_mru, 0, param_get_arc_state_size, "Q", 393 "size of mru state"); 394 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_metadata_esize, CTLFLAG_RD, 395 &ARC_mru.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 396 "size of evictable metadata in mru state"); 397 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_data_esize, CTLFLAG_RD, 398 &ARC_mru.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 399 "size of evictable data in mru state"); 400 /* END CSTYLED */ 401 402 extern arc_state_t ARC_mru_ghost; 403 404 /* BEGIN CSTYLED */ 405 SYSCTL_PROC(_vfs_zfs, OID_AUTO, mru_ghost_size, 406 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 407 &ARC_mru_ghost, 0, param_get_arc_state_size, "Q", 408 "size of mru ghost state"); 409 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_metadata_esize, CTLFLAG_RD, 410 &ARC_mru_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 411 "size of evictable metadata in mru ghost state"); 412 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mru_ghost_data_esize, CTLFLAG_RD, 413 &ARC_mru_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 414 "size of evictable data in mru ghost state"); 415 /* END CSTYLED */ 416 417 extern arc_state_t ARC_mfu; 418 419 /* BEGIN CSTYLED */ 420 SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_size, 421 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 422 &ARC_mfu, 0, param_get_arc_state_size, "Q", 423 "size of mfu state"); 424 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_metadata_esize, CTLFLAG_RD, 425 &ARC_mfu.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 426 "size of evictable metadata in mfu state"); 427 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_data_esize, CTLFLAG_RD, 428 &ARC_mfu.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 429 "size of evictable data in mfu state"); 430 /* END CSTYLED */ 431 432 extern arc_state_t ARC_mfu_ghost; 433 434 /* BEGIN CSTYLED */ 435 SYSCTL_PROC(_vfs_zfs, OID_AUTO, mfu_ghost_size, 436 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 437 &ARC_mfu_ghost, 0, param_get_arc_state_size, "Q", 438 "size of mfu ghost state"); 439 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_metadata_esize, CTLFLAG_RD, 440 &ARC_mfu_ghost.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 441 "size of evictable metadata in mfu ghost state"); 442 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, mfu_ghost_data_esize, CTLFLAG_RD, 443 &ARC_mfu_ghost.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 444 "size of evictable data in mfu ghost state"); 445 /* END CSTYLED */ 446 447 extern arc_state_t ARC_uncached; 448 449 /* BEGIN CSTYLED */ 450 SYSCTL_PROC(_vfs_zfs, OID_AUTO, uncached_size, 451 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 452 &ARC_uncached, 0, param_get_arc_state_size, "Q", 453 "size of uncached state"); 454 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_metadata_esize, CTLFLAG_RD, 455 &ARC_uncached.arcs_esize[ARC_BUFC_METADATA].rc_count, 0, 456 "size of evictable metadata in uncached state"); 457 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, uncached_data_esize, CTLFLAG_RD, 458 &ARC_uncached.arcs_esize[ARC_BUFC_DATA].rc_count, 0, 459 "size of evictable data in uncached state"); 460 /* END CSTYLED */ 461 462 extern arc_state_t ARC_l2c_only; 463 464 /* BEGIN CSTYLED */ 465 SYSCTL_PROC(_vfs_zfs, OID_AUTO, l2c_only_size, 466 CTLTYPE_S64 | CTLFLAG_RD | CTLFLAG_MPSAFE, 467 &ARC_l2c_only, 0, param_get_arc_state_size, "Q", 468 "size of l2c_only state"); 469 /* END CSTYLED */ 470 471 /* dbuf.c */ 472 473 /* dmu.c */ 474 475 /* dmu_zfetch.c */ 476 477 SYSCTL_NODE(_vfs_zfs, OID_AUTO, zfetch, CTLFLAG_RW, 0, "ZFS ZFETCH (LEGACY)"); 478 479 extern uint32_t zfetch_max_distance; 480 481 /* BEGIN CSTYLED */ 482 SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_distance, 483 CTLFLAG_RWTUN, &zfetch_max_distance, 0, 484 "Max bytes to prefetch per stream (LEGACY)"); 485 /* END CSTYLED */ 486 487 extern uint32_t zfetch_max_idistance; 488 489 /* BEGIN CSTYLED */ 490 SYSCTL_UINT(_vfs_zfs_zfetch, OID_AUTO, max_idistance, 491 CTLFLAG_RWTUN, &zfetch_max_idistance, 0, 492 "Max bytes to prefetch indirects for per stream (LEGACY)"); 493 /* END CSTYLED */ 494 495 /* dsl_pool.c */ 496 497 /* dnode.c */ 498 499 /* dsl_scan.c */ 500 501 /* metaslab.c */ 502 503 int 504 param_set_active_allocator(SYSCTL_HANDLER_ARGS) 505 { 506 char buf[16]; 507 int rc; 508 509 if (req->newptr == NULL) 510 strlcpy(buf, zfs_active_allocator, sizeof (buf)); 511 512 rc = sysctl_handle_string(oidp, buf, sizeof (buf), req); 513 if (rc || req->newptr == NULL) 514 return (rc); 515 if (strcmp(buf, zfs_active_allocator) == 0) 516 return (0); 517 518 return (param_set_active_allocator_common(buf)); 519 } 520 521 /* 522 * In pools where the log space map feature is not enabled we touch 523 * multiple metaslabs (and their respective space maps) with each 524 * transaction group. Thus, we benefit from having a small space map 525 * block size since it allows us to issue more I/O operations scattered 526 * around the disk. So a sane default for the space map block size 527 * is 8~16K. 528 */ 529 extern int zfs_metaslab_sm_blksz_no_log; 530 531 /* BEGIN CSTYLED */ 532 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_no_log, 533 CTLFLAG_RDTUN, &zfs_metaslab_sm_blksz_no_log, 0, 534 "Block size for space map in pools with log space map disabled. " 535 "Power of 2 greater than 4096."); 536 /* END CSTYLED */ 537 538 /* 539 * When the log space map feature is enabled, we accumulate a lot of 540 * changes per metaslab that are flushed once in a while so we benefit 541 * from a bigger block size like 128K for the metaslab space maps. 542 */ 543 extern int zfs_metaslab_sm_blksz_with_log; 544 545 /* BEGIN CSTYLED */ 546 SYSCTL_INT(_vfs_zfs_metaslab, OID_AUTO, sm_blksz_with_log, 547 CTLFLAG_RDTUN, &zfs_metaslab_sm_blksz_with_log, 0, 548 "Block size for space map in pools with log space map enabled. " 549 "Power of 2 greater than 4096."); 550 /* END CSTYLED */ 551 552 /* 553 * The in-core space map representation is more compact than its on-disk form. 554 * The zfs_condense_pct determines how much more compact the in-core 555 * space map representation must be before we compact it on-disk. 556 * Values should be greater than or equal to 100. 557 */ 558 extern uint_t zfs_condense_pct; 559 560 /* BEGIN CSTYLED */ 561 SYSCTL_UINT(_vfs_zfs, OID_AUTO, condense_pct, 562 CTLFLAG_RWTUN, &zfs_condense_pct, 0, 563 "Condense on-disk spacemap when it is more than this many percents" 564 " of in-memory counterpart"); 565 /* END CSTYLED */ 566 567 extern uint_t zfs_remove_max_segment; 568 569 /* BEGIN CSTYLED */ 570 SYSCTL_UINT(_vfs_zfs, OID_AUTO, remove_max_segment, 571 CTLFLAG_RWTUN, &zfs_remove_max_segment, 0, 572 "Largest contiguous segment ZFS will attempt to allocate when removing" 573 " a device"); 574 /* END CSTYLED */ 575 576 extern int zfs_removal_suspend_progress; 577 578 /* BEGIN CSTYLED */ 579 SYSCTL_INT(_vfs_zfs, OID_AUTO, removal_suspend_progress, 580 CTLFLAG_RWTUN, &zfs_removal_suspend_progress, 0, 581 "Ensures certain actions can happen while in the middle of a removal"); 582 /* END CSTYLED */ 583 584 /* 585 * Minimum size which forces the dynamic allocator to change 586 * it's allocation strategy. Once the space map cannot satisfy 587 * an allocation of this size then it switches to using more 588 * aggressive strategy (i.e search by size rather than offset). 589 */ 590 extern uint64_t metaslab_df_alloc_threshold; 591 592 /* BEGIN CSTYLED */ 593 SYSCTL_QUAD(_vfs_zfs_metaslab, OID_AUTO, df_alloc_threshold, 594 CTLFLAG_RWTUN, &metaslab_df_alloc_threshold, 0, 595 "Minimum size which forces the dynamic allocator to change its" 596 " allocation strategy"); 597 /* END CSTYLED */ 598 599 /* 600 * The minimum free space, in percent, which must be available 601 * in a space map to continue allocations in a first-fit fashion. 602 * Once the space map's free space drops below this level we dynamically 603 * switch to using best-fit allocations. 604 */ 605 extern uint_t metaslab_df_free_pct; 606 607 /* BEGIN CSTYLED */ 608 SYSCTL_UINT(_vfs_zfs_metaslab, OID_AUTO, df_free_pct, 609 CTLFLAG_RWTUN, &metaslab_df_free_pct, 0, 610 "The minimum free space, in percent, which must be available in a" 611 " space map to continue allocations in a first-fit fashion"); 612 /* END CSTYLED */ 613 614 /* mmp.c */ 615 616 int 617 param_set_multihost_interval(SYSCTL_HANDLER_ARGS) 618 { 619 int err; 620 621 err = sysctl_handle_64(oidp, &zfs_multihost_interval, 0, req); 622 if (err != 0 || req->newptr == NULL) 623 return (err); 624 625 if (spa_mode_global != SPA_MODE_UNINIT) 626 mmp_signal_all_threads(); 627 628 return (0); 629 } 630 631 /* spa.c */ 632 633 extern int zfs_ccw_retry_interval; 634 635 /* BEGIN CSTYLED */ 636 SYSCTL_INT(_vfs_zfs, OID_AUTO, ccw_retry_interval, 637 CTLFLAG_RWTUN, &zfs_ccw_retry_interval, 0, 638 "Configuration cache file write, retry after failure, interval" 639 " (seconds)"); 640 /* END CSTYLED */ 641 642 extern uint64_t zfs_max_missing_tvds_cachefile; 643 644 /* BEGIN CSTYLED */ 645 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, max_missing_tvds_cachefile, 646 CTLFLAG_RWTUN, &zfs_max_missing_tvds_cachefile, 0, 647 "Allow importing pools with missing top-level vdevs in cache file"); 648 /* END CSTYLED */ 649 650 extern uint64_t zfs_max_missing_tvds_scan; 651 652 /* BEGIN CSTYLED */ 653 SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, max_missing_tvds_scan, 654 CTLFLAG_RWTUN, &zfs_max_missing_tvds_scan, 0, 655 "Allow importing pools with missing top-level vdevs during scan"); 656 /* END CSTYLED */ 657 658 /* spa_misc.c */ 659 660 extern int zfs_flags; 661 662 static int 663 sysctl_vfs_zfs_debug_flags(SYSCTL_HANDLER_ARGS) 664 { 665 int err, val; 666 667 val = zfs_flags; 668 err = sysctl_handle_int(oidp, &val, 0, req); 669 if (err != 0 || req->newptr == NULL) 670 return (err); 671 672 /* 673 * ZFS_DEBUG_MODIFY must be enabled prior to boot so all 674 * arc buffers in the system have the necessary additional 675 * checksum data. However, it is safe to disable at any 676 * time. 677 */ 678 if (!(zfs_flags & ZFS_DEBUG_MODIFY)) 679 val &= ~ZFS_DEBUG_MODIFY; 680 zfs_flags = val; 681 682 return (0); 683 } 684 685 /* BEGIN CSTYLED */ 686 SYSCTL_PROC(_vfs_zfs, OID_AUTO, debugflags, 687 CTLTYPE_UINT | CTLFLAG_MPSAFE | CTLFLAG_RWTUN, NULL, 0, 688 sysctl_vfs_zfs_debug_flags, "IU", "Debug flags for ZFS testing."); 689 /* END CSTYLED */ 690 691 int 692 param_set_deadman_synctime(SYSCTL_HANDLER_ARGS) 693 { 694 unsigned long val; 695 int err; 696 697 val = zfs_deadman_synctime_ms; 698 err = sysctl_handle_64(oidp, &val, 0, req); 699 if (err != 0 || req->newptr == NULL) 700 return (err); 701 zfs_deadman_synctime_ms = val; 702 703 spa_set_deadman_synctime(MSEC2NSEC(zfs_deadman_synctime_ms)); 704 705 return (0); 706 } 707 708 int 709 param_set_deadman_ziotime(SYSCTL_HANDLER_ARGS) 710 { 711 unsigned long val; 712 int err; 713 714 val = zfs_deadman_ziotime_ms; 715 err = sysctl_handle_64(oidp, &val, 0, req); 716 if (err != 0 || req->newptr == NULL) 717 return (err); 718 zfs_deadman_ziotime_ms = val; 719 720 spa_set_deadman_ziotime(MSEC2NSEC(zfs_deadman_synctime_ms)); 721 722 return (0); 723 } 724 725 int 726 param_set_deadman_failmode(SYSCTL_HANDLER_ARGS) 727 { 728 char buf[16]; 729 int rc; 730 731 if (req->newptr == NULL) 732 strlcpy(buf, zfs_deadman_failmode, sizeof (buf)); 733 734 rc = sysctl_handle_string(oidp, buf, sizeof (buf), req); 735 if (rc || req->newptr == NULL) 736 return (rc); 737 if (strcmp(buf, zfs_deadman_failmode) == 0) 738 return (0); 739 if (strcmp(buf, "wait") == 0) 740 zfs_deadman_failmode = "wait"; 741 if (strcmp(buf, "continue") == 0) 742 zfs_deadman_failmode = "continue"; 743 if (strcmp(buf, "panic") == 0) 744 zfs_deadman_failmode = "panic"; 745 746 return (-param_set_deadman_failmode_common(buf)); 747 } 748 749 int 750 param_set_slop_shift(SYSCTL_HANDLER_ARGS) 751 { 752 int val; 753 int err; 754 755 val = spa_slop_shift; 756 err = sysctl_handle_int(oidp, &val, 0, req); 757 if (err != 0 || req->newptr == NULL) 758 return (err); 759 760 if (val < 1 || val > 31) 761 return (EINVAL); 762 763 spa_slop_shift = val; 764 765 return (0); 766 } 767 768 /* spacemap.c */ 769 770 extern int space_map_ibs; 771 772 /* BEGIN CSTYLED */ 773 SYSCTL_INT(_vfs_zfs, OID_AUTO, space_map_ibs, CTLFLAG_RWTUN, 774 &space_map_ibs, 0, "Space map indirect block shift"); 775 /* END CSTYLED */ 776 777 778 /* vdev.c */ 779 780 int 781 param_set_min_auto_ashift(SYSCTL_HANDLER_ARGS) 782 { 783 int val; 784 int err; 785 786 val = zfs_vdev_min_auto_ashift; 787 err = sysctl_handle_int(oidp, &val, 0, req); 788 if (err != 0 || req->newptr == NULL) 789 return (SET_ERROR(err)); 790 791 if (val < ASHIFT_MIN || val > zfs_vdev_max_auto_ashift) 792 return (SET_ERROR(EINVAL)); 793 794 zfs_vdev_min_auto_ashift = val; 795 796 return (0); 797 } 798 799 /* BEGIN CSTYLED */ 800 SYSCTL_PROC(_vfs_zfs, OID_AUTO, min_auto_ashift, 801 CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 802 &zfs_vdev_min_auto_ashift, sizeof (zfs_vdev_min_auto_ashift), 803 param_set_min_auto_ashift, "IU", 804 "Min ashift used when creating new top-level vdev. (LEGACY)"); 805 /* END CSTYLED */ 806 807 int 808 param_set_max_auto_ashift(SYSCTL_HANDLER_ARGS) 809 { 810 int val; 811 int err; 812 813 val = zfs_vdev_max_auto_ashift; 814 err = sysctl_handle_int(oidp, &val, 0, req); 815 if (err != 0 || req->newptr == NULL) 816 return (SET_ERROR(err)); 817 818 if (val > ASHIFT_MAX || val < zfs_vdev_min_auto_ashift) 819 return (SET_ERROR(EINVAL)); 820 821 zfs_vdev_max_auto_ashift = val; 822 823 return (0); 824 } 825 826 /* BEGIN CSTYLED */ 827 SYSCTL_PROC(_vfs_zfs, OID_AUTO, max_auto_ashift, 828 CTLTYPE_UINT | CTLFLAG_RWTUN | CTLFLAG_MPSAFE, 829 &zfs_vdev_max_auto_ashift, sizeof (zfs_vdev_max_auto_ashift), 830 param_set_max_auto_ashift, "IU", 831 "Max ashift used when optimizing for logical -> physical sector size on" 832 " new top-level vdevs. (LEGACY)"); 833 /* END CSTYLED */ 834 835 /* 836 * Since the DTL space map of a vdev is not expected to have a lot of 837 * entries, we default its block size to 4K. 838 */ 839 extern int zfs_vdev_dtl_sm_blksz; 840 841 /* BEGIN CSTYLED */ 842 SYSCTL_INT(_vfs_zfs, OID_AUTO, dtl_sm_blksz, 843 CTLFLAG_RDTUN, &zfs_vdev_dtl_sm_blksz, 0, 844 "Block size for DTL space map. Power of 2 greater than 4096."); 845 /* END CSTYLED */ 846 847 /* 848 * vdev-wide space maps that have lots of entries written to them at 849 * the end of each transaction can benefit from a higher I/O bandwidth 850 * (e.g. vdev_obsolete_sm), thus we default their block size to 128K. 851 */ 852 extern int zfs_vdev_standard_sm_blksz; 853 854 /* BEGIN CSTYLED */ 855 SYSCTL_INT(_vfs_zfs, OID_AUTO, standard_sm_blksz, 856 CTLFLAG_RDTUN, &zfs_vdev_standard_sm_blksz, 0, 857 "Block size for standard space map. Power of 2 greater than 4096."); 858 /* END CSTYLED */ 859 860 extern int vdev_validate_skip; 861 862 /* BEGIN CSTYLED */ 863 SYSCTL_INT(_vfs_zfs, OID_AUTO, validate_skip, 864 CTLFLAG_RDTUN, &vdev_validate_skip, 0, 865 "Enable to bypass vdev_validate()."); 866 /* END CSTYLED */ 867 868 /* vdev_mirror.c */ 869 870 /* vdev_queue.c */ 871 872 extern uint_t zfs_vdev_max_active; 873 874 /* BEGIN CSTYLED */ 875 SYSCTL_UINT(_vfs_zfs, OID_AUTO, top_maxinflight, 876 CTLFLAG_RWTUN, &zfs_vdev_max_active, 0, 877 "The maximum number of I/Os of all types active for each device." 878 " (LEGACY)"); 879 /* END CSTYLED */ 880 881 /* zio.c */ 882 883 /* BEGIN CSTYLED */ 884 SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, exclude_metadata, 885 CTLFLAG_RDTUN, &zio_exclude_metadata, 0, 886 "Exclude metadata buffers from dumps as well"); 887 /* END CSTYLED */ 888