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